wxPython:如何在状态栏中放置额外的小部件?

wxPython: how to position extra widgets in the status bar?

我通过将 Choice 作为其子项设法将 wx.Choice 添加到状态栏,理论上它会显示在正确的区域: 问题:

  1. 显然,“选择”小部件隐藏了状态栏的文本。
  2. 我找不到任何方法将我的选择放在 window.

所以你可以猜到,我这里的 objective 是将 window 右侧的 Choice 项对齐,并确保状态栏的文本窗格尊重 Choice 的存在。

import wx

class MainFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, title='Statusbar',size=(300,200))
        panel = wx.Panel(self)
        status_btn = wx.Button(panel, label='Get Statusbar Info')
        status_btn.Bind(wx.EVT_BUTTON, self.on_status)
        self.statusbar = self.CreateStatusBar(2)
        w1 = self.statusbar.Size[0]
        w1= w1 - 50
        self.statusbar.SetStatusWidths([w1, -1])
        self.statusbar.SetMinHeight(30)
        self.statusbar.SetStatusText('Statusbar field 1')
        self.mychoices = wx.Choice(self.statusbar, wx.ID_ANY, choices=[("en"), ("it"), ("de")])
        self.mychoices.SetSelection(0)
        self.mychoices.SetPosition((w1+2, 2))
        self.Show()

    def on_status(self, event):
        print (self.statusbar.GetStatusText())
        print (self.mychoices.GetSelection())
        print (self.mychoices.GetString(self.mychoices.GetSelection()))

if __name__ == '__main__':
    app = wx.App()
    frame = MainFrame()
    app.MainLoop()