def alterPanel(self):
     if self.simpleBevelOptionsAction.isChecked():
         self.setCentralWidget(Panel.SimpleOptionsWidget(self))
     elif self.fullBevelOptionsAction.isChecked():
         self.setCentralWidget(Panel.OptionTableViewWidget(self))
     elif self.bevelSetEditorAction.isChecked():
         self.setCentralWidget(Panel.BevelSetEditorWidget(self))
示例#2
0
 def _addFourierModes():
     dialog = Panel()
     dialog.wm_title("Specify Fourier Modes")
     fstr = StringVar()
     fbox = Entry(master=dialog, textvariable=fstr)
     fbox.insert(0,"10")
     fbox.pack(side=LEFT)
     b = Button(master=dialog, text='Compute')
     b.pack(side=LEFT) 
     b.configure(command=lambda:[self.addFourierModes(fbox.get()), dialog.destroy()])
示例#3
0
 def _addFourierModes():
     dialog = Panel()
     dialog.wm_title("Specify Fourier Modes")
     fstr = StringVar()
     fbox = Entry(master=dialog, textvariable=fstr)
     fbox.insert(0, "10")
     fbox.pack(side=LEFT)
     b = Button(master=dialog, text='Compute')
     b.pack(side=LEFT)
     b.configure(command=lambda:
                 [self.addFourierModes(fbox.get()),
                  dialog.destroy()])
示例#4
0
def unloadItem(item):
    print '--> unload item ' + item

    result = findAtInventory('ship', 0.5)
    if not result:
    	return False
    mouse.leftClickAtP(result)
    time.sleep(2)

    result = findAtInventory(item)
    while not result:
        mouse.moveToP(panel.center(panel.Inventory))
        mouse.wheel(-12)
        mouse.moveTo(100, 100)
        result = findAtInventory(item)

    mouse.leftDownAtP(result)
    result = findAtInventory('item_hangar', 0.5)
    if not result:
    	mouse.leftUp()
    	return False
    mouse.moveToP(result)
    mouse.leftUp()
    time.sleep(1)

    print '<-- unload item ' + item + '\n'
    return True
示例#5
0
def declineMission():
    print '--> decline mission'

    result = None
    while not result:
    	time.sleep(0.2)
    	result = findAtMissionRight('decline')
    mouse.leftClickAtP(result)

    begin = time.time()
    result = None
    while not result and time.time() - begin < 5:
    	time.sleep(0.5)
    	result = findAtFull('yes')
    if result:
    	mouse.leftClickAtP(result)

    print 'wait until decline'
    while not findAtMission('request_mission'):
        time.sleep(0.5)
    mouse.moveToP(panel.center(panel.MissionLeft))

    result = None
    while not result:
    	time.sleep(0.5)
    	result = findAtFull('x')
    mouse.leftClickAtP(result)
    time.sleep(1)

    print '<-- decline mission\n'
    return True
示例#6
0
def back():
	print '--> drones return'

	key.pressEx(sc.DronesReturn)

	mouse.moveToP(panel.center(panel.Drones))
	mouse.wheel(-100)
	mouse.moveToP(panel.center(panel.Full))

	print 'wait until drones return'
	while findAtDrones('returning') or findAtDrones('fighting') or findAtDrones('idle'):
		key.pressEx(sc.DronesReturn)
		time.sleep(0.2)

	print '<-- drones return\n'
	return True
示例#7
0
    def refreshCanvas(self):
        """
        create the canvas for this text layer on top of image layers.

        calls the base class refreshCanvas() method first

        :return Nothing: the text buffer is written to the Panel

        """

        # lay down background color/images etc first
        super(TextAnimBase, self).refreshCanvas()

        # text is drawn on the top of previous layers
        h, w = self.font.getFontBbox()

        x, y = self.origin if self.origin is not None else (0, 0)

        print "TextAnimbase.refreshCanvas() origin", self.origin

        if self.bottomLeftOrigin:
            h, w = self.textBuffer.shape[:2]
            y = y - h

        # set alpha
        # textAlpha is in range 0->1.0
        # multiply current settings
        # no point bothering if alpha is zero
        if self.textAlpha > 0:
            # multiply all alphas by textAlpha to retain relative transparency
            im = self.textBuffer.copy()
            im[:, :, 3] = im[:, :, 3].astype(float) * self.textAlpha
            Panel.DrawImage(x, y, im)
示例#8
0
def switchTo(name):
	print '--> switch overview setting to ' + name

	trycount = 0
	success = False
	while not success and trycount < 3:
		success = True
		trycount += 1
		result = findAtOverview('overview')
		if not result:
			success = False
		mouse.leftClickAtP(result)
		mouse.moveTo(result[0] - 400, result[1])
		time.sleep(0.5)

		result = findAtOverview(name)
		if not result:
			success = False
		mouse.leftClickAtP(result)
		time.sleep(0.5)

		if not success:
			mouse.leftClickAtP(panel.center(panel.Full))

	if not success:
		return False

	print '<-- switch overview setting to ' + name + '\n'
	return True
示例#9
0
	def Initialize(self, X):
		Terms, MinPointsToHaveChildren, MinPanelWidth, Bounds = self.Terms, self.MinPointsToHaveChildren, self.MinPanelWidth, self.Bounds
		DecompGroup, UField = self.DecompGroup, self.UField
		
		# Initialize the tree structure
		self.TreeRoot = _Panel.Panel(MinPointsToHaveChildren, DecompGroup.Depth, X, Bounds[0], Bounds[1], 0)
		
		self.TreeRoot.CalcUV(Terms, DecompGroup)
		self.TreeRoot.PreEval(UField, DecompGroup, X)
示例#10
0
def enterStarMap():
	print '--> enter star map'
	key.pressEx(sc.Map)
	begin = time.time()
	while findAtProgressBar('initializing_map') or time.time() - begin < 3:
		time.sleep(0.5)
	mouse.moveToP(panel.center(panel.Full))
	mouse.wheel(100)
	print '<-- enter star map\n'
示例#11
0
def openInventory():
	print '--> open inventory'

	key.pressEx(sc.Inventory)
	mouse.moveToP(panel.center(panel.Inventory))
	while not findAtInventory('x'):
		time.sleep(0.2)

	print '<-- open inventory\n'
	return True
示例#12
0
def completeMission():
	print '--> complete mission\n'

	result = None
	while not result:
		time.sleep(0.2)
		result = findAtMissionRight('complete_mission')
	mouse.leftClickAtP(result)
	mouse.moveTo(result[0], result[1] - 100)

	print 'wait until complete mission'
	result = None
	flag = False
	while not result:
		result = findAtMissionRight('request_mission')
		if result:
			flag = True
			break

		result = findAtMissionRight('can_not_complete_mission')
		if result:
			flag = False
			break

	if not flag:
		print 'can not complete'

		result = None
		while not result:
			time.sleep(0.2)
			result = findAtFull('ok')
		mouse.leftClickAtP(result)

		result = None
		while not result:
			time.sleep(0.2)
			result = findAtMissionRight('quit_mission')
		mouse.leftClickAtP(result)

		result = None
		while not result:
			time.sleep(0.2)
			result = findAtFull('yes')
		mouse.leftClickAtP(result)

	mouse.moveToP(panel.center(panel.MissionLeft))
	result = None
	while not result:
		time.sleep(0.2)
		result = findAtMission('x')
	mouse.leftClickAtP(result)

	print '<-- complete mission\n'
	return True
示例#13
0
def _launch(group):

	result = None
	while not result:
		mouse.moveToP(panel.center(panel.Drones))
		mouse.wheel(100)
		mouse.moveToP(panel.center(panel.Full))
		result = findAtDrones('bay')

	if group == None:
		mouse.rightClickAtP(result)
	else:
		if not findAtDrones(group):
			mouse.leftClickAtP(result)
		result = findAtDrones(group)
		while not result:
			time.sleep(0.5)
			result = findAtDrones(group)
		mouse.rightClickAtP(result)

	result = findAtDrones('launch_drones')
	while not result:
		time.sleep(0.5)
		result = findAtDrones('launch_drones')
	mouse.leftClickAtP(result)

	print 'wait until drones launching..'
	mouse.moveToP(panel.center(panel.Full))
	# time.sleep(5)
	while not findAtDrones('idle') and not findAtDrones('fighting') and not findAtDrones('returning'):
		mouse.moveToP(panel.center(panel.Drones))
		mouse.wheel(-100)
		mouse.moveToP(panel.center(panel.Full))
		if not findAtDrones('idle') and not findAtDrones('fighting') and not findAtDrones('returning'):
			result = findAtDrones('local_space')
			if result:
				mouse.leftClickAtP(result)
				mouse.wheel(-100)
				mouse.leftClickAt(result[0], result[1] + 20)

	return True
示例#14
0
def warpToMissionLocation():
	print '--> warp to mission location'

	enterStarMap()

	mouse.moveToP(panel.center(panel.Full))
	mouse.leftDown()
	mouse.move(500, 200)
	mouse.leftUp()

	openMissionMenu()

	result = findAtInfo('warp_to_location')
	while not result:
		result = findAtInfo('warp_to_location')
		time.sleep(1)
	mouse.leftClickAtP(result)

	time.sleep(1)
	
	print 'wait to activate gate'
	while not findAtDashboard('warp_drive_active'):
		result = findAtFull('close')
		if not result:
			result = findAtFull('ok')
		if result:
			mouse.leftClickAtP(result)
			mouse.moveTo(result[0], result[1] - 200)
		time.sleep(1)

	print 'wait until reach location'
	while findAtDashboard('warp_drive_active'):
		time.sleep(0.5)

	result = findAtFull('close')
	if not result:
		result = findAtFull('ok')
	if result:
		mouse.leftClickAtP(result)
		mouse.moveTo(result[0], result[1] - 200)
	time.sleep(1)

	while findAtDashboard('warp_drive_active'):
		time.sleep(0.5)

	exitStarMap()

	print '<-- warp to mission location\n'
	return True
    def __init__(self, parent=None):
        super(MainWindowForBevelTool, self).__init__(parent)
        self._bevelNodes = []
        self._bevelOptions = copy.copy(options.bevelOptions)

        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setupUi(self)
        self.setCentralWidget(Panel.SimpleOptionsWidget(self))
        self.bevelActionGroup = QActionGroup(self)
        self.bevelActionGroup.addAction(self.simpleBevelOptionsAction)
        self.bevelActionGroup.addAction(self.fullBevelOptionsAction)
        self.bevelActionGroup.addAction(self.bevelSetEditorAction)
        self.simpleBevelOptionsAction.setChecked(True)

        self.bevelActionGroup.triggered.connect(self.alterPanel)
示例#16
0
def activateAccelerationGate():
	switchTo('pilot')
	general.enterStarMap()

	print '--> activate acceleration gate\n'

	mouse.leftDownAtP(panel.center(panel.Full))
	mouse.move(500, 200)
	mouse.leftUp()

	result = findTarget('acceleration_gate')
	if not result:
		return False
	mouse.leftClickAtP(result)
	key.pressEx(sc.Activate)

	print 'wait to activate gate'
	while not findAtDashboard('warp_drive_active'):
		result = findAtFull('close')
		if not result:
			result = findAtFull('ok')
		if result:
			mouse.leftClickAtP(result)
			mouse.moveTo(result[0], result[1] - 200)
		handleDangerousAction();
		key.pressEx(sc.Activate)
		time.sleep(1)

	print 'wait until reach location'
	while findAtDashboard('warp_drive_active'):
		time.sleep(0.5)

	result = findAtFull('close')
	if not result:
		result = findAtFull('ok')
	if result:
		mouse.leftClickAtP(result)
		mouse.moveTo(result[0], result[1] - 200)
	time.sleep(1)

	while findAtDashboard('warp_drive_active'):
		time.sleep(0.5)

	print '<-- activate acceleration gate\n'

	general.exitStarMap()
	
	return True
示例#17
0
def missionObjectiveComplete():
	print '--> judge if mission complete'

	print 'wait until mission complete'
	while not findAtMissionDetails('v'):
		time.sleep(1)

	mouse.moveToP(panel.center(panel.MissionDetails))
	result = None
	while not result:
		time.sleep(0.5)
		result = findAtMissionDetails('x')
	mouse.leftClickAtP(result)

	print '<-- judge if mission complete\n'
	return True
示例#18
0
    def _run(self):
        self.busy = True

        self.startTime = time.time()

        while self.busy:
            if time.time() - self.startTime >= self.duration:
                break

            self.Xpos = self.Xpos + self.xStep
            self.Ypos = self.Ypos + self.yStep

            Panel.DrawImage(self.Xpos, self.Ypos, self.img)

            # has no effect on speed
            time.sleep(self.loopDelay)

        self.busy = False
示例#19
0
def setMissionWaypoint(retry = False):
	print '--> set mission waypoint'

	enterStarMap()

	openMissionMenu()

	while True:
		result = findAtInfo('set_destination')
		if not result and not retry:
			return False
		elif not result:
			time.sleep(1)
			mouse.leftClickAtP(panel.center(panel.Full))
		else:
			break

	mouse.leftClickAtP(result)

	exitStarMap()

	print '<-- set mission waypoint\n'
	return True
示例#20
0
def findTarget(target, threashould = 0.1):
	print '--> find target "' + target + '"'
	count = 0
	result = findAtOverview(target, threashould)
	while result == None and count < 10:
		if result:
			break
		x, y = panel.center(panel.Overview)
		y += random.random() * 200 - 100
		mouse.leftClickAt(x, y)
		if count < 5:
			mouse.wheel(-20)
		else:
			mouse.wheel(20)
		count += 1
		result = findAtOverview(target)

	if not result:
		print 'can not find target.'
	else:
		print 'target finded.'

	print '<-- find target "' + target + '"\n'
	return result
示例#21
0
def findEnemy():
	print '--> find enemy'
	count = 0
	result = pic.findColorR(panel.Overview, 'c11313')
	while result == None and count < 10:
		if result:
			break
		x, y = panel.center(panel.Overview)
		y += random.random() * 200 - 100
		mouse.leftClickAt(x, y)
		if count < 5:
			mouse.wheel(-20)
		else:
			mouse.wheel(20)
		count += 1
		result = pic.findColorR(panel.Overview, 'c11313')

	if not result:
		print 'can not find enemy.'
	else:
		print 'target finded.'

	print '<-- find enemy'
	return result
示例#22
0
def autopilot():
    print '--> autopilot'

    overview.switchTo('pilot')

    while True:
        print 'try to find target stargate or station'
        finded = ''
        result = None
        for retry in range(3):
            print 'try: ' + str(retry + 1)
            result = findAtOverview('target_station', 0.2)
            if result:
                print 'station finded'
                finded = 'station'
                break
            result = findAtOverview('target_star_gate', 0.2)
            if result:
                print 'stargate finded'
                finded = 'gate'
                break
            x, y = panel.center(panel.Overview)
            y += random.random() * 200 - 100
            mouse.leftClickAt(x, y)
            mouse.wheel(-12)
            mouse.moveToP(panel.center(panel.Full))

        if finded == '':
            print "can't find any waypoint"
            print '<-- autopilot\n'
            return False

        if finded == 'station':
            print 'docking...'
            mouse.leftClickAtP(result)
            key.pressEx(sc.Activate)
            print 'wait until entering station'
            begin = time.time()
            result = findAtProgressBar('entering_station', 0.1) 
            while not result and time.time() - begin < 80:
                result = findAtProgressBar('entering_station', 0.1) 
                time.sleep(0.1)
            if result:
                print 'entering station'
                time.sleep(4)
                print '<-- autopilot\n'
                return True

        if finded == 'gate':
            print 'jump...'
            mouse.leftClickAtP(result)
            key.pressEx(sc.Activate)
            print 'wait until entering space'
            begin = time.time()
            result = findAtProgressBar('entering_space', 0.1)
            while not result  and time.time() - begin < 80:
                result = findAtProgressBar('entering_space', 0.1)
                time.sleep(0.1)
            if result:
                print 'entering space'
                time.sleep(3)
示例#23
0
文件: App.py 项目: cezarmocanu/ImXORy
    def init(self):
        ImageLoader.loadImages()

        #refactoring needed
        self.windowSize = [1000, 700]
        self.size = [1000, 640]
        self.running = True
        GUISize = (self.windowSize[0], self.windowSize[1] - self.size[1])

        #CELLMAP
        App.ROWS = int(self.size[1] / self.CELL_SIZE)
        App.COLS = int(self.size[0] / self.CELL_SIZE)
        cellMap = Map(0, GUISize[1], (App.ROWS, App.COLS), App.CELL_SIZE)
        self.cellMap = cellMap
        #writeToFile("hello.txt",cellMap)
        #readFromFile("hello.txt")

        #GUI
        App.GUIROOT = Panel(0, 0, GUISize[0], GUISize[1], Color.yellow)

        App.MODES = Panel(0, 0, 200, GUISize[1], Color.darkGray)

        def setWireMode():
            App.editMode = 0
            App.option = 1
            App.gateMode.dePush()
            App.fileMode.dePush()
            if len(App.GUIROOT.children) >= 2:
                App.GUIROOT.removeChild(1)
            App.GUIROOT.addChild(App.WIRE_OPTIONS)

        App.wireMode = Button(10, 5, 50, 50, Color.green, Color.red,
                              setWireMode, ImageLoader.WIRE)
        App.MODES.addChild(App.wireMode)

        def setGateMode():
            App.editMode = 1
            App.option = 1
            App.wireMode.dePush()
            App.fileMode.dePush()
            if len(App.GUIROOT.children) >= 2:
                App.GUIROOT.removeChild(1)
            App.GUIROOT.addChild(App.GATE_OPTIONS)

        App.gateMode = Button(70, 5, 50, 50, Color.green, Color.red,
                              setGateMode, ImageLoader.GATE)
        App.MODES.addChild(App.gateMode)

        def setFileMode():
            App.editMode = 2
            App.option = 1
            App.wireMode.dePush()
            App.gateMode.dePush()
            if len(App.GUIROOT.children) >= 2:
                App.GUIROOT.removeChild(1)
            App.GUIROOT.addChild(App.FILE_OPTIONS)

        App.fileMode = Button(130, 5, 50, 50, Color.green, Color.red,
                              setFileMode, ImageLoader.FILE)
        App.MODES.addChild(App.fileMode)

        App.WIRE_OPTIONS = Panel(200, 0, 800, GUISize[1], Color.blue)

        def setDrawOption():
            App.option = 1
            App.jonctionOption.dePush()
            App.inputOption.dePush()
            App.outputOption.dePush()
            App.clickOption.dePush()

        App.drawOption = Button(10, 5, 50, 50, Color.green, Color.red,
                                setDrawOption, ImageLoader.DRAW)

        def setJonctionOption():
            App.option = 2
            App.drawOption.dePush()
            App.inputOption.dePush()
            App.outputOption.dePush()
            App.clickOption.dePush()

        App.jonctionOption = Button(20 + 50, 5, 50, 50, Color.green, Color.red,
                                    setJonctionOption, ImageLoader.JONCTION)

        def setInputOption():
            App.option = 3
            App.jonctionOption.dePush()
            App.drawOption.dePush()
            App.outputOption.dePush()
            App.clickOption.dePush()

        App.inputOption = Button(30 + 100, 5, 50, 50, Color.green, Color.red,
                                 setInputOption, ImageLoader.INPUT)

        def setOutputOption():
            App.option = 4
            App.jonctionOption.dePush()
            App.inputOption.dePush()
            App.drawOption.dePush()
            App.clickOption.dePush()

        App.outputOption = Button(40 + 150, 5, 50, 50, Color.green, Color.red,
                                  setOutputOption, ImageLoader.OUTPUT)

        def setClickOption():
            App.option = 5
            App.jonctionOption.dePush()
            App.inputOption.dePush()
            App.outputOption.dePush()
            App.drawOption.dePush()

        App.clickOption = Button(50 + 200, 5, 50, 50, Color.green, Color.red,
                                 setClickOption, ImageLoader.CLICK)

        #add button
        App.WIRE_OPTIONS.addChild(App.drawOption)
        App.WIRE_OPTIONS.addChild(App.jonctionOption)
        App.WIRE_OPTIONS.addChild(App.inputOption)
        App.WIRE_OPTIONS.addChild(App.outputOption)
        App.WIRE_OPTIONS.addChild(App.clickOption)

        App.GATE_OPTIONS = Panel(200, 0, 800, GUISize[1], Color.lightGray)

        def setNotOption():
            App.option = 1
            App.andOption.dePush()
            App.orOption.dePush()
            App.xorOption.dePush()
            App.nandOption.dePush()
            App.norOption.dePush()
            App.nxorOption.dePush()
            App.deleteOption.dePush()

        App.notOption = Button(10, 5, 50, 50, Color.green, Color.red,
                               setNotOption, ImageLoader.NOT)

        def setAndOption():
            App.option = 2
            App.notOption.dePush()
            App.orOption.dePush()
            App.xorOption.dePush()
            App.nandOption.dePush()
            App.norOption.dePush()
            App.nxorOption.dePush()
            App.deleteOption.dePush()

        App.andOption = Button(20 + 50, 5, 50, 50, Color.green, Color.red,
                               setAndOption, ImageLoader.AND)

        def setOrOption():
            App.option = 3
            App.notOption.dePush()
            App.andOption.dePush()
            App.xorOption.dePush()
            App.nandOption.dePush()
            App.norOption.dePush()
            App.nxorOption.dePush()
            App.deleteOption.dePush()

        App.orOption = Button(30 + 100, 5, 50, 50, Color.green, Color.red,
                              setOrOption, ImageLoader.OR)

        def setXorOption():
            App.option = 4
            App.notOption.dePush()
            App.andOption.dePush()
            App.orOption.dePush()
            App.nandOption.dePush()
            App.norOption.dePush()
            App.nxorOption.dePush()
            App.deleteOption.dePush()

        App.xorOption = Button(40 + 150, 5, 50, 50, Color.green, Color.red,
                               setXorOption, ImageLoader.XOR)

        def setNandOption():
            App.option = 5
            App.notOption.dePush()
            App.andOption.dePush()
            App.orOption.dePush()
            App.xorOption.dePush()
            App.norOption.dePush()
            App.nxorOption.dePush()
            App.deleteOption.dePush()

        App.nandOption = Button(50 + 200, 5, 50, 50, Color.green, Color.red,
                                setNandOption, ImageLoader.NAND)

        def setNorOption():
            App.option = 6
            App.notOption.dePush()
            App.andOption.dePush()
            App.orOption.dePush()
            App.xorOption.dePush()
            App.nandOption.dePush()
            App.nxorOption.dePush()
            App.deleteOption.dePush()

        App.norOption = Button(60 + 250, 5, 50, 50, Color.green, Color.red,
                               setNorOption, ImageLoader.NOR)

        def setNxorOption():
            App.option = 7
            App.notOption.dePush()
            App.andOption.dePush()
            App.orOption.dePush()
            App.xorOption.dePush()
            App.nandOption.dePush()
            App.norOption.dePush()
            App.deleteOption.dePush()

        App.nxorOption = Button(70 + 300, 5, 50, 50, Color.green, Color.red,
                                setNxorOption, ImageLoader.NXOR)

        def setDeleteOption():
            App.option = 8
            App.notOption.dePush()
            App.andOption.dePush()
            App.orOption.dePush()
            App.xorOption.dePush()
            App.nandOption.dePush()
            App.norOption.dePush()

        App.deleteOption = Button(70 + 300, 5, 50, 50, Color.green, Color.red,
                                  setDeleteOption, ImageLoader.DELETE)

        App.GATE_OPTIONS.addChild(App.notOption)
        App.GATE_OPTIONS.addChild(App.andOption)
        App.GATE_OPTIONS.addChild(App.orOption)
        App.GATE_OPTIONS.addChild(App.xorOption)
        App.GATE_OPTIONS.addChild(App.nandOption)
        App.GATE_OPTIONS.addChild(App.norOption)
        App.GATE_OPTIONS.addChild(App.nxorOption)
        App.GATE_OPTIONS.addChild(App.deleteOption)

        App.FILE_OPTIONS = Panel(200, 0, 800, GUISize[1], Color.lightGray)

        def setSaveFileOption():
            writeToFile("hello.txt", self.cellMap)
            App.saveFileOption.dePush()

        App.saveFileOption = Button(10, 5, 50, 50, Color.green, Color.red,
                                    setSaveFileOption, ImageLoader.SAVE)

        def setLoadFileOption():
            readFromFile("hello.txt", self.cellMap)
            App.loadFileOption.dePush()

        App.loadFileOption = Button(20 + 50, 5, 50, 50, Color.green, Color.red,
                                    setLoadFileOption, ImageLoader.LOAD)

        App.FILE_OPTIONS.addChild(App.saveFileOption)
        App.FILE_OPTIONS.addChild(App.loadFileOption)

        App.GUIROOT.addChild(App.MODES)

        #App.GUIROOT.addChild(OPTIONS)

        #PYGAME
        pygame.init()
        pygame.font.init()

        App.FONT = pygame.font.SysFont("arial", 16, bold=False, italic=False)

        self.screen = pygame.display.set_mode(self.windowSize)
示例#24
0
	if not overview.activateAccelerationGate():
		return False

	if not overview.switchTo('lcs'):
		return False

	if not overview.lockTarget('guristas_space', 15):
		return False

	if not drones.launchSmall():
		return False

	ship.fireOnce()

	drones.engage()

	if not general.openMissionDetails():
		return False

	if not general.missionObjectiveComplete():
		return False

	if not drones.back():
		return False

	print '<-- mission The Space Telescope\n'
	return True

if __name__ == '__main__':
	mouse.leftClickAtP(panel.center(panel.Full))
	run()
示例#25
0
        map.start = Croodinate(panel.startX.get(), panel.startY.get())
        map.goal = Croodinate(panel.goalX.get(), panel.goalY.get())
        map.size = panel.size.get()
        map.Algorithm = panel.Algorithm.get()
        map.Heuristic = panel.Heuristic.get()
        map.time = panel.time.get()
    else:
        panel.showMessageBox("Error", "Values are invalid!")


root = Tk()

root.title('Map')
Map = Map(root)


def toplevel():
    top = Toplevel()
    top.title('Panel')
    top.wm_geometry("400x200")
    top.attributes('-alpha', 0.8)
    top.configure(background="black")
    return top


Panel = Panel(toplevel(), 40)
Panel.applyButton.bind(
    "<Button-1>", lambda event, panel=Panel, map=Map: handleApply(panel, map))

root.mainloop()
示例#26
0
from flask import Flask
from flask import render_template
import Panel
import State
from pygooglechart import Chart
from pygooglechart import SimpleLineChart
from pygooglechart import Axis
import os

app = Flask(__name__)
panel1 = Panel.panel_production('Jim', 2, 2, 4, 1)
panel2 = Panel.panel_production('Jim2', 2, 2, 4, 2)
panels = [panel1, panel2]
myPanel = "jim"
CA = State.stateReg('California',15,5)

#initialize sample vars
panel1.setOCV(1)
panel1.setSCI(1)

def makeChart():
    # Set the vertical range from 0 to 100
    max_y = 100
    
    # Chart size of 200x125 pixels and specifying the range for the Y axis
    chart = SimpleLineChart(400, 250, y_range=[0, max_y])
    
    # Add the chart data
    # Aggregate data into array before adding to chart
    data = [
        32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37,
##    clock_t = time()
##    for i in range(Iterations):    
##        TreeRoot = _Panel.Panel(MinPointsToHaveChildren, DecompGroup.Depth, X.X, array([0,0,0], float64), array([1,1,1], float64), 0)
##    InitializationTime.append((time() - clock_t) / Iterations)
##
##    # Time the preevaluation
##    clock_t = time()
##    for i in range(Iterations):
##        TreeRoot.CalcUV(Terms, DecompGroup)
##        TreeRoot.PreEval(UField, DecompGroup, X.X)
##    PreEvalTime.append((time() - clock_t) / Iterations)

    # Time the initialization of the tree structure and pre-eval
    clock_t = time()
    for i in range(Iterations/2):
        TreeRoot = _Panel.Panel(MinPointsToHaveChildren, DecompGroup.Depth, X.X, array([0,0,0], float64), array([1,1,1], float64), 0)
        TreeRoot.CalcUV(Terms, DecompGroup)
        TreeRoot.PreEval(UField, DecompGroup, X.X)
    PreEvalTime.append((time() - clock_t) / (Iterations/2))

    # Time the tree code evaluation    
    clock_t = time()
    for i in range(Iterations):
        TreeRoot.CalcSeriesTerms(X.F)
        TreeRoot.FastEval(X.X, X.F, X.U)
    EvalTime.append((time() - clock_t) / Iterations)

    Nb += 1

##print InitializationTime
##print
示例#28
0
文件: test_web.py 项目: polarise/web
def main():
	P = Page( "my_page", "A new page is born" )
	
	p1 = Panel( "panel1" )
	p2 = Panel( "panel2" )
	p2.load_from_file( 'text.txt' )
	p1.add_panel( p2 )
	P.add_panel( p1 )
	
	p3 = Panel( "panel3" )
	p4 = Panel( "panel4" )
	p5 = Panel( "panel5" )
	p5.load( "There are new things happening." )
	p4.add_panel( p5 )
	p3.add_panel( p4 )
	P.add_panel( p3 )
	
	# render everything
	P.render()
	
	# display
	print P
示例#29
0
    def __init__(self, *args, **kwargs):
           
        def _enterSession(currentrow):

            Label(master=sessionDialog,text='System of Equations:')

            # Vector Size
            V = int(vbox.get())
            # Number of Fourier Modes
            N = int(nbox.get())
            # Period Length
            L = eval(lbox.get())
            # Number of Periods
            P = 2; 
            # Number of mu values
            Z = int(zbox.get())
           
            vbox.configure(state='disabled')
            nbox.configure(state='disabled')
            lbox.configure(state='disabled')
            zbox.configure(state='disabled')

            # Boolean for Eigenvectors (force for efcn plotting)
            vecflag = True
            # Boolean for using existing Fourier Coefficients
            coefbool = False 

            def _enterSystem(s):        

                def _enterCoefficients(order):

                    coeffboxes = []

                    # loop through each coefficient box within one equation
                    for i in range(order,-1,-1):
                        existing = coeffvector[hashmap[s]].split(':')
                        derivstr = ''
                        box = Entry(master=eqnDialog)
                        coeffboxes.append(box)
                        
                        if (len(existing) == order+1):
                            box.insert(0,existing[i])
                        else:
                            box.insert(0,1)

                        for j in range(0,i):
                            derivstr = derivstr + "'"

                        if (i == 0):
                            derivstr = 'y' 
                        else:
                            derivstr = 'y'+derivstr+'+'

                        Label(master=eqnDialog, text=derivstr).grid(row=order-i+1,column=2,sticky=W)
                        box.grid(row=order-i+1,column=1)
            
                    def _saveCoefficients():
                        order = len(coeffboxes)-1

                        str_array = []
                        for i in reversed(range(0,len(coeffboxes))):
                            str_array.append(coeffboxes[i].get())

                        coeffvector[hashmap[s]] += ':'.join(str_array)
                        eqnDialog.destroy()

                    Button(master=eqnDialog,text='Continue',command=_saveCoefficients).grid(row=order+2,column=0)
                    Button(master=eqnDialog,text='Change Order',command=lambda:_changeOrder()).grid(row=order+2,column=1)

                    def _changeOrder():
                        _enterSystem(s)
                        coeffvector[hashmap[s]]=''
                        eqnDialog.destroy()


                eqnDialog = Panel()
                eqnDialog.wm_title(s+": Enter Coefficients")
                if (len(coeffvector) and len(coeffvector[hashmap[s]])):
                    s_coeff = coeffvector[hashmap[s]].split(':')
                    _enterCoefficients(len(s_coeff)-1)
                else:
                    Label(master=eqnDialog, text='Maximum Differential Order:').grid(row=0)
                    orderstr =  StringVar()
                    orderbox = Entry(master=eqnDialog, textvariable=orderstr)
                    orderbox.insert(0, "0")
                    orderbox.grid(row=0,column=1)
                    b = Button(master=eqnDialog, text='Setup Equation',command=lambda:_enterCoefficients(int(orderbox.get())))
                    b.grid(row=0,column=2)
                    b.configure(command=lambda:[_enterCoefficients(int(orderbox.get())), b.destroy(), orderbox.configure(state='disabled')])

      
            coeffvector = []
            hashmap = dict()
            counter = 0

            Label(master=sessionDialog, text='Enter Equations:').grid(row=currentrow,column=0)
            Label(master=sessionDialog, text=u' = \u03bb y').grid(row=currentrow+2,column=V+1)

            for i in range(0,V):
                currentrow = currentrow+1
                for j in range(0,V):
                    coeffvector.append('') 
                    txt = 'L['+str(i+1)+','+str(j+1)+']'
                    hashmap[txt] = counter
                
                    b = Button(master=sessionDialog, text=txt)
                    b.grid(row=1+currentrow,column=j)
                    b.configure(command=lambda widget=b.cget('text'): _enterSystem(widget))
                    counter += 1


            currentrow = currentrow+1

            def _plotSession(Z):
                coeffstr = ';'.join(coeffvector)

                param = paramEntry.get()
                if len(param) > 0:
                    start = startEntry.get()
                    end = endEntry.get()
                    steps = stepsEntry.get()
                    param = param+':'+start+':'+end+':'+steps
                
                debug = False
                sysHashmap = { "VectorSize" : V, 
                               "FourierModes" : N, 
                               "Period" : L, 
                               "NumPeriods" : P, 
                               "MuVals" : Z , 
                               "Coefficients" : coeffstr ,
                               "Parameters" : param}
                print coeffstr
                sys.stdout.flush()
                if debug:
                    sysHashmap = { "VectorSize" : 2, 
                                   "FourierModes" : 10, 
                                   "Period" : pi, 
                                   "NumPeriods" : 2, 
                                   "MuVals" : 50 , 
                                   "Coefficients" : "sqrt(1+v0)*sin(2*x);-0.5+(1+v0)*(1-cos(2*x)):0:-0.5;0.5-(1+cos(2*x)):0:0.5;-sqrt(1+v0)*sin(2*x)",
                                   "Parameters" : "v0:-1:1:10"}

                    # sysHashmap = { "VectorSize" : 1, 
                    #                "FourierModes" : 10, 
                    #                "Period" : pi, 
                    #                "NumPeriods" : 2, 
                    #                "MuVals" : 50 , 
                    #                "Orders" : "4", 
                    #                "Coefficients" : "(1-a^2)*sin(x)*cos(x):a:-sin(x):0:-1",
                    #                "Parameters" : "a:0:1:10" }

                sessionDialog.destroy()
#                 if len(param) > 0:
#                     anipanel = AnimationPanel(sysHashmap)
#                     anipanel.withdraw()
                SessionPanel(sysHashmap)

            currentrow = currentrow + 1
            Label(master=sessionDialog, text='Parameter name:').grid(row=currentrow)
            paramEntry = Entry(master=sessionDialog)
            paramEntry.grid(row=currentrow,column=1)

            currentrow = currentrow + 1
            Label(master=sessionDialog, text='Start value:').grid(row=currentrow)
            startEntry = Entry(master=sessionDialog)
            startEntry.grid(row=currentrow,column=1)

            currentrow = currentrow + 1
            Label(master=sessionDialog, text='End value:').grid(row=currentrow)
            endEntry = Entry(master=sessionDialog)
            endEntry.grid(row=currentrow,column=1)

            currentrow = currentrow + 1
            Label(master=sessionDialog, text='Number of values:').grid(row=currentrow)
            stepsEntry = Entry(master=sessionDialog)
            stepsEntry.grid(row=currentrow,column=1)
                        
            Button(master=sessionDialog, text='Plot Spectrum', 
                   command=lambda:_plotSession(Z)).grid(row=V+1+currentrow)

        # System parameter window
        sessionDialog = Panel()
        sessionDialog.wm_title("System parameters")

        Label(master=sessionDialog, text='Vector size:').grid(row=0)
        vstr = StringVar()
        vbox = Entry(master=sessionDialog, textvariable=vstr)
        vbox.insert(0, "1")
        vbox.grid(row=0,column=1)
        
        Label(master=sessionDialog, text='Number of Fourier Modes:').grid(row=1,sticky=W)
        nbox = Entry(master=sessionDialog)
        nbox.insert(0,"10")
        nbox.grid(row=1,column=1)
        
        Label(master=sessionDialog, text='Period Length:').grid(row=2,sticky=W)
        lbox = Entry(master=sessionDialog)
        lbox.insert(0,"2*pi")
        lbox.grid(row=2,column=1)
        
    # Label(master=sessionDialog, text='Number of Periods').grid(row=3,sticky=W)
    # pbox = Entry(master=sessionDialog)
    # pbox.insert(0,"2")
    # pbox.grid(row=3,column=1)

        Label(master=sessionDialog, text='Number of mu values:').grid(row=4,sticky=W)
        zbox = Entry(master=sessionDialog)
        zbox.insert(0,"50")
        zbox.grid(row=4,column=1)
        row = 5
    # vecvar = IntVar()
    # vecbutton = Checkbutton(master=sessionDialog, text='Eigenvectors', variable=vecvar).grid(row=5,sticky=W)
    # coefvar = IntVar()
    # coefbutton = Checkbutton(master=sessionDialog, text='Use existing Fourier coefficients',variable=coefvar).grid(row=6,sticky=W)
    
        bContinue = Button(master=sessionDialog, text='Continue')
        bContinue.grid(row=5,column=1)
        bContinue.configure(command=lambda:[_enterSession(row+1), bContinue.destroy()])

        Tk.mainloop()
示例#30
0
            def _enterSystem(s):        

                def _enterCoefficients(order):

                    coeffboxes = []

                    # loop through each coefficient box within one equation
                    for i in range(order,-1,-1):
                        existing = coeffvector[hashmap[s]].split(':')
                        derivstr = ''
                        box = Entry(master=eqnDialog)
                        coeffboxes.append(box)
                        
                        if (len(existing) == order+1):
                            box.insert(0,existing[i])
                        else:
                            box.insert(0,1)

                        for j in range(0,i):
                            derivstr = derivstr + "'"

                        if (i == 0):
                            derivstr = 'y' 
                        else:
                            derivstr = 'y'+derivstr+'+'

                        Label(master=eqnDialog, text=derivstr).grid(row=order-i+1,column=2,sticky=W)
                        box.grid(row=order-i+1,column=1)
            
                    def _saveCoefficients():
                        order = len(coeffboxes)-1

                        str_array = []
                        for i in reversed(range(0,len(coeffboxes))):
                            str_array.append(coeffboxes[i].get())

                        coeffvector[hashmap[s]] += ':'.join(str_array)
                        eqnDialog.destroy()

                    Button(master=eqnDialog,text='Continue',command=_saveCoefficients).grid(row=order+2,column=0)
                    Button(master=eqnDialog,text='Change Order',command=lambda:_changeOrder()).grid(row=order+2,column=1)

                    def _changeOrder():
                        _enterSystem(s)
                        coeffvector[hashmap[s]]=''
                        eqnDialog.destroy()


                eqnDialog = Panel()
                eqnDialog.wm_title(s+": Enter Coefficients")
                if (len(coeffvector) and len(coeffvector[hashmap[s]])):
                    s_coeff = coeffvector[hashmap[s]].split(':')
                    _enterCoefficients(len(s_coeff)-1)
                else:
                    Label(master=eqnDialog, text='Maximum Differential Order:').grid(row=0)
                    orderstr =  StringVar()
                    orderbox = Entry(master=eqnDialog, textvariable=orderstr)
                    orderbox.insert(0, "0")
                    orderbox.grid(row=0,column=1)
                    b = Button(master=eqnDialog, text='Setup Equation',command=lambda:_enterCoefficients(int(orderbox.get())))
                    b.grid(row=0,column=2)
                    b.configure(command=lambda:[_enterCoefficients(int(orderbox.get())), b.destroy(), orderbox.configure(state='disabled')])
def run():
	print '--> mission Intercept The Sabateurs'

	if not ship.enableDefense():
		return False

	if not drones.launchSmall():
		return False

	overview.seekAndDestory()

	if not drones.back():
		return False

	ship.enableAfterburn()

	if not overview.activateAccelerationGate():
		return False

	# pocket 1
	# main enemies are 90km away
	# approach for 85 secs
	# mean while clean up nearby enemy

	drones.launchSmall()
	
	if not overview.switchTo('battle'):
		return False

	if not overview.lockEnemy(20):
		return False

	ship.fireOnce()

	if not overview.lockTarget('transport', 1):
		return False

	ship.enableAfterburn()

	ship.approachFor(85)

	# wait for stop
	begin = time.time()
	while time.time() - begin < 20:
		ship.stop()
		key.pressEx(sc.Unlock)

	mouse.moveToP(panel.center(panel.Drones))

	mouse.wheel(-100)

	while findAtDrones('fighting'):
		time.sleep(10)

	drones.back()

	# use sentry to destory all the smalls

	for i in range(6):
		overview.lockTarget('s', 1)

	drones.launchSentry()

	begin = time.time()
	while overview.lockTarget('s', 1) and time.time() - begin < 130:
		ship.fireOnce()
		drones.engage()

	drones.back()

	# do the rest

	ship.fireOnce()

	drones.launchSmall()

	overview.seekAndDestory()

	while not overview.pickCargo():
		pass

	drones.back()

	print '<-- mission Intercept The Sabateurs\n'
	return True