How to create an unclosed dialog in wxPython?

Ê

Êé³æ

In wxPython, after I create a wx.Frame, I want to create a modeless
and unclosed dialog. Here is my step:

app = wx.PySimpleApp()
f = wx.Frame(None, -1, "Test")
d = wx.Dialog(f, -1, "Test Dialog", style = wx.CAPTION)
f.Show()
d.Show()
app.MainLoop()

As you see, I create a dialog with wx.CAPTION style. And than, there
is no close button in this dialog. It seems unclosed dialog, but in
fact, if you enter Alt+F4 in this dialog, it will close. How could I
do?
 
L

liangguanhui

In wxPython, after I create a wx.Frame, I want to create a modeless
and unclosed dialog. Here is my step:

app = wx.PySimpleApp()
f = wx.Frame(None, -1, "Test")
d = wx.Dialog(f, -1, "Test Dialog", style = wx.CAPTION)
f.Show()
d.Show()
app.MainLoop()

As you see, I create a dialog with wx.CAPTION style. And than, there
is no close button in this dialog. It seems unclosed dialog, but in
fact, if you enter Alt+F4 in this dialog, it will close. How could I
do?

Binds the wx.EVT_CLOSE event and ignor it in the handle function.
 
M

Mike Driscoll

Binds the wx.EVT_CLOSE event and ignor it in the handle function.

This is the preferred method...there is a slight caveat that when you
actually want to close the dialog, you'll need to use the dialog's
Destroy() method...

- Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top