vssg/testui.py
2007-01-22 07:10:17 +00:00

72 lines
2.1 KiB
Python

#import testopt
import time
import pyui
import pyui.themes.win2k
class MyFrame(object):
"""A frame is a window that has a titlebar and borders. it is resizable and movable by dragging the titlebar.
"""
def __init__(self, x, y, w, h, title, topmost = 0):
self.theme = getTheme()
self.innerWidth = w
self.innerHeight = h
self.title = title
self.panelOffsetLeft = 0
self.panelOffsetTop = 0
self.panelOffsetRight = 0
self.panelOffsetBottom = 0
Window.__init__(self, x, y, w, h, topmost)
self.setTitle(self.title)
self.panelOffsetLeft = self.theme.getFrameBorderLeft()
self.panelOffsetTop = self.theme.getFrameBorderTop()
self.panelOffsetRight = self.theme.getFrameBorderRight()
self.panelOffsetBottom = self.theme.getFrameBorderBottom()
self._panel.moveto(self.panelOffsetLeft, self.panelOffsetTop)
w += self.panelOffsetLeft + self.panelOffsetRight
h += self.panelOffsetTop + self.panelOffsetBottom
self.backImage = None
def setBackImage(self, filename):
self.backImage = filename
#getRenderer().loadImage(filename)
def draw(self, renderer):
"""Draws to the actual frame if the renderer requires it.
"""
if not self.show:
return
self.hitList = getTheme().drawFrame( (0,0,self.width, self.height), self.title, self.backImage)
Window.draw(self, renderer)
def onbutton(self):
print "got a button "
def run():
#opts = testopt.parseCommandLine(800, 600)
done = 1
frame = 0
t = time.time()
desktop = pyui.init(640, 480, '2d')
print pyui.core.gRenderer.screen
newtheme = pyui.themes.win2k.Win2kTheme(pyui.core.gRenderer, "lucida sans unicode", 14)
desktop.setTheme(newtheme)
w = pyui.widgets.Frame(50, 50, 400, 400, "clipme")
b = pyui.widgets.Button( "A button is here", onbutton)
w.addChild(b)
w.pack()
w.setBackImage("framebg.png")
pyui.run()
print "done"
pyui.quit()
if __name__ == '__main__':
run()