我在 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()