From: Hidetoshi NAGAI Date: 2006-09-05T13:52:25+09:00 Subject: Re: TkDialogBox missing? From: Josef Wolf Subject: Re: TkDialogBox missing? Date: Sun, 3 Sep 2006 21:50:54 +0900 Message-ID: <20060903124054.GA3522@raven.wolf.local> > I can't figure out how to use this widget properly. I have two major > problems with it: Please run '/ext/tk/sample/tkextlib/bwidget/demo.rb', and see '/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb'. > 1. Tk::BWidget::Dialog don't seem to have a "buttons" option? But > without a "buttons" option, options like "cancel", "default" and > "separator" don't really make sense, IMHO. Use Tk::BWidget::Dialog#add to add buttons. > 2. It's draw() method returns the id of the widget instead of an indication > which button was pressed. Please see the next example. --------------------------------------------------------------------- require 'tk' require 'tkextlib/bwidget' d = Tk::BWidget::Dialog.new(:relative=>Tk.root, :modal=>:local, :separator=>true, :title=>'Dialog Test', :side=>:bottom, :anchor=>:c, :default=>0, :cancel=>3) d.add(:text=>'btn0', :command=>proc{d.enddialog('btn0 is pressed')}) d.add(:text=>'btn1', :command=>proc{d.enddialog('btn1 is pressed')}) d.add(:text=>'btn2') # use default cmd => return a string of the index number d.add(:text=>'btn3', :command=>proc{d.enddialog('btn3 is pressed')}) p d.current_itemconfiginfo(0) # f = d.get_frame d.get_frame{|f| TkLabel.new(f, :text=>'Here is a frame of the dialog').pack TkLabel.new(f, :text=>'Please lay-out your widgets here.').pack } TkButton.new(:text=>'show dialog', :command=>proc{p d.draw}).pack Tk.mainloop --------------------------------------------------------------------- > BTW: There seems to be one more widget set called iwidgets. Anybody knows > what it is? If you can use "iwidgets", it may be enough for your purpose to imitate '/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb'. If you want to install "iwidgets" ([incr Widgets]) from its source, you have to compile it. However, BWidgets doesn't need compile, because it witten in pure Tcl/Tk. -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)