wx.Window
wx.Window is a base class out of which many widgets inherit. For instance, the wx.Frame widget inherits from wx.Window. Technically it means that we can use wx.Window's methods for all descendants. We will introduce here some of it's methods.
wx.Window は多くのウィジットが内部で継承する基本となるクラスである。 例えば、wx.Frame ウィジットは wx.Window を継承している。技術的いうと、全ての子クラスがwx.Windowのメソッドを使うことができる事を意味している。 ここでその幾つかのメソッドを紹介する。
-SetTitle(string title) - Sets the window's title. Applicable only to frames and dialogs.
-SetToolTip(wx.ToolTip tip) - Attaches a tooltip to the window.
-SetSize(wx.Size size) - Sets the size of the window.
-SetPosition(wx.Point pos) - Positions the window to given coordinates
-Show(show=True) - Shows or hides the window. show parameter can be True or False.
-Move(wx.Point pos) - Moves the window to the given position.
-SetCursor(wx.StockCursor id) - Sets the window's cursor.
1 #!/usr/bin/python
2
3 # simple2.py
4
5 import wx
6
7 app = wx.App()
8
9 frame = wx.Frame(None, -1, '')
10 frame.SetToolTip(wx.ToolTip('This is a frame'))
11 frame.SetCursor(wx.StockCursor(wx.CURSOR_MAGNIFIER))
12 frame.SetPosition(wx.Point(0,0))
13 frame.SetSize(wx.Size(300,250))
14 frame.SetTitle('simple2.py')
15 frame.Show()
16
17 app.MainLoop()
We create a 'This is a frame' tooltip. The cursor is set to a magnifier cursor. Possible cursor id's: are listed below
We position the window to the upper left corner and size it to 300x250 pixels. Title is set to 'simple2.py'.
'This is a frame' というツールチップを作成した。カーソルは虫眼鏡を指定。利用可能なカーソルのidはこちら 。
ウインドウの位置は左上の角を、サイズは300×250ピクセルとした。タイトルは'simple2.py'である。