Since it may be useful for others <*cough* floatcanvas *cough*> I thought I should let you all know about a new feature of the demo framework that Andrea implemented based on my suggestions.
For almost forever the wxPython demo has had a nested list structure in Main.py that specifies the names of the modules in the demo directory that implement a sample to be shown in the demo, and also specifies their organization. In other words, to add a sample to the demo, this list needs to be modified and then the sample is shown in the demo tree and can be selected by the user.
Andrea's change allows the demo framework to scan for subdirectories that have a __demo__.py module in them,[1] and then it will import that file and use some functions within it to dynamically add more modules to the demo tree. This helps to somewhat decouple a group of related demo modules from the demo framework, thus reducing the need to modify the demo itself when adding or removing modules from that group. Also, since it uses a subdir that means that we can pull that subdir from some other location in SVN, like from the wxPython/3rdParty branch, using a svn:extern property. For example in http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/AGW/ we have agw and demos folders, the first of which is mapped to wx/lib/agw and the second is mapped to demo/agw using svn:externs.
Cool! Whenever I get back to fc2 I'll take advantage of this. Thanks Andrea and Robin for making this work.
-Matthias
P.S.: Anybody else who thinks AGW does not stand for "Advanced Generic Windows"?
路路路
Am 11.11.2008, 02:16 Uhr, schrieb Robin Dunn <robin@alldunn.com>:
Hi All,
Since it may be useful for others <*cough* floatcanvas *cough*> I thought I should let you all know about a new feature of the demo framework that Andrea implemented based on my suggestions.
This looks like it could also be useful for the "callback exceptions"
project I worked on last summer, although it may be tricky to catch all
the possibilities for testing in a single demo. I'll look into testing
a bit more when I have the time.
路路路
On Mon, Nov 10, 2008 at 05:16:45PM -0800, Robin Dunn wrote:
Hi All,
Since it may be useful for others <*cough* floatcanvas *cough*> I
thought I should let you all know about a new feature of the demo
framework that Andrea implemented based on my suggestions.
For almost forever the wxPython demo has had a nested list structure in
Main.py that specifies the names of the modules in the demo directory
that implement a sample to be shown in the demo, and also specifies
their organization. In other words, to add a sample to the demo, this
list needs to be modified and then the sample is shown in the demo tree
and can be selected by the user.
Andrea's change allows the demo framework to scan for subdirectories
that have a __demo__.py module in them,[1] and then it will import that
file and use some functions within it to dynamically add more modules to
the demo tree. This helps to somewhat decouple a group of related demo
modules from the demo framework, thus reducing the need to modify the
demo itself when adding or removing modules from that group. Also,
since it uses a subdir that means that we can pull that subdir from some
other location in SVN, like from the wxPython/3rdParty branch, using a
svn:extern property. For example in http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/AGW/ we have agw and
demos folders, the first of which is mapped to wx/lib/agw and the second
is mapped to demo/agw using svn:externs.
That does look nice. I'll try to see what I can do.
While we're talking about it -- FloatCanvas has a main Demo, but it also has a whole bunch of little demos, currently as its own stand-alone, single file application. Would it be hard to make a launcher for those? Is that something that might be useful elsewhere in the demo?
-CHB
路路路
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
That does look nice. I'll try to see what I can do.
While we're talking about it -- FloatCanvas has a main Demo, but it also has
a whole bunch of little demos, currently as its own stand-alone, single file
application. Would it be hard to make a launcher for those? Is that
something that might be useful elsewhere in the demo?
Uhm, do you really need a "launcher" for those demo? As far as I can
see, if you modify them to be able to run standalone (like
double-clicking on them) *and* in the main wxPython demo (by importing
the "run.py" module from the wxPython distribution) then all you need
to do is to add something like this at the end of your demos:
Am 11.11.2008, 02:16 Uhr, schrieb Robin Dunn <robin@alldunn.com>:
Hi All,
Since it may be useful for others <*cough* floatcanvas *cough*> I
thought I should let you all know about a new feature of the demo framework
that Andrea implemented based on my suggestions.
Cool! Whenever I get back to fc2 I'll take advantage of this. Thanks Andrea
and Robin for making this work.
-Matthias
P.S.: Anybody else who thinks AGW does not stand for "Advanced Generic
Windows"?
Uhm, do you really need a "launcher" for those demo?
maybe not...
As far as I can
see, if you modify them to be able to run standalone (like
double-clicking on them) *and* in the main wxPython demo (by importing
the "run.py" module from the wxPython distribution)
That's probably the way to go.
if __name__ == '__main__':
import sys, os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
but this depends on using the wxPython Demo "run" module, which I do not want the demos to depend on.
Nevertheless, I'm sure it can be done. I just need some time to mess with it.
-Chris
路路路
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Am 11.11.2008, 02:16 Uhr, schrieb Robin Dunn <robin@alldunn.com>:
Hi All,
Since it may be useful for others <*cough* floatcanvas *cough*> I thought I should let you all know about a new feature of the demo framework that Andrea implemented based on my suggestions.
Cool! Whenever I get back to fc2 I'll take advantage of this. Thanks Andrea and Robin for making this work.
-Matthias
P.S.: Anybody else who thinks AGW does not stand for "Advanced Generic Windows"?
Shh... It's a secret.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
That does look nice. I'll try to see what I can do.
While we're talking about it -- FloatCanvas has a main Demo, but it also has a whole bunch of little demos, currently as its own stand-alone, single file application. Would it be hard to make a launcher for those? Is that something that might be useful elsewhere in the demo?
The idea behind this additional framework architecture is to be able to take a bunch of small standalone demos and easily make them be a group within the main demo, without requiring any extra integration work with the main demo other that writing the __demo__.py module. The rest is automatic, and the main demo itself then becomes the launcher.
Another possibility that might work for FC is something like what I did for the Cairo_Snippets sample in the the last release. In a nutshell there is just the one demo item, that in turn can load one of the code snippets named in the listbox and show the output in another panel within the same demo item.
路路路
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Uhm, do you really need a "launcher" for those demo?
maybe not...
As far as I can
see, if you modify them to be able to run standalone (like
double-clicking on them) *and* in the main wxPython demo (by importing
the "run.py" module from the wxPython distribution)
That's probably the way to go.
if __name__ == '__main__':
import sys, os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
but this depends on using the wxPython Demo "run" module, which I do not want the demos to depend on.
Nevertheless, I'm sure it can be done. I just need some time to mess with it.
If desired you can do something other than use run.py. The main intent is that if a demo module is run as the main script then it should run just that sample in a frame, otherwise it should have the runTest() function and the overivew text so it can be used from the demo framework as an import. The run.py module is just a generic, convenient and consistent way to provide the standalone behavior, that also enables the possibility of launching a PyShell or a WIT window too.
路路路
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!