#example of executing a script file #f = file("myscript.cs","rb") #script = f.read() #f.close() #pytorque.evaluate(script) #or, just generate the cs code right inside Python! pytorque.evaluate(""" new GuiBitmapButtonCtrl(MyButton) { profile = "GuiButtonProfile"; horizSizing = "right"; vertSizing = "bottom"; position = "404 361"; extent = "285 85"; minExtent = "8 2"; visible = "1"; text = "Button"; groupNum = "-1"; buttonType = "PushButton"; bitmap = "./button"; helpTag = "0"; };""") #it's easy to grab a reference to the button we created button = TorqueObject("MyButton") #buttons are kind of worthless without commands. Let's make one: def OnMyButton(value): print "Button pushed with value",value
def _startGame(self, port): print "port[%d]" % port #pytorque.evaluate('JoinServerGui.joinServer("%s", "", "IP:%s:%d");'%(self.name, self.ip, port))Canvas.setContent(PlayerSelection); pytorque.evaluate('Canvas.setContent(PlayerSelection);')
def _startGame(self, port): print "port[%d]"%port #pytorque.evaluate('JoinServerGui.joinServer("%s", "", "IP:%s:%d");'%(self.name, self.ip, port))Canvas.setContent(PlayerSelection); pytorque.evaluate('Canvas.setContent(PlayerSelection);')