From: Alex T. <al...@tw...> - 2006-06-13 00:17:33
|
Scott Chapman wrote: >I'm using PythonCard 0.8.2 on Windows XP Pro with Python 2.4.3. >When I add a widget to the screen and have it generate the code for it, it's not >automatically generating code stubs for the event handlers. Can I make it do that? > > > Not directly - but see below. >I run it with debug options on and I see it's adding bindings for a few things, >but not the widgets I added. > > It will automatically bind the events to the methods if they exist. So if you use the layoutEditor to add a button named "buttonMine", no binding happens. If you then add a handler on_buttonMine_mouseClick to the Python source, then it will be bound for you next time you run. There's no need (and no purpose) in adding event stub code (since by definition the stub code does nothing) - as soon as there is "real " code there, it will be bound to the event. When you run with the Message Watcher, it will show the "unused" events as gray, while the events for which there is code are shown in black (or you can click the checkbox to hide the unused ones). >Are there plans to make it work more like Visual Basic does where you could >right-click on a widget edit the Python code for the event handler you select? > > > No specific plans in the short term. However, there is already a feature which is (slightly) like that. In 0.8.2 there are actually two versions of the resource editor (resourceEditor and layoutEditor), and two versions of the code editor (codeEditor/codeEditor and oneEditor/tabcodeEditor). In both cases, the latter is the newer version, and we are fairly close to removing the older ones, as the newer versions get enough mileage under them to know they are OK. tabcodeEditor differs in two ways from the older codeEditor - you can edit multiple files simultaneously, in a "tabbed notebook" - there is some minor integration with resource files. If the file you are editing has a matching .rsrc.py file, then the "drop-down" choice above the notebook will be populated with a list of all your widgets. Selecting one of them will then display another drop-down, showing all the events for that widget type; those for which a handler has been found will show with a "+" (plus sign). Selecting one of these will find the relevant handler in the source file, while selecting an event for which there is not yet a handler will insert a stub handler (at current cursor position = beware !) It's an 'empty' stub (i.e. 3 lines of code) so it's not a big deal to have it inserted - the important thing was seeing the list of widgets and then a list of events. btw - the choice of name for the tool (i.e. 'oneEditor') might give a clue to the long-term thinking - but it's not solid enough to call it a 'plan' yet :-) -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.8.3/361 - Release Date: 11/06/2006 |