By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,715 Members | 748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

Another Question

P: n/a
How can i bind function that handle the mouse clicking window X event
or clicking alt+F4
thanks
Jun 27 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On May 23, 10:45*am, Gandalf <goldn...@gmail.comwrote:
How can i bind function that handle the mouse clicking *window X event
or clicking alt+F4

thanks
You really need to learn to ask good questions. Unless people dive
into your previous posts, they won't know what Python GUI toolkit you
are using, which version of said toolkit, which Python or which OS.

Here's a good place to read about events in general:

http://wiki.wxpython.org/EventPropagation

If you use Google, you can look for the close event, which gives you
this:

http://www.wxpython.org/docs/api/wx....ent-class.html

So you'll want to bind your frame to EVT_CLOSE. You can disable the
"X" in your frame's window by using non-standard style parameters.

Mike
Jun 27 '08 #2

P: n/a
On May 23, 6:25 pm, Mike Driscoll <kyoso...@gmail.comwrote:
On May 23, 10:45 am, Gandalf <goldn...@gmail.comwrote:
How can i bind function that handle the mouse clicking window X event
or clicking alt+F4
thanks

You really need to learn to ask good questions. Unless people dive
into your previous posts, they won't know what Python GUI toolkit you
are using, which version of said toolkit, which Python or which OS.

Here's a good place to read about events in general:

http://wiki.wxpython.org/EventPropagation

If you use Google, you can look for the close event, which gives you
this:

http://www.wxpython.org/docs/api/wx....ent-class.html

So you'll want to bind your frame to EVT_CLOSE. You can disable the
"X" in your frame's window by using non-standard style parameters.

Mike
OK you right. I use WX on windows XP.
I didn't understood how to use this wx.CloseEvent function.

i really struggle with my poor english to understand this language, so
your help is crucial for my progress and i appreciate it

Thanks
Jun 27 '08 #3

P: n/a
On May 23, 12:02*pm, Gandalf <goldn...@gmail.comwrote:
On May 23, 6:25 pm, Mike Driscoll <kyoso...@gmail.comwrote:
On May 23, 10:45 am, Gandalf <goldn...@gmail.comwrote:
How can i bind function that handle the mouse clicking *window X event
or clicking alt+F4
thanks
You really need to learn to ask good questions. Unless people dive
into your previous posts, they won't know what Python GUI toolkit you
are using, which version of said toolkit, which Python or which OS.
Here's a good place to read about events in general:
http://wiki.wxpython.org/EventPropagation
If you use Google, you can look for the close event, which gives you
this:
http://www.wxpython.org/docs/api/wx....ent-class.html
So you'll want to bind your frame to EVT_CLOSE. You can disable the
"X" in your frame's window by using non-standard style parameters.
Mike

OK you right. I use WX on windows XP.
I didn't understood how to use this wx.CloseEvent function.

i really struggle with my poor english to understand this language, so
your help is crucial for my progress and i appreciate it

Thanks
No problem. It just makes it much harder to help if we don't know what
you're doing. I forget to mention stuff when I post too.

Just in case you still don't get it, here's some generic code:

<code>

self.frame.Bind(wx.EVT_CLOSE, self.onClose)

def onClose(self, event):
self.frame.Destroy()

</code>

Note that I called the frame's Destroy() method instead of its Close()
method. If you call Close() then the EVT_CLOSE event gets fired again
and you basically end up in a loop.

Mike
Jun 27 '08 #4

P: n/a
you've been very helpful but still i have only one problem. I wont the
window not to be close after clicking the X button.
I wont the program to stay on the toolbar

thanks!
Jun 27 '08 #5

P: n/a
On May 23, 1:44*pm, Gandalf <goldn...@gmail.comwrote:
you've been very helpful but still i have only one problem. I wont the
window not to be close after clicking the X button.
I wont the program to stay on the toolbar

thanks!
Well then, in your event handler, just don't do anything.

def onClose(self, event):
pass

or maybe you want to hide the frame?

def onClose(self, event):
self.frame.Hide()

Just make sure you give the user some other way to close it and in
that handler, you'll need to call self.frame.Destroy().

Alternatively, you can just tell the frame not to create the "X"
button:

self.frame = wx.Frame(None, -1, title="My Frame",
style=wx.SYSTEM_MENU)

However, that makes it pretty annoying to close.

Mike
Jun 27 '08 #6

P: n/a
On May 23, 10:47 pm, Mike Driscoll <kyoso...@gmail.comwrote:
On May 23, 1:44 pm, Gandalf <goldn...@gmail.comwrote:
you've been very helpful but still i have only one problem. I wont the
window not to be close after clicking the X button.
I wont the program to stay on the toolbar
thanks!

Well then, in your event handler, just don't do anything.

def onClose(self, event):
pass

or maybe you want to hide the frame?

def onClose(self, event):
self.frame.Hide()

Just make sure you give the user some other way to close it and in
that handler, you'll need to call self.frame.Destroy().

Alternatively, you can just tell the frame not to create the "X"
button:

self.frame = wx.Frame(None, -1, title="My Frame",
style=wx.SYSTEM_MENU)

However, that makes it pretty annoying to close.

Mike
OK the first method still didn't work. no matter what i do the window
keep closing but the last one worked nice and all the top menu
disappear

thanks!
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.