wxWidgets と Python の使い方を学んでいますが、フレーム内でウィジェットのサイズを調整する方法がわかりません。
コンストラクターを呼び出すときにカスタム size=(x,y) 値を与えることで、さまざまなウィジェットのサイズを設定できるという印象を受けています。このコードは wxPython の例からコピー アンド ペーストされ、wx.TextCtrl() コンストラクターに value="example",pos=(0,0) および size=(100,100) の値を追加しましたが、実行するとこのプログラムでは、テキスト コントロールが 500x500 フレーム全体を占めています。理由はわかりませんが、それを機能させるために何か助けていただければ幸いです。
import wx
class MainWindow(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(500,500))
self.control = wx.TextCtrl(self,-1,value="example",pos=(0,0),size=(100,100))
self.CreateStatusBar() # A Statusbar in the bottom of the window
# Setting up the menu.
filemenu= wx.Menu()
# wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program")
filemenu.AppendSeparator()
filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")
# Creating the menubar.
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar
self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content.
self.Show(True)
app = wx.App(False)
frame = MainWindow(None, "Sample editor")
app.MainLoop()