我正在创建一个 GUI,并且正在使用多个 wx.sbSizer 对小部件进行分组。但是我需要更改 wx.sbSizer 标签('MyApp')的字体和颜色,虽然我已经搜索过,但我无法找到如何去做。
这是一个最小的工作示例:
class MyFrame ( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer1 = wx.BoxSizer( wx.VERTICAL )
self.m_panel31 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
bSizer1_2 = wx.BoxSizer( wx.VERTICAL )
sbSizer1_2_1 = wx.StaticBoxSizer( wx.StaticBox( self.m_panel31, wx.ID_ANY, u"MyApp" ), wx.VERTICAL )
self.m_button6 = wx.Button( sbSizer1_2_1.GetStaticBox(), wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, 0 )
sbSizer1_2_1.Add( self.m_button6, 0, wx.ALL, 5 )
self.m_button7 = wx.Button( sbSizer1_2_1.GetStaticBox(), wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, 0 )
sbSizer1_2_1.Add( self.m_button7, 0, wx.ALL, 5 )
bSizer1_2.Add( sbSizer1_2_1, 1, wx.EXPAND, 5 )
self.m_panel31.SetSizer( bSizer1_2 )
self.m_panel31.Layout()
bSizer1_2.Fit( self.m_panel31 )
bSizer1.Add( self.m_panel31, 1, wx.EXPAND |wx.ALL, 5 )
self.SetSizer( bSizer1 )
self.Layout()
self.Centre( wx.BOTH )
def __del__( self ):
pass
if __name__ == "__main__":
app = wx.App(redirect=False)
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show(True)
app.MainLoop()
感谢您的任何帮助。