Revision: 10718 http://pure-data.svn.sourceforge.net/pure-data/?rev=10718&view=rev Author: eighthave Date: 2009-02-02 19:13:22 +0000 (Mon, 02 Feb 2009)
Log Message: ----------- - replaced the very obtuse code where there were global variables that had variable names in it with a system where the widgets themselves are queried for their values.
-Unfortunately, you still need a global variable with the radiobuttons, so I switched that to a hash rather than global variables holding variable names -This line, and those below, will be ignored--
M gatom.tcl
Modified Paths: -------------- branches/pd-devel/0.41.4/src/gatom.tcl
Modified: branches/pd-devel/0.41.4/src/gatom.tcl =================================================================== --- branches/pd-devel/0.41.4/src/gatom.tcl 2009-02-02 17:22:20 UTC (rev 10717) +++ branches/pd-devel/0.41.4/src/gatom.tcl 2009-02-02 19:13:22 UTC (rev 10718) @@ -7,6 +7,9 @@ namespace export pdtk_gatom_dialog }
+# the radiobutton widget requires this to be global +global gatomlabel_position + ############ pdtk_gatom_dialog -- run a gatom dialog #########
# dialogs like this one can come up in many copies; but in TK the easiest @@ -28,7 +31,7 @@ set ret [string map {"$" "#"} $sym] } } - return unspace_text $ret + return [unspace_text $ret] }
proc ::gatom::unescape {sym} { @@ -47,40 +50,16 @@ }
proc ::gatom::apply {mytoplevel} { - set vid [string trimleft $mytoplevel .] - - # TODO replace this $$/global stuff by setting the values that were given - # to use by Pd directly to the entry boxes, then when calling the apply - # proc, use [$myentry get] - set var_gatomwidth [concat gatomwidth_$vid] - global $var_gatomwidth - set var_gatomlo [concat gatomlo_$vid] - global $var_gatomlo - set var_gatomhi [concat gatomhi_$vid] - global $var_gatomhi - set var_gatomwherelabel [concat gatomwherelabel_$vid] - global $var_gatomwherelabel - set var_gatomlabel [concat gatomlabel_$vid] - global $var_gatomlabel - set var_gatomsymfrom [concat gatomsymfrom_$vid] - global $var_gatomsymfrom - set var_gatomsymto [concat gatomsymto_$vid] - global $var_gatomsymto - - # set cmd [concat $id param $gatomwidth $gatomlo $gatomhi ;] - - set cmd [concat $mytoplevel param \ - [eval concat $$var_gatomwidth] \ - [eval concat $$var_gatomlo] \ - [eval concat $$var_gatomhi] \ - [eval ::gatom::escape $$var_gatomlabel] \ - [eval concat $$var_gatomwherelabel] \ - [eval ::gatom::escape $$var_gatomsymfrom] \ - [eval ::gatom::escape $$var_gatomsymto] \ - ;] - - # puts stderr $cmd - pdsend $cmd + global gatomlabel_position + + pdsend "$mytoplevel param \ + [$mytoplevel.width.entry get] \ + [$mytoplevel.limits.lower.entry get] \ + [$mytoplevel.limits.upper.entry get] \ + [::gatom::escape [$mytoplevel.gatomlabel.name.entry get]] \ + $gatomlabel_position($mytoplevel) \ + [::gatom::escape [$mytoplevel.s_r.send.entry get]] \ + [::gatom::escape [$mytoplevel.s_r.receive.entry get]]" }
@@ -104,94 +83,69 @@ ::gatom::cancel $mytoplevel }
-proc ::gatom::pdtk_gatom_dialog {mytoplevel initwidth initlo inithi \ - wherelabel label symfrom symto} { +proc ::gatom::pdtk_gatom_dialog {mytoplevel initwidth initlower initupper \ + initgatomlabel_position \ + initgatomlabel initsend initreceive} { + global gatomlabel_position + set gatomlabel_position($mytoplevel) $initgatomlabel_position
- set vid [string trimleft $mytoplevel .] - - # TODO replace this $$/global stuff by setting the values that were given - # to use by Pd directly to the entry boxes, then when calling the apply - # proc, use [$myentry get] - set var_gatomwidth [concat gatomwidth_$vid] - global $var_gatomwidth - set var_gatomlo [concat gatomlo_$vid] - global $var_gatomlo - set var_gatomhi [concat gatomhi_$vid] - global $var_gatomhi - set var_gatomwherelabel [concat gatomwherelabel_$vid] - global $var_gatomwherelabel - set var_gatomlabel [concat gatomlabel_$vid] - global $var_gatomlabel - set var_gatomsymfrom [concat gatomsymfrom_$vid] - global $var_gatomsymfrom - set var_gatomsymto [concat gatomsymto_$vid] - global $var_gatomsymto - - set $var_gatomwidth $initwidth - set $var_gatomlo $initlo - set $var_gatomhi $inithi - set $var_gatomwherelabel $wherelabel - set $var_gatomlabel [::gatom::unescape $label] - set $var_gatomsymfrom [::gatom::unescape $symfrom] - set $var_gatomsymto [::gatom::unescape $symto] - - toplevel $mytoplevel + toplevel $mytoplevel -class PdPanel wm title $mytoplevel "atom box properties" wm resizable $mytoplevel 0 0 wm protocol $mytoplevel WM_DELETE_WINDOW "::gatom::cancel $mytoplevel"
::pd_bindings::panel_bindings $mytoplevel "gatom"
- frame $mytoplevel.params -height 7 - pack $mytoplevel.params -side top - label $mytoplevel.params.entryname -text "width" - entry $mytoplevel.params.entry -textvariable $var_gatomwidth -width 4 - pack $mytoplevel.params.entryname $mytoplevel.params.entry -side left + frame $mytoplevel.width -height 7 + pack $mytoplevel.width -side top + label $mytoplevel.width.label -text "width" + entry $mytoplevel.width.entry -width 4 + pack $mytoplevel.width.label $mytoplevel.width.entry -side left
labelframe $mytoplevel.limits -text "limits" -padx 15 -pady 4 -borderwidth 1 \ -font highlight_font pack $mytoplevel.limits -side top -fill x frame $mytoplevel.limits.lower pack $mytoplevel.limits.lower -side left - label $mytoplevel.limits.lower.entryname -text "lower" - entry $mytoplevel.limits.lower.entry -textvariable $var_gatomlo -width 8 - pack $mytoplevel.limits.lower.entryname $mytoplevel.limits.lower.entry -side left + label $mytoplevel.limits.lower.label -text "lower" + entry $mytoplevel.limits.lower.entry -width 8 + pack $mytoplevel.limits.lower.label $mytoplevel.limits.lower.entry -side left frame $mytoplevel.limits.upper pack $mytoplevel.limits.upper -side left frame $mytoplevel.limits.upper.spacer -width 20 - label $mytoplevel.limits.upper.entryname -text "upper" - entry $mytoplevel.limits.upper.entry -textvariable $var_gatomhi -width 8 - pack $mytoplevel.limits.upper.spacer $mytoplevel.limits.upper.entryname \ + label $mytoplevel.limits.upper.label -text "upper" + entry $mytoplevel.limits.upper.entry -width 8 + pack $mytoplevel.limits.upper.spacer $mytoplevel.limits.upper.label \ $mytoplevel.limits.upper.entry -side left
frame $mytoplevel.spacer1 -height 7 pack $mytoplevel.spacer1 -side top
- labelframe $mytoplevel.label -text "label" -padx 5 -pady 4 -borderwidth 1 \ + labelframe $mytoplevel.gatomlabel -text "label" -padx 5 -pady 4 -borderwidth 1 \ -font highlight_font - pack $mytoplevel.label -side top -fill x - frame $mytoplevel.label.name - pack $mytoplevel.label.name -side top - entry $mytoplevel.label.name.entry -textvariable $var_gatomlabel -width 33 - pack $mytoplevel.label.name.entry -side left - frame $mytoplevel.label.radio - pack $mytoplevel.label.radio -side top - radiobutton $mytoplevel.label.radio.left -value 0 \ - -variable $var_gatomwherelabel \ - -text "left " -justify left - radiobutton $mytoplevel.label.radio.right -value 1 \ - -variable $var_gatomwherelabel \ - -text "right" -justify left - radiobutton $mytoplevel.label.radio.top -value 2 \ - -variable $var_gatomwherelabel \ - -text "top" -justify left - radiobutton $mytoplevel.label.radio.bottom -value 3 \ - -variable $var_gatomwherelabel \ - -text "bottom" -justify left - pack $mytoplevel.label.radio.left -side left -anchor w - pack $mytoplevel.label.radio.right -side right -anchor w - pack $mytoplevel.label.radio.top -side top -anchor w - pack $mytoplevel.label.radio.bottom -side bottom -anchor w + pack $mytoplevel.gatomlabel -side top -fill x + frame $mytoplevel.gatomlabel.name + pack $mytoplevel.gatomlabel.name -side top + entry $mytoplevel.gatomlabel.name.entry -width 33 + pack $mytoplevel.gatomlabel.name.entry -side left + frame $mytoplevel.gatomlabel.radio + pack $mytoplevel.gatomlabel.radio -side top + radiobutton $mytoplevel.gatomlabel.radio.left -value 0 \ + -variable gatomlabel_position($mytoplevel) \ + -text "left " -justify left -takefocus 0 + radiobutton $mytoplevel.gatomlabel.radio.right -value 1 \ + -variable gatomlabel_position($mytoplevel) \ + -text "right" -justify left -takefocus 0 + radiobutton $mytoplevel.gatomlabel.radio.top -value 2 \ + -variable gatomlabel_position($mytoplevel) \ + -text "top" -justify left -takefocus 0 + radiobutton $mytoplevel.gatomlabel.radio.bottom -value 3 \ + -variable gatomlabel_position($mytoplevel) \ + -text "bottom" -justify left -takefocus 0 + pack $mytoplevel.gatomlabel.radio.left -side left -anchor w + pack $mytoplevel.gatomlabel.radio.right -side right -anchor w + pack $mytoplevel.gatomlabel.radio.top -side top -anchor w + pack $mytoplevel.gatomlabel.radio.bottom -side bottom -anchor w
frame $mytoplevel.spacer2 -height 7 pack $mytoplevel.spacer2 -side top @@ -199,31 +153,45 @@ labelframe $mytoplevel.s_r -text "messages" -padx 5 -pady 4 -borderwidth 1 \ -font highlight_font pack $mytoplevel.s_r -side top -fill x - frame $mytoplevel.s_r.paramsymto - pack $mytoplevel.s_r.paramsymto -side top -anchor e - label $mytoplevel.s_r.paramsymto.entryname -text "send symbol" - entry $mytoplevel.s_r.paramsymto.entry -textvariable $var_gatomsymto -width 21 - pack $mytoplevel.s_r.paramsymto.entry $mytoplevel.s_r.paramsymto.entryname -side right + frame $mytoplevel.s_r.send + pack $mytoplevel.s_r.send -side top -anchor e + label $mytoplevel.s_r.send.label -text "send symbol" + entry $mytoplevel.s_r.send.entry -width 21 + pack $mytoplevel.s_r.send.entry $mytoplevel.s_r.send.label -side right
- frame $mytoplevel.s_r.paramsymfrom - pack $mytoplevel.s_r.paramsymfrom -side top -anchor e - label $mytoplevel.s_r.paramsymfrom.entryname -text "receive symbol" - entry $mytoplevel.s_r.paramsymfrom.entry -textvariable $var_gatomsymfrom -width 21 - pack $mytoplevel.s_r.paramsymfrom.entry $mytoplevel.s_r.paramsymfrom.entryname -side right + frame $mytoplevel.s_r.receive + pack $mytoplevel.s_r.receive -side top -anchor e + label $mytoplevel.s_r.receive.label -text "receive symbol" + entry $mytoplevel.s_r.receive.entry -width 21 + pack $mytoplevel.s_r.receive.entry $mytoplevel.s_r.receive.label -side right
frame $mytoplevel.buttonframe -pady 5 pack $mytoplevel.buttonframe -side top -fill x -pady 2m - button $mytoplevel.buttonframe.cancel -text {Cancel}\ + button $mytoplevel.buttonframe.cancel -text {Cancel} \ -command "::gatom::cancel $mytoplevel" pack $mytoplevel.buttonframe.cancel -side left -expand 1 - button $mytoplevel.buttonframe.apply -text {Apply}\ + button $mytoplevel.buttonframe.apply -text {Apply} \ -command "::gatom::apply $mytoplevel" pack $mytoplevel.buttonframe.apply -side left -expand 1 - button $mytoplevel.buttonframe.ok -text {OK}\ + button $mytoplevel.buttonframe.ok -text {OK} \ -command "::gatom::ok $mytoplevel" pack $mytoplevel.buttonframe.ok -side left -expand 1
- $mytoplevel.params.entry select from 0 - $mytoplevel.params.entry select adjust end - focus $mytoplevel.params.entry + $mytoplevel.width.entry insert 0 $initwidth + $mytoplevel.limits.lower.entry insert 0 $initlower + $mytoplevel.limits.upper.entry insert 0 $initupper + if {$initgatomlabel ne "-"} { + $mytoplevel.gatomlabel.name.entry insert 0 $initgatomlabel + } + set gatomlabel_position($mytoplevel) $initgatomlabel_position + if {$initsend ne "-"} { + $mytoplevel.s_r.send.entry insert 0 $initsend + } + if {$initreceive ne "-"} { + $mytoplevel.s_r.receive.entry insert 0 $initreceive + } + + $mytoplevel.width.entry select from 0 + $mytoplevel.width.entry select adjust end + focus $mytoplevel.width.entry }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.