473,224 Members | 1,459 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Binding wxPython events to buttons

2
This is a problem faced by one of my friends. I have NO knowledge of Python but am just eager to help him.

He created a button using Python 2.4 and used event bindings using the id for the button in the format

self.Bind(wx.EVT_MENU, self.quit, id=102) (this is not from his code)

Now he migrated to Python 2.5 and for a certain button, he did the button (lets say A) click binding without the id.

But now he faces problems where if he clicks this button (A) a function bound to some other button is called. Could this have anything to do with the internal ids created for buttons ??

Please let me know if this query makes no sense because I have NO KNOWLEDGE about Python.
Oct 4 '07 #1
3 5724
bartonc
6,596 Expert 4TB
This is a problem faced by one of my friends. I have NO knowledge of Python but am just eager to help him.

He created a button using Python 2.4 and used event bindings using the id for the button in the format

self.Bind(wx.EVT_MENU, self.quit, id=102) (this is not from his code)

Now he migrated to Python 2.5 and for a certain button, he did the button (lets say A) click binding without the id.

But now he faces problems where if he clicks this button (A) a function bound to some other button is called. Could this have anything to do with the internal ids created for buttons ??

Please let me know if this query makes no sense because I have NO KNOWLEDGE about Python.
The Python version has nothing to do with this issue.
This is the old "self.bind vs button.bind" issue. Buttons are normally bound directly to their handlers. As in:
Expand|Select|Wrap|Line Numbers
  1. wxID_TRAILDATAVIEWERCOMMITBUTTON = wx.NewID()
  2.         self.CommitButton = wx.Button(id=wxID_TRAILDATAVIEWERCOMMITBUTTON,
  3.                label='Apply Changes',
  4.                name='CommitButton',
  5.                parent=self,
  6.                pos=wx.Point(20, 624),
  7.                size=wx.Size(184, 34),
  8.                style=0)
  9.         self.CommitButton.Bind(wx.EVT_BUTTON, self.OnCommitButton,
  10.                 id=wxID_TRAILDATAVIEWERCOMMITBUTTON)
I can post a link to an article that talks about these issues, if you like.

Note also that it is very bad practice to use literals in the ID argument. They may collide with IDs used internally.
Oct 4 '07 #2
swbi
2
The Python version has nothing to do with this issue.
This is the old "self.bind vs button.bind" issue. Buttons are normally bound directly to their handlers. As in:
Expand|Select|Wrap|Line Numbers
  1. wxID_TRAILDATAVIEWERCOMMITBUTTON = wx.NewID()
  2.         self.CommitButton = wx.Button(id=wxID_TRAILDATAVIEWERCOMMITBUTTON,
  3.                label='Apply Changes',
  4.                name='CommitButton',
  5.                parent=self,
  6.                pos=wx.Point(20, 624),
  7.                size=wx.Size(184, 34),
  8.                style=0)
  9.         self.CommitButton.Bind(wx.EVT_BUTTON, self.OnCommitButton,
  10.                 id=wxID_TRAILDATAVIEWERCOMMITBUTTON)
I can post a link to an article that talks about these issues, if you like.

Note also that it is very bad practice to use literals in the ID argument. They may collide with IDs used internally.

Thank you for your response. Can you please point me to the appropriate link that talks about such issues.
We are not using literals in our ID arguments. We are creating new IDs using wx.NewId() call. Can there still be clashes between the internal IDs and the ones used in the program.
Another thing to point about the code is that my friend is using a mixed approach of self.bind() and button.bind() . Could this be causing a problem ?
Oct 5 '07 #3
bartonc
6,596 Expert 4TB
Thank you for your response. Can you please point me to the appropriate link that talks about such issues.
We are not using literals in our ID arguments. We are creating new IDs using wx.NewId() call. Can there still be clashes between the internal IDs and the ones used in the program.
Another thing to point about the code is that my friend is using a mixed approach of self.bind() and button.bind() . Could this be causing a problem ?
This article in the Python Forum Articles section links to an in-depth article on this issue. I'm linking to the articles section here to make people aware of its existence.
Oct 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Grant Edwards | last post by:
Can anybody recommend a good book on wxPython? Are there any books on wxPython? I've been trying to learn wxPython and/or wax for a few weeks, and I'm just not getting it. wxWindows seems...
8
by: Erik Johnson | last post by:
I am looking for some input on GUI libraries. I want to build a Python-driven GUI, but don't really understand the playing field very well. I have generally heard good things about wxPython. I...
4
by: KvS | last post by:
Hi all, I'm pretty new to (wx)Python so plz. don't shoot me if I've missed something obvious ;). I have a panel inside a frame, on which a Button and a StaticText is placed: self.panel =...
2
by: Larry Lard | last post by:
Here's the scenario: Show the user a list of Things. User picks one, and the Thing edit frame is populated with the details of the Thing they picked. This frame has Save / Discard buttons that...
6
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.2 release of wxPython is now available for download at http://wxpython.org/download.php. This is a mostly bug fix release and takes care of several "unfortunate...
0
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.2 release of wxPython is now available for download at http://wxpython.org/download.php. This is a mostly bug fix release and takes care of several "unfortunate...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
2
by: Kevin Walzer | last post by:
I'm porting a Tkinter application to wxPython and had a question about wxPython's event loop. The Tkinter app provides a GUI to a command-line tool. It gathers user input, and opens an...
7
by: Terry Carroll | last post by:
I'm trying to use wx.ProgressBar, and the cancel button is not responding. Here is a simple program that exhibits the problem: ######################################################### import...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.