菜单栏在 wxPython 中错误对齐

Menubars aligning wrongly in wxPython

我是 wxPython.I 的新手,制作了一个试图在小 window 上显示菜单栏的小程序。 但是,当我单击菜单栏时,它会随机出现异常行为,因为它会与其他人对齐 places.I 我正在粘贴我的代码 here.My 操作系统是 ubuntu 18.04。我有前 3 个菜单,它们有子菜单。点击菜单似乎随机错误对齐,如图所示。

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。我在 windows 10 上尝试了该代码,它是 运行 并且一切都正确对齐。我建议使用另一个名为 tkinter 的 python GUI 库。我在 ubuntu 上遇到了 0 个问题。