【问题标题】:wx python windows can't hide my MenuBarwx python windows无法隐藏我的菜单栏
【发布时间】:2014-08-25 21:35:59
【问题描述】:

是的,一切都在标题中,我想在我的软件上隐藏我的 wx.MenuBar(),这在我的 Ubuntu 上运行良好,但是当我在 Windows 上切换我的软件时,我的 wx.MenuBar() 没有隐藏...有什么想法吗?

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

编辑:那么我如何在没有 EVT_MENU 的情况下捕捉 CTRL+L 呢?

【问题讨论】:

  • 我认为它不能在 Windows 中隐藏。不确定强硬。

标签: python wxpython


【解决方案1】:

没关系,我找到了:

#!/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()    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多