472,333 Members | 1,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 2011
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
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...
2
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...
0
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...
1
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...
4
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...
8
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....
8
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...
3
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
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.