| | |
wxPython Error while running.
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
Hi, I finding difficult to execute this program. The wx.Notebook i created is coming on the splitted frame(self.p2). How do I that. I am started to learn wxPython, and when I run the code, the code doesnot close gracefully, it throughs me an error.
"pythonw.exe has encountered a problem and needs to close. We are sorry for the inconvenience"
I clicked for more information, then I got the error message which I have attached it in text file. Please help me out with this problem.
here is the code.... seems a bit lengthy, sorry about that.
Please help me to find my mistake, and how do I go forward resolving this problem.
thank you,
Regards,
kath
"pythonw.exe has encountered a problem and needs to close. We are sorry for the inconvenience"
I clicked for more information, then I got the error message which I have attached it in text file. Please help me out with this problem.
here is the code.... seems a bit lengthy, sorry about that.
Please help me to find my mistake, and how do I go forward resolving this problem.
Python Syntax (Toggle Plain Text)
import wx ID_ADD_NEW = 5001 ID_DEACTIVATE = 5002 ID_EXIT = 5003 class _AddNewFund(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) box=wx.StaticBox(self, -1, "Add New Fund") boxsizer=wx.StaticBoxSizer(box, wx.HORIZONTAL) t=wx.StaticText(self, -1, "Please select an Excel file to upload new funds.", (20,20)) boxsizer.Add(t, 0, wx.TOP|wx.LEFT, 10) t=wx.StaticText(self, -1, "This is page one content2", (20,40)) boxsizer.Add(t, 0, wx.TOP|wx.LEFT, 10) self.text1=wx.TextCtrl(self, -1, "") b1 = wx.Button(self, 10, " Browse ") b2 = wx.Button(self, 10, " Upload ", (60, 20)) self.Bind(wx.EVT_BUTTON, self.OnBrowse, b1) self.Bind(wx.EVT_BUTTON, self.OnUpload, b2) b1.SetDefault() b1.SetSize(b1.GetBestSize()) b2.SetSize(b2.GetBestSize()) grid1=wx.FlexGridSizer(0,2,0,0) grid1.Add( self.text1, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) grid1.Add( b1, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) #grid1.Add( b2, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 ) border=wx.BoxSizer() border.Add(boxsizer, 1, wx.EXPAND) self.SetSizer(border) boxsizer.Add(grid1, 0, wx.ALIGN_CENTRE) border.Add(boxsizer, 0, wx.ALIGN_CENTRE) #print "end ADD NEW class" def OnBrowse(self, event): self.dirname="" d=wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", wx.Open) if d.ShowModal() == wx.ID_OK: self.filename=d.GetFilename() self.dirname=d.GetDirectory() self.text1.WriteTest(join(os.path.join(self.dirname, self.filename))) d.Destroy() def OnUpload(self, event): pass class ParentWindow(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, "Euro Fund manager") self.createMenu() self.Bind(wx.EVT_MENU, self.onAddnewfund, id=ID_ADD_NEW) self.Bind(wx.EVT_MENU, self.onDeactivate, id=ID_DEACTIVATE) self.Bind(wx.EVT_MENU, self.onExit, id=ID_EXIT) self.spw=wx.SplitterWindow(self) self.p1=wx.Panel(self.spw, style=wx.BORDER_NONE) self.p1.SetBackgroundColour("white") self.p2=wx.Panel(self.spw, style=wx.BORDER_NONE) self.spw.SplitVertically(self.p1, self.p2, 200) self.CreateStatusBar() def createMenu(self): menu=wx.Menu() menu.Append(ID_ADD_NEW, "&Add new fund(s)", "Add new fund(s)") menu.Append(ID_DEACTIVATE, "&Deactivate fund(s)", "Deactivate fund(s)") menu.AppendSeparator() menu.Append(ID_EXIT, "E&xit", "Exit") menubar=wx.MenuBar() menubar.Append(menu, "&File") self.SetMenuBar(menubar) def onAddnewfund(self, event): #p=wx.Panel(self.p2) #print "panel created" nb=wx.Notebook(self.p2) #print "notebook created" addPage=_AddNewFund(nb) nb.AddPage(addPage, "Add new Fund") #print "page got added" sizer=wx.BoxSizer() sizer.Add(nb, 1, wx.EXPAND) self.p2.SetSizer(sizer) #print "end of add function" def onDeactivate(self, event): pass def onExit(self, event): self.Close() app = wx.App() frm=ParentWindow() frm.SetSize((800,500)) frm.Show() app.SetTopWindow(frm) app.MainLoop()
thank you,
Regards,
kath
Your problem is similar to one just discussed. You are adding a sizer object to a sizer object. That will lead to runtime errors. Look at Ene Uran's comments here:
http://www.daniweb.com/techtalkforums/post269933-2.html
http://www.daniweb.com/techtalkforums/post269933-2.html
May 'the Google' be with you!
![]() |
Similar Threads
- Error coming while running an App (JSP)
- serious error message after running chkdsk (Windows NT / 2000 / XP)
- Cannot Find Server or DNS Error - Secure Sites Pls Review HiJacks Log (Viruses, Spyware and other Nasties)
- Error message when running ASP login page (ASP)
- Error message when compiling in MS Vis (C++)
- pls help! programs don't work, scandisk error (Windows 95 / 98 / Me)
- Error message when running simple Java pgm (Java)
- Error message when running ASP email script (ASP)
Other Threads in the Python Forum
- Previous Thread: A Simple Solvent Database
- Next Thread: global or function?
Views: 1837 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
abrupt apache application argv beginner binary book calculator change cipher code command converter dictionaries dictionary dynamic event examples excel file float format ftp function google gui hints homework import inches input java keyboard launcher line linux list lists loop maze microphone mouse movingimageswithpygame newb number numbers obexftp output parsing path permissions phonebook plugin port prime program programming projects py2exe pygame pyqt python random recursion recursive refresh remote scrolledtext search session signal simple ssh string strings strip table terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 valueerror variable verify vigenere windows wordgame wxpython xlwt






