hello,

i want to utilize the demo code given in the wxpython 2.8 documentation & demos.
can any one guide me how can i do that???
when i try to copy that code to editor to change it according to my requirements ..it gives me an error message and close the editor without giving any message...

any onw ho knows how to edit those demo codes please let me know..your help will be highly appreciated...
Regards,
punter

Recommended Answers

All 6 Replies

You have to understand the basic of wxpython.
Then you use only the part of code that you need.

Examlpe.

import wx

class MyFrame(wx.Frame):
    '''info abot class | Doc string'''
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
         
        #---| Window color |---#
        self.SetBackgroundColour('light blue')
        
        #---| Panel for frame |---#
        self.panel = wx.Panel(self)       
        

if __name__ == "__main__":
    app = wx.App()   
    mytitle = 'My window'  
    width = 300
    height = 200
    MyFrame(None, mytitle, (width, height)).Show()
    app.MainLoop()

Now i have a basic window.
So start wxpython demo.
I what to use choicebox code from demo.
Now i only copy the part i need,not all demo code.

import wx

class MyFrame(wx.Frame):
    '''info abot class | Doc string'''
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
         
        #---| Window color |---#
        self.SetBackgroundColour('light blue')
        
        #---| Panel for frame |---#
        self.panel = wx.Panel(self)          
        
        #Demo code
        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                      'six', 'seven', 'eight']        
        #Demo code
        self.ch = wx.Choice(self.panel, -1, (100, 50), choices = sampleList)
        self.Bind(wx.EVT_CHOICE, self.EvtChoice, self.ch)

    #Demo code 
    def EvtChoice(self, event):
        a = event.GetString()  #I change event handling like this i dont wanne write out like in the demo      
        self.a = wx.StaticText(self.panel, -1, str(a), pos = (105,80))  

if __name__ == "__main__":
    app = wx.App()   
    mytitle = 'My window'  
    width = 300
    height = 200
    MyFrame(None, mytitle, (width, height)).Show()
    app.MainLoop()

There is a module that is imported that is on wxDemo DIR. I don't remember well but it is something like run
You should modify that

yes you right as i try to run the demo code in the editor it gives me an error which is as follows
no package name run
and after this error the editor close down...

can you guide me how can i modify that run module???

post whole code from demo and say which part you want so that someone can guide you on that. I don't even have Python installed here

Pulling usable code out the wxPython demo code is a royal pain. However, there are a lot of nicely working examples here:
http://www.daniweb.com/forums/thread128350.html

Tell us which widget of the demo you are interested in and we can try to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.