[英]wxpython toolbar textctrl spacing
我在wxPython工具栏中有textctrl,我无法弄清楚如何将它与图标(22x22)对齐,并在工具栏图标和文本控件之间以及框架边框之间有一些间距/填充。
import wx
class MyGUI(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(500, 500))
menubar = wx.MenuBar()
file = wx.Menu()
help = wx.Menu()
file.Append(101, '&Open', 'Open a new document')
file.Append(102, '&Save', 'Save the document')
file.AppendSeparator()
quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the Application')
quit.SetBitmap(wx.Image('media/22/actions/system-log-out.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap())
file.AppendItem(quit)
menubar.Append(file, '&File')
menubar.Append(help, '&Help')
self.SetMenuBar(menubar)
self.CreateStatusBar()
self.toolbar = self.CreateToolBar()
textctrl = self.toolbar.AddControl( wx.TextCtrl( self.toolbar, wx.ID_ANY,size=(100, -1)))
tconn = self.toolbar.AddLabelTool(wx.ID_UNDO, '', wx.Bitmap('media/22/actions/server-connect-icon.png'))
tplay = self.toolbar.AddLabelTool(wx.ID_REDO, '', wx.Bitmap('media/22/actions/media-playback-start.png'))
self.toolbar.AddSeparator()
texit = self.toolbar.AddLabelTool(wx.ID_EXIT, '', wx.Bitmap('media/22/actions/stop.png'))
self.toolbar.EnableTool(wx.ID_EXIT, False)
self.toolbar.Realize()
class MyApp(wx.App):
def OnInit(self):
frame = MyGUI(None, -1, 'MyGUI')
frame.SetBackgroundColour('#004681')
frame.SetIcon(wx.Icon('media/launch.ico', wx.BITMAP_TYPE_ICO))
frame.Show(True)
return True
if __name__ == '__main__':
app = MyApp(0)
app.MainLoop()
工具栏小部件遵循操作系统本机工具栏的外观,因此实际上没有办法改变它。 请参阅以下主题:
其中有一些使用空白图像或标签进行间距的变通方法。 或者,您可以使用水平框sizer创建自己的工具栏,并将所有小部件添加到其中。 然后你就可以使用sizer来解决一些问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.