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. <al...@se...> - 2004-09-17 16:12:48
|
On Sep 17, 2004, at 8:15 AM, Gregory Pi=F1ero wrote: > Here's a longshot question. You know how you can write in python: > > a=3Draw_input("write text here") > > And basically when you run the program the user is prompted to enter > text, and you get the actual text the user entered. > > Is there any way to get raw_input from a text field in pyCard? Of > course I may already be getting this, but somehow by the time the > query gets to mySQL, it has gotten all mungled. > > I feel it is more a problem with the mySQL api if anything, but I was > curious if you guys had any ideas. I posted a question there which > has more details about the specific problem > = http://sourceforge.net/forum/forum.php?thread_id=3D1146165&forum_id=3D7046= 1 > > I would really appriciate it if anyone has any ideas at all, I've been > stuck on this problem for 3 days now. Maybe there's something > fundamental in python I'm doing wrong, but googling didn't turn up > anything useful. > > Thanks, > > -Greg > I don't know what you mean about raw input? Are you saying you want to=20= capture hidden control characters or you're having problems with=20 Unicode text or somehow you're quotes and apostrophes are getting=20 mangled? There isn't any special manipulations done to the text, the=20 text attribute is just an alias for the underlying wxPython GetValue=20 and SetValue methods which you'll see if you look at=20 PythonCard/components/textfield.py If you want to see exactly what the field contains just import pprint=20 and use pprint.pprint() to see what the text contains. For example,=20 running the minimal sample with the shell (-s on the command-line) you=20= can do: >>> import pprint >>> pprint.pprint(comp.field1.text) 'Hello PythonCard' >>> My guess is that you are having problems with SQL quoting rules and=20 should be using string formatting or interpolation as well as some=20 character escaping or normalization for problematic characters like=20 quotes. Perhaps Andy or some other person on the list that does more=20 SQL work than me will explain in more depth. Here's an example of building up a string from some vars. >>> s =3D "Hello %s is %d words." % ('World', 2) >>> s 'Hello World is 2 words.' >>> http://docs.python.org/lib/typesseq-strings.html ka |
From: Kevin A. <al...@se...> - 2004-09-17 15:56:34
|
On Sep 17, 2004, at 8:10 AM, John wrote: > On Thu, 16 Sep 2004, Kevin Altis wrote: > >> On Sep 16, 2004, at 12:28 PM, John wrote: >> >>> Why don't we put this back on the list. Others may be interested. >>> >>> Something else popped up for me. While looking at converting my >>> dialogs I realized I need to pass a database 'handle' from my main >>> app >>> to >>> the dialogs which executes operations on the tables. With the dialogs >>> it >>> was easy, call the dialog with the handle when I instantiate the >>> class, and >>> assign the handle to self.handle in the __init__ method. If I were to >>> call >>> a 'sub' -app it does not seem to be as straight forward, give how >>> backgrounds are called. Although I could have a get like method say >>> getdbhandle, to accomplish what I was doing in the >>> 'constructor' __init__. I'll guess I'll dive into the background >>> code and find out. ;) >> >> You have a couple of options. One, simply refer to variables in the >> parent. For example, it is common when creating a CustomDialog to set >> the parent as so (example from resourceEditor dialogInfoDialog.py... >> >> class DialogInfoDialog(model.CustomDialog): >> def __init__(self, aBg, rsrc): >> model.CustomDialog.__init__(self, aBg) >> >> self.parent = aBg >> ... >> >> If you had an attribute in the main background that called the dialog >> called db then you could refer to it as self.parent.db. Actually, the >> line above is redundant because CustomDialog __init__ sets the parent >> as well. For Background, CustomDialog, and PageBackground you can >> always just use the wxPython GetParent() method to get the same info. >> There is a mixedCase getParent alias as well. >> >> If you're creating a child window then you can set variables in the >> child using the reference you keep when you create the child, so >> something like: >> >> self.subWindow = model.childWindow(...) >> self.subWindow.db = self.db >> >> In your child window, you could then use self.db. The on_initialize >> event handler won't run until after your current event handler >> terminates, so the on_initialize can actually make references to >> self.db. >> >> ka >> > I get the dialog in fact that's close to what I'm currently doing. My > question is how to pass parameters to a class derived from > model.background *in the constructor* once you have the instance it's > easy enough to set them, but is it possible to pass parameters to the > __init__ for model.background or oninitialize when you make the call > app = model.Application(Launcher) for example. > -john You can't pass additional args to on_initialize, nor can you pass additional args to a subclass of model.Background because you don't ever make a direct instantiation of your Background subclass, that is done for you by the childWindow function. So, if you want to add additional args, the simplest thing to do is to make your own childWindow function that calls model.childWindow and then tacks on your additional attributes before returning the instance of the class. This is similar to the suggestion I made to Bartek in an email on 2004-09-10 and to which I just sent a correction. def childWindow(parent, frameClass, filename=None, rsrc=None, additonalArg1, additionalArg2): background = model.childWindow(parent, frameClass, filename, rsrc) background.additionalArg1 = additionalArg1 background.additionalArg2 = additionalArg2 return background Or if you want to get really complicated you could completely replace the childWindow function so it sends additional args when instantiating frameClass, provide your own __init__ method in your subclass, making sure to call model.Background.__init__ with the proper args, but that seems a lot more complicated. ka |
From: Kevin A. <al...@se...> - 2004-09-17 15:51:18
|
On Sep 10, 2004, at 4:18 PM, Kevin Altis wrote: > On Sep 10, 2004, at 12:12 PM, bartek wilczynski wrote: > >> Hi, >> >> When I'm opening a child window, which is a pythonCard Alocated in >> different >> directory, the PythonCard jumps to that directory. As my application >> involves a >> lot of it, it becomes annoying to track "where am I". >> >> Is there any possibility of opening a child window without changing >> the current >> directory ?. >> -- >> greetings >> Bartek > > It could be done, but I'm not sure if it would be consistent since > there is an explicit chdir done for the main background window, and > child windows are just another window that just happen to have a > parent. This could be problematic for the on_initialize handler in > particular if it makes assumptions about the current working directory > being the same as the module directory... Anyway, I can see pro and > con arguments. > > In the meantime, you can just make your own childWindow wrapper > function that you call instead of the one in model.py. You can either > provide the args as shown below or just use *args and *kwargs for the > arg list. > > def childWindow(parent, frameClass, filename=None, rsrc=None): > cwd = os.getcwd() > model.childWindow(parent, frameClass, filename, rsrc) > os.chdir(cwd) > > Also, in case you didn't know, self.application.applicationDirectory > is the directory that contains your main source file in case you ever > need to jump back there or make a relative path change. > I just realized that the code above doesn't actually work, because I didn't return the result, so it should be: def childWindow(parent, frameClass, filename=None, rsrc=None): cwd = os.getcwd() background = model.childWindow(parent, frameClass, filename, rsrc) os.chdir(cwd) return background Assuming that the on_initialize handler in the child window isn't going to need to make references to files in the directory of the child source and resource files. If it does need to make a reference, then you would need to do something like: def childWindow(parent, frameClass, filename=None, rsrc=None): cwd = os.getcwd() wx.CallAfter(os.chdir, cwd) return model.childWindow(parent, frameClass, filename, rsrc) I haven't tested either of the above, but they look correct. ka |
From: Kevin A. <al...@se...> - 2004-09-17 15:34:37
|
On Sep 17, 2004, at 2:26 AM, normanwinn wrote: > Hi, > > Since my last post on doing on this I have made opening the resource > editor optional. If a checkbox is checked and the file looks like a > resource file then it is opened in the resource editor. If unchecked > it is opened in the code editor. > > I then went on to see if I could highlight the search results. Using > FindFiles to go code shopping I found the the 'redemo.py' implements > this very nicely. So, feeling brave, I started to cut and paste the > necessary functions into my version of FindFiles and alter the > component names accordingly. Finally got it running but bumped into > the problem that List component has no text attribute. Tried using a > TextArea component instead but this lacks the attributes of a list. > > Clearly, I need the functionality of a List but with a text attribute. > I notice there are various ListBox controls in wxPython but I am too > young in PythonCard to try to weave my own component, > > Norman > Originally, the findfiles tool did use a TextArea and if you look at on_listResults_mouseDoubleClick you'll see the code for calculating the clickLine commented out. You can probably go into your findfiles.rsrc.py file and change the type of the listResults from 'List' to 'TextArea', add an 'editable':False attribute.Then comment out the code that applies to a List and uncomment the code for calculating the line that was double-clicked. Unfortunately, the code for adding lines to listResults will need to be tweaked as well. Once the anonymous cvs web pages are back online you could look for one of the early versions of findfiles to see the selection code, etc. used before I switched to using a List. I suspect that I added some kind of comment like 'switched to List component for listResults' or something similar when I made the change. ka |
From: <gre...@gm...> - 2004-09-17 15:18:44
|
Here's a longshot question. You know how you can write in python: a=raw_input("write text here") And basically when you run the program the user is prompted to enter text, and you get the actual text the user entered. Is there any way to get raw_input from a text field in pyCard? Of course I may already be getting this, but somehow by the time the query gets to mySQL, it has gotten all mungled. I feel it is more a problem with the mySQL api if anything, but I was curious if you guys had any ideas. I posted a question there which has more details about the specific problem http://sourceforge.net/forum/forum.php?thread_id=1146165&forum_id=70461 I would really appriciate it if anyone has any ideas at all, I've been stuck on this problem for 3 days now. Maybe there's something fundamental in python I'm doing wrong, but googling didn't turn up anything useful. Thanks, -Greg |
From: Kevin A. <al...@se...> - 2004-09-17 15:17:09
|
SF Site Status shows that anonymous cvs for projects starting with p=20 are down... "( 2004-09-17 06:55:49 - Project CVS Service ) =A0 As of 2004-09-17=20= there is a problem with the CVS host serving anonymous CVS, nightly=20 tarballs and ViewCVS for projects that start with the letters q, z, p,=20= m, t, n and y. We currently do not have an estimate on when they will =20= be back up." http://sourceforge.net/docman/display_doc.php?group_id=3D1&docid=3D2352 Just check that page or attempt to do a checkout periodically until you=20= have success. ka On Sep 17, 2004, at 1:46 AM, normanwinn wrote: > Hi, > > I am trying to get cvs working. Have followed the instructions in=20 > Kevin Altis document on the subject. Installing cvs has gone OK but I=20= > have had no luck in connecting. This doc doesn't mention the need to=20= > log in but the sourceforge guide=20 > (http://sourceforge.net/cvs/?group_id=3D19015) does. If I go the=20 > sourceforge route and issue this command: > > cvs -d:pserver:ano...@cv...:/cvsroot/pythoncard login > > I get this response: > > Logging in to=20 > :pserver:ano...@cv...:2401/cvsroot/pythoncard > CVS password: > > When I hit enter (as instructed) I get this: > > cvs [login aborted]: unrecognized auth response from=20 > cvs.sourceforge.net: cvs ps > erver: cannot open /cvsroot/pythoncard/CVSROOT/config: Input/output=20 > error > > I'm sure the answer is simple but I can't fathom it out. Thanks for=20 > any help, > > Norman |
From: John <joh...@jo...> - 2004-09-17 15:11:06
|
On Thu, 16 Sep 2004, Kevin Altis wrote: > On Sep 16, 2004, at 12:28 PM, John wrote: > > > Why don't we put this back on the list. Others may be interested. > > > > Something else popped up for me. While looking at converting my > > dialogs I realized I need to pass a database 'handle' from my main app > > to > > the dialogs which executes operations on the tables. With the dialogs > > it > > was easy, call the dialog with the handle when I instantiate the > > class, and > > assign the handle to self.handle in the __init__ method. If I were to > > call > > a 'sub' -app it does not seem to be as straight forward, give how > > backgrounds are called. Although I could have a get like method say > > getdbhandle, to accomplish what I was doing in the > > 'constructor' __init__. I'll guess I'll dive into the background > > code and find out. ;) > > You have a couple of options. One, simply refer to variables in the > parent. For example, it is common when creating a CustomDialog to set > the parent as so (example from resourceEditor dialogInfoDialog.py... > > class DialogInfoDialog(model.CustomDialog): > def __init__(self, aBg, rsrc): > model.CustomDialog.__init__(self, aBg) > > self.parent = aBg > ... > > If you had an attribute in the main background that called the dialog > called db then you could refer to it as self.parent.db. Actually, the > line above is redundant because CustomDialog __init__ sets the parent > as well. For Background, CustomDialog, and PageBackground you can > always just use the wxPython GetParent() method to get the same info. > There is a mixedCase getParent alias as well. > > If you're creating a child window then you can set variables in the > child using the reference you keep when you create the child, so > something like: > > self.subWindow = model.childWindow(...) > self.subWindow.db = self.db > > In your child window, you could then use self.db. The on_initialize > event handler won't run until after your current event handler > terminates, so the on_initialize can actually make references to > self.db. > > ka > I get the dialog in fact that's close to what I'm currently doing. My question is how to pass parameters to a class derived from model.background *in the constructor* once you have the instance it's easy enough to set them, but is it possible to pass parameters to the __init__ for model.background or oninitialize when you make the call app = model.Application(Launcher) for example. -john --------------------------------------------------------- My religion consists of a humble admiration of the illimitable superior spirit who reveals himself in the slight details we are able to perceive with our frail and feeble mind. Albert Einstein |
From: normanwinn <nor...@on...> - 2004-09-17 09:27:14
|
Hi, Since my last post on doing on this I have made opening the resource editor optional. If a checkbox is checked and the file looks like a resource file then it is opened in the resource editor. If unchecked it is opened in the code editor. I then went on to see if I could highlight the search results. Using FindFiles to go code shopping I found the the 'redemo.py' implements this very nicely. So, feeling brave, I started to cut and paste the necessary functions into my version of FindFiles and alter the component names accordingly. Finally got it running but bumped into the problem that List component has no text attribute. Tried using a TextArea component instead but this lacks the attributes of a list. Clearly, I need the functionality of a List but with a text attribute. I notice there are various ListBox controls in wxPython but I am too young in PythonCard to try to weave my own component, Norman |
From: normanwinn <nor...@on...> - 2004-09-17 08:46:27
|
Hi, I am trying to get cvs working. Have followed the instructions in Kevin Altis document on the subject. Installing cvs has gone OK but I have had no luck in connecting. This doc doesn't mention the need to log in but the sourceforge guide (http://sourceforge.net/cvs/?group_id=19015) does. If I go the sourceforge route and issue this command: cvs -d:pserver:ano...@cv...:/cvsroot/pythoncard login I get this response: Logging in to :pserver:ano...@cv...:2401/cvsroot/pythoncard CVS password: When I hit enter (as instructed) I get this: cvs [login aborted]: unrecognized auth response from cvs.sourceforge.net: cvs ps erver: cannot open /cvsroot/pythoncard/CVSROOT/config: Input/output error I'm sure the answer is simple but I can't fathom it out. Thanks for any help, Norman |
From: Kevin A. <al...@se...> - 2004-09-16 22:38:14
|
On Sep 16, 2004, at 3:23 PM, Alex Tweedly wrote: > At 14:46 16/09/2004 -0700, Kevin Altis wrote: > > >> I'm glad you were able to work this out. I haven't had resourceEditor >> support in findfiles previously, because usually I want to edit the >> .rsrc.py files using the codeEditor to make some quick change. >> However, I think it would be a good option that could be toggled on >> and off, so I'll look at adding that. In the meantime, all you need >> to do is a simple string check, in fact, I'm not sure why I'm not >> doing this in the existing code, except maybe the current way seemed >> cleaner than filename.endswith('.py) or filename.endswith('.pyw'). > > Well, os.path goes to all the trouble of giving us a splitext > function, so it may be a good idea to use it. Some day, someone may > find a file system that uses something other than "." as the separator > .... > >> if filename.endswith('.rsrc.py'): >> program = os.path.join("..", "resourceEditor", >> "resourceEditor.py") >> elif os.path.splitext(filename)[-1] in ['.py', '.pyw']: >> ... >> Obviously, you can put the additional code in to check for a >> resourceEditor.pyw file, but the main thing is to just use the >> endswith string method and make sure that check is done before the >> .py/.pyw check. > > You could go one step further and do > name,ext = os.path.splitext(filename) > if ext in ['py', 'pyw]]: > if name.endswith(".rsrc") then > resource editor > else: > code editor > else: > text editor > > (Hmmm - or get really carried away and put in a table of file types > and programs to use to open them with - with a menu option to > create/edit associations, and .... :) Actually, that was the plan at one point, but it seemed like overkill. Sort of like having a built-in codeEditor (childWindow) in findfiles, though that is actually easy to do and sort of appealing, hmm... > Which brings me to a real question ... why .rsrc.py rather than > .rsrc ? > That way you could have associated .rsrc with the resource editor in > the OS. Historical decision. There is a .py extension because the resource files are valid python files, so if you open them in a Python-aware editor you get syntax highlighting, syntax checks should work, etc. I also needed a way of separating attributes of the filename to support automatic international resource support like minimal.fr.rsrc.py so dots seemed like the way to go. What we need to decide is whether the current import methodology makes sense or whether it would actually be better to make the resources into real modules so they could just be imported. To do that, the extra dots as separators have to be dropped they would be misinterpreted by import. Switching to underscores would solve the problem there. The resource file would need one tiny change, something like: RESOURCE_DICT = { 'application':{ 'type':'Application', instead of just { 'application':{ 'type':'Application', The reason for the uppercase name is that if something obvious and unique like that is used, then it would be relatively simple to identify it as a global in any file. Conceivably, you could then inherit attributes from other resource files which would reduce duplication of common menus, or layouts. I don't know how the resourceEditor would be able to parse that, but it has some interesting uses. Anyway, we have to decide about changes like that pretty soon. I've been putting it off since it means changing so many files, but it needs to be done before say release 0.9. To minimize hassles it would be a good time to decide whether the CustomDialog resource format should really be different than Background as well as whether the name Background should finally be changed to just plain Window or Frame or something before we get to 1.0 ka |
From: Alex T. <al...@tw...> - 2004-09-16 22:12:12
|
At 14:46 16/09/2004 -0700, Kevin Altis wrote: >I'm glad you were able to work this out. I haven't had resourceEditor >support in findfiles previously, because usually I want to edit the >.rsrc.py files using the codeEditor to make some quick change. However, I >think it would be a good option that could be toggled on and off, so I'll >look at adding that. In the meantime, all you need to do is a simple >string check, in fact, I'm not sure why I'm not doing this in the existing >code, except maybe the current way seemed cleaner than >filename.endswith('.py) or filename.endswith('.pyw'). Well, os.path goes to all the trouble of giving us a splitext function, so it may be a good idea to use it. Some day, someone may find a file system that uses something other than "." as the separator .... > if filename.endswith('.rsrc.py'): > program = os.path.join("..", "resourceEditor", > "resourceEditor.py") > elif os.path.splitext(filename)[-1] in ['.py', '.pyw']: > ... >Obviously, you can put the additional code in to check for a >resourceEditor.pyw file, but the main thing is to just use the endswith >string method and make sure that check is done before the .py/.pyw check. You could go one step further and do name,ext = os.path.splitext(filename) if ext in ['py', 'pyw]]: if name.endswith(".rsrc") then resource editor else: code editor else: text editor (Hmmm - or get really carried away and put in a table of file types and programs to use to open them with - with a menu option to create/edit associations, and .... :) Which brings me to a real question ... why .rsrc.py rather than .rsrc ? That way you could have associated .rsrc with the resource editor in the OS. -- Alex. |
From: Kevin A. <al...@se...> - 2004-09-16 22:00:14
|
The Seattle Python Interest Group (SeaPig) is hosting some Python sprints in Bellevue, Washington, October 23rd and 24th. One of the sprint topics will be PythonCard and I'll be driving up from Portland to attend both days, give an intro presentation like the one I did at the VanPy conference and help people work on the framework, documentation, samples, and tools or their own applications. The sprint is free, so if you're able to attend, please let me know and sign-up on the wiki pages below. I hope to see you there. http://seapig.org/SprintPythonCard http://seapig.org/NorthwestPythonSprint Directions: http://www.construx.com/contact/driving.php ka --- Kevin Altis al...@se... http://altis.pycs.net/ http://www.pythoncard.org/ |
From: Kevin A. <al...@se...> - 2004-09-16 21:50:32
|
I've fixed the codeEditorR.py program to correctly handle CustomDialog resource files. If you aren't working from cvs, you can make the fix yourself by replacing the setResourceFile method with the one below. def setResourceFile(self): self.components.popComponentNames.items = [] self.components.popComponentEvents.items = [] try: self.resourceFilename = getResourceFilename(self.documentPath) self.rsrc = resource.ResourceFile(self.resourceFilename).getResource() self.rsrcComponents = {} if hasattr(self.rsrc, 'application'): components = self.rsrc.application.backgrounds[0].components else: # CustomDialog components = self.rsrc.components for c in components: self.rsrcComponents[c.name] = c.type items = self.rsrcComponents.keys() items.sort() self.components.popComponentNames.items = items except: pass ka |
From: Kevin A. <al...@se...> - 2004-09-16 21:46:44
|
On Sep 16, 2004, at 12:53 PM, normanwinn wrote: > Hi, > > I was having trouble getting Walkthough 3 to work. Having already > posted I felt too guilty to admit I hadn't even got that far. I > trawled the web for hints but didn't get anywhere. Then I played with > 'FindFiles'. I soon wanted it to open resource files in the resource > editor (no doubt someone will come back and tell me that was already > possible). So I decided to see if I could add this functionality > myself. > > First I had to find the '.rsrc' files. To do this I just searched for: > > { 'application':{ 'type':'Application', > > not elegant, but it worked. > > I first found where the highlighted file was opened which was inside > this function (only showing the part I played with): > >> def editFile(self, filename, lineno=None): >> if filename == '': >> return >> >> log.debug("filename: " + filename + " lineno: " + >> str(lineno)) >> # edit Python scripts with codeEditor >> # everything else with textEditor >> # the list of extensions and associated programs to >> # open with should be user settable >> if os.path.splitext(filename)[-1] in ['.py', '.pyw']: >> program = os.path.join("..", "codeEditor", >> "codeEditor.pyw") >> if not os.path.exists(program): >> program = os.path.join("..", "codeEditor", >> "codeEditor.py") >> else: >> program = os.path.join("..", "textEditor", >> "textEditor.pyw") >> if not os.path.exists(program): >> program = os.path.join("..", "textEditor", >> "textEditor.py") >> # throw an exception if textEditor can't be found? >> log.debug('program: ' + program) > > > I had made a copy of the 'FindFiles' directory content and put it > elsewhere. It took me a while to fathom the FindFiles depends on > hanging off the 'Tools' folder to work. I then moved my copy there and > started to get somewhere. > > I tried adding a condition to so that I could operate on '.rsrc.py' > files. The interactive shell is a great tool for learning. I imported > 'os' and worked out what 'os.path.splitext' does. I copied a path and > assigned it to a variable (still in the shell) and finally found that: > > os.path.splitext(filename)[0][-5:] > > gave me the '.rsrc' I was trying for. > > I was not successful at getting the resource editor to run so I tried > assigning the above to a variable and just to show it with a 'print'. > Evidently, this produced an error. > > I saw all those 'log.debug' lines so went about finding which of the > imported modules it came from. Once I found it I imported this in the > shell and looked for help on how 'log' worked. Nice and simple, so I > put: > > log.enable() > > in the function 'on_initialize' and I had log information pouring out > to me in the shell. > > This told me that I was extracting the right string. I then divined my > error. I was using 'is' instead of '==' to test my string. I changed > it and it worked. I felt real proud of myself when the resource editor > opened up. > > So, if anyone is interested here is what those lines above became: > >> def editFile(self, filename, lineno=None): >> if filename == '': >> return >> >> log.debug("filename: " + filename + " lineno: " + >> str(lineno)) >> # edit Python scripts with codeEditor >> # everything else with textEditor >> # the list of extensions and associated programs to >> # open with should be user settable >> rsrcFile = os.path.splitext(filename)[0][-5:] >> log.debug('rsrcFile: ' + rsrcFile) >> if rsrcFile == '.rsrc': >> program = os.path.join("..", "resourceEditor", >> "resourceEditor.py") >> if not os.path.exists(program): >> program = os.path.join("..", "resourceEditor", >> "resourceEditor.py") >> else: >> if os.path.splitext(filename)[-1] in ['.px', '.pyx']: >> program = os.path.join("..", "codeEditor", >> "codeEditor.pyw") >> if not os.path.exists(program): >> program = os.path.join("..", "codeEditor", >> "codeEditor.py") >> else: >> program = os.path.join("..", "textEditor", >> "textEditor.pyw") >> if not os.path.exists(program): >> program = os.path.join("..", "textEditor", >> "textEditor.py") > > > I realise that using a variable to get my string is not very elegant > but I did it that way to isolate my error. > > I am relating this partly as one test I have set myself is to see if I > can learn PythonCard and Python 'top down'. I learnt Object Pascal in > Delphi that way and had thought it would not be possible. Seems I am > wrong, I'm glad you were able to work this out. I haven't had resourceEditor support in findfiles previously, because usually I want to edit the .rsrc.py files using the codeEditor to make some quick change. However, I think it would be a good option that could be toggled on and off, so I'll look at adding that. In the meantime, all you need to do is a simple string check, in fact, I'm not sure why I'm not doing this in the existing code, except maybe the current way seemed cleaner than filename.endswith('.py) or filename.endswith('.pyw'). if filename.endswith('.rsrc.py'): program = os.path.join("..", "resourceEditor", "resourceEditor.py") elif os.path.splitext(filename)[-1] in ['.py', '.pyw']: ... Obviously, you can put the additional code in to check for a resourceEditor.pyw file, but the main thing is to just use the endswith string method and make sure that check is done before the .py/.pyw check. And just in case it wasn't obvious, in the File types: field of Find Files, just search for *.rsrc.py files. > Norman > > PS I still can't get the child window to open. My script runs OK but > as soon as I hit 'Increment' or 'Decrement' I get > What is the actual error? I haven't looked at that walkthrough in a while, so it hasn't been updated for release 0.8. Make sure to change on_openBackground to on_initialize. ka |
From: Kevin A. <al...@se...> - 2004-09-16 21:28:59
|
On Sep 16, 2004, at 12:28 PM, John wrote: > Why don't we put this back on the list. Others may be interested. > > Something else popped up for me. While looking at converting my > dialogs I realized I need to pass a database 'handle' from my main app > to > the dialogs which executes operations on the tables. With the dialogs > it > was easy, call the dialog with the handle when I instantiate the > class, and > assign the handle to self.handle in the __init__ method. If I were to > call > a 'sub' -app it does not seem to be as straight forward, give how > backgrounds are called. Although I could have a get like method say > getdbhandle, to accomplish what I was doing in the > 'constructor' __init__. I'll guess I'll dive into the background > code and find out. ;) You have a couple of options. One, simply refer to variables in the parent. For example, it is common when creating a CustomDialog to set the parent as so (example from resourceEditor dialogInfoDialog.py... class DialogInfoDialog(model.CustomDialog): def __init__(self, aBg, rsrc): model.CustomDialog.__init__(self, aBg) self.parent = aBg ... If you had an attribute in the main background that called the dialog called db then you could refer to it as self.parent.db. Actually, the line above is redundant because CustomDialog __init__ sets the parent as well. For Background, CustomDialog, and PageBackground you can always just use the wxPython GetParent() method to get the same info. There is a mixedCase getParent alias as well. If you're creating a child window then you can set variables in the child using the reference you keep when you create the child, so something like: self.subWindow = model.childWindow(...) self.subWindow.db = self.db In your child window, you could then use self.db. The on_initialize event handler won't run until after your current event handler terminates, so the on_initialize can actually make references to self.db. ka |
From: normanwinn <nor...@on...> - 2004-09-16 19:53:40
|
Hi, I was having trouble getting Walkthough 3 to work. Having already posted I felt too guilty to admit I hadn't even got that far. I trawled the web for hints but didn't get anywhere. Then I played with 'FindFiles'. I soon wanted it to open resource files in the resource editor (no doubt someone will come back and tell me that was already possible). So I decided to see if I could add this functionality myself. First I had to find the '.rsrc' files. To do this I just searched for: { 'application':{ 'type':'Application', not elegant, but it worked. I first found where the highlighted file was opened which was inside this function (only showing the part I played with): > def editFile(self, filename, lineno=None): > if filename == '': > return > > log.debug("filename: " + filename + " lineno: " + str(lineno)) > # edit Python scripts with codeEditor > # everything else with textEditor > # the list of extensions and associated programs to > # open with should be user settable > if os.path.splitext(filename)[-1] in ['.py', '.pyw']: > program = os.path.join("..", "codeEditor", "codeEditor.pyw") > if not os.path.exists(program): > program = os.path.join("..", "codeEditor", > "codeEditor.py") > else: > program = os.path.join("..", "textEditor", "textEditor.pyw") > if not os.path.exists(program): > program = os.path.join("..", "textEditor", > "textEditor.py") > # throw an exception if textEditor can't be found? > log.debug('program: ' + program) I had made a copy of the 'FindFiles' directory content and put it elsewhere. It took me a while to fathom the FindFiles depends on hanging off the 'Tools' folder to work. I then moved my copy there and started to get somewhere. I tried adding a condition to so that I could operate on '.rsrc.py' files. The interactive shell is a great tool for learning. I imported 'os' and worked out what 'os.path.splitext' does. I copied a path and assigned it to a variable (still in the shell) and finally found that: os.path.splitext(filename)[0][-5:] gave me the '.rsrc' I was trying for. I was not successful at getting the resource editor to run so I tried assigning the above to a variable and just to show it with a 'print'. Evidently, this produced an error. I saw all those 'log.debug' lines so went about finding which of the imported modules it came from. Once I found it I imported this in the shell and looked for help on how 'log' worked. Nice and simple, so I put: log.enable() in the function 'on_initialize' and I had log information pouring out to me in the shell. This told me that I was extracting the right string. I then divined my error. I was using 'is' instead of '==' to test my string. I changed it and it worked. I felt real proud of myself when the resource editor opened up. So, if anyone is interested here is what those lines above became: > def editFile(self, filename, lineno=None): > if filename == '': > return > > log.debug("filename: " + filename + " lineno: " + str(lineno)) > # edit Python scripts with codeEditor > # everything else with textEditor > # the list of extensions and associated programs to > # open with should be user settable > rsrcFile = os.path.splitext(filename)[0][-5:] > log.debug('rsrcFile: ' + rsrcFile) > if rsrcFile == '.rsrc': > program = os.path.join("..", "resourceEditor", > "resourceEditor.py") > if not os.path.exists(program): > program = os.path.join("..", "resourceEditor", > "resourceEditor.py") > else: > if os.path.splitext(filename)[-1] in ['.px', '.pyx']: > program = os.path.join("..", "codeEditor", > "codeEditor.pyw") > if not os.path.exists(program): > program = os.path.join("..", "codeEditor", > "codeEditor.py") > else: > program = os.path.join("..", "textEditor", > "textEditor.pyw") > if not os.path.exists(program): > program = os.path.join("..", "textEditor", > "textEditor.py") I realise that using a variable to get my string is not very elegant but I did it that way to isolate my error. I am relating this partly as one test I have set myself is to see if I can learn PythonCard and Python 'top down'. I learnt Object Pascal in Delphi that way and had thought it would not be possible. Seems I am wrong, Norman PS I still can't get the child window to open. My script runs OK but as soon as I hit 'Increment' or 'Decrement' I get |
From: Alex T. <al...@tw...> - 2004-09-16 01:48:27
|
At 02:30 16/09/2004 +0100, Alex Tweedly wrote: >WARNING: The remainder of this message has not been transferred. >The estimated size of this message is 41479 bytes. Oops - sorry, didn't realize that was so big, or I'd have ZIPped it. Here's my first example using the notebook component - lets you view multiple csv files, one per tab of the notebook. You can only open and close them for now, but it does show setting status bar, title, opening and closing pages, etc. And, of course, it resizes them - using the autosizer (also included in the zip file). The resizing is imperfect - sometimes the initial open of a csv file doesn't fill the page - but as soon as you resize it, that comes right. NOTE - this uses an up-to-date from CVS version of Pythoncard - it depends on at least one of the changes made since the very first appearance of notebook. -- Alex. |
From: Alex T. <al...@tw...> - 2004-09-16 01:20:13
|
#---------------------------------------------------------------------- # Name: wxPython.lib.rcsizer # Purpose: RowColSizer: # # Author: Robin Dunn, adapted from code by Niki Spahiev # # further adapted by Alex Tweedly # uses different scheme for allocating space to col(row) from a # component that spans multiple cols(rows). Process all single col items # first, then for spanning items, allocate only additional as needed. # # Also, added the concept of component being able to grow in one dimension only # to better handle things like text fields which shouldn't grow in size in height # even if the row grows for other reasons. !? """ A pure-Python Sizer that lays out items in a grid similar to wx.FlexGridSizer but item position is not implicit but explicitly specified by row and col, and row/col spanning is supported. Adapted from code by Niki Spahiev. """ import operator import wx DEBUG = False #---------------------------------------------------------------------- class RowColSizer(wx.PySizer): # default sizes for cells with no item col_w = 10 row_h = 22 def __init__(self, min_w=10, min_h=22, border=0): wx.PySizer.__init__(self) self.col_w = min_w self.row_h = min_h self.border = border self.growableRows = [] self.growableCols = [] def AddGrowableRow(self, idx): self.growableRows.append(idx) def AddGrowableCol(self, idx): self.growableCols.append(idx) #-------------------------------------------------- def Add(self, item, option=0, flag=0, border=0, # row, col and spanning can be specified individually... row=-1, col=-1, rowspan=1, colspan=1, # or as tuples (row,col) and (rowspan,colspan) pos=None, size=None, growXonly = False ): if pos is not None: row, col = pos if size is not None: rowspan, colspan = size if rowspan == 0: rowspan = 1 if colspan == 0: rowspan = 1 assert row != -1, "Row must be specified" assert col != -1, "Column must be specified" # Do I really want to do this? Probably not... #if rowspan > 1 or colspan > 1: # flag = flag | wx.EXPAND #rint "----", rowspan, colspan, row, col wx.PySizer.Add(self, item, option, flag, border, userData=(row, col, row+rowspan, col+colspan, growXonly)) #AddWindow = Add #AddSizer = Add def AddSpacer(self, width, height, option=0, flag=0, border=0, row=-1, col=-1, rowspan=1, colspan=1, pos=None, size=None, ): if pos is not None: row, col = pos if size is not None: rowspan, colspan = size assert row != -1, "Row must be specified" assert col != -1, "Column must be specified" wx.PySizer.Add(self, (width, height), option, flag, border, userData=(row, col, row+rowspan, col+colspan, False)) #-------------------------------------------------- def _addRow( self, size, r, r2 ): # are the widths and heights lists long enough? if r2 > len(self.rowHeights): x = [self.row_h] * (r2-len(self.rowHeights)) self.rowHeights.extend( x ) # set the widths and heights lists for this item ## if DEBUG: print "rows", r, r2 if r == r2-1: already = self.rowHeights[r] else: already = reduce( operator.add, self.rowHeights[r:r2] ) if DEBUG and False: print "already have", already if already < size.height+2*self.border: scale = (r2 - r) delta = (size.height+2*self.border-already) / scale extra = (size.height+2*self.border-already) % scale for i in range(r, r2): self.rowHeights[i] += delta self.rowHeights[r] += extra if DEBUG and False: print "just added (row) ", size, "at", r,r2, self.rowHeights #-------------------------------------------------- def _addCol( self, size, c, c2 ): # are the widths and heights lists long enough? if c2 > len(self.colWidths): x = [self.col_w] * (c2-len(self.colWidths)) self.colWidths.extend( x ) # set the widths and heights lists for this item ## if DEBUG: print "cols", c, c2 if c == c2-1: already = self.colWidths[c] else: already = reduce( operator.add, self.colWidths[c:c2]) if already < size.width+2*self.border: scale = (c2 - c) delta = (size.width+2*self.border-already) / scale extra = (size.width+2*self.border-already) % scale for i in range(c, c2): self.colWidths[i] += delta self.colWidths[c] += extra if DEBUG: print "just added", size, "at", c, c2, self.colWidths #-------------------------------------------------- def CalcMin( self ): global DEBUG self.rowHeights = [] self.colWidths = [] items = self.GetChildren() if not items: return wx.Size(10, 10) for item in items: r, c, r2, c2, growXonly = item.GetUserData() # unpack coords and spanning if r2 == r+1: if DEBUG: print "do single row", r,r2 self._addRow( item.CalcMin(), r, r2 ) if c2 == c+1: if DEBUG: print "do single col", r,r2 self._addCol( item.CalcMin(), c, c2 ) for item in items: r, c, r2, c2, growXonly = item.GetUserData() # unpack coords and spanning if r2 > r+1: if DEBUG: print "do multi row", r,r2 self._addRow( item.CalcMin(), r, r2 ) if c2 > c+1: if DEBUG: print "do multi col", r,r2 self._addCol( item.CalcMin(), c, c2 ) size = wx.Size( reduce( operator.add, self.colWidths), reduce( operator.add, self.rowHeights) ) if DEBUG: print "Calc min", self.rowHeights, self.colWidths DEBUG=False return size #-------------------------------------------------- def RecalcSizes( self ): # save current dimensions, etc. curWidth, curHeight = self.GetSize() px, py = self.GetPosition() minWidth, minHeight = self.CalcMin() # Check for growables if self.growableRows and curHeight > minHeight: delta = (curHeight - minHeight) / len(self.growableRows) extra = (curHeight - minHeight) % len(self.growableRows) for idx in self.growableRows: self.rowHeights[idx] += delta self.rowHeights[self.growableRows[0]] += extra if self.growableCols and curWidth > minWidth: delta = (curWidth - minWidth) / len(self.growableCols) extra = (curWidth - minWidth) % len(self.growableCols) for idx in self.growableCols: self.colWidths[idx] += delta self.colWidths[self.growableCols[0]] += extra rpos = [0] * len(self.rowHeights) cpos = [0] * len(self.colWidths) for i in range(len(self.rowHeights)): height = self.rowHeights[i] rpos[i] = py py += height for i in range(len(self.colWidths)): width = self.colWidths[i] cpos[i] = px px += width # iterate children and set dimensions... for item in self.GetChildren(): r, c, r2, c2, growXonly = item.GetUserData() if DEBUG: print "reduce in recalc", r, r2, "and cols", c, c2, item width = reduce( operator.add, self.colWidths[c:c2] ) height = reduce( operator.add, self.rowHeights[r:r2] ) starty = rpos[r] if growXonly: ix, newHeight = item.CalcMin() if DEBUG: print "replacing ", height, " by ", newHeight starty = starty + (height-newHeight)/2 height = newHeight self.SetItemBounds( item, cpos[c], starty, width, height ) #-------------------------------------------------- def SetItemBounds(self, item, x, y, w, h): # calculate the item's actual size and position within # its grid cell ipt = wx.Point(x, y) isz = item.CalcMin() flag = item.GetFlag() if flag & wx.EXPAND or flag & wx.SHAPED: isz = wx.Size(w, h) else: if flag & wx.ALIGN_CENTER_HORIZONTAL: ipt.x = x + (w - isz.width) / 2 elif flag & wx.ALIGN_RIGHT: ipt.x = x + (w - isz.width) if flag & wx.ALIGN_CENTER_VERTICAL: ipt.y = y + (h - isz.height) / 2 elif flag & wx.ALIGN_BOTTOM: ipt.y = y + (h - isz.height) item.SetDimension(ipt, isz) #---------------------------------------------------------------------- #---------------------------------------------------------------------- |
From: <gre...@co...> - 2004-09-15 19:30:53
|
I just want to check if I get this email in the right place, I just changed my address for the list. -Greg |
From: John <joh...@jo...> - 2004-09-15 18:32:26
|
On Wed, 15 Sep 2004, Kevin Altis wrote: > On Sep 15, 2004, at 6:07 AM, normanwinn wrote: > > > > > A pretty neat design trick in Filemaker might be easily added to the > > PythonCard resource editor. When an object is selected the arrow > > buttons move the object a pixel (or grid position) at a time. > > Yeah that was on the to do list, so I just added it and checked the > change into cvs. It supports 1 pixel movement right now. I didn't feel > like grappling with the calculation to figure the right relative grid > jump before I had some coffee, but I'll look at that later ;-) > > > If I manage to get my Python up to speed I'd like to try to generate > > the function definition header directly in the code by double clicking > > the item or event in the resource editor - =E0 la Delphi. Good or bad > > idea? > > > > This is another topic that has been brought up before. Since the > resourceEditor doesn't deal with actually editing the code yet, events > are not part of the attribute list since the assumption is that people > will be using the codeEditor or some other editor to manipulate the > source code. > > There is a codeEditorR.py program based on the codeEditor that has an > additional experimental feature. When you are editing a source file, it > reads the associated .rsrc.py file and provides a dropdown menu of all > the components. When you select one of the components from the menu, it > populates the second dropdown menu with a list of all the events for > the component type. The events that are already defined have a + in > front of the name. If you select an item with a + in front, the cursor > jumps to that event handler in the code. If you select an event that > isn't in your code, then an event handler stub for that event is > inserted at the current cursor location. > > ka > Kevin this works on the samples but not on a project I converted by hand fomr Pyhoncard prototype. Is there something else I need to add to my source or resource to enable this? Thanks. -john --------------------------------------------------------- Everything should be made as simple as possible, but not one bit simpler. Albert Einstein (attributed) |
From: Alex T. <al...@tw...> - 2004-09-15 18:32:21
|
At 14:17 15/09/2004 -0400, Gregory Pi=F1ero wrote: >I'd love to have that feature. Visual Basic does that too. Where do I=20 >get this codeEditorR.py program? Was it already installed with pyCard? It's in Pythoncard/tools/codeEditor -- Alex. |
From: <gre...@co...> - 2004-09-15 18:15:18
|
Kevin Altis wrote: > On Sep 15, 2004, at 6:07 AM, normanwinn wrote: > >> >> A pretty neat design trick in Filemaker might be easily added to the >> PythonCard resource editor. When an object is selected the arrow >> buttons move the object a pixel (or grid position) at a time. > > > Yeah that was on the to do list, so I just added it and checked the > change into cvs. It supports 1 pixel movement right now. I didn't feel > like grappling with the calculation to figure the right relative grid > jump before I had some coffee, but I'll look at that later ;-) > >> If I manage to get my Python up to speed I'd like to try to generate >> the function definition header directly in the code by double clicking >> the item or event in the resource editor - à la Delphi. Good or bad idea? >> > > This is another topic that has been brought up before. Since the > resourceEditor doesn't deal with actually editing the code yet, events > are not part of the attribute list since the assumption is that people > will be using the codeEditor or some other editor to manipulate the > source code. I'd love to have that feature. Visual Basic does that too. Where do I get this codeEditorR.py program? Was it already installed with pyCard? -Greg > > There is a codeEditorR.py program based on the codeEditor that has an > additional experimental feature. When you are editing a source file, it > reads the associated .rsrc.py file and provides a dropdown menu of all > the components. When you select one of the components from the menu, it > populates the second dropdown menu with a list of all the events for the > component type. The events that are already defined have a + in front of > the name. If you select an item with a + in front, the cursor jumps to > that event handler in the code. If you select an event that isn't in > your code, then an event handler stub for that event is inserted at the > current cursor location. > > ka > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: thawte's Crypto Challenge Vl > Crack the code and win a Sony DCRHC40 MiniDV Digital Handycam > Camcorder. More prizes in the weekly Lunch Hour Challenge. > Sign up NOW http://ad.doubleclick.net/clk;10740251;10262165;m > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > |
From: Kevin A. <al...@se...> - 2004-09-15 16:00:38
|
On Sep 15, 2004, at 6:07 AM, normanwinn wrote: > > A pretty neat design trick in Filemaker might be easily added to the=20= > PythonCard resource editor. When an object is selected the arrow=20 > buttons move the object a pixel (or grid position) at a time. Yeah that was on the to do list, so I just added it and checked the=20 change into cvs. It supports 1 pixel movement right now. I didn't feel=20= like grappling with the calculation to figure the right relative grid=20 jump before I had some coffee, but I'll look at that later ;-) > If I manage to get my Python up to speed I'd like to try to generate=20= > the function definition header directly in the code by double clicking=20= > the item or event in the resource editor - =E0 la Delphi. Good or bad=20= > idea? > This is another topic that has been brought up before. Since the=20 resourceEditor doesn't deal with actually editing the code yet, events=20= are not part of the attribute list since the assumption is that people=20= will be using the codeEditor or some other editor to manipulate the=20 source code. There is a codeEditorR.py program based on the codeEditor that has an=20 additional experimental feature. When you are editing a source file, it=20= reads the associated .rsrc.py file and provides a dropdown menu of all=20= the components. When you select one of the components from the menu, it=20= populates the second dropdown menu with a list of all the events for=20 the component type. The events that are already defined have a + in=20 front of the name. If you select an item with a + in front, the cursor=20= jumps to that event handler in the code. If you select an event that=20 isn't in your code, then an event handler stub for that event is=20 inserted at the current cursor location. ka |
From: bartek w. <ba...@re...> - 2004-09-15 04:33:51
|
Cytowanie Alex Tweedly <al...@tw...>: <long snip> > BUT there is a problem - I get errors because some variables within the > csvPage don't exist. > Adding some debug "print"s, I found that the on_openfile seems to be called > > before the on_initialize. > It looks as though the on_initialize is being called later (maybe from > wxMainLoop) > <snip> It seems to be general behaviour. I have the same problem when I try to open a child window with resource editor and open a file in it from parent window. In my understanding if you try to do something like: child = model.childWindow(....) child.doSomethingNow(...) You may run into initialization problems. It's just my experience and I dont' know how to solve it in general (even though I'd like to :), my quick &dirty solution so far is to create modified version of ResourceEditor, that takes another argument (say file_to_open) and opening it after it knows that the initialization is done. Bartek Wilczynski |
From: Kevin A. <al...@se...> - 2004-09-15 01:16:31
|
On Sep 14, 2004, at 5:33 PM, Alex Tweedly wrote: > At 11:04 14/09/2004 -0700, Kevin Altis wrote: > >> There didn't seem to be any major objections, so I went ahead and >> checked in the Notebook component, the necessary changes to the >> framework, and a testNotebook sample. The changes should show up on >> anonymous cvs later this afternoon. See my other comments below. > > Not sure if it's better to cc the whole list on these messages while I > stumble around trying the Notebook component or not - might save > others repeating the same sequence, so I'll do that for now, and take > it off-list if this goes on too long. > > Aim - build a program that uses a tabbed notebook to display multiple > csv files; each time you do File/Open, it creates a new tab and > displays the file in it. > > First, I built a very simple csv-viewer program (one component, a > multicolumn list), and only filled in the FIle/Open handler, to get a > file name, then call on_openFile to read in the csv file and display > it. > > Then I changed that from a stand-alone program to make it ready for > inclusion in a notebook (i.e. I changed it from model.Background to > model.PageBackground). > > Then I built another very simple app (one component - a notebook), but > didn't put anything into the notebook in on_initialize; and I made its > on_openFile do the following : > > win = model.childWindow(self.components.myNotebook, > csv_page.csvPage) > self.components.myNotebook.AddPage(win, pageName, True) > win.openFile(path) > > i.e. create the window, add it to the notebook, then invoke the > openFile handler, passing in the filename to read ..... > > It kind of works - it displays the data from the csv file in a > multicolumnlist inside the notebook; and if I open another file, it > opens a new tab, and displays it. > > BUT there is a problem - I get errors because some variables within > the csvPage don't exist. > Adding some debug "print"s, I found that the on_openfile seems to be > called before the on_initialize. > It looks as though the on_initialize is being called later (maybe from > wxMainLoop) > > Does that make any sense ? > Or should I go back and look for other causes for why things seem to > be called in the "wrong" order ? > That is the expected behavior. initialize is an event that is posted when PageBackground is created. However, you don't give it a chance to run until after win.openFile(path) because you are still in the event where you are creating the window and adding it to the notebook. So, you have a couple of options besides making your own __init__ method in your PageBackground subclass, which is a little complicated. The simplest is probably just to change the last line to wx.CallAfter(win.openFile, path) Once the event message queue empties, openFile will be called and that should be after on_initialize runs. Additional technical details... Due to event order when windows are created, some events such as size, move, gainFocus, or idle may also occur before initialize. Linux/GTK seems particularly bad about this and I have never figured out a good workaround. In cases like that you have to use some protection code to avoid doing some operation before proper initialization has occurred. That might be as simple as something like: if not hasattr(self, 'path'): event.skip() return Where the assumption is that self.path would be created in your on_initialize handler. I suggest running the testvents sample application. I may have to explicitly bind the gainFocus event separately from all the other events to fix that particular problem. I have left it alone so far because gainFocus just isn't used; the only sample or tool that uses it is testevents. ka |