コード例 #1
0
 def createAction(self):
     # Make the new action
     if self.confActiveList==self.curList:
         action=self.openActionSetup(Action(passive=False,trigger='Set Trigger'))
     else:
         action=self.openActionSetup(Action(passive=True,trigger=[]))
     self.insertLazyAction(action)
コード例 #2
0
ファイル: Agent.py プロジェクト: yangwangaaa/ADPRL2015
 def __init__(self, maze, discount, goal, goalcost, movecost):
     self.maze = maze
     self.V = np.zeros_like(maze, dtype=np.float)
     self.policy = np.zeros_like(maze) # Policy is just a matrix of numbers corresponding to actions
     self.gamma = discount
     self.actions = [Action(), Up(), Down(), Left(), Right()] # Action() is no action
     self.goal = goal
     self.goalcost = goalcost
     self.movecost = movecost
コード例 #3
0
    def getActionImpl(self):
        obs = self.obs
        npimg = Image.fromarray(obs['img'].decompressPNG()[:, :, 0:3])
        # npimg.show()
        # print(npimg.size)
        inputImg = self.transform(npimg)
        sm = torch.nn.Softmax()
        if self.usegpu:
            img = Variable(inputImg.unsqueeze_(0).cuda())
        else:
            img = Variable(inputImg.unsqueeze_(0))
        classActivation = self.model(img).data
        probs = self.model.getClassifications(Variable(classActivation), sm)
        # action = Action(probs.cpu().numpy())
        action = Action(np.zeros(3))
        action.meta['activations'] = probs.cpu().numpy()[0]

        return action
コード例 #4
0
    def __init__(self, conf):
        super(Agent, self).__init__(conf)
        self.conf = conf
        self.toTensor = transforms.ToTensor()
        #
        # Check if cuda is available.
        self.usegpu = torch.cuda.is_available() and self.conf.usegpu
        #
        # Load the model.
        if self.conf.modelLoadPath != None and os.path.isfile(
                self.conf.modelLoadPath):
            if self.usegpu:
                checkpoint = torch.load(self.conf.modelLoadPath)
            else:
                checkpoint = torch.load(self.conf.modelLoadPath,
                                        map_location={'cuda:0': 'cpu'})
            self.model = checkpoint['model']
            self.nnconf = checkpoint['conf']
            self.model.load_state_dict(checkpoint['state_dict'])
            printColour('Loaded model from path: %s' % self.conf.modelLoadPath,
                        colours.OKBLUE)
        else:
            printError('Could not load model from path: %s' %
                       self.conf.modelLoadPath)
            raise RuntimeError

        if self.usegpu:
            self.model.cuda()

        self.model.eval()
        self.model_input_img_shape = conf.image_shape
        #
        # Heuristic Parameters
        #
        # action dim for array
        self.action_array_dim = 11
        #
        # minimum probability of collision free to go straight
        self.straight_min_prob = 0.80
        #
        # minimum probability of collision free to stop
        self.stop_min_prob = 0.0
        #
        # min turning probabilty
        self.turn_min_prob = 0.70
        #
        # max vt w
        action_ = Action(np.zeros(self.action_array_dim))
        self.max_v_t = action_.max_v_t
        self.max_w = action_.max_w

        self.mode = 0
        self.angle = None
        self.last_pose = None
        self.last_time = None
        self.still_counter = 0
        random.seed(time.time())
コード例 #5
0
ファイル: RLAgent.py プロジェクト: younghj/flot
    def getActionImpl(self):
        obs = self.obs
        npimg = obs['img'].uint8Img
        # If image is available
        if npimg is not None:
            action = self.policy_network.compute(npimg)
            action = np.clip(action, -1, 1)
            v_ref, w_ref = action[0], action[1]
            action = Action(v_t=-v_ref * self.max_v_t, w=w_ref * self.max_w)
            print("Linear Velocity: {:.2f} Angular Velocity: {:.2f}".format(
                action.v_t, action.w))

        # Take no action when no image is available
        else:
            action = Action(v_t=0, w=0)

        action.meta['visualbackprop'] = False
        # Do more stuff.
        return action
コード例 #6
0
ファイル: slack_tc.py プロジェクト: DS-KoolAid/slackbot_iocs
def parse_event(event):
    # Ignore messages from the bot
    if 'bot_id' in event['event']:
        return
    logger.debug(pformat(event))
    logger.debug('----------------------------------------------------------')

    channel = event['event']['channel']
    user = event['event']['user']

    command = ''
    command_arguments = []
    message = event['event']['blocks'][0]['elements'][0]['elements']
    for element in message:
        if element['type'] == 'text':
            # text can contain multiple words
            words = element['text'].strip().split()
            for word in words:
                # skip extra spaces
                if not word:
                    continue
                # first word we see is the command
                if not command:
                    command = word.lower()
                # any other words are arguments for the command
                else:
                    command_arguments.append(word.lower())
        elif element['type'] == 'link':
            command_arguments.append(element['url'])

    data = {
        'channel': channel,
        'user': user,
        'command': command,
        'command_arguments': command_arguments
    }

    if 'files' in event['event']:
        data['files'] = event['event']['files']
    logger.debug(pformat(data))

    action = Action(**data)
    action.execute()
コード例 #7
0
ファイル: testAgent.py プロジェクト: younghj/flot
    def getActionImpl(self):
        if self.obs == None:
            printError(
                "Agent's Observation is None, make sure to giveObservation to Agent before calling getAction"
            )
        else:
            if self.numObs <= self.obsCount:
                print("Data Collection Complete")
                sys.exit()
            self.obsCount += 1
            if self.obsCount % 50 == 0:
                print("{} Data Collected".format(self.obsCount))

            self.testAction = Action(
                array=abs(np.random.randn(3) * np.array([0, 1, 0])))
            if self.obs['hasCollided'].val:
                self.testAction = Action(v_t=0.0, w=0.0, isReset=True)

            return self.testAction
コード例 #8
0
ファイル: NNAgent.py プロジェクト: younghj/flot
 def getActionImpl(self):
     obs = self.obs
     npimg = obs['img'].decompressPNG()[:, :, 0:3]
     #
     # NORMALIZE IMAGE.
     # img = Variable(self.toTensor(npimg).unsqueeze_(0).cuda())
     img = Variable(self.transforms(npimg).unsqueeze_(0).cuda())
     out = self.model(img)
     _, predicted = torch.max(out.data, 1)
     #
     # Since we are doing a 1,0 encoding take the max and push it through.
     move = predicted.cpu().numpy().tolist()
     print(move)
     act = Action(v_t=move[0] * 1.0, w=0.0)
     return act
コード例 #9
0
ファイル: Automate.py プロジェクト: Yeab1/No-Hands
def on_click(x,y, button, pressed):
    if pressed:
        if len(allActions) != 0 and allActions[-1].actionType == "keyPress" and allActions[-1].getKey() == keyboard.Key.esc:
            return False
        if str(button) == "Button.middle":
            return False
        else:
            newClick = Action("click")
            newClick.setPosition(x, y)
            newClick.setButton(str(button))
            
            allActions.append(newClick)
コード例 #10
0
ファイル: Automate.py プロジェクト: Yeab1/No-Hands
def on_release(key):
    print('{0} released'.format(
        key))
    
    if key == keyboard.Key.esc:
        keyPressed = Action("keyPress")
        keyPressed.key = key
        allActions.append(keyPressed)
        # Stop listener
        return False
    else:
        keyPressed = Action("keyPress")
        keyPressed.key = key
        allActions.append(keyPressed)
コード例 #11
0
ファイル: RLAgent.py プロジェクト: younghj/flot
    def __init__(self, conf):
        super(Agent, self).__init__(conf)
        self.conf = conf
        self.policy_network = A2CPolicyNetwork(None, 2, None, 4)

        #
        # Load the model.
        if self.conf.modelLoadPath != None and os.path.isfile(
                self.conf.modelLoadPath):
            self.policy_network.load_state_dict(
                torch.load(self.conf.modelLoadPath))
        else:
            printError('Could not load model from path: %s' %
                       self.conf.modelLoadPath)
            raise RuntimeError

        self.action_array_dim = 11
        action_ = Action(np.zeros(self.action_array_dim))
        self.max_v_t = action_.max_v_t
        self.max_w = action_.max_w
コード例 #12
0
 def copyAction(self):
     # Make a copy of the action
     newAction=Action()
     for key,val in iteritems(self.menuAction.__dict__):
         if key!='func':
             setattr(newAction,key,val)
     newAction.linkToFunction(self.main)
     # Set up the new actions tag
     seenKeys=self.act.keys()
     i=0
     while self.menuAction.tag+'('+str(i)+')' in seenKeys:
         i+=1
     # Assign the unique tag, and give a meaningless trigger (if an active action)
     newAction.tag=self.menuAction.tag+'('+str(i)+')'
     if not newAction.passive:
         print('Update '+newAction.tag+' trigger value, will be deleted upon configuration closure otherwise')
         newAction.trigger='Set Trigger'
     # Insert the copied action
     self.insertLazyAction(newAction)
コード例 #13
0
ファイル: RobotActions.py プロジェクト: younghj/flot
 def __init__(self, array, v_t, w):  #add teleport thing
     Action.__init__(self, array, v_t, w)
コード例 #14
0
    def getActionImpl(self):
        col = self.obs['hasCollided'].val
        camPos = self.obs['cameraPosition']
        camRot = self.obs['cameraRotation']
        pose = [camPos.x, camPos.y, camPos.z, \
                camRot.pitch, camRot.roll, camRot.yaw]

        if self.last_pose != pose:
            self.last_pose = pose
            self.still_counter = 0
        else:
            self.still_counter += 1

        print('{}: {}'.format('self.mode', self.mode))
        print('{}: {}'.format('pose', pose))
        print('{}: {}'.format('col', col))
        print()

        if self.angle:
            diff = angdiff(self.angle, camRot.yaw)

        # if self.still_counter > 15:
        #     print('quit\n')
        #     quit()
        #
        # el
        if self.mode == 0 and self.angle is None:
            self.angle = random.uniform(-self.PI, self.PI)
            action = Action(v_t=0.0, w=0.0)

        elif self.mode == 0 and abs(diff) > self.TOLERANCE:
            speed = self.ROT_SPEED * diff
            action = Action(v_t=0.0, w=speed)

        elif self.mode == 0 and abs(diff) < self.TOLERANCE:
            action = Action(v_t=0.0, w=0.0)
            self.mode = 1

        elif self.mode == 1 and not col:
            action = self.smartAction()
            ############################

        elif self.mode == 1 and col:
            self.flight_duration = random.uniform(0.5, 2.5)
            self.mode = 2

            self.angle = None
            action = Action(v_t=0.0, w=0.0)
            self.last_time = time.time()

        elif self.mode == 2 and time.time() - self.last_time <= 1.5:
            action = Action(v_t=0.0, w=0.0)

        elif self.mode == 2 and time.time() - self.last_time > 1.5:
            self.mode = 3
            action = Action(v_t=-self.SPEED, w=0.0)
            self.last_time = time.time()

        elif self.mode == 3 and time.time(
        ) - self.last_time <= self.flight_duration:
            action = Action(v_t=-self.SPEED, w=0.0)

        elif self.mode == 3 and time.time(
        ) - self.last_time > self.flight_duration:
            self.mode = 0
            action = Action(v_t=0.0, w=0.0)
            self.last_time = None
        action.z = -1.45

        return action
コード例 #15
0
ファイル: Cmd.py プロジェクト: sboosali/mandimus
 def __init__(self, data=None, log=False, queryOnly=False):
     Action.__init__(self, data)
     self.log = log
     self.queryOnly = queryOnly
コード例 #16
0
    def getActionImpl(self):
        camPos = self.obs['cameraPosition']
        camRot = self.obs['cameraRotation']

        col = self.obs['hasCollided'].val

        pose = [camPos.x, camPos.y, camPos.z, \
                camRot.pitch, camRot.roll, camRot.yaw]

        if self.last_pose != pose:
            self.last_pose = pose
            self.still_counter = 0
        else:
            self.still_counter += 1

        print('{}: {}'.format('pose', pose))
        print('{}: {}'.format('self.angle', self.angle))
        print('{}: {}'.format('self.mode', self.mode))
        print('{}: {}'.format('self.still_counter', self.still_counter))
        print('{}: {}'.format('col', col))
        print()

        if self.angle:
            diff = angdiff(self.angle, camRot.yaw)
            diff = 0

        if not self.DEBUG:

            # if self.still_counter > 15:
            #     quit()
            #
            # el
            if self.mode == 0 and self.angle is None:
                self.angle = random.uniform(-0.1, 0.1)
                self.dumbAction = Action(v_t=0.0, w=0.0)

            elif self.mode == 0 and abs(diff) > self.TOLERANCE:
                speed = self.ROT_SPEED * diff
                # if angdiff(self.angle, camRot.yaw) < 0:
                # speed *= -1
                self.dumbAction = Action(v_t=0.0, w=speed)

            elif self.mode == 0 and abs(diff) < self.TOLERANCE:
                self.dumbAction = Action(v_t=self.SPEED, w=self.angle)
                self.mode = 1
                self.last_time = time.time()

            elif self.mode == 1 and time.time() - self.last_time > 5:
                duration = random.uniform(0, time.time() - self.last_time)
                self.flight_duration = max(duration, 0.5)
                self.mode = 2

                self.angle = None
                self.dumbAction = Action(v_t=0.0, w=0.0)
                self.last_time = time.time()

            elif self.mode == 2 and time.time() - self.last_time > 1.5:
                self.mode = 3
                self.dumbAction = Action(v_t=-self.SPEED, w=0.0)
                self.last_time = time.time()

            elif self.mode == 3 and time.time(
            ) - self.last_time > self.flight_duration:
                self.mode = 0
                self.dumbAction = Action(v_t=0.0, w=0.0)
                self.last_time = None

        if self.DEBUG:
            self.debugAction()

        print('Linear %f, Angular %f' %
              (self.dumbAction.v_t, self.dumbAction.w))

        self.dumbAction.meta['visualbackprop'] = False
        return self.dumbAction
コード例 #17
0
 def debugAction(self):
     if self.mode == 0:
         self.dumbAction = Action(v_t=self.SPEED, w=0.0)
         self.mode = 1
コード例 #18
0
    def getActionImpl(self):
        obs = self.obs
        npimg = obs['img'].decompressPNG()[:, :, 0:3]
        cropped_imgs = self.cropImageToThree(npimg)
        collision_free_prob = []
        softmax = torch.nn.Softmax()
        probs = None
        for idx, cropped_img in enumerate(cropped_imgs):
            if self.usegpu:
                img = Variable(self.toTensor(cropped_img).unsqueeze_(0).cuda())
            else:
                img = Variable(self.toTensor(cropped_img).unsqueeze_(0))
            classActivation = self.model(img)
            collision_free_pred = classActivation.data
            if idx == 1:
                probs = self.model.getClassifications(classActivation, softmax)
            collision_free_prob.append(
                softmax(Variable(collision_free_pred))[0,
                                                       1].data.cpu().numpy())
        #
        # collision free probability
        left_prob, center_prob, right_prob = collision_free_prob
        left_prob, center_prob, right_prob = [
            left_prob[0], center_prob[0], right_prob[0]
        ]
        action_array = np.zeros(self.action_array_dim)
        if center_prob > self.straight_min_prob:
            action_array[int(self.action_array_dim / 2)] = 1
            action = Action(action_array)

        elif left_prob < self.stop_min_prob and center_prob < self.stop_min_prob and right_prob < self.stop_min_prob:
            action = Action(action_array)

        elif left_prob > right_prob and left_prob < self.turn_min_prob:
            action_array[0] = 1
            action = Action(action_array)

        elif right_prob >= left_prob and right_prob < self.turn_min_prob:
            action_array[-1] = 1
            action = Action(action_array)

        elif left_prob > right_prob:
            action = Action(v_t=left_prob * self.max_v_t,
                            w=left_prob * self.max_w)

        else:
            action = Action(v_t=right_prob * self.max_v_t,
                            w=right_prob * self.max_w)
        # action = Action(action_array)
        print(
            '_____________________________________________________________________________________________________________________________________'
        )
        print("Collsion Free Prob: left:{} center:{} right:{}".format(
            collision_free_prob[0], collision_free_prob[1],
            collision_free_prob[2]))
        print("Linear Velocity: {} Angular Velocity: {}".format(
            action.v_t, action.w))
        #
        # Place the activations for visualization.
        action.meta['activations'] = probs.cpu().numpy()[0]
        #
        # Do more stuff.
        return action
コード例 #19
0
ファイル: MultiTrajAgent.py プロジェクト: younghj/flot
    def getActionImpl(self):
        obs = self.obs
        npimg = obs['img'].uint8Img
        # If image is available
        if npimg is not None:
            collision_free_prob = []
            softmax = torch.nn.Softmax()
            probs = None
            vbp = None
            img = self.t(npimg)
            if self.usegpu:
                img = Variable(img.unsqueeze_(0).cuda(async=True))
            else:
                img = Variable(img.unsqueeze_(0))

            classActivation = self.model(img)
            collision_free_pred = classActivation.data
            probs = self.model.getClassifications(classActivation, softmax)
            if self.useVisualBackProp:
                # tmp = self.ToPIL(self.visualbackprop.visualize(img).squeeze_())
                tmp = self.visualbackprop.visualize(img)
                combined = combine(npimg, tmp, self.model_input_img_shape)
                vbp = Image.fromarray(combined.astype('uint8'), 'RGB')

            collision_free_prob = probs.numpy()[0]

            # collision free probability
            left_prob, center_prob, right_prob = collision_free_prob[
                0], collision_free_prob[1], collision_free_prob[2]
            action_array = np.zeros(self.action_array_dim)
            if center_prob > self.straight_min_prob:
                #action_array[int(self.action_array_dim/2)] = 1
                #action = Action(action_array)
                action = Action(v_t=self.max_v_t, w=0)

            elif left_prob < self.stop_min_prob and center_prob < self.stop_min_prob and right_prob < self.stop_min_prob:
                action = Action(action_array)

            elif center_prob < self.back_min_prob:
                action = Action(v_t=-1.25 * self.max_v_t, w=0)

            elif left_prob > right_prob and left_prob < self.turn_min_prob:
                action_array[-1] = 1
                action = Action(action_array)

            elif right_prob >= left_prob and right_prob < self.turn_min_prob:
                action_array[-1] = 1
                action = Action(action_array)

            elif left_prob > right_prob:
                action = Action(v_t=left_prob * self.max_v_t,
                                w=left_prob * self.max_w)

            else:
                action = Action(v_t=right_prob * self.max_v_t,
                                w=right_prob * self.max_w)
            #action = Action(action_array)
            print(
                '_____________________________________________________________________________________________________________________________________'
            )
            print("Collsion Free Prob: left:{} center:{} right:{}".format(
                collision_free_prob[0], collision_free_prob[1],
                collision_free_prob[2]))
            print("Linear Velocity: {:.2f} Angular Velocity: {:.2f}".format(
                action.v_t, action.w))

            # Place the activations for visualization.
            action.meta['activations'] = probs.cpu().numpy()[0]
            action.meta['visualbackprop'] = vbp

        # Take no action when no image is available
        else:
            action = Action(v_t=0, w=0)

        # Do more stuff.
        return action
コード例 #20
0
 def __init__(self, array, v_t, w):
     Action.__init__(self, array, v_t, w)
コード例 #21
0
ファイル: MultiTrajAgent.py プロジェクト: younghj/flot
    def __init__(self, conf):
        super(Agent, self).__init__(conf)
        self.conf = conf
        self.toTensor = transforms.ToTensor()
        #
        # Check if cuda is available.
        self.usegpu = torch.cuda.is_available() and self.conf.usegpu
        self.ToPIL = transforms.ToPILImage()
        #
        # If you want to use visualbackprop
        self.useVisualBackProp = True
        #
        # Load the model.
        if self.conf.modelLoadPath != None and os.path.isfile(
                self.conf.modelLoadPath):
            if self.usegpu:
                checkpoint = torch.load(self.conf.modelLoadPath)
            else:
                print('Running the agent on CPU!')
                checkpoint = torch.load(self.conf.modelLoadPath,
                                        map_location={'cuda:0': 'cpu'})
            self.model = checkpoint['model']
            if self.useVisualBackProp:
                self.visualbackprop = VisualBackProp(self.model)
            self.nnconf = checkpoint['conf']
            self.model.load_state_dict(checkpoint['state_dict'])
            printColour('Loaded model from path: %s' % self.conf.modelLoadPath,
                        colours.OKBLUE)
        else:
            printError('Could not load model from path: %s' %
                       self.conf.modelLoadPath)
            raise RuntimeError

        if self.usegpu:
            self.model.cuda()

        self.model.eval()

        self.model_input_img_shape = conf.image_shape
        norm = transforms.Normalize([0, 0, 0], [1, 1, 1])
        tnn = self.nnconf.transforms
        crop = transforms.CenterCrop(self.nnconf.hyperparam.cropShape)
        for tf in tnn.transforms:
            if isinstance(tf, DataUtil.Normalize):
                norm = tf.norm
                break
        self.t = transforms.Compose([crop, transforms.ToTensor(), norm])
        #
        # Rescale transforms.
        if any(isinstance(tf, DataUtil.Rescale) for tf in tnn.transforms):
            self.model_input_img_shape = (self.nnconf.hyperparam.cropShape[0],
                                          self.nnconf.hyperparam.cropShape[1],
                                          3)
            self.t = transforms.Compose([
                transforms.ToPILImage(),
                crop,
                transforms.Resize(self.nnconf.hyperparam.image_shape),
                transforms.ToTensor(),
                norm,
            ])
        else:
            print('there is no rescale')
        #
        # Heuristic Parameters
        #
        # action dim for array
        self.action_array_dim = 11
        #
        # minimum probability of collision free to go straight
        self.straight_min_prob = 0.60
        #
        # minimum probability of collision free to stop
        self.stop_min_prob = 0.0
        #
        # min turning probabilty
        self.turn_min_prob = 0.70
        #
        #
        self.back_min_prob = 0.07
        # max vt w
        action_ = Action(np.zeros(self.action_array_dim))
        self.max_v_t = action_.max_v_t
        self.max_w = action_.max_w
コード例 #22
0
ファイル: Agent.py プロジェクト: yangwangaaa/ADPRL2015
 def actionset(self, state):
     """ Returns set of actions possible in state, used for staying in goal state """
     if state.pos == self.goal:
         return [Action()]
     else:
         return self.actions
コード例 #23
0
ファイル: Cmd.py プロジェクト: jgarvin/mandimus
 def __init__(self, data=None, log=False, queryOnly=False):
     Action.__init__(self, data)
     self.log = log
     self.queryOnly = queryOnly
コード例 #24
0
class UI():

    action = Action()

    def run_main_window(self):

        self.root = Tk()
        self.root.title('PyfoC')
        self.root.geometry('260x290')
        self.root.resizable(False, False)

        self.first_menu_item_label = Label(self.root, text="1.")
        self.first_menu_item_label.grid(column=1, row=0, sticky=E)

        self.second_menu_item_label = Label(self.root, text="2.")
        self.second_menu_item_label.grid(column=1, row=2, sticky=E)

        self.third_menu_item_label = Label(self.root, text="3.")
        self.third_menu_item_label.grid(column=1, row=4, sticky=E)

        self.fourth_menu_item_label = Label(self.root, text="4.")
        self.fourth_menu_item_label.grid(column=1, row=7, sticky=E)

        self.appdata_lable = Label(
            self.root, text="-- Operations with AppData -----------")
        self.appdata_lable.grid(column=2,
                                row=0,
                                columnspan=2,
                                pady=3,
                                sticky=W)

        self.open_appdata_folder_button = Button(
            self.root,
            text="Open AppData",
            command=self.action.open_appdata_folder)
        self.open_appdata_folder_button.grid(row=1, column=2)

        self.clear_appdata_button = Button(self.root,
                                           text="Clear AppData",
                                           command=self.action.clear_appdata)
        self.clear_appdata_button.grid(row=1, column=3)

        self.logs_lable = Label(self.root,
                                text="-- Operations with Logs ---------------")
        self.logs_lable.grid(column=2, row=2, columnspan=2, pady=3, sticky=W)

        self.open_logs_folder_button = Button(
            self.root, text="Open Logs", command=self.action.open_logs_folder)
        self.open_logs_folder_button.grid(row=3, column=2)

        self.delete_logs_button = Button(self.root,
                                         text="Delete Logs",
                                         command=self.action.del_logs)
        self.delete_logs_button.grid(row=3, column=3)

        self.CUE_lable = Label(self.root,
                               text="-- Operations with CUE ----------------")
        self.CUE_lable.grid(column=2, row=4, columnspan=2, pady=3, sticky=W)

        self.start_CUE_button = Button(self.root,
                                       text="Start CUE",
                                       command=self.action.start_CUE)
        self.start_CUE_button.grid(row=5, column=2)

        self.close_CUE_button = Button(self.root,
                                       text="Close CUE",
                                       command=self.action.close_CUE)
        self.close_CUE_button.grid(row=5, column=3)

        self.clear_appdata_check = IntVar()
        self.with_cleared_appdata_checkbutton = Checkbutton(
            self.root,
            text='with cleared AppData',
            variable=self.clear_appdata_check,
            onvalue=1,
            offvalue=0)
        self.with_cleared_appdata_checkbutton.grid(row=6,
                                                   column=3,
                                                   pady=5,
                                                   sticky=W)

        self.restart_CUE_button = Button(
            self.root,
            text="Restart CUE",
            command=self.get_clear_appdata_check_state)
        self.restart_CUE_button.grid(row=6, column=2, pady=5, ipadx=5)

        self.builds_downloading_lable = Label(
            self.root, text="-- Build's downloading ----------------")
        self.builds_downloading_lable.grid(column=2,
                                           row=7,
                                           columnspan=2,
                                           pady=3,
                                           sticky=W)

        self.get_builds_button = Button(self.root,
                                        text="get",
                                        command=self.action.get_builds_list)
        self.get_builds_button.grid(row=8, column=2, sticky=E)

        self.downloading_builds_button = Button(self.root,
                                                text="Download",
                                                command=self.action.close_CUE)
        self.downloading_builds_button.grid(row=9, column=3, sticky=E)

        self.build = StringVar()
        self.choose_build_combobox = ttk.Combobox(self.root,
                                                  textvariable=self.build,
                                                  values=builds[::-1],
                                                  state='readonly',
                                                  height=6,
                                                  width=5)
        self.choose_build_combobox.grid(row=8, column=2, sticky=W)

        self.builds_versions = StringVar()
        self.builds_versions_list = []
        self.choose_builds_versions_combobox = ttk.Combobox(
            self.root,
            textvariable=self.builds_versions,
            values=self.builds_versions_list,
            state='readonly',
            height=10,
            width=18)
        self.choose_builds_versions_combobox.grid(row=8, column=3, sticky=E)

        self.root.mainloop()

    def get_clear_appdata_check_state(self):
        self.state = self.clear_appdata_check.get()
        self.action.restart_CUE(self.state)
コード例 #25
0
ファイル: Automate.py プロジェクト: Yeab1/No-Hands
def on_scroll(x,y,dx,dy):
    newScroll = Action("scroll")
    newScroll.setPosition(x, y)
    newScroll.setSpeed(dx, dy)

    allActions.append(newScroll)
コード例 #26
0
ファイル: Automate.py プロジェクト: Yeab1/No-Hands
        window['-Errors-'].update("Press 'ESC' stop recording")
        mouse = threading.Thread(target = mouseAction)
        keys = threading.Thread(target = keyBoardAction)

        mouse.start()
        keys.start()
        mouse.join()
        keys.join()
        
    if event == "Stop Recording":
        window['-Errors-'].update("Recording Stopped")
        
    if event == "Wait (in Seconds)":
        try:
            waitTime = int(values["-waitTime-"])
            currWaitTime = Action("wait")
            currWaitTime.setWaitTime(waitTime)
            allActions.append(currWaitTime)
            
        except (ValueError):
            window['-Errors-'].update("Please insert time to wait in seconds")
            
    if event == "Start Wait":
        window['-Errors-'].update("Waiting Started.")
        startTime = time.time()
        
    if event == "Stop Wait":
        stopTime = time.time()
        window['-Errors-'].update("Wait time recorded.")
        
    if startTime and stopTime: