473,503 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pythoncard Multiple components

I am using pythoncard 0.7.2 for windows.

I am trying to use the same code for a large number of buttons so
started out by using
def on_mouseDown(self,event):

but then I need to display the button that I pressed but you can only
have an absolute component name like:
self.component.Button1.label = "clicked"

How can I identify the button pressed and still use the same procedure
to update the clicked button? I tried self.component.label =
"clicked" with out the reference to the actual button used?

Any ideas, especially snippets of code if you have to start using
self.components.data etc.

A second question occurres: Is it possible to create a component at
run time? If so how would you start.
Thanks
"Python... the way C++ programming should be :)"
Jul 18 '05 #1
2 2065
In article <37**************************@posting.google.com >, Adrian Smith:
I am using pythoncard 0.7.2 for windows.

I am trying to use the same code for a large number of buttons so
started out by using
def on_mouseDown(self,event):

but then I need to display the button that I pressed but you can only
have an absolute component name like:
self.component.Button1.label = "clicked"

How can I identify the button pressed and still use the same procedure
to update the clicked button? I tried self.component.label =
"clicked" with out the reference to the actual button used?

Any ideas, especially snippets of code if you have to start using
self.components.data etc.

I have a pythoncard app where I want to know which of a (large)
number of checkboxes gets clicked. I do something like:

def on_mouseClick(self, event):
name = event.target.name
if name in self.availability.times:
button = getattr(self.components, name)
avail = self.availability.avail[name]
#print dir(button)
if button.checked:
if button.backgroundColor == AVAIL:
self.availability.avail[name] = 1
else:
self.availability.avail[name] = 0
button.backgroundColor = (255, 255, 255)
else:
if self.availability.avail[name]:
button.backgroundColor = AVAIL
else:
button.backgroundColor = UNAVAIL
Notice my comment #print dir(button) I use those quite often
when doing pythoncard just to see what it is that I have a
handle on, and what I can do with it.

A second question occurres: Is it possible to create a component at
run time? If so how would you start.
Thanks


I am pretty sure that the pythoncard resource editor is written in
pythoncard, so I would say "yes" and "read the pythoncard source code".

Jul 18 '05 #2
Lee Harr wrote:
In article <37**************************@posting.google.com >, Adrian Smith:
I am using pythoncard 0.7.2 for windows.

I am trying to use the same code for a large number of buttons so
started out by using
def on_mouseDown(self,event):

but then I need to display the button that I pressed but you can only
have an absolute component name like:
self.component.Button1.label = "clicked"

How can I identify the button pressed and still use the same procedure
to update the clicked button? I tried self.component.label =
"clicked" with out the reference to the actual button used?

Any ideas, especially snippets of code if you have to start using
self.components.data etc.

I have a pythoncard app where I want to know which of a (large)
number of checkboxes gets clicked. I do something like:

def on_mouseClick(self, event):
name = event.target.name
if name in self.availability.times:
button = getattr(self.components, name)
avail = self.availability.avail[name]
#print dir(button)
if button.checked:
if button.backgroundColor == AVAIL:
self.availability.avail[name] = 1
else:
self.availability.avail[name] = 0
button.backgroundColor = (255, 255, 255)
else:
if self.availability.avail[name]:
button.backgroundColor = AVAIL
else:
button.backgroundColor = UNAVAIL
Notice my comment #print dir(button) I use those quite often
when doing pythoncard just to see what it is that I have a
handle on, and what I can do with it.


A second question occurres: Is it possible to create a component at
run time? If so how would you start.
Thanks

I am pretty sure that the pythoncard resource editor is written in
pythoncard, so I would say "yes" and "read the pythoncard source code".


If in doubt, run your application with the shell (-s on the command
line) and have a look. Its a great tool and by far the best way to find
out what is going on 'under the hood'. With the message watcher (-m) and
the namespace viewer (-n) as well you have a full run time inspection
environment.

Yes, you can add components at run time, look at the example on the
documentation page
(http://pythoncard.sourceforge.net/text/addmethod.txt) and the dbBrowser
sample application.

As a final observation, PythonCard comes with its own logging module
(similar to the standard module in 2.3) and can be used instead of
'print' statements for a more persistent record of what your application
is doing. See log.py in the PythonCard distribution for information.

Regards,
Andy
--
--------------------------------------------------------------------------------
From the desk of Andrew J Todd esq - http://www.halfcooked.com/

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1616
by: Oriana | last post by:
Hi! I was wondering if anyone can give me any light in this...I've written a PythonCard application and I'm trying to create a Windows executable but when I run my setup I get a bunch of...
2
633
by: PipedreamerGrey | last post by:
I'm trying to create a standalone version (.exe) of PythonCard's Custdb sample using Py2Exe version 0.5.0. Everytime I attempt to compile the program, I get an error during compilation. This is...
0
1185
by: fiddlehead | last post by:
Hello. I'd to use gauge component in the code below. I want to show Queue.quantity in gauge (during running thread, every time when it changed). I don't know which event i must use. I find some...
1
1311
by: DarkBlue | last post by:
Is it possible to create pythoncard textField components dynamically during run time ? Something on the lines of pseudo code : def make_textfield(length,topleftposx,topleftposy): doit
4
2340
by: Tequila | last post by:
I'm having some trouble starting PythonCard on my PC. I've downloaded and ran python-2.5.msi to install Python on my machine. And PythonCard-0.8.2.win32.exe to install PythonCard. When I try...
8
2050
by: king kikapu | last post by:
Hi to all folks here, i downloaded and "playing" with PythonCard and i just want to share my thoughts so maybe we can discuss a little about it. I was used to wxGlade before and i think...
8
5960
by: Kevin Walzer | last post by:
I'm curious to know what others think of these two frameworks for building wxPython apps. PythonCard has been around longer, but its development seems to have slowed. The last release, 0.8.2,...
3
1500
by: Michal Lipinski | last post by:
Hi its my first post. I have a problem, I want to user eval() function in a for loop to set labels to staticText so i done something like this: ...
24
2345
by: John Henry | last post by:
For serveral years, I have been looking for a way to migrate away from desktop GUI/client-server programming onto the browser based network computing model of programming. Unfortunately, up until...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.