RE: [tcltk-perl] Re: Perl/Tk Aqua progress?
Brought to you by:
hobbs
From: Konovalov, V. <vko...@sp...> - 2004-12-08 15:03:59
|
> > use Tcl::Tk qw=:perlTk=; > > $mw=tkinit; > > $mw->Declare('feedback','iwidgets::feedback',-require=>'Iwidgets',- > > prefix=>' > > feedb'); > > $fb=$mw->feedback(-steps=>10000)->pack(-fill=>'x'); > > $fb->step(1),$fb->update for 0..9999; > > MainLoop; > > For someone coming from a Perl/Tk (as opposed to a Tcl/Tk) > background, > how would I find out about these Tcl/Tk widgets and how to use them? The more perlTk syntax supported, the more you can just use perlTk's documentation. For other Tcl/Tk widgets that do not have perlTk counterpart you should use Tcl/Tk documentation that comes with that widget. While reading, following rules should apply: - Tcl interpreter is used to process Tcl/Tk widgets; Similar perlTk concept exists, but very opaque (for me at least) All Tcl::Tk widget commands are translated to Tcl syntax and directed to Tcl interpreter. This is why $interp->Eval("text .t") is same as $mw->Text; except that in second place Tcl::Tk will generate widget's name for you - in Tcl/Tk widget have path, which consist of several names starting with dot separated by dots. mainwindow has name '.' child window have name of parent window appended with another dot appended with this widget's name. example - frame .fr contains button .fr.b on it - when widget is created, a special command is created within Tk - a widget's path. That said, .fr.b is Tk's command Transition is simple. Tcl/Tk => Tcl::Tk --- $button = $interp->widget(".fr.b"); Tcl::Tk => Tcl/Tk --- $path = $button->path; This is why we read in Tcl/Tk about button: The "button" command creates a new Tcl command whose name is pathName. This command may be used to invoke various operations on the widget. It has the following general form: - widget options are same in Tcl::Tk and Tcl/Tk - when you read in Tcl/Tk documentation something like following: pathName method-name optional-parameters (some description) you should understand that widget in question has said method and you could invoke it as $widget->method-name(optional-parameters); $widget is that widget with pathName Sometimes in Tcl/Tk method-name consist of two words (verb1 verb2), in this case it should be invoked as verb1Verb2 And - if you do not succeed with perlTk syntax, you could always use Tcl syntax. Best regards, Vadim. |