Version 14 of How can I make effective use of the BWidgets toolset

Updated 2004-06-26 19:19:23

Purpose: to provide a community updatable web page demonstrating uses for the BWidget toolset, enhancing the docs, pointing to tutorials, etc.


Can anyone discuss the various cross platform issues relating directly to BWidgets? For instance, when I try the demo on a Mac using a Tclkit version of Tcl and Tk, I find a number of errors when trying to test the progress indicator, the -armcommand, the french and german language dialog boxes, the select color dialog box, etc.


What additional documentation is needed for BWidgets?

What new widgets have you written based on the BWidgets toolkit? Is the source available for re-use?


BWidget Examples

The BWidget documentation could really benefit from a few examples, illustrating some of the details.

Paned Window

    package require BWidget

    set pw [PanedWindow .topframe -side bottom]
    for {set i 0} {$i<5} {incr i} {
        set p [$pw add -minsize 100]
        set t [text $p.text]
        pack $t
    }
    pack $pw
    pack .topframe

ScrollableFrame and ScrolledWindow

AM (24 june 2004) To create a scrollable frame, that is, a window that can be moved via scrollbars, use code like:

   #
   # Add a scrollable frame, so that we do not have to worry about the size
   #
   set sw  [ScrolledWindow $tabwin.sw -relief sunken -borderwidth 2]
   set sff [ScrollableFrame $tabwin.sw.f]
   $sw setwidget $sff

   set sf  [$sff getframe]
   #
   # Add the various elements
   #
   set lid [label  $sf.name -text "Name"] 
   set eid [entry $sf.editname -textvariable name]

   pack $sw -fill both -expand yes
   #  do not pack $sff
   pack $lid $eid

(So the trick is: first create a scrolled window, then create a scrollable frame inside it and have it managed by that scrolled window. This extra level is required, because a frame has no xscroll/yscroll subcommand.)

KJN 2004-06-26 added pack statements. Note that the scrollable frame itself should not be packed. The command "$sw setwidget $sff" tells the scrolled window to do geometry management of the scrollable frame. Packing is unnecessary and will lead to an error.


2003-03-13, Svenn Bjerkem: Tried this example with ActiveTcL 8.4.0.1 and got following error:

 bad option "identify": must be cget or configure
    while executing
 "$w identify $x $y"
    (procedure "::tk::panedwindow::Motion" line 3)
    invoked from within
 "::tk::panedwindow::Motion . 102 2 "
    (command bound to event)

checked the documentation for tk builtins for tk and found that the widget panedwindow has the command identify. For some reason I want to use BWidget, but use the builtin. How come?

AK: AFAIK this could be a confusion in the bindings. I.e. both Tk's panedwindow and Bwidgets panedwindow using the same class name. This causes the Bwidgets panedwindow to get the bindings for Tk's panedwindow, which do not work. I thought we had a bug report about this in Tk or Bwidgets, but can't seem to find it. Or maybe it was something on c.l.t.


Recently, George Petasis answered the following question on comp.lang.tcl:

What can I do to make native Tk widgets and BWidgets look closer, when using them on Linux?

George answered:

 option add *highlightBackground [. cget -background]

(this will make your white borders the same colour as the rest of the window...)

If you want to remove completely these "frames", simply use:

 option add *highlightThickness 0

To use the icons provided with BWidget, you can either

 set im [image create photo -file [file join ::BWIDGET::LIBRARY images folder.gif]]

But it's much easier to use the undocumented (but used in BWidget Demo)

 set im [Bitmap::get folder]

Thanks to de for pointing this out!


See Enhancing BWidget for more BWidget help.

See also A vertical-tab notebook - Windows Registry Browser - Multi-column display in text widget - Beveled lines - Creating a BWidget Widget


Category GUI