WxWidgets アプリがあります。私はPythonで取り組んでいます。このアプリには、メイン フレーム、メニュー バー、下部にステータス バーがあり、中央のメイン コンテンツには、グラデーションでペイントされたパネルを使用して、素敵な背景シェーディング効果を与えたいと考えています。これで機能しましたが、GUI ウィジェットをパネルに追加したいと思います (静的テキスト ラベルと編集ボックスのセットなど)。これらをパネルに追加して、パネルの上に表示するにはどうすればよいですか? 以下のサンプル コードでは、テキスト フィールドをパネルに追加すると、小さなサイズに折りたたまれます。
助けてくれてありがとう。
def createGui(self, parent, title):
wx.Frame.__init__(self, parent, title=title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
self.SetBackgroundColour("white")
self.SetSizeHints(800, 640, 800, 600)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.panel = wx.Panel(self, size=(800, 600))
self.sizer.Add(self.panel)
self.panel.Bind(wx.EVT_PAINT, self.on_paint)
self.label1 = wx.StaticText(self, -1, "PV Power" , wx.Point(1, 1))
# This next part is not working, I want to add static text at certain geometric locations to the panel, so I get to see
# the panel with it's background gradient and the text labels on top
#self.panel.AddChild(self.label1)
menubar = wx.MenuBar()
fileMenu = wx.Menu()
fitem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
menubar.Append(fileMenu, '&File')
self.SetMenuBar(menubar)
self.Bind(wx.EVT_MENU, self.onQuit, fitem)
# Create a box at the bottom for buttons
self.statusbar = self.CreateStatusBar()
self.statusbar.SetStatusText('Waiting to run')
self.sizer.Add(self.statusbar)
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)
self.Show()
def on_paint(self, event):
dc = wx.PaintDC(self.panel)
x = 0
y = 0
w, h = self.GetSize()
dc.GradientFillLinear((x, y, w, h), 'white', 'light grey')