From: Kevin Smith Date: 2000-12-18T10:02:29+09:00 Subject: [ruby-talk:7527] Re: Popping up secondary Tk windows harryo@zipworld.com.au (Harry Ohlsen) wrote: >I've written a simple Tk-based GUI using Ruby and, so far, I've been >able to work out how to do everything I need by reading Tcl and perl >Tk documentation or from searches on Google. > >However, I've now hit a bit of a brick wall. I have a situation where >I want to pop up a data entry window at the current cursor location, >to allow the user to enter a label to associate with an item on the >screen. > >Can someone point me at an example of code that does this in any >language at all? I can't copy/paste at the moment (don't ask), but here's a paraphrased version of my working ruby code. Hopefully I won't put in a stupid typo that messes you up. It assumes that the main app has already created its own root window. root = TkRoot.new # root is a singleton--get it window = TkToplevel.new(root) window.title('Compose Message') label = TkLabel.new(window) label.text('Tl:') label.grid('row' => '1', 'column' => '0', 'sticky' => 'nw') # could use pack instead to = TkEntry.new(window) to.grid('row' => '1', 'column' => '1', 'sticky' => 'nsew') # could use pack instead This is invoked in response to a command, and will create a new toplevel window. After this code returns, the new window will remain open and the main message loop will serve both windows. Kevin