アットウィキロゴ

First Steps

First Steps

最初の一歩

We start with a simple example.

次のサンプルから初めよう。

  1 #!/usr/bin/python
  2 
  3 # simple.py
  4 
  5 import wx
  6 
  7 app = wx.App()
  8 
  9 frame = wx.Frame(None, -1, 'simple.py')
 10 frame.Show()
 11 
 12 app.MainLoop()

In every wxPython application, we must import the wx library.

全てのwxPythonアプリケーションは必ずwx ライブラリをインポートしなければならない。

import wx

An application object is created by initiating class wx.App.

アプリケーションのオブジェクトがwx.Appクラスの初期化にて作成される 。

app = wx.App()

We create a frame widget. The window pops up only if we call Show() method on a widget.

フレームウィジットを作成する。ウインドウはウィジットのShow関数を呼んだときだけ出現する。

frame = wx.Frame(None, -1, "simple.py")
frame.Show()

The last line enters a Mainloop. A mainloop is an endless cycle that catches up all events coming up to your application.

It is an integral part of any windows GUI application.

最後の行でメインループに入る。メインループとはずっとアプリケーションに送られる全てのイベントをキャッチするサイクルのことだ。

ウインドウを使うGUIアプリケーションに必要な部分である。

app.MainLoop()

Although the code is very simple, you can do a lot of things with your window.

You can maximize it, minimize it, move it, resize it. All these things have been already done.

コードは随分とシンプルだが、ウインドウは沢山のことができる。

最大化、最小化、動かしたり、リサイズしたり。

それらは既に組込まれている。

最終更新:2009年01月15日 15:44