Hi Paul, On Tue, 30 Jul 2013 12:02:37 +0200 Paul Malherbe <p...@tartan.co.za> wrote:
> HI > > I have a question regarding tkFileDialog. > > Is there any way I can create the dialog with customised dimensions as > the default is very small? There doesn't seem to be something obvious. I tried to use the option database with: root.option_add('*TkFDialog*width', 40) root.option_add('*TkFDialog*height', 40) which to my surprise actually made the dialog rather wide (though I am not sure about the units, but had no effect on the dialog's height. Then I tried another, more ambtious approach, with: root.tk.call('wm', 'geometry', '.__tk_filedialog', '800x600') which apparently fails if no dialog windoe has been created yet. Finally I actually got it working, with this somewhat weird bit of code: ######################################################################### from Tkinter import * from tkFileDialog import askopenfilename, asksaveasfilename root=Tk() def test(): #print 'test' try: w, h = root.winfo_screenwidth(), root.winfo_screenheight() x, y = w / 2 - 400, h /2 - 300 root.tk.call('wm', 'geometry', '.__tk_filedialog', '800x600+%d+%d' % (x, y)) except TclError: root.after(100, test) test() def test1(ev): askopenfilename() def test2(ev): asksaveasfilename() root.bind('<F1>', test1) root.bind('<F2>', test2) root.mainloop() ######################################################################### Hmm... the "center on screen" gimmick works only with the first dialog, can someone fix that ;) Anyway, unless we come up with something better, I'd classify this as strictly "don't try this at home"-ish :) Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. No one wants war. -- Kirk, "Errand of Mercy", stardate 3201.7 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss