![](/img/trans.png)
[英]How can we change a wx.MenuBar background and foreground colour using wxpython?
[英]How to add a button to the wx.MenuBar()?
我有以下问题:
全屏模式下的wx.Frame()失去系统菜单以及“关闭”和“最小化”按钮。 至少在Windows上可以。
这通常是合乎需要的,但是不幸的是,我的应用程序的用户将变得非常愚蠢,期望他们使用菜单执行这两项操作实在太多了。 我必须保持全屏显示状态,因为我需要大量空间和每个像素控件。
因此,我将不得不手动添加这两个按钮。 我打算使用位图按钮,但不确定如何解决该问题。 由于没有标题,因此菜单栏位于框架的顶部。
那么,我是否继承wx.MenuBar()并在那里做一些愚蠢的事情,还是将按钮强加于它之上? OS甚至会让我动动菜单栏吗?
我希望有人以前做过类似的事情,这样我就不必迷迷糊糊了。 欢迎举几个简短的例子。 如果它们是跨平台友好的,那么它们绝对是受欢迎的。
import wx
class NoCaptionFrame(wx.Frame):
def __init__(self):
no_caption = wx.RESIZE_BORDER
wx.Frame.__init__(self, None, title="No Caption", style=no_caption)
toolbar = self.CreateToolBar(style=wx.TB_VERTICAL)
quittool1 = toolbar.AddLabelTool(wx.ID_ANY, 'Quit', wx.Bitmap('exit.png'))
quittool2 = toolbar.AddLabelTool(wx.ID_ANY, 'Quit', wx.Bitmap('exit.png'))
quittool3 = toolbar.AddLabelTool(wx.ID_ANY, 'Quit', wx.Bitmap('exit.png'))
toolbar.Realize()
menubar=wx.MenuBar()
first=wx.Menu()
second=wx.Menu()
first.Append(1,"New Window","This is a new window")
first.Append(2,"Open...","Open A New Window")
menubar.Append(first,"File")
menubar.Append(second,"Edit")
self.SetMenuBar(menubar)
self.Bind(wx.EVT_TOOL, self.OnQuit, quittool1)
self.Show()
def OnQuit(self, e):
self.Close()
if __name__ == "__main__":
app = wx.App()
frame = NoCaptionFrame()
app.MainLoop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.