bindings: Picture, Anchor
[sdk] / bindings / python / samples / sample.py
1 # -*- coding: utf-8 -*-
2 from pyEcere import *
3 app = GuiApplication()
4 printLn("Testing Variadic Functions!\n", 1, " + ", 2, " = ", 1+2)
5 printLn("Pi = ", 3.141592653589)
6
7 class MyForm(Window):
8    def __init__(self):
9       Window.__init__(self,
10          displayDriver = "OpenGL",
11          caption = I18N("Hello, Python!!"),
12          hasClose = True,
13          hasMaximize = True,
14          hasMinimize = True,
15          borderStyle = BorderStyle.sizable,
16          clientSize = Size(640, 480),
17          background = Color(b = 255),
18          foreground = Color(r = 235, b = 115, g = 200),
19          font = FontResource("Merriweather", 30, outlineSize = 4.0, outlineFade = 0.2) )
20
21       def myOnRedraw(self, surface):
22          surface.writeTextf(20, 20, I18N("Writing Stuff on the wall!!"))
23       self.onDrawOverChildren = myOnRedraw
24
25       def button1Clicked(self, button, x, y, mods):
26          printLn("I got pushed! (master is ", self.caption, ")")
27          self.background = Color(b = 255, g = 192, r = 64)
28          MessageBox(caption = I18N("Hello, Python!"), contents = I18N("Python is pretty nifty.")).modal()
29          return True
30
31       self.picture1 = Picture(parent = self, anchor = Anchor(0,0,0,0), image = BitmapResource("C:/Users/Jerome/Desktop/khaleesi.png"))
32
33       self.button1 = Button(
34           parent = self,
35           caption = "Push It!",
36           position = Point(80,80),
37           font = FontResource("Merriweather", 30),
38           notifyClicked = button1Clicked )
39
40 MyForm()
41
42 Window(
43    caption = "Bindings are cool, 詠春 too!",
44    hasClose = True,
45    clientSize = Size(320, 200),
46    background = Color(255) )
47
48 app.main()