TkDialogBox missing?

J

Josef Wolf

Hello!

I am pretty new to ruby, but I have used perl/Tk in my previous life ;-)
I can't find ruby's aequivalent to perl's Tk::DialogBox. I need to
implement something similar to firefox's "preferences" dialog. The
TkDialog class don't look as if it can maintain arbitrary widgets.

I have checked the archives and google, but could find only a thread[*]
dated back to the year 2000.

What is the current status? Are dialog boxes still not supported?
Or am I just misunderstanding something? Maybe there's some sort of
work-around?

[*] http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/7548?7484-8460
 
H

Hidetoshi NAGAI

From: Josef Wolf <[email protected]>
Subject: TkDialogBox missing?
Date: Fri, 1 Sep 2006 07:50:34 +0900
Message-ID: said:
I am pretty new to ruby, but I have used perl/Tk in my previous life ;-)
I can't find ruby's aequivalent to perl's Tk::DialogBox. I need to

That is NOT a standard widget of Tcl/Tk.
Probably, it is a perl/Tk specific one.

I think that "Dialog" widget of BWidget extension is one of
similar widgets. BWidget extension is written in pure Tcl/Tk.
So, it is not difficult to install.
Ruby/Tk supports BWidget extension by 'tkextlib/bwidget.rb'.

# Of course, you can write such new widget class by your own. :)
 
J

Josef Wolf

On Fri, Sep 01, 2006 at 12:01:13PM +0900, Hidetoshi NAGAI wrote:

Thanks for your quick reply! (BTW: is Hidetishi your first name?)
That is NOT a standard widget of Tcl/Tk.
Probably, it is a perl/Tk specific one.

I think that "Dialog" widget of BWidget extension is one of
similar widgets. BWidget extension is written in pure Tcl/Tk.
So, it is not difficult to install.
Ruby/Tk supports BWidget extension by 'tkextlib/bwidget.rb'.

It looks as if it is already installed on my suse box. But I can't find
any documentation. I assume it is to be used similar to ruby/Tk?
Anyway, I'll go dive into it. Thanks again!
 
J

Josef Wolf

It looks as if it is already installed on my suse box. But I can't find
any documentation. I assume it is to be used similar to ruby/Tk?
Anyway, I'll go dive into it. Thanks again!

I can't figure out how to use this widget properly. I have two major
problems with it:

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.

2. It's draw() method returns the id of the widget instead of an indication
which button was pressed.

This is what I do:

pressed=nil
dia=Tk::BWidget::Dialog.new('parent'=>parent)
label=Tk::BWidget::LabelEntry.new('parent'=>dia, 'label'=>'Entity',
'text'=>'Hello').pack
TkButton.new(dia,'text'=>'OK',
'command'=>proc{dia.enddialog(dia); pressed="OK"}).pack
TkButton.new(dia,'text'=>'Cancel',
'command'=>proc{dia.enddialog(dia); pressed="Cancel"}).pack

dia.draw

Is it really meant to be used that way? I bet I am missing some very
important details, but I can't figure out what it is.

BTW: There seems to be one more widget set called iwidgets. Anybody knows
what it is?
 
M

Morton Goldberg

BTW: There seems to be one more widget set called iwidgets.
Anybody knows
what it is?

The iwidget widget set is Ruby support for [incr Widgets]. You can
find documentation at <http://incrtcl.sourceforge.net/iwidgets/>.
This is Tk documentation, but the Ruby implementation seems to
follows it closely.

I have just began to experiment with [incr Widgets]. So far so good.
They are higher level than the basic Tk widgets and seem to easy to use.

Here is a list:

buttonbox
calendar
canvasprintbox
canvasprintdialog
checkbox
combobox
dateentry
datefield
dialog
dialogshell
disjointlistbox
entryfield
extbutton
extfileselectionbox
extfileselectiondialog
feedback
fileselectionbox
fileselectiondialog
finddialog
hierarchy
hyperhelp
labeledframe
labeledwidget
mainwindow
menubar
messagebox
messagedialog
notebook
optionmenu
panedwindow
promptdialog
pushbutton
radiobox
regexpfield
scrolledcanvas
scrolledframe
scrolledhtml
scrolledlistbox
scrolledtext
scrolledwidget
selectionbox
selectiondialog
shell
spindate
spinint
spinner
spintime
tabnotebook
tabset
timeentry
timefield
toolbar

Regards, Morton
 
J

Josef Wolf

On Mon, Sep 04, 2006 at 11:30:01AM +0900, Morton Goldberg wrote:

Thanks for your reply, Morton!
BTW: There seems to be one more widget set called iwidgets.
Anybody knows what it is?

The iwidget widget set is Ruby support for [incr Widgets]. You can
find documentation at <http://incrtcl.sourceforge.net/iwidgets/>.

This page mentions examples and tutorials, but I can't find them on
this site. A google search did not reveal anything useful, too. Could
you find anything useful?
This is Tk documentation, but the Ruby implementation seems to
follows it closely.

I have just began to experiment with [incr Widgets]. So far so good.
They are higher level than the basic Tk widgets and seem to easy to use.

Would you dare to share some examples how the ruby bindings are to be
used?
 
H

Hidetoshi NAGAI

From: Josef Wolf <[email protected]>
Subject: Re: TkDialogBox missing?
Date: Sun, 3 Sep 2006 21:50:54 +0900
Message-ID: said:
I can't figure out how to use this widget properly. I have two major
problems with it:

Please run '<ruby-src>/ext/tk/sample/tkextlib/bwidget/demo.rb',
and see ' said:
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
'<ruby-src>/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.
 
M

Morton Goldberg

On Mon, Sep 04, 2006 at 11:30:01AM +0900, Morton Goldberg wrote:

Thanks for your reply, Morton!
BTW: There seems to be one more widget set called iwidgets.
Anybody knows what it is?

The iwidget widget set is Ruby support for [incr Widgets]. You can
find documentation at <http://incrtcl.sourceforge.net/iwidgets/>.

This page mentions examples and tutorials, but I can't find them on
this site. A google search did not reveal anything useful, too.
Could
you find anything useful?

Did you try clicking on any of the widget names in the sidebar? When
I click on the name of a widget, I get a tutorial with example code
for that widget. In the lower right corner of the tutorial is a set
of buttons that link to reference material for the given widget.
Altogether I think this the [incr Widgets] are pretty well
documented. I could wish Ruby/Tk were so well documented.
This is Tk documentation, but the Ruby implementation seems to
follows it closely.

I have just began to experiment with [incr Widgets]. So far so good.
They are higher level than the basic Tk widgets and seem to easy
to use.

Would you dare to share some examples how the ruby bindings are to be
used?

I am new to both Ruby and Tk -- I have just started exploring, so I
don't have much to offer. All I have done (and only for a two of the
[incr Widgets]) is translate the web site's example code into Ruby/Tk
and probably not very elegantly. With that disclaimer in mind, do you
still want me to post my code?

Regards, Morton
 
H

Hidetoshi NAGAI

From: Morton Goldberg <[email protected]>
Subject: Re: TkDialogBox missing?
Date: Tue, 5 Sep 2006 14:13:47 +0900
Message-ID: said:
I am new to both Ruby and Tk -- I have just started exploring, so I
don't have much to offer. All I have done (and only for a two of the
[incr Widgets]) is translate the web site's example code into Ruby/Tk
and probably not very elegantly. With that disclaimer in mind, do you
still want me to post my code?

Do you have any requests for Iwidgets support of Ruby/Tk?
 
M

Morton Goldberg

From: Morton Goldberg <[email protected]>
Subject: Re: TkDialogBox missing?
Date: Tue, 5 Sep 2006 14:13:47 +0900
Message-ID: said:
I am new to both Ruby and Tk -- I have just started exploring, so I
don't have much to offer. All I have done (and only for a two of the
[incr Widgets]) is translate the web site's example code into Ruby/Tk
and probably not very elegantly. With that disclaimer in mind, do you
still want me to post my code?

Do you have any requests for Iwidgets support of Ruby/Tk?

Not at this stage of my explorations. So far what little I've tried
seems to work much as I expected. I really haven't gotten in deep
enough so that anything I've done moves me to make a support request.
There are still many [incr Widgets] with which I need to become
familiar before I use them in a real application. When I reach the
stage of building a real application, I think then I might find
myself moved to request support, but not before.

But thank you for asking.

Regards, Morton
 
J

Josef Wolf

On Sep 4, 2006, at 1:25 PM, Josef Wolf wrote:
The iwidget widget set is Ruby support for [incr Widgets]. You can
find documentation at <http://incrtcl.sourceforge.net/iwidgets/>.

This page mentions examples and tutorials, but I can't find them on
this site. A google search did not reveal anything useful, too.
Could you find anything useful?

Did you try clicking on any of the widget names in the sidebar?

Yes, but for me, this looks more like a man page than a tutorial. ;-)
Altogether I think this the [incr Widgets] are pretty well
documented. I could wish Ruby/Tk were so well documented.

Well, the iwidgets are documented for tcl. tcl documentation for Tk
is available, too. ;-)
I am new to both Ruby and Tk -- I have just started exploring, so I
don't have much to offer. All I have done (and only for a two of the
[incr Widgets]) is translate the web site's example code into Ruby/Tk
and probably not very elegantly. With that disclaimer in mind, do you
still want me to post my code?

We could try to reduce the documentation-vacuum by collecting some
examples how to use them. The examples need not be perfect from the
beginning. I bet many readers from this list would happily help
improving the code :)
 
J

Josef Wolf

Please see the next example.

Now with your example, it is pretty clear how it works. Thank you very
much!
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
'<ruby-src>/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb'.

If you want to install "iwidgets" ([incr Widgets]) from its source,
you have to compile it.

I have not checked yet whether I can use them. But their bindings seem
to be part of the ruby/tk package:

$ rpm -qf /usr/lib/ruby/1.8/tkextlib/iwidgets.rb
ruby-tk-1.8.2-11
$ cat /etc/SuSE-release
SUSE LINUX 10.0 (i586)
VERSION = 10.0
$
 
M

Morton Goldberg

Yes, but for me, this looks more like a man page than a tutorial. ;-)

A man page with sample code and a picture of the result? That's
hardly your typical Unix man page :)
Altogether I think this the [incr Widgets] are pretty well
documented. I could wish Ruby/Tk were so well documented.

Well, the iwidgets are documented for tcl. tcl documentation for Tk
is available, too. ;-)

I refer to it regularly. I could wish Ruby/Tk were so well documented :)
I am new to both Ruby and Tk -- I have just started exploring, so I
don't have much to offer. All I have done (and only for a two of the
[incr Widgets]) is translate the web site's example code into Ruby/Tk
and probably not very elegantly. With that disclaimer in mind, do you
still want me to post my code?

We could try to reduce the documentation-vacuum by collecting some
examples how to use them. The examples need not be perfect from the
beginning. I bet many readers from this list would happily help
improving the code :)

OK, I'll post and we'll see how it goes. I'll post each example in a
new thread. I think that would be best.

Regards, Morton
 
A

Andrew Thompson

Morton said:
Yes, but for me, this looks more like a man page than a tutorial. ;-)

A man page with sample code and a picture of the result? That's
hardly your typical Unix man page :)
Altogether I think this the [incr Widgets] are pretty well
documented. I could wish Ruby/Tk were so well documented.

Well, the iwidgets are documented for tcl. tcl documentation for Tk
is available, too. ;-)

I refer to it regularly. I could wish Ruby/Tk were so well documented :)
I am new to both Ruby and Tk -- I have just started exploring, so I
don't have much to offer. All I have done (and only for a two of the
[incr Widgets]) is translate the web site's example code into Ruby/Tk
and probably not very elegantly. With that disclaimer in mind, do you
still want me to post my code?

We could try to reduce the documentation-vacuum by collecting some
examples how to use them. The examples need not be perfect from the
beginning. I bet many readers from this list would happily help
improving the code :)

OK, I'll post and we'll see how it goes. I'll post each example in a
new thread. I think that would be best.

Regards, Morton

Hey all,

I've been doing a LOT of Ruby/TK development lately using a combination
of the builtin widgets and Tile. I was considering contributing back
some documentation and I'd be interested in helping out.

And, Hidetoshi NAGAI: I think I have found some bugs in the Tile
bindings. Are you still the Ruby/Tk maintainer? I have monkey-patched my
code, but I should probably submit the fixes to *someone*...

Andrew - sorry for using ruby-forum (I'm lazy)
 
H

Hidetoshi NAGAI

From: Josef Wolf <[email protected]>
Subject: Re: TkDialogBox missing?
Date: Wed, 6 Sep 2006 02:11:01 +0900
Message-ID: said:
I have not checked yet whether I can use them. But their bindings seem
to be part of the ruby/tk package:

$ rpm -qf /usr/lib/ruby/1.8/tkextlib/iwidgets.rb
ruby-tk-1.8.2-11
$ cat /etc/SuSE-release
SUSE LINUX 10.0 (i586)
VERSION = 10.0
$

It doesn't verify whether your Ruby/Tk can load Iwidgets extension or not.
Please exec "ruby /usr/lib/ruby/1.8/tkextlib/pkc_checker.rb".
If it denotes lack of libraries, you cannot use the extension.
For example, the following shows that Iwidgets is NOT available.
-------------------------------------------------------
:
:
Ready : itcl.rb : require->{}
*LACK : itcl/incr_tcl.rb : require->{} FAIL->[["Itcl", :package]]
Ready : itcl/setup.rb : require->{}

Ready : itk.rb : require->{}
*LACK : itk/incr_tk.rb : require->{} FAIL->[["Itk", :package]]
Ready : itk/setup.rb : require->{}

*LACK : iwidgets.rb : require->{} FAIL->[["tkextlib/itcl", :require_ruby_lib],
["tkextlib/itk", :require_ruby_lib], ["Iwidgets", :package]]
Ready : iwidgets/canvasprintbox.rb : require->{}
Ready : iwidgets/buttonbox.rb : require->{}
:
:
 
H

Hidetoshi NAGAI

From: Andrew Thompson <[email protected]>
Subject: Re: TkDialogBox missing?
Date: Wed, 6 Sep 2006 08:41:17 +0900
Message-ID: said:
I've been doing a LOT of Ruby/TK development lately using a combination
of the builtin widgets and Tile. I was considering contributing back
some documentation and I'd be interested in helping out.

And, Hidetoshi NAGAI: I think I have found some bugs in the Tile
bindings. Are you still the Ruby/Tk maintainer? I have monkey-patched my
code, but I should probably submit the fixes to *someone*...

Great! Please post here or send to me.
 
J

Josef Wolf

From: Josef Wolf <[email protected]>
I have not checked yet whether I can use them. But their bindings seem
to be part of the ruby/tk package:

$ rpm -qf /usr/lib/ruby/1.8/tkextlib/iwidgets.rb
ruby-tk-1.8.2-11
$ cat /etc/SuSE-release
SUSE LINUX 10.0 (i586)
VERSION = 10.0
$

It doesn't verify whether your Ruby/Tk can load Iwidgets extension or not.
Please exec "ruby /usr/lib/ruby/1.8/tkextlib/pkc_checker.rb".
If it denotes lack of libraries, you cannot use the extension.
For example, the following shows that Iwidgets is NOT available.
-------------------------------------------------------
:
:
Ready : itcl.rb : require->{}
*LACK : itcl/incr_tcl.rb : require->{} FAIL->[["Itcl", :package]]
Ready : itcl/setup.rb : require->{}

Ready : itk.rb : require->{}
*LACK : itk/incr_tk.rb : require->{} FAIL->[["Itk", :package]]
Ready : itk/setup.rb : require->{}

*LACK : iwidgets.rb : require->{} FAIL->[["tkextlib/itcl", :require_ruby_lib],
["tkextlib/itk", :require_ruby_lib], ["Iwidgets", :package]]
Ready : iwidgets/canvasprintbox.rb : require->{}
Ready : iwidgets/buttonbox.rb : require->{}
:
:
-------------------------------------------------------

$ ruby /usr/lib/ruby/1.8/tkextlib/pkg_checker.rb
[ ... ]
Ready : itcl.rb : require->{}
Ready : itcl/incr_tcl.rb : require->{"Itcl"=>"3.3"}
Ready : itcl/setup.rb : require->{}
[ ... ]
Ready : itk.rb : require->{}
Ready : itk/incr_tk.rb : require->{"Itk"=>"3.3"}
Ready : itk/setup.rb : require->{}

Ready : iwidgets.rb : require->{"Iwidgets"=>"4.0.1"}
Ready : iwidgets/canvasprintbox.rb : require->{}
Ready : iwidgets/buttonbox.rb : require->{}
[ ... ]
Ready : iwidgets/timefield.rb : require->{}
Ready : iwidgets/toolbar.rb : require->{}
Ready : iwidgets/watch.rb : require->{}

Looks like they are ready to be used?
 
A

Andrew Thompson

Hidetoshi said:
Great! Please post here or send to me.

Okay, it's been a while since I wrote these, so I'm not entirely sure
what I ended up changing... if you have any questions, please ask...
This was all minor tweaks I believe...

#add the 'tab' method so we can do per-tab configuration
class Tk::Tile::TNotebook
def tab(idx, keys=nil)
if keys and keys != None
tk_send('tab', idx, *hash_kv(keys))
else
tk_send('tab', idx)
end
end
def select(idx=nil)
if idx
tk_send('select', idx)
else
tk_send('select')
end
self
end
end

class Tk::Tile::TCombobox
def current
number(tk_send_without_enc('current'))
end
end

#insert should return the rowid
class Tk::Tile::Treeview
def insert(parent, idx, keys={})
keys = _symbolkey2str(keys)
id = keys.delete('id')
if id
tk_send('insert', parent, idx, '-id', id, *hash_kv(keys))
else
tk_send('insert', parent, idx, *hash_kv(keys))
end
end
end

Andrew
 
H

Hidetoshi NAGAI

From: Josef Wolf <[email protected]>
Subject: Re: TkDialogBox missing?
Date: Thu, 7 Sep 2006 01:40:35 +0900
Message-ID: said:
$ ruby /usr/lib/ruby/1.8/tkextlib/pkg_checker.rb
[ ... ]
Ready : itcl.rb : require->{}
Ready : itcl/incr_tcl.rb : require->{"Itcl"=>"3.3"}
Ready : itcl/setup.rb : require->{}
[ ... ]
Ready : itk.rb : require->{}
Ready : itk/incr_tk.rb : require->{"Itk"=>"3.3"}
Ready : itk/setup.rb : require->{}

Ready : iwidgets.rb : require->{"Iwidgets"=>"4.0.1"}
Ready : iwidgets/canvasprintbox.rb : require->{}
Ready : iwidgets/buttonbox.rb : require->{}
[ ... ]
Ready : iwidgets/timefield.rb : require->{}
Ready : iwidgets/toolbar.rb : require->{}
Ready : iwidgets/watch.rb : require->{}

Looks like they are ready to be used?

I think so.
 
H

Hidetoshi NAGAI

From: Andrew Thompson <[email protected]>
Subject: Re: TkDialogBox missing?
Date: Thu, 7 Sep 2006 03:23:04 +0900
Message-ID: said:
Okay, it's been a while since I wrote these, so I'm not entirely sure
what I ended up changing... if you have any questions, please ask...

Thank you for your patch. I have some questions.

* Which version of Tile extension is your patch based on?

* [about Tk::Tile::TNotebook#tab]
There are Tk::Tile::TNotebook#tabconfigure, tabconfiginfo, tabcget,
and current_tabconfiginfo (similar as item configuration strategy on
other widgets). Aren't those enough?

* [about Tk::Tile::TNotebook#select]
How about adding new method "Tk::Tile::TNotebook#selected"?
-------------------------------------------
class Tk::Tile::TNotebook
def selected
num_or_str(tk_send_without_enc('select'))
end
end
-------------------------------------------

* [about Tk::Tile::Treeview#insert]
Is the following OK?
-------------------------------------------
class Tk::Tile::Treeview
def insert(parent, idx, keys={})
keys = _symbolkey2str(keys)
id = keys.delete('id')
if id
num_or_str(tk_send('insert', parent, idx, '-id', id, *hash_kv(keys)))
else
num_or_str(tk_send('insert', parent, idx, *hash_kv(keys)))
end
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top