From: Morton Goldberg Date: 2006-08-20T05:58:18+09:00 Subject: Re: help with TkRoot Now that I've looked a little deeper into the problem, I see that Tk.root.withdraw wouldn't be useful, because in your case, if you use it, you won't see the root window's menu bar. What to do? Well, you might try something like the following: root = TkRoot.new {title 'Ruby Tk'} mnu_bar = TkMenu.new() windo_mnu = TkMenu.new(mnu_bar) windo_mnu.add_command( 'label'=>"Show", 'command'=>lambda {windo_mnu.show} ) windo_mnu.add_command( 'label'=>"Hide", 'state'=>'disabled', 'command'=>lambda {windo_mnu.hide} ) def windo_mnu.show entryconfigure(0, 'state'=>'disabled') # disable show entryconfigure(1, 'state'=>'normal') # enable hide Tk.root.geometry($visible) end def windo_mnu.hide entryconfigure(1, 'state'=>'disabled') # disable hide entryconfigure(0, 'state'=>'normal') # enable show Tk.root.geometry("0x0+0+0") end mnu_bar.add_cascade('label'=>"Window", 'menu'=>windo_mnu) root.menu(mnu_bar) min_w, min_h = 200, 100 root.minsize(min_w, min_h) root_x = (root.winfo_screenwidth - min_w) / 2 $visible = "#{min_w}x#{min_h}+#{root_x}+50" root.geometry("0x0+0+0") root.bind('Command-q') {exit} Tk.mainloop This is my best shot at the moment. It's not very elegant since you can still see the vestigial root window in the upper left-hand corner of the screen if you look hard, but perhaps it's good enough to fool your users :) Regards, Morton On Aug 19, 2006, at 3:23 PM, Morton Goldberg wrote: > Yes, you can make the root window invisible. The following produces > a default menu bar but no (visible) root window on my Mac: > > require 'tk' > > root = TkRoot.new > root.withdraw > Tk.mainloop