Basics ...

I agree with you regarding rewriting the demos as stand alone units. I left
the logging in on some. Here is an example of the EditableListBox demo
rewritten as a standalone module.

from wxPython.wx import *

···

#====================================================================

from wxPython.gizmos import *

class TestPanel(wxPanel):
    def __init__(self, parent, log):
        wxPanel.__init__(self, parent, -1)
        self.log = log

        self.elb = wxEditableListBox(self, -1, "List of Stuff",
                                     (50,50), (250, 250),
                                     )
                                     #style=wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT

wxEL_ALLOW_DELETE)

        self.elb.SetStrings(["This is a nifty ListBox widget",
                             "that is editable by the user.",
                             "",
                             "Use the buttons above to",
                             "manipulate items in the list",
                             "Or to add new ones.",
                             ])

#====================================================================

class MainWindow(wxFrame):

    def __init__(self, parent, id, title):
        wxFrame.__init__(self, parent, id, title, size=(640,580))
        self.CenterOnScreen()

        self.CreateStatusBar()
        self.SetStatusText("This is the statusbar")

        self.log = wxTextCtrl(self, 1, style=wxTE_MULTILINE)
        self.demoPanel = TestPanel(self,self.log)

        sizer = wxBoxSizer(wxVERTICAL)
        sizer.Add(self.demoPanel,3,wxEXPAND)
        sizer.Add(self.log,1,wxEXPAND)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)

        self.Show(True)

app = wxPySimpleApp()
frame = MainWindow(None,-1," Empty Demo")
app.MainLoop()

<gary.h.merrill@gsk.com> wrote in message
news:OF2058E24F.7700EBD4-ON85256DAB.0048FE7F@sb.com...

This is a problem that must arise for every new user of wxPython. The

demo

is a very good illustration of a large number of classes, but in order to
make it modular and easily maintainable/extensible, a certain amount of
"infrastructure" (like runTest()) have been incorporated into it.

The very best thing to do (I found) is to first study what runTest does,
and then take one of the demo examples and rewrite it so it is a
"stand-alone" example which does not use runTest or any of the other
associated "infrastructure" code. There are two primay hurdles here:

(1)

elimination of any use of the log (you don't need this to illustrate most
features of an example and it complicates the stand-alone code to keep

it),

and (2) avoidance of the various levels of indirection involving runTest,
run.main, etc. This turns out to be not too difficult, and you will
discover that such an example will have the general structure of ...

#########
#
# Most of the existing code for the example goes here, but
# without any of the runTest stuff, run.main(), etc. I also eliminate all
of the
# references to the log -- which generally amounts to simply deleting
parameters
# in class and function definitions and any references to 'log'.
#
##########

# Then at the bottom of your file, you'll have something like ...

if __name__ == '__main__':

   class App(wxApp):
       def OnInit(self):
           wxInitAllImageHandlers()
           frame = MyFrame(None, -1, "My frame") # or whatever parameters
are appropriate
           frame.Show()
           return True
       def OnExit(self):
           pass

   app = App(0)
   app.MainLoop()

Here, MyFrame can be the frame class defined in the example. If the
example involves a dialog rather than a frame, you need to create a frame
first, and then create the dialog with the frame as its parent. You will
also, of course, need to make available to this stand-alone example the
various .py files that the original example uses (imports). An easy way

to

do this is just to develop the stand-alone example .py file in the same
directory as the example files. Otherwise, copy what you need to whatever
directory you are constructing the stand-alone in.

I'm sorry that this is a little vague, but I don't currently have any
simple stand-alone examples lying around any longer. However, it ought to
point you at least in the right direction. Beware. Some examples

(various

graphics ones) may require some additional imports or initializations.

But

going through just one exercise of creating such a stand-alone will be

very

worthwhile. And then you can start to modify it and play around with it
without the additional complication of the demo infrastructure.

--------------------------------------
Gary H. Merrill
Director and Principal Scientist, New Applications
Data Exploration Sciences
GlaxoSmithKline Inc.
(919) 483-8456