0

I am a newbie in wx.python and python and wanted to use the MultiSplitterWindow.py demo code in my own application.

I have read other stackoverflow entries regarding this subject but the answers given there don't seem to work for me.

I would really appreciate if anybody could help me to solve this issue.

As the demos use the demo framework:

if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

It does not work in my app, I have tried replacing the above using the example given in:

[] http://wiki.wxpython.org/Using%20wxPython%20Demo%20Code

But I might be doing something wrong because I does not work.

Any help is much appreciated.

Maverick
  • 7
  • 1
  • 6

2 Answers2

0

Download demos from here http://wxpython.org/download.php install and go C:\Program Files\wxPython3.0-Docs-and-Demos\demo and run.

Gab
  • 69
  • 8
  • Hi, Thanks for your answer. The demos run all right for me. That is not the my problem. What I want is to be able to use the Demos code on my own program, to do something different. But when I try to do so the code does not work anymore... – Maverick Mar 15 '15 at 14:21
0

I wrote about this on the wxPython wiki:

Most of the time, you can copy the relevant portions of the widget code in question and paste it in your own code. The part you don't want is the references to self.log. That just allows the demo to log the messages and is demo specific code. I would actually rewrite my initial example to look like the following though:

import wx

########################################################################
class MyPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)


########################################################################
class MyFrame(wx.Frame):

    #----------------------------------------------------------------------
    def __init__(self):
        wx.Frame.__init__(self, None, title="Demo Test")
        panel = MyPanel(self)

        self.Show()

#----------------------------------------------------------------------
if __name__ == '__main__':
    app = wx.App(False)
    frame = MyFrame()
    app.MainLoop()

Now if you want to copy the code in from the demo, you won't have to change all the self instances to `self.panel':

import wx
from wx.lib.wordwrap import wordwrap

########################################################################
class MyPanel(wx.Panel):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        b = wx.Button(self, -1, "Show a wx.AboutBox", (50,50))
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)

    def OnButton(self, evt):
        # First we create and fill the info object
        info = wx.AboutDialogInfo()
        info.Name = "Hello World"
        info.Version = "1.2.3"
        info.Copyright = "(C) 2006 Programmers and Coders Everywhere"
        info.Description = wordwrap(
            "A \"hello world\" program is a software program that prints out "
            "\"Hello world!\" on a display device. It is used in many introductory "
            "tutorials for teaching a programming language."

            "\n\nSuch a program is typically one of the simplest programs possible "
            "in a computer language. A \"hello world\" program can be a useful "
            "sanity test to make sure that a language's compiler, development "
            "environment, and run-time environment are correctly installed.",
            350, wx.ClientDC(self))
        info.WebSite = ("http://en.wikipedia.org/wiki/Hello_world", "Hello World home page")
        info.Developers = [ "Joe Programmer",
                            "Jane Coder",
                            "Vippy the Mascot" ]

        info.License = wordwrap(licenseText, 500, wx.ClientDC(self))

        # Then we call wx.AboutBox giving it that info object
        wx.AboutBox(info)


########################################################################
class MyFrame(wx.Frame):

    #----------------------------------------------------------------------
    def __init__(self):
        wx.Frame.__init__(self, None, title="Demo Test")
        panel = MyPanel(self)

        self.Show()

licenseText = "blah " * 250 + "\n\n" +"yadda " * 100

#----------------------------------------------------------------------
if __name__ == '__main__':
    app = wx.App(False)
    frame = MyFrame()
    app.MainLoop()
Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88