473,378 Members | 1,438 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,378 software developers and data experts.

How to make Python identify GUI buttons by their label

The contractor we hired told us that Python can only recognize GUI objects, specifically buttons, by their ID. This is very inconvenient and hard to work with as the button IDs change a lot between builds. Instead, I want to reference a button by its label like "Save", "Preview", or "Submit." Does anyone know how I can accomplish this?

We use ActiveState ActivePython 2.6.4.8 (32 bit), wxPython 2.8.10.1, and PyScripter 2.3.3.

Thx in advance,
Christopher
Nov 8 '10 #1
2 2268
bvdet
2,851 Expert Mod 2GB
I would say your contractor may be right, assuming he means assigning the GUI object to a descriptive identifier instead of the literal ID (masterframe vs. .18497168). I don't know much about wxPython though. In Tkinter, you can access the widgets of a master widget with widget method winfo_children(), iterate on the GUI objects, access each object's options dictionary with configure() and look for a text attribute with the appropriate value. That seems like too much work to me.

Maybe you should consider refactoring your code so it would be easier to maintain between builds.
Nov 10 '10 #2
Mariostg
332 100+
That is pretty much how WxPython works. Check the Window Identifier (A button is a Window in WxPython)section at http://zetcode.com/wxpython/events/ to get a better idea.
There is a method GetID() that allows to retreive the id of widgets. So I don't know how that would be a show stopper. There are also standard identifiers like WX_EXIT, EX_SAVE.
Ultimately, you can always map your labels to their ID in a dictionary. But I would let WxPython do its business logic...
Nov 10 '10 #3

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

Similar topics

1
by: Tim Bradshaw | last post by:
I'd like to be able to install python with stow, and then to install various modules which use distutils, also with stow. This currently pretty much won't work, because Python chases symlinks to...
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....
5
by: TomB | last post by:
Please take a look at this page: http://deimos.curious.be/~dusk/contact.php?action=show_booking As you can see the radio/check buttons do not line up with their label. It works with the input...
1
by: Benjamin Grant | last post by:
Hi all, I'd greatly appreciate any help. I can configure, make and install everything fine. I'm using python 2.4 I have ubuntu dapper drake. I am trying to install hplip which requires python. ...
7
by: dmitrey | last post by:
howto make Python list from numpy.array? Thx, D.
8
by: Alexey Smirnov | last post by:
How to make bold part of the text in a Windows.Forms.Label? Thank you.
9
by: korean_dave | last post by:
From command Prompt, i type in a script, "tryme.py". This, instead, brings up PythonWin editor and Interactive Window. Path variable is "C:\Python24". (I need Python 2.4 installed, not 2.5) ...
8
tharden3
by: tharden3 | last post by:
I just want to see what others have made. Any of you make Python Programs that you use for day to day tasks like Calendar keeping or simple calculations? Maybe a conversion tool? Have you written any...
3
by: theConker | last post by:
how i wanna make the maximumLength dynamically, not fixed as below? <af:inputText label="id :" columns="10" maximumLength="20" ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.