#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    44
    Rep Power
    11

    Dialog application ...


    I tried to make dialog based application using wxPython but it doesnt work, I managed to get the Dialog Box but I can put text box, button etc... here's the code... anythingh wrong?
    Code:
    from wxPython.wx import *
    
    class testdialog(wxDialog):
        def _init_(self,parent,ID,title,pos,size):
            wxDialog._init__(self,parent,ID,title,pos,size)
            self.tHello = wxTextCtrl(panel, -1, '', (3,3), (185,22))
    	self.bHello = wxTextCtrl(panel, -1, '', (3,30), (185,22))
    	self.tHello.SetInsertionPoint(1)
            button = wxButton(panel, 10, 'Count', (3, 60))
            button_clear = wxButton(panel,11,'Clear',(112,60))
    
            
    class okrun(wxApp):
        def OnInit(self):
            dlg = testdialog(NULL,-1,'My Dialog',(200,200),(300,120))
            dlg.ShowModal()       
            dlg.Destroy()
            return true
    
    app = okrun()
    app.MainLoop()
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I havn't done much with wxPython so there could be other problems besides this on but as i see it _init_ and _init__ should both be __init__. Try changing that and give it a go .

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    In addition your references to panel should be self:
    Code:
    from wxPython.wx import *
    
    class testdialog(wxDialog):
        def __init__(self,parent,ID,title,pos,size):
            from wxPython.lib.layoutf import Layoutf
            id = wxNewId()
            wxDialog.__init__(self,parent,id,title,pos,size)
            panel = self
            self.tHello = wxTextCtrl(panel, id,'', (3,3), (185,22))
    	self.bHello = wxTextCtrl(panel, id, '', (3,30), (185,22))
    	self.tHello.SetInsertionPoint(1)
            button = wxButton(panel, id, 'Count', (3, 60))
            button_clear = wxButton(panel,id,'Clear',(112,60))
            
    class okrun(wxApp):
        def OnInit(self):
            return True
    
    app = okrun(0)
    dlg = testdialog(NULL,-1,'My Dialog',(200,200),(300,120))
    dlg.ShowModal()       
    dlg.Destroy()
    Now you need to add the event logic

    Grim
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    44
    Rep Power
    11
    Thanx Grim it works

IMN logo majestic logo threadwatch logo seochat tools logo