A
Albert Schlef
I have a program that run in the terminal. But once in a while I need it
to bring up a window (GUI) with some information (and interactive
widgets).
So I do:
root = TkRoot.new
.....set up the window.....
Tk.mainloop
This works. Then the user closes the window and the program continues
running.
HOWEVER, the next time I try to bring up the window, Tk gives the
following error:
can't invoke "frame" command: application has been destroyed
(RuntimeError)
(I also tried with TkToplevel instead of TkRoot.)
How can I solve this problem?
I looked into the source code of '/ext/tk/lib/dialog.rb', thinking
perhaps TkDialog is what I need. I tried the following code:
class MyDialog < TkDialog
def initialize(*args)
super(*args)
TkLabel.new(self, :text => 'this is a test').pack
end
end
MyDialog.new :title => 'something'
Now, this is already an improvement because I can call MyDialog.new()
again and again without Tk telling me that the "application has been
destroyed". HOWEVER, I can't put my own widgets in the dialog: my 'this
is a test' label doesn't show up...
to bring up a window (GUI) with some information (and interactive
widgets).
So I do:
root = TkRoot.new
.....set up the window.....
Tk.mainloop
This works. Then the user closes the window and the program continues
running.
HOWEVER, the next time I try to bring up the window, Tk gives the
following error:
can't invoke "frame" command: application has been destroyed
(RuntimeError)
(I also tried with TkToplevel instead of TkRoot.)
How can I solve this problem?
I looked into the source code of '/ext/tk/lib/dialog.rb', thinking
perhaps TkDialog is what I need. I tried the following code:
class MyDialog < TkDialog
def initialize(*args)
super(*args)
TkLabel.new(self, :text => 'this is a test').pack
end
end
MyDialog.new :title => 'something'
Now, this is already an improvement because I can call MyDialog.new()
again and again without Tk telling me that the "application has been
destroyed". HOWEVER, I can't put my own widgets in the dialog: my 'this
is a test' label doesn't show up...