我设法通过将Choice作为子项添加到状态栏中的wx.Choice,理论上它确实显示在右侧区域: 问题:
您可以猜到,我的目标是在窗口右侧对齐Choice项目,并确保状态栏的文本窗格尊重Choice的存在。
答案 0 :(得分:0)
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()