You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(116) |
Sep
(146) |
Oct
(78) |
Nov
(69) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(188) |
Feb
(142) |
Mar
(143) |
Apr
(131) |
May
(97) |
Jun
(221) |
Jul
(127) |
Aug
(89) |
Sep
(83) |
Oct
(66) |
Nov
(47) |
Dec
(70) |
2003 |
Jan
(77) |
Feb
(91) |
Mar
(103) |
Apr
(98) |
May
(134) |
Jun
(47) |
Jul
(74) |
Aug
(71) |
Sep
(48) |
Oct
(23) |
Nov
(37) |
Dec
(13) |
2004 |
Jan
(24) |
Feb
(15) |
Mar
(52) |
Apr
(119) |
May
(49) |
Jun
(41) |
Jul
(34) |
Aug
(91) |
Sep
(169) |
Oct
(38) |
Nov
(32) |
Dec
(47) |
2005 |
Jan
(61) |
Feb
(47) |
Mar
(101) |
Apr
(130) |
May
(51) |
Jun
(65) |
Jul
(71) |
Aug
(96) |
Sep
(28) |
Oct
(20) |
Nov
(39) |
Dec
(62) |
2006 |
Jan
(13) |
Feb
(19) |
Mar
(18) |
Apr
(34) |
May
(39) |
Jun
(50) |
Jul
(63) |
Aug
(18) |
Sep
(37) |
Oct
(14) |
Nov
(56) |
Dec
(32) |
2007 |
Jan
(30) |
Feb
(13) |
Mar
(25) |
Apr
(3) |
May
(15) |
Jun
(42) |
Jul
(5) |
Aug
(17) |
Sep
(6) |
Oct
(25) |
Nov
(49) |
Dec
(10) |
2008 |
Jan
(12) |
Feb
|
Mar
(17) |
Apr
(18) |
May
(12) |
Jun
(2) |
Jul
(2) |
Aug
(6) |
Sep
(4) |
Oct
(15) |
Nov
(45) |
Dec
(9) |
2009 |
Jan
(1) |
Feb
(3) |
Mar
(18) |
Apr
(8) |
May
(3) |
Jun
|
Jul
(13) |
Aug
(2) |
Sep
(1) |
Oct
(9) |
Nov
(13) |
Dec
|
2010 |
Jan
(2) |
Feb
(3) |
Mar
(9) |
Apr
(10) |
May
|
Jun
(1) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(1) |
Dec
(4) |
2011 |
Jan
|
Feb
|
Mar
(10) |
Apr
(44) |
May
(9) |
Jun
(22) |
Jul
(2) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(5) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
|
Jul
(3) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Kevin A. <kev...@gm...> - 2007-08-10 14:01:12
|
On 8/7/07, Tony Cappellini <cap...@gm...> wrote: > What is the future of Python Card? There are several futures, depending on the amount of developer interest, which is currently at a low point. I hadn't been coding for the last year or so, but recently started making bug fix and documentation checkins to CVS and plan to release those as 0.8.3, most likely in September or early October. I still don't expect any major changes to the current development tree, but I have moved to Python 2.5.x and wxPython 2.8.x for my own work, so that is what I'm testing against. While we didn't do a 1.0 release, what we have today is basically what was planned for 1.0, so depending on who else is interested in more framework and tools coding, I still expect we'll eventually do an official 1.0. It would be nice if we could make some big improvements to the tools part of PythonCard, those changes would not break existing code, but that is very dependent on Alex and new blood in the developer part of the project. For anyone listening, speak up if you're interested by joining pythoncard-devel and making a post of what you want to work on. There are a lot of things I would like to do differently in PythonCard, but I'm pretty sure those changes are drastic enough they need to be part of a 2.0 branch so we can experiment with using the wx xml style resources, providing thinner layers on wxPython for better integration, etc. Depending on what you use PythonCard for, something like dabo might be a better fit for you. PythonCard will likely continue to focus on being a fully integrated and simple framework/environment suitable for small simple projects and rapid prototype development, but inappropriate for bigger team projects where raw wxPython and its tool set is more sensible. > wx has many widgets that are not part of Python Card. > > Will Python Card be modified to include more widgets? Future versions of PythonCard will get more widgets, but it is highly unlikely that it will ever provide every widget available in wxPython. You can always manually place any wxPython widget in your layout, typically in your on_initialize event handler, just like sizers are currently handled. What you can't do is place them with the resourceEditor or have them included in the .rsrc.py file. It is relatively easy to wrap a wxPython widget as a PythonCard component, just look at the PythonCard/components directory for many examples. We should probably have a tutorial covering the various aspects of a wrapper, but there are several levels for anyone interested in making a component from a simple wrapper that let's use you the component in a .rsrc.py file, to adding auto-event binding for the component, attributes (rather than Get/Set wx methods), and finally making the component available in the resourceEditor. You can also provide your own components by using an appcomponents directory in your applications directory, something like this: minimal <- directory minimal.py minimal.rsrc.py appcomponents <- directory button.py mywidget.py In the example above button.py would override the default button.py component of PythonCard and the mywidget.py would be your own component specific to your minimal application. I hope that helps, ka |
From: phil j. <int...@gm...> - 2007-08-10 10:38:54
|
Yeah, I'm interested in this question too. Although I'd like to ask a slight variation. What's the "problem" (if there is one) with PythonCard development? Not enough people involved? Have the original people lost interest and moved on to something else? Is it really to do with a fall off in interest in building desktop GUI based applications. How many people here are also looking at using the browser as their GUI these days? phil On 8/9/07, John Henry <ec...@ya...> wrote: > > --- Tony Cappellini <cap...@gm...> wrote: > > > What is the future of Python Card? > > > > wx has many widgets that are not part of Python > > Card. > > > > Will Python Card be modified to include more > > widgets? > > > > That would be nice. I wish I know enough to help. I > have become very productive with Pythoncard. > > -- > John Henry > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > |
From: John H. <ec...@ya...> - 2007-08-08 23:23:46
|
--- Tony Cappellini <cap...@gm...> wrote: > I would like to put several controls into a widget > so the components > can all be moved together at design time. > > Unfortunately the Static Box doesn't move the > controls placed on it, > when it is moved. > > Is there any way to get this functionality, within > Python card? > I don't believe you can do it at design time. You would have to do it at run time. -- John Henry |
From: John H. <ec...@ya...> - 2007-08-08 23:21:26
|
--- Tony Cappellini <cap...@gm...> wrote: > What is the future of Python Card? > > wx has many widgets that are not part of Python > Card. > > Will Python Card be modified to include more > widgets? > That would be nice. I wish I know enough to help. I have become very productive with Pythoncard. -- John Henry |
From: Tony C. <cap...@gm...> - 2007-08-07 18:23:53
|
What is the future of Python Card? wx has many widgets that are not part of Python Card. Will Python Card be modified to include more widgets? |
From: Tony C. <cap...@gm...> - 2007-08-07 18:22:36
|
I would like to put several controls into a widget so the components can all be moved together at design time. Unfortunately the Static Box doesn't move the controls placed on it, when it is moved. Is there any way to get this functionality, within Python card? |
From: Kevin A. <al...@se...> - 2007-07-30 14:40:26
|
I've updated the installation instructions for Windows and Mac OS X Tiger to use Python 2.5.1 and wxPython 2.8.4.0. These are the software versions I'm using on my main machines for further development and testing. I will be working through the other documentation fixing errors and updating them for any changes in the tools, but initially I've just corrected some typos with the File- >About menu example in the first walkthrough. http://pythoncard.sourceforge.net/windows_installation.html http://pythoncard.sourceforge.net/macosx_tiger_installation.html http://pythoncard.sourceforge.net/walkthrough1.html If you see any errors, please let me know. In addition, I've added a page on What is Python and Why Python? that may help people that aren't already convinced of the usefulness of Python. Let me know if you find it helpful and feel free to link to that page from your blogs, etc. http://pythoncard.sourceforge.net/what_is_python.html ka |
From: Andrew G. <AG...@ev...> - 2007-07-03 09:07:26
|
Please ignore my questions. There was debugging left on that was somehow causing my problem. Thanks again for the help. Cheers, Andrew Grist -----Original Message----- From: Andrew Grist Sent: 03 July 2007 04:05 To: 'pyt...@li...'; 'Phil Edwards' Subject: FW: [Pythoncard-users] PythonCard Question Thank you very much for you quick reply. I am fairly new at coding, let alone python. Python does make it fairly easy and quick to learn. First problem. When I run my app from cmd prompt using python app.py it works correctly. When I run from the Standalone build before compiling, it has an option to check script, it all works correctly. Only after compile do the choice boxes not drop down. I used the Choice box component in PythonCard. Second problem. I see where it is going wrong there. You were right about it not getting compiled into the build directory. Any help on item 1 would be helpful. Cheers, Andrew Grist -----Original Message----- From: Phil Edwards [mailto:ph...@li...] Sent: 02 July 2007 16:28 To: PythonCard Users Subject: Re: [Pythoncard-users] PythonCard Question Andrew Grist wrote: > > First: None of my drop down box's work (the choice box). In the > development area, they drop down and I see my selections. After > compile, I can select items, but the drop down part doesn't work so I > can't see the options. > Couple of things worth checking here, if you haven't done so already. Firstly, have you tried running your standalone application from a command prompt to see if it's throwing up any exceptions? Second, how are you creating the list of choices for your drop-down components? Are you using a list in the resource file or populating 'manually' from within your code? > > Second: I included .png graphics. These give an error when the app is > executed, could not load image, file does not exist. I know I included > them during the setup process for StandAlone builder. > Can you clarify what you mean by 'included .png graphics'? By default, standaloneBuilder will expect any graphics files to be located in the 'pixmaps' folder within your main project directory, and if you have them located elsewhere they may not be getting copied into the build directory for the standalone version of your application. > > Any help on this would be great full. > If these suggestions don't get you anywhere, I'd be happy to have a go at building your application on my machine and see if I can figure out what the problem is. -- Regards Phil Edwards Brighton, UK ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Pythoncard-users mailing list Pyt...@li... https://lists.sourceforge.net/lists/listinfo/pythoncard-users |
From: Andrew G. <AG...@ev...> - 2007-07-03 08:03:08
|
Thank you very much for you quick reply. I am fairly new at coding, let alone python. Python does make it fairly easy and quick to learn. First problem. When I run my app from cmd prompt using python app.py it works correctly. When I run from the Standalone build before compiling, it has an option to check script, it all works correctly. Only after compile do the choice boxes not drop down. I used the Choice box component in PythonCard. Second problem. I see where it is going wrong there. You were right about it not getting compiled into the build directory. Any help on item 1 would be helpful. Cheers, Andrew Grist -----Original Message----- From: Phil Edwards [mailto:ph...@li...] Sent: 02 July 2007 16:28 To: PythonCard Users Subject: Re: [Pythoncard-users] PythonCard Question Andrew Grist wrote: > > First: None of my drop down box's work (the choice box). In the > development area, they drop down and I see my selections. After > compile, I can select items, but the drop down part doesn't work so I > can't see the options. > Couple of things worth checking here, if you haven't done so already. Firstly, have you tried running your standalone application from a command prompt to see if it's throwing up any exceptions? Second, how are you creating the list of choices for your drop-down components? Are you using a list in the resource file or populating 'manually' from within your code? > > Second: I included .png graphics. These give an error when the app is > executed, could not load image, file does not exist. I know I included > them during the setup process for StandAlone builder. > Can you clarify what you mean by 'included .png graphics'? By default, standaloneBuilder will expect any graphics files to be located in the 'pixmaps' folder within your main project directory, and if you have them located elsewhere they may not be getting copied into the build directory for the standalone version of your application. > > Any help on this would be great full. > If these suggestions don't get you anywhere, I'd be happy to have a go at building your application on my machine and see if I can figure out what the problem is. -- Regards Phil Edwards Brighton, UK ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Pythoncard-users mailing list Pyt...@li... https://lists.sourceforge.net/lists/listinfo/pythoncard-users |
From: Phil E. <ph...@li...> - 2007-07-02 20:28:11
|
Andrew Grist wrote: > > First: None of my drop down box’s work (the choice box). In the > development area, they drop down and I see my selections. After > compile, I can select items, but the drop down part doesn’t work so I > can’t see the options. > Couple of things worth checking here, if you haven't done so already. Firstly, have you tried running your standalone application from a command prompt to see if it's throwing up any exceptions? Second, how are you creating the list of choices for your drop-down components? Are you using a list in the resource file or populating 'manually' from within your code? > > Second: I included .png graphics. These give an error when the app is > executed, could not load image, file does not exist. I know I included > them during the setup process for StandAlone builder. > Can you clarify what you mean by 'included .png graphics'? By default, standaloneBuilder will expect any graphics files to be located in the 'pixmaps' folder within your main project directory, and if you have them located elsewhere they may not be getting copied into the build directory for the standalone version of your application. > > Any help on this would be great full. > If these suggestions don't get you anywhere, I'd be happy to have a go at building your application on my machine and see if I can figure out what the problem is. -- Regards Phil Edwards Brighton, UK |
From: Andrew G. <AG...@ev...> - 2007-07-02 18:04:34
|
I hope someone can give me some guidance as I am sure this is a basic question. I am using PythonCard for a simple and easy gui (got sick of Tkinter, time consuming). I just used StandAlone Builder to create my project and found a couple issues. First: None of my drop down box's work (the choice box). In the development area, they drop down and I see my selections. After compile, I can select items, but the drop down part doesn't work so I can't see the options. Second: I included .png graphics. These give an error when the app is executed, could not load image, file does not exist. I know I included them during the setup process for StandAlone builder. Any help on this would be great full. Cheers Andrew Grist Production Engineering Master Control and Branding Evertz Microsystems LTD Reading UK ph: +44 118 935 0200 cell: +44 791 937 7497 Quartz, an Evertz Brand |
From: John H. <ec...@ya...> - 2007-06-30 12:11:29
|
Thanks for the response. Here's the code that works the best (not perfect): def on_field1_gainFocus(self, event): event.target.size=(160,event.target.size[1]) event.target.redraw() event.skip(True) return def on_field1_select(self, event): event.target.size=event.target.userdata event.target.redraw() event.skip(True) return where userdata contains the original size of the field. The above works good enough but not perfect. You know how when you click a normal combo box and the selection list pulls down? Well, with the above, the first time I click on that arrow, the combo box widens. Then I have to click it a second time for the selection list to pull down. --- Kevin Altis <al...@se...> wrote: > There are a couple of issues to deal with. Normally, > you need to have > your event handler finish before wx is going to > process the next > event. Since you want to change the component size > during the select, > the event for that would occur after your handler > finishes. On some > platforms the resize of the component is probably > deselecting the > list, though this might be a bug, I'm not sure. I > don't have your > specific code, but you probably just want to call > the redraw() method > which is defined for all components to force an > update after you > change the component size. The method as defined in > widget.py looks > like this: > > def redraw(self): > """Force an immediate redraw without > waiting for an event > handler to finish.""" > self.Refresh() > self.Update() > > You would make a call such as... > > event.target.redraw() > > If you're losing the selection after the redraw you > might be able to > do just redo the selection... > > temp = event.target.selection > # resize > # redraw > event.target.selection = temp > > something like that. Depending on the platform, it > might be necessary > to do some other tweaks. > > ka > > On Jun 29, 2007, at 5:58 PM, John Henry wrote: > > > Hi list, > > > > After I'm done with an event and I wish PythonCard > to > > continue processing that event, don't I have to > stuff > > the event back onto the event queue? > > > > For instance, let say I wish to change the width > of a > > combo box when the user click on the selection > list. > > I need to do this at run time because there is no > > space for the field at design time. So, I set up > a > > event handler for the "select" event and change > the > > width. But then if I don't do anything, the list > > won't even open right. If I do a event.skip(), > the > > field gets wider, but then I have to click on the > > selection again. So, it appears that I need to > > redispatch the "select" event after I'm done with > it. > > > > At least that's what one has to do in native > Windows > > programming. > > > > Anybody knows? > > > > Regards, > > > > > > > > > > -- > > John Henry > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 > express and take > control of your XML. No limits. Just data. Click to > get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- John Henry |
From: Kevin A. <al...@se...> - 2007-06-30 06:40:52
|
There are a couple of issues to deal with. Normally, you need to have your event handler finish before wx is going to process the next event. Since you want to change the component size during the select, the event for that would occur after your handler finishes. On some platforms the resize of the component is probably deselecting the list, though this might be a bug, I'm not sure. I don't have your specific code, but you probably just want to call the redraw() method which is defined for all components to force an update after you change the component size. The method as defined in widget.py looks like this: def redraw(self): """Force an immediate redraw without waiting for an event handler to finish.""" self.Refresh() self.Update() You would make a call such as... event.target.redraw() If you're losing the selection after the redraw you might be able to do just redo the selection... temp = event.target.selection # resize # redraw event.target.selection = temp something like that. Depending on the platform, it might be necessary to do some other tweaks. ka On Jun 29, 2007, at 5:58 PM, John Henry wrote: > Hi list, > > After I'm done with an event and I wish PythonCard to > continue processing that event, don't I have to stuff > the event back onto the event queue? > > For instance, let say I wish to change the width of a > combo box when the user click on the selection list. > I need to do this at run time because there is no > space for the field at design time. So, I set up a > event handler for the "select" event and change the > width. But then if I don't do anything, the list > won't even open right. If I do a event.skip(), the > field gets wider, but then I have to click on the > selection again. So, it appears that I need to > redispatch the "select" event after I'm done with it. > > At least that's what one has to do in native Windows > programming. > > Anybody knows? > > Regards, > > > > > -- > John Henry |
From: John H. <ec...@ya...> - 2007-06-30 01:12:04
|
I tried event.skip(True) but it doesn't do it. After I resize the combo box, I have to click it again for the list to get displayed. Annoying. May be this is a wx issue. --- John Henry <ec...@ya...> wrote: > Hi list, > > After I'm done with an event and I wish PythonCard > to > continue processing that event, don't I have to > stuff > the event back onto the event queue? > > For instance, let say I wish to change the width of > a > combo box when the user click on the selection list. > > I need to do this at run time because there is no > space for the field at design time. So, I set up a > event handler for the "select" event and change the > width. But then if I don't do anything, the list > won't even open right. If I do a event.skip(), the > field gets wider, but then I have to click on the > selection again. So, it appears that I need to > redispatch the "select" event after I'm done with > it. > > At least that's what one has to do in native Windows > programming. > > Anybody knows? > > Regards, > > > > > -- > John Henry > -- John Henry |
From: John H. <ec...@ya...> - 2007-06-30 00:58:07
|
Hi list, After I'm done with an event and I wish PythonCard to continue processing that event, don't I have to stuff the event back onto the event queue? For instance, let say I wish to change the width of a combo box when the user click on the selection list. I need to do this at run time because there is no space for the field at design time. So, I set up a event handler for the "select" event and change the width. But then if I don't do anything, the list won't even open right. If I do a event.skip(), the field gets wider, but then I have to click on the selection again. So, it appears that I need to redispatch the "select" event after I'm done with it. At least that's what one has to do in native Windows programming. Anybody knows? Regards, -- John Henry |
From: John H. <ec...@ya...> - 2007-06-26 22:05:56
|
Man, life is gooooooooooood.... By creating controls dynamically, my efficiency in creating GUI code went up many many fold. I must have created 50 different panels in less than a day - including code for designing, presentation, and processing of user input. I can not imagine how long it would have taken me to do the same thing using the static method. Just for completeness, I am posting the final version of my Control_Factory code, along with code for destruction of controls on the fly. May be this code would be of use to other PythonCard users: #!/usr/bin/python """ __version__ = "$Revision: 1.6 $" __date__ = "$Date: 2004/05/05 16:53:27 $" """ import wx from PythonCard import model import new from PythonCard import log from PythonCard import model class Minimal(model.Background): def addHandler(self, aMethod): # Add the Handler to our Handler list. if aMethod.name not in self._handlers: log.debug("addHandler: " + aMethod.name) #self._handlers[aMethod.name] = event.Handler(aMethod) self._handlers[aMethod.name] = aMethod def delHandler(self, aMethod): # Add the Handler to our Handler list. if aMethod.name in self._handlers: log.debug("delHandler: " + aMethod.name) del self._handlers[aMethod.name] del aMethod def Control_factory(self, attribute, eventHandlers): name=attribute['name'] methods=[] for eventName in eventHandlers.keys(): eventFct=eventHandlers[eventName] def function(self, background, event): if eventFct==None: return None return eventFct(event) function.name = "on_%s_%s" % (name,eventName) method = new.instancemethod(function, self, self.__class__) setattr(self, function.name, method) self.addHandler(method) methods.append(method) self.components[name] = attribute return methods To use it, I simply set up a table like this: ({"type":"StaticText","name":"stFIELD1","text":"This is easy:",'position':(5, 10), },{}), ({"type":"TextField", "name":"tfFIELD1",'position':(35, 10-4), 'size':(70,-1)},{}), ({"type":"Button", "name":"pbBUTTON",'label':'Execute', 'position':(70, 10+75)}, {"mouseClick":self.on_pbBUTTON_mouseClick}), and then invoke Control_factory repeatedly. Thanks for a wonderful package PythonCard. Couldn't do this work without it. > -----Original Message----- > From: pyt...@li... > [mailto:pyt...@li...] On > Behalf Of John Henry > Sent: Monday, June 25, 2007 10:57 AM > To: Kevin Altis; pythoncard-Users > Subject: Re: [Pythoncard-users] Creating dynamic window > > > Oh, silly me. Control_factory can be further > simplied: > > def Control_factory(self, attribute, eventHandlers): > name=attribute['name'] > for eventName in eventHandlers.keys(): > eventFct=eventHandlers[eventName] > def function(self, background, event): > if eventFct==None: > return None > return eventFct(self, event) > function.name = "on_%s_%s" % (name,eventName) > method = new.instancemethod(function, self, > self.__class__) > setattr(self, function.name, method) > self.addHandler(method) > self.components[name] = attribute > return function > -- John Henry |
From: John H. <ec...@ya...> - 2007-06-25 17:56:35
|
Oh, silly me. Control_factory can be further simplied: def Control_factory(self, attribute, eventHandlers): name=attribute['name'] for eventName in eventHandlers.keys(): eventFct=eventHandlers[eventName] def function(self, background, event): if eventFct==None: return None return eventFct(self, event) function.name = "on_%s_%s" % (name,eventName) method = new.instancemethod(function, self, self.__class__) setattr(self, function.name, method) self.addHandler(method) self.components[name] = attribute return function --- John Henry <ec...@ya...> wrote: > > Hmm, the code I sent to the list worked perfectly > on > > my machine. > > Don't you just love software development? > > > Did > > you try and run the code as is? > > Yes I did. Same failure. > > > Which version of > > Python are you > > using? > > Latest version of Python 2.3 under Windows XP w > latest > FP > > >I was trying it with 2.4.3 on a Mac, but if > > you're using 2.5 > > maybe they added additional flags you're supposed > to > > use at the > > command-line so that Python doesn't give you a > > warning?! I'm also a > > bit confused about the multiple args. I added the > > line... > > > > print "You clicked '%s'." % event.target.name > > > > to show that the event being passed in is what > we're > > expecting and > > again on my box it works as expected. > > > > ka > > > > > > That part doesn't bother me. > > Now, I've played around the idea more and I came up > with a version that works in the general case - for > all controls, and in-line with the resource > structure > of PythonCard. See below: > > def addHandler(self, aMethod): > # Add the Handler to our Handler list. > if aMethod.name not in self._handlers: > log.debug("addHandler: " + aMethod.name) > #self._handlers[aMethod.name] = > event.Handler(aMethod) > self._handlers[aMethod.name] = aMethod > > def Control_factory(self, attribute, > eventHandlers): > name=attribute['name'] > for eventName in eventHandlers.keys(): > eventFct=eventHandlers[eventName] > def function(self, background, event): > if eventFct==None: > return None > return eventFct(self, event) > function.name = "on_%s_%s" % (name,eventName) > method = new.instancemethod(function, self, > self.__class__) > setattr(self, function.name, method) > self.addHandler(method) > self.components[name] = {} > for key in attribute.keys(): > self.components[name][key]=attribute[key] > return function > > > Now, everytime I need to create a control - any kind > of PythonCard controls, I simply do a: > > # This is my button mouseClick handler > def on_Button_mouseClick(self, event): > return > > Create a button: > > Control_factory(self, attribute={"type":"Button", > "name":"Button1", > "label":"Button1","position":(5,35)}, > eventHandlers={"mouseClick":on_Button_mouseClick}) > > Notice that the attribute is a standard dictionary > no > different from that in the resource file. > > And it works for all controls. Some form of this > should exist in standard form of PythonCard. > > -- > John Henry > -- John Henry |
From: John H. <ec...@ya...> - 2007-06-25 06:40:46
|
> Hmm, the code I sent to the list worked perfectly on > my machine. Don't you just love software development? > Did > you try and run the code as is? Yes I did. Same failure. > Which version of > Python are you > using? Latest version of Python 2.3 under Windows XP w latest FP >I was trying it with 2.4.3 on a Mac, but if > you're using 2.5 > maybe they added additional flags you're supposed to > use at the > command-line so that Python doesn't give you a > warning?! I'm also a > bit confused about the multiple args. I added the > line... > > print "You clicked '%s'." % event.target.name > > to show that the event being passed in is what we're > expecting and > again on my box it works as expected. > > ka > > That part doesn't bother me. Now, I've played around the idea more and I came up with a version that works in the general case - for all controls, and in-line with the resource structure of PythonCard. See below: def addHandler(self, aMethod): # Add the Handler to our Handler list. if aMethod.name not in self._handlers: log.debug("addHandler: " + aMethod.name) #self._handlers[aMethod.name] = event.Handler(aMethod) self._handlers[aMethod.name] = aMethod def Control_factory(self, attribute, eventHandlers): name=attribute['name'] for eventName in eventHandlers.keys(): eventFct=eventHandlers[eventName] def function(self, background, event): if eventFct==None: return None return eventFct(self, event) function.name = "on_%s_%s" % (name,eventName) method = new.instancemethod(function, self, self.__class__) setattr(self, function.name, method) self.addHandler(method) self.components[name] = {} for key in attribute.keys(): self.components[name][key]=attribute[key] return function Now, everytime I need to create a control - any kind of PythonCard controls, I simply do a: # This is my button mouseClick handler def on_Button_mouseClick(self, event): return Create a button: Control_factory(self, attribute={"type":"Button", "name":"Button1", "label":"Button1","position":(5,35)}, eventHandlers={"mouseClick":on_Button_mouseClick}) Notice that the attribute is a standard dictionary no different from that in the resource file. And it works for all controls. Some form of this should exist in standard form of PythonCard. -- John Henry |
From: Kevin A. <al...@se...> - 2007-06-24 22:01:04
|
On Jun 24, 2007, at 12:32 PM, John Henry wrote: > Thanks for the response. > > The code almost worked. The offending line is: > > function.func_name = "on_%s_mouseClick" % name > > which is a TypeError violation (readonly attribute). > I ran into this too when I try to set method.__name__ > directly. > Hmm, the code I sent to the list worked perfectly on my machine. Did you try and run the code as is? Which version of Python are you using? I was trying it with 2.4.3 on a Mac, but if you're using 2.5 maybe they added additional flags you're supposed to use at the command-line so that Python doesn't give you a warning?! I'm also a bit confused about the multiple args. I added the line... print "You clicked '%s'." % event.target.name to show that the event being passed in is what we're expecting and again on my box it works as expected. ka |
From: John H. <ec...@ya...> - 2007-06-24 21:00:17
|
Okay, here's a version that works, clean, and not requiring any changes to PythonCard. #!/usr/bin/python """ __version__ = "$Revision: 1.6 $" __date__ = "$Date: 2004/08/17 19:46:06 $" """ import new from PythonCard import log from PythonCard import model from PythonCard.model import SetInitParam rsrc = {'application':{'type':'Application', 'name':'Minimal', 'backgrounds': [ {'type':'Background', 'name':'bgMin', 'title':'Minimal PythonCard Application', 'size':(200, 300), 'components': [ ] # end components } # end background ] # end backgrounds } } class Background_Dynamic(model.Background): def __init__(self, aParent, aBgRsrc, SetInitParamFct=SetInitParam): model.Background.__init__(self, aParent, aBgRsrc, SetInitParamFct) def addHandler(self, aMethod): # Add the Handler to our Handler list. if aMethod.name not in self._handlers: log.debug("addHandler: " + aMethod.name) #self._handlers[aMethod.name] = event.Handler(aMethod) self._handlers[aMethod.name] = aMethod def mouseclick_factory(self, name): def function(self, background, event): self.mouseclick_factory("Button"+str(int(name[-1:])+1)) function.name = "on_%s_mouseClick" % name method = new.instancemethod(function, self, self.__class__) setattr(self, function.name, method) self.addHandler(method) self.components[name] = {'type':'Button', 'name':name, 'label':name, 'position':(5, 5+int(name[-1:])*30), 'text':name} return function class Minimal(Background_Dynamic): def on_initialize(self, event): self.components['field1'] = {'type':'TextField','name':'field1','position':(5, 5),'size':(150, -1),'text':'Hello PythonCard'} self.mouseclick_factory("Button1") if __name__ == '__main__': app = model.Application(Minimal, None, rsrc) app.MainLoop() --- Kevin Altis <al...@se...> wrote: > After a bit of research I came up with the following > working example > which uses a slightly modified version of your > original factory. > func_name seems to be the important attribute. I was > able to use > addMethod to clean up the code a bit . > > This still doesn't solve the problem of creating an > arbitrary > function/method from a string, but that's a generic > Python problem > that I don't know the answer to rather than > something PythonCard- > specific. > > ka > --- > > from PythonCard import model > > rsrc = {'application':{'type':'Application', > 'name':'Minimal', > 'backgrounds': [ > {'type':'Background', > 'name':'bgMin', > 'title':'Minimal PythonCard Application', > 'size':(200, 100), > 'components': [ > > ] # end components > } # end background > ] # end backgrounds > } } > > class Minimal(model.Background): > def on_initialize(self, event): > self.components['field1'] = > {'type':'TextField', > > 'name':'field1', > > 'position':(5,5), > > 'size':(150, -1), > > 'text':'Hello PythonCard'} > self.mouseclick_factory("Button1") > self.mouseclick_factory("Button2") > > def mouseclick_factory(self, name): > def function(self, event): > # changed to event.target.name to > verify we're getting > # the correct target when button is > clicked > print "You clicked '%s'." % > event.target.name > # func_name seems to be the magic attribute > rather than > # just setting func.name > function.func_name = "on_%s_mouseClick" % > name > self.addMethod(function) > self.components[name] = {'type':'Button', > 'name':name, > 'label':name, > > 'position':(5,5+int(name[-1:]) > *30), > 'text':name} > return function > > > if __name__ == '__main__': > app = model.Application(Minimal, None, rsrc) > app.MainLoop() > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 > express and take > control of your XML. No limits. Just data. Click to > get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- John Henry |
From: John H. <ec...@ya...> - 2007-06-24 19:32:22
|
Thanks for the response. The code almost worked. The offending line is: function.func_name = "on_%s_mouseClick" % name which is a TypeError violation (readonly attribute). I ran into this too when I try to set method.__name__ directly. The workaround, as it seems, is to have an addHandler function (rather then the _addHandler function) that does this: def addHandler(self, aMethod): # Add the Handler to our Handler list. if aMethod.name not in self._handlers: log.debug("addHandler: " + aMethod.name) #self._handlers[aMethod.name] = event.Handler(aMethod) self._handlers[aMethod.name] = aMethod instead of this: def _addHandler(self, aMethod): # Add the Handler to our Handler list. if aMethod.__name__ not in self._handlers: log.debug("_addHandler: " + aMethod.__name__) #self._handlers[aMethod.__name__] = event.Handler(aMethod) self._handlers[aMethod.__name__] = aMethod When I call addHandler then, the code works. When I click the first button, a new button gets created. One minor puzzle though, Python passes down 3 parameters to the handler (rather then just 2). The first 2 are both the same and it's the normal "self" parameter you get with other handlers. The 3rd one is the event object. I don't know why I get "self" twice though. --- Kevin Altis <al...@se...> wrote: > After a bit of research I came up with the following > working example > which uses a slightly modified version of your > original factory. > func_name seems to be the important attribute. I was > able to use > addMethod to clean up the code a bit . > > This still doesn't solve the problem of creating an > arbitrary > function/method from a string, but that's a generic > Python problem > that I don't know the answer to rather than > something PythonCard- > specific. > > ka > --- > > from PythonCard import model > > rsrc = {'application':{'type':'Application', > 'name':'Minimal', > 'backgrounds': [ > {'type':'Background', > 'name':'bgMin', > 'title':'Minimal PythonCard Application', > 'size':(200, 100), > 'components': [ > > ] # end components > } # end background > ] # end backgrounds > } } > > class Minimal(model.Background): > def on_initialize(self, event): > self.components['field1'] = > {'type':'TextField', > > 'name':'field1', > > 'position':(5,5), > > 'size':(150, -1), > > 'text':'Hello PythonCard'} > self.mouseclick_factory("Button1") > self.mouseclick_factory("Button2") > > def mouseclick_factory(self, name): > def function(self, event): > # changed to event.target.name to > verify we're getting > # the correct target when button is > clicked > print "You clicked '%s'." % > event.target.name > # func_name seems to be the magic attribute > rather than > # just setting func.name > function.func_name = "on_%s_mouseClick" % > name > self.addMethod(function) > self.components[name] = {'type':'Button', > 'name':name, > 'label':name, > > 'position':(5,5+int(name[-1:]) > *30), > 'text':name} > return function > > > if __name__ == '__main__': > app = model.Application(Minimal, None, rsrc) > app.MainLoop() > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 > express and take > control of your XML. No limits. Just data. Click to > get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- John Henry |
From: Kevin A. <al...@se...> - 2007-06-24 17:20:33
|
After a bit of research I came up with the following working example which uses a slightly modified version of your original factory. func_name seems to be the important attribute. I was able to use addMethod to clean up the code a bit . This still doesn't solve the problem of creating an arbitrary function/method from a string, but that's a generic Python problem that I don't know the answer to rather than something PythonCard- specific. ka --- from PythonCard import model rsrc = {'application':{'type':'Application', 'name':'Minimal', 'backgrounds': [ {'type':'Background', 'name':'bgMin', 'title':'Minimal PythonCard Application', 'size':(200, 100), 'components': [ ] # end components } # end background ] # end backgrounds } } class Minimal(model.Background): def on_initialize(self, event): self.components['field1'] = {'type':'TextField', 'name':'field1', 'position':(5,5), 'size':(150, -1), 'text':'Hello PythonCard'} self.mouseclick_factory("Button1") self.mouseclick_factory("Button2") def mouseclick_factory(self, name): def function(self, event): # changed to event.target.name to verify we're getting # the correct target when button is clicked print "You clicked '%s'." % event.target.name # func_name seems to be the magic attribute rather than # just setting func.name function.func_name = "on_%s_mouseClick" % name self.addMethod(function) self.components[name] = {'type':'Button', 'name':name, 'label':name, 'position':(5,5+int(name[-1:]) *30), 'text':name} return function if __name__ == '__main__': app = model.Application(Minimal, None, rsrc) app.MainLoop() |
From: John H. <ec...@ya...> - 2007-06-24 08:44:09
|
No dice. Here's what I have: def mouseclick_factory(parent, name): def function(self, event): print "You clicked '%s'." % name function.name = "on_%s_mouseClick" % name method = new.instancemethod(function, parent, parent.__class__) setattr(parent, function.name, method) parent._addHandler(method) parent.components[name] = {'type':'Button', 'name':name, 'label':name, 'position':(5, 5+int(name[-1:])*30), 'text':name} return function class Minimal(model.Background): def on_initialize(self, event): self.components['field1'] = {'type':'TextField','name':'field1','position':(5, 5),'size':(150, -1),'text':'Hello PythonCard'} mouseclick_factory(self, "Button1") if __name__ == '__main__': app = model.Application(Minimal, None, rsrc) app.MainLoop() When I click on Button1, nothing happens. --- Kevin Altis <al...@se...> wrote: > > On Jun 23, 2007, at 12:36 PM, John Henry wrote: > > > There are people at the Python newsgroup > suggesting > > that I should avoid using exec to accomplish this. > > Here's what they suggested: > > > > ... > > > function = mouseclick_factory(self, name) > # as > > before > > method = new.instancemethod(function, > self, > > self.__class__) > > setattr(self, function.name, method) > > ... > > You're basically doing what addMethod does, so after > the setattr > call, try > > self._addHandler(method) > > As mentioned before you're going to have to create > the component > after the event handler is created and bound or its > bind events > "magic" won't happen correctly. That means this bit > in your factory > needs to be moved out and after the _addHandler > call. > > parent.components[name] = {'type':'Button', > 'name':name, > 'label':name, > 'position':(5, > 5+id_num*30), > 'text':name} > > The way the PythonCard event binding works now is > more efficient as I > said but it is faster in part because of the caching > of event handler > names which is what the call to _addHandler is > doing. You can see all > this code in model.py. The handler name is added to > a simple > dictionary used for lookups by the findHandler > method. In the old > system, there was a lot of looping done at event > dispatch time to > find the right handler, back when everything was > dynamic, but when I > streamlined the code, I kept the old strategy, but > simply moved it > into a one-time event binding when a component is > created. > > > Unfortunately, it doesn't work. PythonCard > doesn't > > calll the fuction created by the > mouseclick_factory. > > However, if I place the following statement right > > after the setattr call, it works (proving that the > > function actually gets created). > > > > self.on_Button1_mouseClick(event) > > > > Any idea why this doesn't work? > > > > Thanks, > > > > -- > > John Henry > > ka > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 > express and take > control of your XML. No limits. Just data. Click to > get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- John Henry |
From: Kevin A. <al...@se...> - 2007-06-24 05:21:59
|
On Jun 23, 2007, at 12:36 PM, John Henry wrote: > There are people at the Python newsgroup suggesting > that I should avoid using exec to accomplish this. > Here's what they suggested: > ... > function = mouseclick_factory(self, name) # as > before > method = new.instancemethod(function, self, > self.__class__) > setattr(self, function.name, method) ... You're basically doing what addMethod does, so after the setattr call, try self._addHandler(method) As mentioned before you're going to have to create the component after the event handler is created and bound or its bind events "magic" won't happen correctly. That means this bit in your factory needs to be moved out and after the _addHandler call. parent.components[name] = {'type':'Button', 'name':name, 'label':name, 'position':(5, 5+id_num*30), 'text':name} The way the PythonCard event binding works now is more efficient as I said but it is faster in part because of the caching of event handler names which is what the call to _addHandler is doing. You can see all this code in model.py. The handler name is added to a simple dictionary used for lookups by the findHandler method. In the old system, there was a lot of looping done at event dispatch time to find the right handler, back when everything was dynamic, but when I streamlined the code, I kept the old strategy, but simply moved it into a one-time event binding when a component is created. > Unfortunately, it doesn't work. PythonCard doesn't > calll the fuction created by the mouseclick_factory. > However, if I place the following statement right > after the setattr call, it works (proving that the > function actually gets created). > > self.on_Button1_mouseClick(event) > > Any idea why this doesn't work? > > Thanks, > > -- > John Henry ka |
From: John H. <ec...@ya...> - 2007-06-23 19:36:40
|
There are people at the Python newsgroup suggesting that I should avoid using exec to accomplish this. Here's what they suggested: #!/usr/bin/python """ __version__ = "$Revision: 1.6 $" __date__ = "$Date: 2004/08/17 19:46:06 $" """ import new from PythonCard import model rsrc = {'application':{'type':'Application', 'name':'Minimal', 'backgrounds': [ {'type':'Background', 'name':'bgMin', 'title':'Minimal PythonCard Application', 'size':(200, 300), 'components': [ ] # end components } # end background ] # end backgrounds } } def mouseclick_factory(parent, name): id_num=int(name[-1:]) parent.components[name] = {'type':'Button', 'name':name, 'label':name, 'position':(5, 5+id_num*30), 'text':name} def function(self, event): print "You clicked '%s'." % name function.name = "on_%s_mouseClick" % name return function class Minimal(model.Background): def on_initialize(self, event): self.components['field1'] = {'type':'TextField','name':'field1','position':(5, 5),'size':(150, -1),'text':'Hello PythonCard'} name = "Button1" function = mouseclick_factory(self, name) # as before method = new.instancemethod(function, self, self.__class__) setattr(self, function.name, method) if __name__ == '__main__': app = model.Application(Minimal, None, rsrc) app.MainLoop() Unfortunately, it doesn't work. PythonCard doesn't calll the fuction created by the mouseclick_factory. However, if I place the following statement right after the setattr call, it works (proving that the function actually gets created). self.on_Button1_mouseClick(event) Any idea why this doesn't work? Thanks, -- John Henry |