473,554 Members | 2,919 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(se lf,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 2073
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(se lf,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(s elf, event):
name = event.target.na me
if name in self.availabili ty.times:
button = getattr(self.co mponents, name)
avail = self.availabili ty.avail[name]
#print dir(button)
if button.checked:
if button.backgrou ndColor == AVAIL:
self.availabili ty.avail[name] = 1
else:
self.availabili ty.avail[name] = 0
button.backgrou ndColor = (255, 255, 255)
else:
if self.availabili ty.avail[name]:
button.backgrou ndColor = AVAIL
else:
button.backgrou ndColor = 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(se lf,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.componen ts.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(s elf, event):
name = event.target.na me
if name in self.availabili ty.times:
button = getattr(self.co mponents, name)
avail = self.availabili ty.avail[name]
#print dir(button)
if button.checked:
if button.backgrou ndColor == AVAIL:
self.availabili ty.avail[name] = 1
else:
self.availabili ty.avail[name] = 0
button.backgrou ndColor = (255, 255, 255)
else:
if self.availabili ty.avail[name]:
button.backgrou ndColor = AVAIL
else:
button.backgrou ndColor = 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
1621
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 errors... My setup looks like this: from distutils.core import setup import py2exe
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 the exact code I'm using in the setup file: from distutils.core import setup import py2exe setup( name = "custdb", console = , data_files = ) ]
0
1188
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 info about Time event for gauge but don't understand how it works. Any suggestions? #---gauge.rcrc.py---
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
2344
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 to run the program I get the following error: ====================================== C:\Python25\Lib\site-packages\PythonCard\tools...
8
2051
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 PythonCard is even better. I like the separate implementation of GUI and Code that PythonCard provides, i also like the "binding system" so you can bind...
8
5966
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, has been out for quite awhile now. Dabo is newer and seems to have gathered a lot of buzz. Anyone try both? What's your preference and why? Is one...
3
1503
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: dzien=self.components.Calendar.GetDate().GetDay() for i in range(1,8): act=dzien+i -1 eval( 'self.components.d' + str(i) + '.text = "'+ str(act) + '"')
24
2357
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 recently, browser based programs are very limited - due to the limitation of HTML itself. Eventhough PythonCard hasn't keep up with the latest...
0
7521
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7802
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7563
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7889
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5155
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3560
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2020
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 we have to send another system
1
1134
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.