Venster

Index

Tutorial: Hello Venster

This tutorial walks trough the classic minimal example of any software system, the famous 'HelloWorld' program.

Some working knowledge of WIN32 API programming is presumed.

 1 from venster.windows import *
 2 from venster.wtl import *

 3 from venster import gdi

 4 class MyWindow(Window):
 5   _window_title_ = "Hello World"
 6   _window_background_ = gdi.GetStockObject(WHITE_BRUSH)
 7   _window_class_style_ = CS_HREDRAW | CS_VREDRAW
 8
 9   def OnPaint(self, event):
10      ps = PAINTSTRUCT()
11      hdc = self.BeginPaint(ps)
12      rc = self.GetClientRect()
13
14      msg = "Hello World"
15      gdi.TextOut(hdc, rc.width / 2, rc.height / 2, msg, len(msg))
16
17      self.EndPaint(ps)
18
19   msg_handler(WM_PAINT)(OnPaint)
20
21
22   def OnDestroy(self, event):
23       PostQuitMessage(NULL)
24
25   msg_handler(WM_DESTROY)(OnDestroy)
26
27 myWindow = MyWindow()
28
29 application = Application()
30 application.Run()