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

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()

Edited 6 Years Ago by snippsat: n/a

Attachments 1.png 8.37 KB 2.png 7.85 KB

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...

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

This question has already been answered. Start a new discussion instead.