Search code examples
pythonwxpython

wx python windows can't hide my MenuBar


Yop, all is in title, i wanna Hide my wx.MenuBar() on my soft, and that is works well on my Ubuntu, but when i switch my soft on Windows, my wx.MenuBar() is not hide... Any Ideas?

    menuBar = wx.MenuBar()
    self.fileMenu = wx.Menu()
    i = self.fileMenu.Append(-1, _("Load Model\tCTRL+L"))
    self.Bind(wx.EVT_MENU, self.showLoadModel(), i)
    menuBar.Append(self.fileMenu, 'File')
    self.SetMenuBar(menuBar)
    menuBar.Hide()

EDIT: Then how can i catch a CTRL+L without EVT_MENU ?


Solution

  • It's ok i found it:

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    
    
    import wx
    
    class Example(wx.Frame):
    
        def __init__(self, *args, **kw):
            super(Example, self).__init__(*args, **kw) 
    
            self.InitUI()
    
        def InitUI(self):
    
            pnl = wx.Panel(self)
            pnl.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
            pnl.SetFocus()
    
            self.SetSize((250, 180))
            self.SetTitle('Key event')
            self.Centre()
            self.Show(True)  
    
        def OnKeyDown(self, e):
    
            key = e.GetKeyCode()
    
            if key == wx.WXK_ESCAPE:
    
                ret  = wx.MessageBox('Are you sure to quit?', 'Question', 
                    wx.YES_NO | wx.NO_DEFAULT, self)
    
                if ret == wx.YES:
                    self.Close()               
    
    def main():
    
        ex = wx.App()
        Example(None)
        ex.MainLoop()