Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使状态在单击菜单wxpython时不消失?_Wxpython - Fatal编程技术网

如何使状态在单击菜单wxpython时不消失?

如何使状态在单击菜单wxpython时不消失?,wxpython,Wxpython,我用Python制作了一个带有状态栏和菜单的文本编辑器。单击菜单时,当前状态消失。这是wxPython的一部分还是有办法禁用它。如果有办法禁用它,如何禁用 提前谢谢 import wx import wx.stc as stc import os class Window(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title, size=(50

我用Python制作了一个带有状态栏和菜单的文本编辑器。单击菜单时,当前状态消失。这是wxPython的一部分还是有办法禁用它。如果有办法禁用它,如何禁用

提前谢谢

import wx
import wx.stc as stc
import os

class Window(wx.Frame):
    def __init__(self, parent, title):

        wx.Frame.__init__(self, parent, title=title, size=(500, 500))
        self.control = stc.StyledTextCtrl(self, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)

        self.control.Bind(wx.EVT_KEY_UP, self.LineColumn)

        self.FileMenu(), self.MenuBar()
        self.Status_Bar()

    def FileMenu(self):
        self.filemenu = wx.Menu()
        self.new = self.filemenu.Append(wx.ID_ANY, "&New\tCtrl+N")

    def MenuBar(self):
        #MenuBar
        self.menu = wx.MenuBar()
        self.menu.Append(self.filemenu, "&File")
        self.SetMenuBar(self.menu)

    def Status_Bar(self):
        #Status Bar
        self.statusbar = self.CreateStatusBar(1)
        self.LineColumn(self)

    def LineColumn(self, e):
        line = self.control.GetCurrentLine() + 1
        col = self.control.GetColumn(self.control.GetCurrentPos())
        stat = "Ln: %s, Col: %s" % (line, col)
        self.StatusBar.SetStatusText(stat, 0)

    def RandomText(self, e):
        self.StatusBar.SetStatusText("Random Text", 3)

def main():
    app = wx.App()
    frame = Window(None, "Text Editor")
    frame.Show()
    app.MainLoop()

if __name__ == '__main__':
    main()

默认情况下,单击菜单项envokes event
wx.EVT\u menu\u高亮显示

如果您已经传递了菜单项a
帮助文本
,此时它将显示在状态区域中。
如果要绕过此功能,请捕获事件并绕过它。
试试这个:

def FileMenu(self):
    self.filemenu = wx.Menu()
    self.new = self.filemenu.Append(wx.ID_ANY, "&New\tCtrl+N", "Open new file")
    self.Bind(wx.EVT_MENU_HIGHLIGHT, self.Bypass)

def Bypass(self,event):
    pass

默认情况下,单击菜单项envokes event
wx.EVT\u menu\u高亮显示

如果您已经传递了菜单项a
帮助文本
,此时它将显示在状态区域中。
如果要绕过此功能,请捕获事件并绕过它。
试试这个:

def FileMenu(self):
    self.filemenu = wx.Menu()
    self.new = self.filemenu.Append(wx.ID_ANY, "&New\tCtrl+N", "Open new file")
    self.Bind(wx.EVT_MENU_HIGHLIGHT, self.Bypass)

def Bypass(self,event):
    pass