root/trunk/RBPrivate/Prototypes/RBwin32/cetest.py

Revision 352, 2.9 kB (checked in by sholloway, 6 years ago)

*** empty log message ***

Line 
1 #!/usr/bin/env python
2 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 ##~ License
4 ##~
5 ##- The RuneBlade Foundation library is intended to ease some
6 ##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.)
7 ##- applications, while providing the flexibility to modularly change the
8 ##- architecture. Enjoy.
9 ##~
10 ##~ Copyright (C) 2002  TechGame Networks, LLC.
11 ##~
12 ##~ This library is free software; you can redistribute it and/or
13 ##~ modify it under the terms of the BSD style License as found in the
14 ##~ LICENSE file included with this distribution.
15 ##~
16 ##~ TechGame Networks, LLC can be reached at:
17 ##~ 3578 E. Hartsel Drive #211
18 ##~ Colorado Springs, Colorado, USA, 80920
19 ##~
20 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 #~ Imports
24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
26
27 import os, sys, time
28 filebase = '/Storage Card/Shane'
29 if __name__=='__main__' and sys.platform != 'win32':
30     sys.stderr = file(os.path.join(filebase, 'stderr.txt'),'w', 0)
31     print >> sys.stderr, '# %s.%s.%s at %s:%s:%s' % time.localtime(time.time())[:6]
32     sys.stdout = file(os.path.join(filebase, 'stdout.txt'),'w', 0)
33     print >> sys.stdout, '# %s.%s.%s at %s:%s:%s' % time.localtime(time.time())[:6]
34
35     # HACK WARNING
36     os.getcwd = lambda: filebase
37 else:
38     filebase = '.'
39
40 import Widgets
41 import win32gui
42 import win32con
43
44 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45 #~ Definitions
46 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47
48 if __name__=='__main__':
49     dims = win32gui.GetClientRect(win32gui.GetDesktopWindow())
50     t = Widgets.Window(None, 'Shane\'s Test', dims[:2], dims[2:], style=win32con.WS_CLIPCHILDREN)
51
52     x,y,w,h = t.GetClientRect()
53
54     h = h/2
55     b = Widgets.Button(t, 'Close button', (x,y), (w/2,h))
56     b2 = Widgets.Button(t, 'A button', (x+w/2,y), (w/2,h))
57
58     y += h
59     e = Widgets.Edit(t, 'An edit box', (x,y), (w,h))
60     e.SetText('Funny')
61
62     print 't', t
63     print 'b', b
64     print 'e', e
65
66     def OnWindowMessage(hwnd, msg, wparam, lparam):
67         if lparam in [b,b2,e]:
68             return win32gui.SendMessage(lparam, msg, wparam, lparam)
69         elif lparam == t.WindowHandle:
70             print "T:", hwnd, msg, wparam, lparam
71         else: print "?:", hwnd, msg, wparam, lparam
72     t.SetMessageMap({win32con.WM_COMMAND: OnWindowMessage})
73     def OnCloseButtonMessage(hwnd, msg, wparam, lparam):
74         assert hwnd == lparam == b.WindowHandle
75         print "Close button pressed... exiting"
76         return win32gui.PostQuitMessage(0)
77     b.SetMessageMap({win32con.WM_COMMAND: OnCloseButtonMessage})
78     def OnButtonMessage(hwnd, msg, wparam, lparam):
79         assert hwnd == lparam == b2.WindowHandle
80         e.SetText(repr(t))
81     b2.SetMessageMap({win32con.WM_COMMAND: OnButtonMessage})
82
83     t.Show(win32con.SW_SHOW)
84     t.Refresh()
85
86     win32gui.SetCursor(win32gui.LoadCursor(0,0))
87     win32gui.PumpMessages()
Note: See TracBrowser for help on using the browser.