All,

Here is a similar situation:

import wx

ID_STAT = 1
ID_TOOL = 2

class CheckMenuItem(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(350, 250))
        
        # create a menubar
        menubar = wx.MenuBar()
        
        # create file menu
        file = wx.Menu()
        
        # create view menu
        view = wx.Menu()
        
        # add items to view menu
        self.shst = view.Append(ID_STAT, 'Show statusbar', 'Show statusbar', 
kind=wx.ITEM_CHECK)
        self.shtl = view.Append(ID_TOOL, 'Show toolbar', 'Show toolbar', 
kind=wx.ITEM_CHECK)
        view.Check(ID_STAT,True)
        view.Check(ID_TOOL,True)
        
        # bindings
        self.Bind(wx.EVT_MENU,self.toggleStatusBar,id=ID_STAT)
        
        # add menus to menubar
        menubar.Append(file, '&File')
        menubar.Append(view, '&View')
        
        # add menubar to Frame
        self.SetMenuBar(menubar)
        
        # add toolbar
        self.toolbar = self.CreateToolBar()
        self.toolbar.AddLabelTool(3,'',wx.Bitmap('icons/calendar.png'))
        self.toolbar.Realize()
        
        # add status bar
        self.statusbar = self.CreateStatusBar()
        self.statusbar.Show()
        
        # center and show frame
        self.Centre()
        self.Show()
        
    def ToggleStatusBar(self,event):
        if self.shst.IsChecked():
            self.statusbar.Show()
        else:
            self.statusbar.Hide()
            
        
app = wx.App()        
CheckMenuItem(None, -1, 'Check Menu Item')
app.MainLoop()

Because I wrote toggleStatusBar instead of ToggleStatusBar in my binding, the 
GUI won't run, but no errors are reported anywhere in PyDev.

What can I do in this situation other than struggle manually to find this 
little typo?

D.
        

On Mar 7, 2010, at 12:13 PM, David Arnold wrote:

> All,
> 
> Here is a situation I find myself in frequently. The code throws no errors, 
> but the GUI won't open.
> 
> import wx
> 
> class MenuExample(wx.Frame):
>    def __init__(self, parent, id, title):
>        wx.Frame.__init__(self, parent, id, title, size=(250, 200))
> 
>        # this creates the menubar
>        menubar = wx.MenuBar()
> 
>        # this creates main 'file' menu
>        file = wx.Menu()
> 
>        # add an 'Open' submenu to 'file' menu
>        open = wx.MenuItem(file, 1, '&Open\tCtrl+O')
>        file.AppendItem(open)
> 
>        # add a 'Quit' submenu to 'file' menu
>        quit = wx.MenuItem(file, 2, '&Quit\tCtrl+Q')
>        file.AppendItem(quit)
> 
>        self.Bind(wx.EVT_MENU, self.onQuit, 2)
> 
>        # this adds the 'file' menu to the menubar
>        menubar.Append(file, '&File')
> 
>        # this adds the menubar to the frame
>        self.SetMenuBar(menubar)
> 
>        # center and show the frame
>        self.Centre()
>        self.Show()
> 
>    def onQuit(self,event):
>        self.Close()
> 
> app = wx.App()
> MenuExample(None, -1, 'Menu Example')
> app.MainLoop()
> 
> 
> I found the error. I should have:          self.Bind(wx.EVT_MENU, 
> self.onQuit, id=2)
> 
> However, I am wondering if there is anything I can do with the PyDev debugger 
> (or other strategy) to help locate this type of error when it happens. It is 
> very frustrating when no errors are returned but the GUI won't run.
> 
> David.
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Pydev-users mailing list
> Pydev-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pydev-users


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Pydev-users mailing list
Pydev-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pydev-users

Reply via email to