wxPython中的菜单栏对齐错误
我是wxPython的新手。我制作了一个小程序,试图在一个小窗口上显示菜单栏。 但当我点击菜单栏时,它会随机地在其他地方注册,从而导致错误行为。我将代码粘贴在这里。我的操作系统是ubuntu 18.04。我有前三个菜单,它们都有子菜单。点击菜单时,菜单似乎随机排列错误,如图所示wxPython中的菜单栏对齐错误,python,ubuntu,wxpython,Python,Ubuntu,Wxpython,我是wxPython的新手。我制作了一个小程序,试图在一个小窗口上显示菜单栏。 但当我点击菜单栏时,它会随机地在其他地方注册,从而导致错误行为。我将代码粘贴在这里。我的操作系统是ubuntu 18.04。我有前三个菜单,它们都有子菜单。点击菜单时,菜单似乎随机排列错误,如图所示 import wx class Example(wx.Frame): def __init__(self, *args, **kwargs): super(Example, self).__
import wx
class Example(wx.Frame):
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
def InitUI(self):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
newfile = fileMenu.Append(wx.ID_NEW, '&New')
fileMenu.Append(wx.ID_OPEN, '&Open')
fileMenu.Append(wx.ID_SAVE, '&Save')
fileMenu.AppendSeparator()
imp = wx.Menu()
imp.Append(wx.ID_ANY, 'Import newsfeed list...')
imp.Append(wx.ID_ANY, 'Import bookmarks...')
imp.Append(wx.ID_ANY, 'Import mail...')
fileMenu.Append(wx.ID_ANY, 'I&mport', imp)
qmi = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quit\tCtrl+W')
fileMenu.Append(qmi)
self.Bind(wx.EVT_MENU, self.OnQuit, qmi)
self.Bind(wx.EVT_MENU, self.onclick_subfile, newfile)
menubar.Append(fileMenu, '&File')
# Edit Menu
editm = wx.Menu()
editm.Append(wx.ID_UNDO, "Undo\tCtrl+Z")
editm.Append(wx.ID_REDO, "Redo\tCtrl+Shift+Z")
editm.Append(wx.ID_COPY, "Copy\tCtrl+C")
editm.Append(wx.ID_CUT, "Cut\tCtrl+X")
editm.Append(wx.ID_PASTE, "Paste\tCtrl+V")
editm.Append(wx.ID_SELECTALL, "SelectAll\tCtrl+A")
editm.AppendSeparator()
menubar.Append(editm, "&Edit")
services = wx.Menu()
services.Append(wx.ID_UNDO, "Undo\tCtrl+Z")
menubar.Append(services, "&Service")
self.SetMenuBar(menubar)
self.SetTitle('Billing System')
self.Maximize(True)
self.Centre()
def OnQuit(self, e):
self.Close()
# **********HERE*************
def onclick_subfile(self, event):
frame = wx.Frame(None, -1, "My Second Frame")
frame.Center()
frame.Show()
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
这个问题似乎出现在
ubuntu
上。我在windows10
上尝试了该代码,它正在运行,并且所有内容都正确对齐。我建议使用另一个名为tkinter
的python GUI库。我在ubuntu上没有遇到任何问题。谢谢你的回答。tkinter适合复杂窗口吗applications@somanraj是的,在我看来,它是大型应用程序最好的GUI
库。使用Mint上的python 3.6.9、Gtk2和Gtk3,它似乎运行良好,这是基于Ubuntu的。我只能假设,这是您的盒子的环境或库的问题。