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

[Tkx] Search for dialog box for text input

by GUIfriend (Sexton)
on Apr 20, 2012 at 11:51 UTC ( [id://966182]=perlquestion: print w/replies, xml ) Need Help??

GUIfriend has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on my 1st project that uses Tkx for the GUI (up to now I have used Perl/Tk). I want to pop up a dialog box that allows the user to enter some text. In my current project it would be best if I could include some spinboxes or comboboxes in the dialog. But if necessary a simple entry widget would be acceptable.
  • Comment on [Tkx] Search for dialog box for text input

Replies are listed 'Best First'.
Re: [Tkx] Search for dialog box for text input
by zentara (Archbishop) on Apr 20, 2012 at 13:50 UTC
    Just from a Tk ( or any GUI toolkit perspective) you would need to add a Frame to your DialogBox, then fill the Frame with your other widgets. Google is always your friend, see Tkx DialogBox discussion. Look at Jeff Hobb's reply, it shows how to get a Tkx DialogBox and get it's internal Frame.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Thank you, this link was a great help. After some effort I got the example working. Here is my result (it may help successors):
      use strict; use warnings; use Tkx; my $mw = Tkx::widget->new("."); Tkx::package_require('widget::dialog'); my $db = $mw->new_widget__dialog( -title => 'MyTitle', -type => "okcancel", -modal => "local", # -parent => $mw, # -padding => 10, -synchronous => 1, ); $db->g_bind('<Key-Return>', sub { $db->close('ok'); }); my $f = $db->getframe(); my $yearval = 2012; my $weekval = 16; my $sel_fr = $db->new_ttk__frame; my $ly = $sel_fr->new_ttk__label(-text => "Year"); my $lw = $sel_fr->new_ttk__label(-text => "Week"); my $y = $sel_fr->new_ttk__spinbox( -textvariable => \$yearval, -from => 2009, -to => 2014, ); my $w = $sel_fr->new_ttk__spinbox( -textvariable => \$weekval, -from => 1, -to => 53, ); $ly->g_grid(-row => 0, -column => 0); $lw->g_grid(-row => 1, -column => 0); $y->g_grid(-row => 0, -column => 1); $w->g_grid(-row => 1, -column => 1); $sel_fr->g_pack(-in => $f); my $answer = $db->display; if ($answer ne "ok") {exit};

      This solution is acceptable, but not perfect. For some reason the dialog buttons stick to the right side of the window.

      In the meantime I found an alternative at http://tktable.sourceforge.net/tile/doc/dialog.html. This module has more modern syntax (options instead of positional parameters), and also additional interesting options. Unfortunately I failed already at the 1st line, translating

      package require ttk::dialog

      from Tcl/Tk to Perl/Tkx. Hopefully one of you monks can help me along again.

      Kind regards

      GUIfriend

Re: [Tkx] Search for dialog box for text input
by Anonymous Monk on Apr 20, 2012 at 12:02 UTC

    And the question is?

    I would switch to Tcl::pTk, its like Tk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://966182]
Approved by halfcountplus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-18 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found