Sorry for the slow reply, busy week last week. Replace Michael's filedialog function with the following:
def filedialog(): oldFoc = top.focus_get() print tkFileDialog.askopenfilename() if oldFoc: oldFoc.focus_set() ...then you should have the behaviour you expect. (the 'if' is necessary in case their is no prior focus). At least on my Windows XP running Python 2.5.3 Mick On Wed, Oct 14, 2009 at 4:14 AM, BlackKnight <wwwwar3...@gmail.com> wrote: > Hi folks, > > I am using Tkinter to do a simple GUI for my program. > > It contains A MainGui and A ChildGui: > A button on the MainGUI will popout the childgui. > On the childgui there is a browse button which popout a dialog to allow > user to browser and choose a file. > > I have no problem at doing them. > > The problem is after the uesr choose a file the focus will return to the > MainGui intead of the childgui. The child gui just go hide behind the Main. > > I've tried focus_set, focus_force but none of them seem work. > > I did some research but found nothing working. It's not a big problem, > but is really really annoying. > (Actually I notice the examples from some python book I am reading has > the exact same problem. The author even tried to spawn the child gui > away from the main one, so when the focus return from the browse dialog > , the maingui won't block the child one~~ Is that how tkinter should work?) > > Any suggestions? > > Thanks in advance~~ > > > Frank > > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss@python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss