# Bwidgets on Ruby question

**URL:** <https://www.ruby-forum.com/t/bwidgets-on-ruby-question/69604>\
**Category:** Ruby\
**Created:** [September 22, 2006, 7:16am UTC](https://www.ruby-forum.com/t/bwidgets-on-ruby-question/69604 "2006-09-22T07:16:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpthompson\_at\_gmail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@mpthompson\_at\_gmail](https://www.ruby-forum.com/u/mpthompson_at_gmail)\
**Post date:** [September 22, 2006, 7:16am UTC](https://www.ruby-forum.com/t/bwidgets-on-ruby-question/69604/1 "2006-09-22T07:16:27Z")

</div>

Hi everyone,

I’m looking for some help to get a start with the BWidget wrappers in  
Ruby.

Some quick background. While looking into using different Tk  
extensions with Ruby and I’ve come across both IWidgets and BWidgets.  
They both seem to be installed for me on Windows XP when using the  
One-Click Installer and ActiveTcl 8.4. There seems to be a fair amount  
of sample Ruby code installed for the IWidget wrappers which give me a  
pretty good idea of how they work and ook. Unfortunately, there seems  
to be no sample code I can find anywhere for the BWidget wrappers. I’m  
curious to try out BWidget on Ruby because the Tcl sample applications  
for BWidget installed with ActiveTcl 8.4 looks very nice.

I did manage to come across the following Bwidget code on  
comp.lang.ruby, but it doesn’t work for me. By ‘not work’ I mean that  
the d.draw method doesn’t bring up a dialog box and I can’t figure out  
why.

* * *

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

Can anyone give a tip on locating some Bwidget sample code or help me  
figure out why the above BWidget code doesn’t work.

Thanks,

Mike Thompson

---

<div class="post-metadata">

**Author:** ![mpthompson\_at\_gmail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@mpthompson\_at\_gmail](https://www.ruby-forum.com/u/mpthompson_at_gmail)\
**Post date:** [September 22, 2006, 9:16am UTC](https://www.ruby-forum.com/t/bwidgets-on-ruby-question/69604/2 "2006-09-22T09:16:35Z")

</div>

On Sep 22, 2006, at 1:15 AM, mpthompson at [gmail.com](http://gmail.com) wrote:

> of sample Ruby code installed for the IWidget wrappers which give me a  
> pretty good idea of how they work and ook. Unfortunately, there seems  
> to be no sample code I can find anywhere for the BWidget wrappers.  
> I’m  
> curious to try out BWidget on Ruby because the Tcl sample applications  
> for BWidget installed with ActiveTcl 8.4 looks very nice.

Suggest you visit

```
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/ext/tk/sample/

```

tkextlib/bwidget/

Regards, Morton

---

<div class="post-metadata">

**Author:** ![mpthompson\_at\_gmail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@mpthompson\_at\_gmail](https://www.ruby-forum.com/u/mpthompson_at_gmail)\
**Post date:** [September 22, 2006, 10:36am UTC](https://www.ruby-forum.com/t/bwidgets-on-ruby-question/69604/3 "2006-09-22T10:36:41Z")

</div>

Morton,

Thanks a lot. Exactly what I was looking for. I should have simply  
searched my Ruby directory tree rather than try to use Google to find  
these on the web.

Mike
