Go to the documentation of this file.00001 import BigWorld
00002 import GUI
00003
00004 from Window import DraggableWindow
00005
00006 import random
00007 from functools import partial
00008
00009 def clear():
00010 while len(GUI.roots()):
00011 GUI.delRoot(GUI.roots()[0])
00012
00013 def _deleteComponent( t ):
00014 if t.parent:
00015 t.parent.delChild(t)
00016 else:
00017 GUI.delRoot(t)
00018
00019 class TestWindow( DraggableWindow ):
00020
00021 factoryString = "PyGUI.Test.TestWindow"
00022
00023 def __init__( self, component ):
00024 DraggableWindow.__init__( self, component )
00025
00026 def buttonClicked( self ):
00027
00028
00029 t = GUI.Text( "Button Clicked!" )
00030 t.colour = (255,0,0,255)
00031 t.position.y = 0.85
00032 t.verticalAnchor = "TOP"
00033 GUI.addRoot(t)
00034
00035 BigWorld.callback( 2.5, partial(_deleteComponent, t) )
00036
00037 def buttonToggled( self, newState ):
00038
00039 self.component.statusLabel.text = "Toggle state: %s" % ("True" if newState else "False")
00040
00041 def draggableBeginDrag( self ):
00042
00043 self.component.draggableStatus.text = "Dragging"
00044
00045 def draggableEndDrag( self ):
00046
00047 self.component.draggableStatus.text = ""
00048
00049
00050 def draggableDragging( self ):
00051
00052 self.component.draggableStatus.colour = ( int(random.random()*127),
00053 int(random.random()*127),
00054 int(random.random()*127),
00055 255 )
00056
00057 def onBound( self ):
00058
00059 self.component.button1.script.onClick = self.buttonClicked
00060 self.component.button2.script.onActivate = lambda:self.buttonToggled(True)
00061 self.component.button2.script.onDeactivate = lambda:self.buttonToggled(False)
00062
00063 self.component.draggable.script.onBeginDrag = self.draggableBeginDrag
00064 self.component.draggable.script.onEndDrag = self.draggableEndDrag
00065 self.component.draggable.script.onDragging = self.draggableDragging
00066
00067
00068 def testWindow():
00069 BigWorld.camera(BigWorld.CursorCamera())
00070 BigWorld.setCursor( GUI.mcursor() )
00071 GUI.mcursor().visible = True
00072
00073 clear()
00074 w = GUI.load("gui/tests/window.gui")
00075 GUI.addRoot( w )
00076 return w
00077
00078
00079