Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Creating GUI's that work across several versions of Tk

by strat (Canon)
on May 29, 2006 at 07:56 UTC ( #552262=note: print w/ replies, xml ) Need Help??


in reply to Creating GUI's that work across several versions of Tk

I always try to keep the Tk code within one or two modules e.g. MyApp::Widgets which contains little wrapper subroutines for the widgets I use, e.g

package MyApp::Widgets; ... sub Button { my ($parent, $text, $callback, %options) = @_; if (ref $text) { $options{-textvariable} = $text } else { $options{-text} = $text } if (ref($callback) ....) { $options{-command} = $callback; } else { $options{-background} = '#ff0000'; } # else return $parent->Button( -font => $StdButtonFont, -background => '#ffdd00', %options, ); } # Button

or the like (code not tested)

and perhaps MyApp::Callbacks) which contains the whole callbacks to Tk. It's not too beautiful to call such a sub (e.g. my $button = &MyApp::Widgets::Button($parent, 'bla', sub { print "Exit }, -font => $BoldFont);), but this way I can give every widget default properties very easily; in addition to that, the whole Tk-Code is bundled within one or two modules which can easily be exchanged based on the Tk version by an installer or the like)

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"


Comment on Re: Creating GUI's that work across several versions of Tk
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://552262]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-07-26 03:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls