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

标签 user-interface drop-down-menu wxpython statusbar

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

  1. 显然,Choice 小部件隐藏了状态栏的文本。
  2. 我找不到任何方法将我的选择定位到右侧 窗口。

正如您所猜测的,我的目标是在窗口右侧对齐 Choice 项目,并确保状态栏的文本 Pane 尊重 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()

enter image description here

关于user-interface - wxPython:如何在状态栏中放置额外的小部件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46515840/

相关文章:

java - 自己插入 LeafElement

c# - 如何制作一个窗口管理器?

javascript - 使用 JavaScript、jQuery 或 CSS 更改下拉菜单选项的颜色

angularjs - 如何让 ng-model 在 ng-if 中工作?

grid - WxPython:如何获取wx网格中显示单元格的范围?

python - 使用 ctrl-c 和 ctrl-v 复制并粘贴到 wxPython 中的 wx.Grid

python - 无法清除输出文本 : tkinter. TclError:错误的文本索引 "0"

java - 如何解决 Android Studio 中组件重叠的问题?

html - CSS 下拉菜单在 iOS 设备上不起作用

onclick - 如何将wxpython listctrl与onclick按钮事件绑定(bind)