Hi,
From: tony summerfelt <
[email protected]>
Subject: Interactive Fox GUI Builder and Code Generator
Date: Mon, 10 Jan 2005 03:44:52 +0900
Message-ID: <
[email protected]>
i did not know that...has anybody done this and liked the results?
for me that's a good short term solution.
However, you must decide how to get information from your GUI.
The following is a sample of using Tcl/Tk's 'rolodex' demo.
Please attend that Ruby/Tk creates widget objects automatically
when refers the widgets.
# Of course, you can create a widget object for a widget
# (that already exists) by your method call.
# e.g. TkEntry.new
widgetname=>'.frame.entry1', :without_creating=>true)
----------------------------------------------------------
$ /usr/local/bin/irb -r tk
irb(main):001:0> Tk.load_tclscript('rolodex')
=> ""
irb(main):002:0> Thread.new{Tk.mainloop}
=> #<Thread:0x40308768 sleep>
irb(main):003:0> TkWinfo.children(Tk.root)
=> [#<TkFrame:0x402f08c0 @path=".frame", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>, #<TkFrame:0x402ed9f4 @path=".buttons", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>, #<TkFrame:0x402ed3f0 @path=".menu", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>]
irb(main):004:0> TkWinfo.children(Tk.root).size
=> 3
irb(main):005:0> f = TkWinfo.children(Tk.root)[0]
=> #<TkFrame:0x402f08c0 @path=".frame", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>
irb(main):006:0> TkWinfo.children(f)
=> [#<TkLabel:0x402e496c @path=".frame.label1">, #<TkEntry:0x4021f600 @path=".frame.entry1">, #<TkLabel:0x4021d51c @path=".frame.label2">, #<TkEntry:0x4021b578 @path=".frame.entry2">, #<TkLabel:0x40219750 @path=".frame.label3">, #<TkEntry:0x4021810c @path=".frame.entry3">, #<TkLabel:0x40217a90 @path=".frame.label4">, #<TkEntry:0x402174dc @path=".frame.entry4">, #<TkLabel:0x40216d20 @path=".frame.label5">, #<TkEntry:0x40215a38 @path=".frame.entry5">, #<TkLabel:0x402147a0 @path=".frame.label6">, #<TkEntry:0x402128b0 @path=".frame.entry6">, #<TkLabel:0x40211140 @path=".frame.label7">, #<TkEntry:0x4020fc3c @path=".frame.entry7">]
irb(main):007:0> TkWinfo.children(f)[1].insert
end, 'asdf')
=> #<TkEntry:0x4021f600 @path=".frame.entry1">
irb(main):008:0> e = TkWinfo.children(f)[1]
=> #<TkEntry:0x4021f600 @path=".frame.entry1">
irb(main):009:0> e.insert
end, 'qwer')
=> #<TkEntry:0x4021f600 @path=".frame.entry1">
irb(main):010:0> e.value
=> "asdfqwer"
irb(main):011:0>