Tk Source Code

Artifact [c131ccb0]
Login

Artifact c131ccb05d3cc1d17801c717afe92f019c0ca9f2:

Attachment "primary-selection-demo.tcl" to ticket [de156e9e] added by kjnash 2017-06-13 18:05:00.
#! /usr/bin/env wish

# Simple script with all the widgets that have -exportselection and can
# therefore write to the PRIMARY selection.

set script {
    label .lab1 -text {text widget:}
    text  .text -width 25 -height 8 -bg white

    label .lab2 -text {entry widget:}
    entry .entry -width 20 -bg white

    label .lab3 -text {ttk::entry widget:}
    ttk::entry .ttkentry -width 20

    label .lab4 -text {listbox widget:}
    listbox .listbox -height 5

    label .lab5 -text "spinbox widget\n(modified entry widget):"
    spinbox .spinbox -from 0.00 -to 5.00 -increment 0.25 -format %5.2f -width 10 \
            -justify center -textvariable ::var

    label .lab6 -text "ttk::spinbox widget\n(modified ttk::entry widget):"
    ttk::spinbox .ttkspinbox -from 0.00 -to 5.00 -increment 0.25 -format %5.2f -width 10 \
            -justify center -textvariable ::var2

    pack .lab1 -pady {10 5}
    pack .text

    pack .lab2 -pady {10 5}
    pack .entry

    pack .lab3 -pady {10 5}
    pack .ttkentry

    pack .lab4 -pady {10 5}
    pack .listbox

    pack .lab5 -pady {10 5}
    pack .spinbox

    pack .lab6 -pady {10 5}
    pack .ttkspinbox

    .text insert end "This script can be used\nto test whether\
            its\nwidgets can write to the\nPRIMARY selection.\n\nMake a selection\
            and then\ntry <<PasteSelection>>\nin a different process."
    .entry insert end {hijklmn}
    .ttkentry insert end {opqrstu}
    .listbox insert end list1 list2 list3 list4 list5
    set ::var  0.75
    set ::var2 1.50
}

# To run in the master interpreter.
# eval $script

# To run in a slave interpreter.
set int slave1
::safe::interpCreate $int
::safe::loadTk $int
$int eval $script