From: Hidetoshi NAGAI Date: 2009-10-10T07:25:24+09:00 Subject: Re: better looking directory chooser for tk? From: Roger Pack Subject: better looking directory chooser for tk? Date: Fri, 9 Oct 2009 22:20:58 +0900 Message-ID: > Currently in windows with Tk > if I run > Tk.chooseDirectory > > it gives me the cruddy "teeny windows" version that forces you to start > at my computer to navigate through, and the window can't be expanded, > even. Please see the section "Standard Dialogs" on http://www.tkdocs.com/tutorial/windows.html (at TkDocs site). The dialog is a standard one on a Windows version of Tk. To give an initial directory, please use 'initialdir' option (e.g. Tk.chooseDirectory(:initaildir=>'c:\ruby'). Its full option is: (:initialdir=>'dir-when-pops-up', :parent=>logical-parent-widget, :title=>"title-string-of-dialogbox", :mustexist=>boolean-value) Please read the Tcl/Tk's man page of "tk_chooseDirectory" about the option values. > Anybody know how I can get a better looking directory chooser? I know > it's possible, since other programs have the normal ones. If you hate the standard dialogs, you must create your own dialogs. However, if the "other programs" which you said are written in Tcl/Tk (Tcl/Tk script only, or with some Tcl/Tk extensions which work on your environment), you can load and use them on Ruby/Tk. For example, the standard "tk_chooseDirectory" dialog on Unix (Linux) is written in pure Tcl/Tk (see /choosedir.tcl). So, you can use it on Windows. The following replaces Tk.chooseDirectory method to the Unix version. ------------------------------------------------------------------ Tk.load_tclscript(File.join(Tk::TK_LIBRARY, "choosedir.tcl")) def Tk.chooseDirectory(params = {}) Tk.tk_call('::tk::dialog::file::chooseDir::', params) end ------------------------------------------------------------------ -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)