wxPython frame

Dan Perl danperl at rogers.com
Tue Nov 2 10:26:07 EST 2004


"Austin" <austin at maxtronic.com.tw> wrote in message 
news:41872581$1 at news.seeder.net...
> In tkinter, the dialogs  has the function grab_set(). That means disable
> other windows while it's open.
> Is there any function like that in wxPython. I want to use it on my frame.
> For example, a.py is main frame. There is a button "config" to open
> b.py(config frame).
> If the function exists in wxPython, i could put that in b.py when b.py is
> open and we couldn't
> click a.py. Or any other ways to avoid click a.py when b.py is open.
>
> Thanks a lot.

Your question refers to frames, but I think you may mean dialogs (subclasses 
of wx.Dialog).  So wx.Dialog.ShowModal( ) may be what you're looking for. 
See 
http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin_wxdialog.html#wxdialogshowmodal.

Here is an example with a file dialog from a project I am working on:
        dlg = wx.FileDialog(
            self,
            message="Save file as ...",
            defaultDir=os.path.join(os.environ['zigzag_install_dir'], 
'config'),
            wildcard="Python source (*.py)|*.py",
            style=wx.SAVE
            )
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            # Open the file and write into it
            saveFile = file(path, "w")
            # [...] removed code that writes into the file
            saveFile.close()
        dlg.Destroy()

Peter is right though, you may be better off asking questions on wxPython in 
the wxPython mailing list (http://www.wxpython.org/maillist.php).

Dan 





More information about the Python-list mailing list