From: Hidetoshi NAGAI Date: 2009-07-01T19:54:18+09:00 Subject: [RFC] Are these widgets worth adding as standard libraries of Ruby/Tk? Hi, I'm planning to upgrade some Ruby/Tk samples to standard widgets of Ruby/Tk. I want comments of yours about making each of widgets as a standard library. Ruby's source archive includes Ruby/Tk sample scripts. Some of them are only demonstration, but some of the others are usable as widget class libraries. The following sample script includes the classes which are candidates for upgrading (Probably, class names are modified and bug-fixed when upgrade). * editable_listbox.rb class Editable_Listbox A listbox widget, but you can edit the text of each item with your keyboard. For example, when double-crick on an item of the listbox, a entry box is shown on the item to edit the text of the item. Of course, the result of editing is reflected on the listbox. * scrollframe.rb class TkScrollFrame A frame widget, but it has a scrollable view window to see a part of the frame. For example, please remember a toolbar with many buttons, and the toolbar is very long than the window size. Then, you may want to scroll the toolbar buttons. TkScrollFrame can do that easily. * tkalignbox.rb It may be a little difficult to keep same width/height of widgets (e.g. buttons with differnt length of text and different height of font) even if the window size is changed. The followings are kinds of Frame widget to make it easy. class Tk::HBox class Tk::HLBox class Tk::HRBox class Tk::VBox class Tk::VTBox class Tk::VBBox For example, Tk::HLBox.new(parent).add(b1, b2, b3, b4, ...) adds buttons b1, b2, b3, b4, ... from left to right on the HLBox frame widget, and gives and keeps same width/height on the buttons. A HLBox frame widget is a widget. So, of course, you can pack it as same as other widgets. * tkballoonhelp.rb class TkBalloonHelp Add a balloonhelp tip on its parent widget. Of course, you can contoll its message, on-mouse interval before showing the balloonhelp, and so on. You can add a hook-method at showing. It means you can also show a different message for each line of a listbox. * tkcombobox.rb class TkAutoScrollListbox A listbox widget, but has up/down autoscroll tabs when has items out of display range. (Mouse on the tab and don't move mouse, then scroll listbox automatically.) class TkCombobox A combobox widget, but its select-listbox has autoscroll tabs. * tktextframe.rb Based on TkTextFrame class, design Tk::ScrollbarComposite module. The module help to add scrollbars to a scrollable widget. For example, define --------------------------------------- class ScrListbox < Tk::Listbox include Tk::ScrollbarComposite DEFALUT_HSCROLL = false def create_component(keys={}) Tk::Listbox.new(@frame, keys) end private :create_component end --------------------------------------- then, you can treat listbox widgets with Y scrollbar, by calling ScrListbox.new().pack() and so on. -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)