def enter():
    global stage2, player, mermadiaList, ui, portal, mermadiaCount, stage2Bgm, storeSound
    stage2 = Stage2()
    player = Player(340)
    lizard = Lizard(player.x)
    ui = UI()
    portal = Portal(1125, 200)

    stage2Bgm = load_music('Stage2Bgm.mp3')
    stage2Bgm.set_volume(100)
    stage2Bgm.repeat_play()

    storeSound = load_wav('StoreSound.wav')
    storeSound.set_volume(64)

    f = open("stageInfoLoad.txt", 'r')
       
    data = f.readline()
    ui.money = int(data)
    
    data = f.readline()
    ui.score = int(data)
    f.close()

    for i in range(0, 14):
        mermadiaList.append(Mermadia())
        mermadiaCount += 1
def main(path, refresh_rate):

    run_info = RunInfo(path)
    towerbloxx = Towerbloxx(run_info)
    ui = UI(towerbloxx, refresh_rate)
    
    ui.show()
Exemple #3
0
def main():
    logger.info("Start Kiosk")
    #    try:
    if True:
        NC = NoteControl("test.ini")
        window = UI(NC)
        window.main()
    #    except Exception, e:
    #        logger.error('Unable to start Kiosk. %s' % (e.message,))
    logger.info("Kiosk finished")
 def savenext(self, obj):
     try:
         self.save(obj)
     except NotValid:
         self.error("Data not valid")
         return
     item = self.stores.get_item(self.filename, self)
     UI.save_previous(self, item)
     self.sameButton.set_sensitive(1)
     self.next(obj)
     self.saveable(self.stores.is_dirty())
Exemple #5
0
def main():
    '''
    Main function for user iteractions
    '''
    if (len(sys.argv) == 1):
        folderpath = get_folder_from_user()
    else:
        folderpath = sys.argv[1]
        if not os.path.isdir(folderpath):
            folderpath = get_folder_from_user()
    user_interface = UI(folderpath)
    user_interface.show()
    def transfer(self):
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
        #             H O H M A N N              #
        #            T R A N S F E R             #
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

        self.control.rcs = False
        self.control.throttle = 0
        time.sleep(1)
        self.ap.reference_frame = self.vessel.orbital_reference_frame
        self.ap.target_direction = (0, 1, 0)
        self.ap.engage()
        print(self.mode)
        ui = UI()

        while self.mode != "Xfered":

            if self.mode == "LEO":
                _hoh_xfer_dv = self.transfer_injection_dv(self.mu, self.semi_major_axis(), self.target_orbit_radius)
                _time_to_burn = self.time_to_burn(self.ETA_pe(), self.maneuver_burn_time(_hoh_xfer_dv))

                if _time_to_burn > 120: self.KSC.warp_to(self.ut() + _time_to_burn - 90)
                elif _time_to_burn > 34: self.fix_aoa(_time_to_burn, self.maneuver_burn_time(_hoh_xfer_dv))
                elif _time_to_burn < 5: self.ullage_rcs(); self.mode = "Xfer Burn"

            if self.mode == "Xfer Burn":
                self.control.rcs = False
                if self.apoapsis_radius() > self.target_orbit_radius:
                    self.control.throttle = 0
                    time.sleep(1)
                    self.mode = "Xfer Cruise"

            if self.mode == "Xfer Cruise":
                _time_to_burn = self.time_to_burn(self.ETA_ap(), self.maneuver_burn_time(self.circ_dv()))

                if _time_to_burn > 120: self.KSC.warp_to(self.ut() + _time_to_burn - 90)
                elif _time_to_burn > 34: self.fix_aoa(_time_to_burn, self.maneuver_burn_time(self.circ_dv()))
                elif _time_to_burn < 5:
                    self.ullage_rcs()
                    self.mode = "Final Burn"

            if self.mode == "Final Burn":
                self.control.rcs = False
                if (self.circ_dv() < 10) or (self.orbital_period(self.target_orbit_radius, self.mu) < self.period()):
                    self.control.throttle = 0
                    time.sleep(1)
                    self.mode = "Xfered"

            time.sleep(.05)
            ui.transfer(self.mode)

        print("Done")
def main():
    window = Tk()
    window.title("Score DataBase Management Program")

    #모듈 객체 생성
    ui = UI(window)
    data_admin = dataadmin.dataadmin(ui)
    file_admin = fileadmin.FileAdmin(ui, data_admin)

   #ui의 button초기화
    ui.get_dataModule(data_admin)
    ui.get_fileModule(file_admin)

    window.mainloop()
Exemple #8
0
def main():
    if not has_ttk():
        tkMessageBox.showerror("No ttk",
                "No ttk module (Python/Tkinter too old?).\nPeanuts won't run.")
    else:
        controller = BoardController()
        ui = UI(about=about, preferences=preferences, controller=controller,
                app_title='Peanuts',
                min_board_width=400, board_width=500,
                no_pil=('no_pil' in sys.argv))
        controller.open_collection('problems/')
        controller.next_problem()
        if not has_pil():
            tkMessageBox.showwarning("No PIL", "No PIL library found.")
        ui.run()
Exemple #9
0
    def launch(self):
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
        #              L A U N C H               #
        #             P R O G R A M              #
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

        self.ap.engage()
        print("For 300km Parking Orbit - Moon Shot launch at LAN = 334.56846 - 6.68379")
        _tp = self.orbital_period(self.parking_orbit_alt + self.radius_eq, self.mu)
        ui = UI()

        while self.mode == "Launch Prep":
            if self.control.get_action_group(9):
                self.control.throttle = 1
                self.stage()
                self.mode = "Launch"

        while self.mode != "Orbit":
            self.pitch_and_heading()

            if self.falafels is True:
                if self.altitude() > 80000:
                    self.control.toggle_action_group(8)
                    self.falafels = False

            if self.mode == "Launch":
                _twr = self.twr_calc(self.thrust(), self.mass(), self.altitude(), self.radius_eq, self.mu)
                if _twr > 1:
                    self.lAz_data = self.azimuth_init()
                    self.stage()
                    self.mode = "Booster"

            if self.mode == "Booster":
                self.flameout("Core Stage")

            if self.mode == "Core Stage":
                self.flameout("Orbit Insertion")

            if self.mode == "Orbit Insertion":
                if (self.circ_dv() < 10) or (_tp < self.period()):
                    self.control.throttle = 0
                    self.mode = "Orbit"

            if self.circ_dv() > 500: time.sleep(.1)
            ui.gravity_turn(self.mode)

        ui.remove_ui()
        self.launch_final()
Exemple #10
0
class Linux(object):
    def __init__(self, modules, rpyc=None, modules_user=None, rpyc_user=None):
        self._modules = modules
        self._modules_user = modules_user
        self._rpyc = rpyc
        self._rpyc_user = rpyc_user
        self._shell = Shell(self._modules, self._rpyc, self._modules_user)
        if self._rpyc is not None:
            self._ip = self.cmd("netstat -na | grep ':18812.*ESTABLISHED' | head -1 | tr ':' ' ' | awk {'print $4'}", shell=True).stdout.read().strip()
        else:
            self._ip = "127.0.0.1"


    def __del__(self):
        if self._rpyc is not None:
            self._rpyc.close()

    def start(self):
        self._shell.wait_process_by_short_name("Xorg")
        time.sleep(10)
        self._ui = UI(self._shell)
        self._ui.start()

    def stop(self):
        self._ui.stop()
        self.cmd('pkill rpyc', infrastructure=True)

    @property
    def modules(self):
        return self._modules

    @property
    def shell(self):
        return self._shell

    @property
    def ui(self):
        return self._ui

    @property
    def ip(self):
        return self._ip

    def cmd(self, cmdline, *args, **kw):
        return self.shell.cmd(cmdline, *args, **kw)
Exemple #11
0
class Linker():
	def __init__(self):
		self.stateDict = {}
	
		print "starting Table init"
		self.tableObj = Table()
		p1 = Player("p1", 1000)
		p2 = Player("p2", 1000)
		p3 = Player("p3", 1000)
		self.tableObj.addPlayer(p1)
		self.tableObj.addPlayer(p2)
		self.tableObj.addPlayer(p3)
		self.tableObj.beginRound()
		print "starting UI"
		self.UIObj = UI(self)
		self.UIObj.loop()
		
	def linkCall(self):
		self.tableObj.call(self.tableObj.playerList[self.tableObj.turn])
		
	def linkRaise(self, amount):
		self.tableObj.raiseBet(self.tableObj.playerList[self.tableObj.turn], amount)
		
	def linkFold(self):
		self.tableObj.fold(self.tableObj.playerList[self.tableObj.turn])
		
	def checkForUpdate(self):
		if self.tableObj.stateDict != {}:
			statePickle = cPickle.dumps(self.tableObj.stateDict)
			self.tableObj.stateDict = {}
			return statePickle
		else:
			return None
		
	def printTableState(self):
		gameStateMapping = ["PREFLOP","FLOP","TURN","RIVER"]
	
		print "Player List: {0}".format(self.tableObj.playerList)
		print "Betting Round: {0}".format(gameStateMapping[self.tableObj.gameState])
		print "Pots: {0}\tCurrent Bet: {1}".format(self.tableObj.pots, self.tableObj.currentBet)
		print "Player: {0}\tHand: {1}".format(	self.tableObj.playerList[self.tableObj.turn].name, \
												Cards.convertNumToCards(self.tableObj.playerList[self.tableObj.turn].hand) )
		print "Money: {0}\tBet Amount: {1}".format(self.tableObj.playerList[self.tableObj.turn].money, self.tableObj.playerList[self.tableObj.turn].betAmount)
		print "Community: {0}".format(Cards.convertNumToCards(self.tableObj.communityCards))
Exemple #12
0
 def run(soc, recvdata, queue):
     comlist = recvdata.split()
     commandname = comlist.pop(0)
     if commandname == 'gamestart':
         gameWindow = UI(900,600, soc, queue, comlist[0],comlist[1],comlist[2])
         gameWindow.start()
         queue[commandname] = comlist
         return queue
     elif commandname == 'dealcard':
         templist=queue.get(commandname,[])
         templist+=comlist
         queue[commandname]= templist
         return queue
     elif commandname == 'cardplay':
         if comlist[1] == queue['gamestart'][0]:
             for card in comlist[2:]:
                 queue['dealcard'].remove(card)
             if len(comlist)==2:
                 comlist+=['pass']
             queue['mycardplay'] = comlist[1:]
             queue['myremain'] = int(comlist[0])
         elif comlist[1] == queue['gamestart'][1]:
             if len(comlist)==2:
                 comlist+=['pass']
             queue['leftcardplay'] = comlist[1:]
             queue['leftremain'] = int(comlist[0])
         elif comlist[1] == queue['gamestart'][2]:
             if len(comlist)==2:
                 comlist+=['pass']
             queue['rightcardplay'] = comlist[1:]
             queue['rightremain'] = int(comlist[0])
         return queue
     elif commandname =='roundover':
         if comlist ==['True']:
             queue['mycardplay']=[]
             queue['rightcardplay']=[]
             queue['leftcardplay']=[]
         return queue    
     else:
         queue[commandname] = comlist
         return queue
 def __init__ (self, store, pics):
     if has_gtk == 0:
         raise GtkUnavailable
     UI.__init__(self, store)
     self.gladexml = gtk.glade.XML(GLADE_INTERFACE)
     dic = { "on_quit1_activate" : self.quit,
             "on_quit_without_saving2_activate" : self.die,
             "on_save1_activate" : self.save_store,
             "on_main_destroy" : self.die,
             "on_SaveButton_clicked" : self.savenext,
             "on_SameButton_clicked" : self.samenext,
             "on_SkipButton_clicked" : self.next,
             "on_about1_activate" : self.about,
             "on_closebutton1_clicked" : self.about_close,
             "on_saveandquit_activate" : self.savequit,
             }
     self.gladexml.signal_autoconnect(dic)
     self.status = self.gladexml.get_widget("Status")
     self.name = self.gladexml.get_widget("ImageName")
     self.title = self.gladexml.get_widget("TitleField")
     self.desc = self.gladexml.get_widget("DescriptionField")
     self.image = self.gladexml.get_widget("Image")
     self.saveButton= self.gladexml.get_widget("SaveButton")
     self.sameButton= self.gladexml.get_widget("SameButton")
     self.skipButton= self.gladexml.get_widget("SkipButton")
     self.aboutbox= self.gladexml.get_widget("AboutBox")
     self.progressBar = self.gladexml.get_widget("AnswerProgress")
     abouttitle = self.gladexml.get_widget("AboutTitle")
     abouttitle.set_label(re.sub("VERSION", Version.v, abouttitle.get_label()))
     self.args = pics
     if len(self.args) > 0:
         self.progress_step = 1.0 / len(self.args)
         self.show_picturedata(self.args[0])
         self.args = self.args[1:]
     else:
         self.error("No image specified")
         sys.exit(0)
     gtk.main()
     sys.exit(0)
Exemple #14
0
    def transfer(self):
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
        #               L U N A R                #
        #            T R A N S F E R             #
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

        self.xfer_setup()
        self.KSC.warp_to(self.ut() + self.injection_ETA() - 240)
        ui = UI()

        while self.injection_ETA() > 140:
            ui.transfer(self.mode)
            time.sleep(1)

        self.ullage_rcs()
        self.control.throttle = 1

        while self.apoapsis_radius() < 400000000:
            if self.eng_status(self.get_active_engine(), "Status") == "Flame-Out!": self.stage()
            time.sleep(.1)
            ui.transfer(self.mode)

        self.control.throttle = 0
Exemple #15
0
	def __init__(self):
		self.stateDict = {}
	
		print "starting Table init"
		self.tableObj = Table()
		p1 = Player("p1", 1000)
		p2 = Player("p2", 1000)
		p3 = Player("p3", 1000)
		self.tableObj.addPlayer(p1)
		self.tableObj.addPlayer(p2)
		self.tableObj.addPlayer(p3)
		self.tableObj.beginRound()
		print "starting UI"
		self.UIObj = UI(self)
		self.UIObj.loop()
Exemple #16
0
    def attack(self, attack, defend, retaliate = False):
        ind1, ind2 = None, None

        if attack[2] == 1:
            army_a = self.__army1
            army_d = self.__army2
        else:
            army_a = self.__army2
            army_d = self.__army1

        for i in range(0, len(army_a.stacks)):
            if attack[1] == army_a.stacks[i].type:
                ind1 = i
                break
        for i in range(0, len(army_d.stacks)):
            if defend[1] == army_d.stacks[i].type:
                ind2 = i
                break

        if army_a.stacks[ind1].attack > army_d.stacks[ind2].defence:
            damage = army_a.stacks[ind1].quantity * \
                     np.random.choice(np.linspace(army_a.stacks[ind1].dmg[0],
                                                  army_a.stacks[ind1].dmg[1], 100)) * \
                     (1 + 0.05 * (army_a.stacks[ind1].attack - army_d.stacks[ind2].defence))
        else:
            damage = army_a.stacks[ind1].quantity * \
                     np.random.choice(np.linspace(army_a.stacks[ind1].dmg[0],
                                                  army_a.stacks[ind1].dmg[1], 100)) / \
                     (1 + 0.05 * (army_d.stacks[ind2].defence - army_a.stacks[ind1].attack))
        UI.print_dmg(damage, army_a.stacks[ind1].type)
        least_hp = (((army_d.stacks[ind2].quantity - 1) * army_d.stacks[ind2].base_hp) +
                    army_d.stacks[ind2].hp) - damage
        if least_hp > 0:
            UI.print_quantity_diff(army_d.stacks[ind2].quantity, least_hp // army_d.stacks[ind2].base_hp + 1,
                                   army_d.stacks[ind2].type)
            army_d.stacks[ind2].quantity = least_hp // army_d.stacks[ind2].base_hp + 1
            army_d.stacks[ind2].hp = least_hp % army_d.stacks[ind2].base_hp
            if army_d.stacks[ind2].retaliate and retaliate is False:
                army_d.stacks[ind2].retaliate = False
                self.attack(defend, attack, retaliate=True)
        else:
            UI.print_dead(army_d.stacks[ind2].type)
            army_d.stacks[ind2].kill()
            for i in range(0, len(self.__init)):
                if self.__init[i][1] == defend[1] and self.__init[i][2] == defend[2]:
                    arr = list(self.__init)
                    self.__init = deque(arr[0:i] + arr[i + 1:])
                    break
            if self.count_stacks(defend[2]) == 0:
                self.__isCompleted = True
                self.__winner = attack[2]

        if retaliate is False and len(self.__init) != 0 and self.__init[0] == attack:
            self.__init.popleft()
Exemple #17
0
    def __init__(self):
        super().__init__()
        self.app = QApplication(sys.argv)

        self.gray_color_table = [qRgb(i, i, i) for i in range(256)]

        # self.int_validator = QRegExpValidator(QRegExp("^([+-]?[0-9]\d*|0)$"))
        self.uint_validator = QRegExpValidator(QRegExp("^([+]?[0-9]\d*|0)$"))
        self.glevel_validator = QRegExpValidator(QRegExp("\\b(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\b"))
        self.ratio_validator = QRegExpValidator(QRegExp("0+([.][0-9]+)?|1([.]0)?"))
        self.float_validator = QRegExpValidator(QRegExp("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)"))

        self.ui = UI(title="Style Transfer")
        self.ui.transfer_btn.clicked.connect(self.transfer)
        self.ui.original_browse_btn.clicked.connect(self.set_original_image)
        self.ui.stlye_browse_btn.clicked.connect(self.set_style_image)
        self.ui.export_btn.clicked.connect(self.export)
        self.ui.get_mask_btn.clicked.connect(self.get_segmentation_mask)
        self.ui.segmentation_mode_combo.currentTextChanged.connect(self.set_stack_view)
        self.ui.grab_cut_mode_combo.currentTextChanged.connect(self.set_grab_cut_mode)
        self.ui.cv_init_level_set_combo.currentTextChanged.connect(self.set_chan_vese_init_level)
        self.ui.mcv_init_level_set_combo.currentTextChanged.connect(self.set_morphological_chan_vese_init_level)
        self.ui.fs_mcv_mode_combo.currentTextChanged.connect(self.set_fs_morphological_chan_vese_mode)

        self.set_validators()

        self.content_image = -1
        self.style_image = -1
        self.output_image = False
        self.grab_cut_mode = cv2.GC_INIT_WITH_MASK
        self.fs_morphological_chan_vese_init_level = "edges"
        self.chan_vese_init_level = "checkerboard"
        self.morphological_chan_vese_init_level = "edges"
        self.x = None
        self.c = None
        self.mask = None
Exemple #18
0
def main():
    # Get API keys
    news_api = news.News()
    news_data = news_api.getNews(datetime.today())
    news_words = news_api.get_words()
    print(news_words)

    # Get spotify playlist
    playlist = spotify.addWords(news_words)

    # Load in UI
    root = Tk()
    root.geometry("800x800+800+800")

    # Congifure user interface
    app = UI()
    app.render_news(news_data)
    app.render_playlist(playlist)
    root.mainloop()
Exemple #19
0
class Game(QWidget):
    def __init__(self):
        super().__init__()

        # 初始化变量
        self.isStart = False  # 控制键盘
        self.nowScore = 0  # 当前得分
        # 最高得分从文件夹中获取
        with open('maxScore.txt', 'r') as f:
            self.maxScore = int(f.readline())  # 最高得分

        self.grabKeyboard()  # 窗口接受键盘事件

        # 开始游戏
        self.start()

    def start(self):
        """
        开始游戏
        :return:
        """
        # 重新开始时,当前分数为0
        self.nowScore = 0  # 当前得分

        # 建立Board
        self.board = Board()

        # 建立UI界面
        self.ui = UI()
        self.ui.restartButton.clicked.connect(self.restart)  # 连接槽函数

    def restart(self):
        """
        重新开始
        :return:
        """
        self.start()
        self.ui.changeUI(self.board.board_list, self.nowScore,
                         self.maxScore)  # 刚开始有两个
        self.ui.lbt.close()
        self.ui.restartButton.setText("重新开始")
        self.ui.restartButton.setStyleSheet(
            "QPushButton{color:rgb(255,255,255);background:rgb(247,127,102);border-radius:8px;}"
        )
        self.isStart = True  # 可以开始游戏

    # 设置键盘响应操作
    def keyPressEvent(self, event):  # 响应键盘操作
        if self.isStart == True:
            if event.key() == Qt.Key_Left:
                self.nowScore = self.board.moveLeft(self.nowScore)
            if event.key() == Qt.Key_Right:
                self.nowScore = self.board.moveRight(self.nowScore)
            if event.key() == Qt.Key_Up:
                self.nowScore = self.board.moveUp(self.nowScore)
            if event.key() == Qt.Key_Down:
                self.nowScore = self.board.moveDown(self.nowScore)
            # 校检
            self.check()

    def check(self):
        """
        每次移动完都要进行判断
        :return:
        """
        # 判断一下是否赢了
        if self.isWin():
            self.isStart = False
            self.QMS = QMessageBox.information(
                self, 'YOU WIN', '成功的人\n决不步人后尘\n而是永不放弃,创新!\n希望你能更上一层楼!',
                QMessageBox.Ok)
            self.start()
        # 判断是否输了
        elif self.isLose():
            self.isStart = False
            self.QMS = QMessageBox.information(
                self, 'YOU LOSE',
                '只有经历过失败才是真正的赢\n因为你吸取了失败的教训,懂得了失败的真谛\n别灰心,再接再励!',
                QMessageBox.Ok)
            self.start()
        else:
            # 在空白的地方,随机添加2,4
            self.board.addPiece()
            # 修改当前分数
            self.ui.changeUI(self.board.board_list, self.nowScore,
                             self.maxScore)

    def isWin(self):
        # 判断游戏是否赢了
        # 空位也要找出来
        return self.board.checkWin()

    def isLose(self):
        # 判断是否输了
        return self.board.checkLose()
    def drawDefects(self, frame, defects):
        if defects is None:
            return
        #put inside each element the tie x,y and the color   true==> red   &  false ==> blue  & start of the finger and change in x and change in y
        vec = []

        #blue refer to reverse hand
        #count number of blue ties
        countDefectsBlue = 0

        #red refer to straight hand
        #count number of red ties
        countDefectsRed = 0
        countDefectsYellow = 0
        global cnt
        try:
            for i in range(defects.shape[0]):

                s, e, f, d = defects[i, 0]
                start = tuple(cnt[s][0])  #finger tip
                end = tuple(cnt[e][0])  #another finger tip
                tie = tuple(cnt[f][0])  # tie between them

                #if the distance between start line with end to the tie is less than 1000 this means that this not a tie (noise for example)
                if d < 1000:
                    continue

                cv2.line(frame, start, end, [0, 255, 0], 2)

                # find length of all sides of triangle
                a = math.sqrt(
                    (end[0] - start[0])**2 + (end[1] - start[1])**
                    2)  # distance between finger tip and another finger tip
                b = math.sqrt((tie[0] - start[0])**2 + (tie[1] - start[1])**
                              2)  # distance between finger tip and a tie
                c = math.sqrt(
                    (end[0] - tie[0])**2 + (end[1] - tie[1])**
                    2)  # distance between another finger tip and a tie

                # apply cosine rule here
                angle = math.acos(
                    (b**2 + c**2 - a**2) / (2 * b * c)) * 180 / 3.14

                #get distance between finger tips in X and Y
                dx = abs(start[0] - end[0])
                dy = abs(start[1] - end[1])

                #if the angle between fingers tips is less than 60 and difference in X is larger than Y it can be W, V, A or M
                if angle <= 60:
                    if (dx > dy):
                        if abs(tie[1] - start[1]) > dy and abs(tie[1] -
                                                               end[1]) > dy:
                            # if the tie y axis is less than y axis for any of the two finger tips then  the hand is reversed
                            if tie[1] < start[1] or tie[1] < end[1]:
                                countDefectsBlue += 1  # increment the blue defects
                                vec.append(
                                    (start, tie, 1, end)
                                )  # push the tie into the array to print later
                            # if the tie y axis is larger than y axis for any of the two finger tips then  the hand is straight
                            elif tie[1] > start[1] or tie[1] > end[1]:
                                countDefectsRed += 1  # increment the red defects
                                vec.append(
                                    (start, tie, 0, end)
                                )  # push the tie into the array to print later
                #if the angle between fingers tips is 90 to 110 it can be L
                elif angle < 110 and angle >= 70:
                    # y0 is the finger tip with less Y
                    y0, y1 = start, end
                    if start[1] < end[1]:
                        y0 = start
                        y1 = end
                    else:
                        y0 = end
                        y1 = start
                    #if the change in x axis between the finger and the tie is less than the shorter finger and the tie
                    if abs(y0[0] - tie[0]) < abs(y1[0] - tie[0]) and abs(
                            y0[1] - tie[1]) > 1.5 * abs(y1[1] - tie[1]):
                        countDefectsYellow += 1  # increment the yellow defects
                        vec.append((
                            start, tie, 2,
                            end))  # push the tie into the array to print later

            interface = UI()
            #print the ties
            interface.printTies(frame, vec, countDefectsRed, countDefectsBlue,
                                countDefectsYellow)
            #print Characters by count and color of points
            interface.identifyChar(frame, countDefectsRed, countDefectsBlue,
                                   countDefectsYellow)

        except Exception as e:
            print(e)
Exemple #21
0
 def setUp(self):
     tfi = TextFileInterface(relative_directory="TestDB/")
     self.environment = Environment(tfi)
     self.ui = UI(self.environment)
     self.environment.database.clear_database()
Exemple #22
0
from UI import UI
from Logging import Logging
UI.about()
Exemple #23
0
    print(50.0 / (t1 - t0))

    mean = torch.Tensor([0.485, 0.456, 0.406]).cuda()
    std = torch.Tensor([0.229, 0.224, 0.225]).cuda()

    # camera = USBCamera(width=WIDTH, height=HEIGHT, capture_fps=15)
    camera = CSICamera(width=WIDTH, height=HEIGHT, capture_fps=15)

    return ut, camera, model_trt

    # while True:
    #     image = camera.read()
    #     data = ut.preprocess(image)
    #     cmap, paf = model_trt(data)
    #     cmap, paf = cmap.detach().cpu(), paf.detach().cpu()
    #     # counts, objects, peaks = ut.parseObjects(cmap, paf)
    #     counts, objects, peaks = ut.parseObjects(cmap, paf)
    #     ut.drawObjects(image, counts, objects, peaks)
    #     cv2.imshow("Image", image)
    #     # cv2.waitKey(0)
    #     if cv2.waitKey(1) & 0xFF == ord('x'):
    #         break

    # cv2.destroyAllWindows()


if __name__ == "__main__":
    ut, camera, model_trt = load_model_and_run()
    ui = UI(ut, camera, model_trt)
from UI import UI
from ADT import ADT

DirectedGraph = ADT()
Menu = UI(DirectedGraph)

Menu.StartMenu()
Exemple #25
0
from processing.color_processing import mean_color_in_contour, predict_color
from processing.image_processing import image_saving, draw_bouding_box, eraze_backgraund, white_balance
from Detection import feature_vector
from Camera import VideoStream
from NNModel import Model
from UI import UI
from K_Means_model import K_Means
import cv2
import time

# Настройка робота
robot = RobotPulse('10.10.10.20:8081')

# Вызов UI
app = QApplication(sys.argv)
interface = UI(app)
interface.show()

# Инициализация и подгрузка нейронной сети, задание смещения камеры
nn_model = Model()
KMeans = K_Means()
stream = VideoStream(0)
robot.change_base(position([0, 0, 0], [0, 0, 0]))
roll, pitch = -0.016667, 0.012
robot.change_base(position([0, 0, -0.132], [-roll, -pitch, 0]))
src = 0


def create_tool(radius, height, name):
    """
    The tool is created as cylinder with R = radius and H = height
Exemple #26
0
 def start(self):
     self._shell.wait_process_by_short_name("Xorg")
     time.sleep(10)
     self._ui = UI(self._shell)
     self._ui.start()
Exemple #27
0
                print("You clicked ", self.hanlder_list_song_remove.__name__)
                # Todo

        def hanlder_list_song_double_clicked(self, view):
                print("You double clicked ", self.hanlder_list_song_double_clicked.__name__)
                # Todo

        def hanlder_list_change(self, selection):
                print("You clicked ", self.hanlder_list_change.__name__)
                # Todo

        def hanlder_search_song(self, button):
                print("You clicked ", self.hanlder_search_song.__name__)
                # Todo

        def hanlder_play_pause(self, button):
                print("You clicked ", self.hanlder_play_pause.__name__)
                # Todo

        def hanlder_play_next(self, button):
                print("You clicked ", self.hanlder_play_next.__name__)
                # Todo

        def hanlder_play_last(self, button):
                print("You clicked ", self.hanlder_play_last.__name__)
                # Todo

if __name__ == "__main__":
        app = UI()
        app.bind_hanlder(hanlder())
        app.main()
 def samenext(self, obj):
     item = UI.get_previous(self)
     self.title.entry.set_text(item.get_title(1))
     self.__textview_set(self.desc, item.get_description(1))
     self.savenext(obj)
from UI import UI
from page import Page
import time

display = UI ()

illustrations = [
    "test_bookpage1.png",
    "test_bookpage2.png",
    "test_bookpage3.png",
    "test_bookpage4.png"
]

raw_pages = [
    "One fish",
    "two fish",
    "red fish",
    "blue fish",
    "Hello, this is some test text.",
    "This is some more text.",
    "This is some more text.",
    "This is some more text.",
    "This is some more text.",
    "This is the last page."
]



page_callbacks = []

def make_page_callback (i):
def convent_dict2ui(child):
    ui = UI()
    ui.id = child.attrib.get('id')
    ui.frame = 'CGRectMake(0,0,0,0)'
    ui.parent = None
    ui.type = child.tag
    ui.name = ui.id + '_' + toCap(child.tag)
    if child.attrib.get('userLabel'):
        ui.name = child.attrib.get('userLabel') + toCap(child.tag)
    ui.masonry = ''
    ui.color = ''
    ui.uselabel = ''
    ui.props = child
    return ui
db.add(Discipline("FPcurs"))
db.add(Discipline("FPlab"))
db.add(Discipline("FPseminar"))
db.add(Discipline("Logica"))
db.add(Discipline("ASC"))
db.add(Discipline("Algebra"))
db.add(Discipline("Analiza"))
a=input("Press 1 for nonfile or 2 for file.")
if int(a)==2:
    undoCtrl=UndoController()
    sc=StudentController(fsb,undoCtrl)
    
    gc=GradeController(fgb,undoCtrl)
    dc=DisciplineController(db)
    sts=StatisticsController(gc,sc,dc)
    ui=UI(gc,sc,dc,undoCtrl,sts)
    ui.mainMenu()

    
   
elif int(a)==1:
    sb.add(Student(1,"Darius"))
    sb.add(Student(2,"Paul"))
    sb.add(Student(3,"Mark"))
    gb.add(Grade("FPcurs",1,"arthur",10))
    
    gb.add(Grade("FPseminar",2,"iuliana",10))
    gb.add(Grade("FPlab",3,"arthur",10))
    undoCtrl=UndoController()
    sc=StudentController(sb,undoCtrl)
    
    def launch(self):
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
        #              L A U N C H               #
        #             P R O G R A M              #
        # -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

        self.ap.engage()
        ui = UI()

        while self.mode == "Launch Prep":
            if self.control.get_action_group(9): self.mode = "Launch"; self.control.activate_next_stage()
            time.sleep(1)

        while self.mode != "Orbit":
            self.pitch_and_heading()

            if self.mode == "Launch":
                self.control.throttle = 1
                _twr = self.twr_calc(self.thrust(), self.mass(), self.altitude(), self.radius_eq, self.mu)
                if _twr > 1:
                    self.lAz_data = self.azimuth_init()
                    self.control.activate_next_stage()
                    self.mode = "Booster Stage"

            if self.mode == "Booster Stage":

                if (self.altitude() > 80000) and (self.falafels is True):
                    self.control.activate_next_stage()
                    self.falafels = False

                self.flameout("Upper Stage")

            if self.mode == "Upper Stage":

                if self.eng_status(self.get_active_engine(), "Status") == "Flame-Out!":
                    self.control.throttle = 0
                    time.sleep(1.5)
                    self.control.activate_next_stage()
                    self.control.rcs = True
                    self.mode = "Cruise"

            if self.mode == "Cruise":
                if self.time_to_burn(self.ETA_ap(), self.maneuver_burn_time(self.circ_dv())) < 5:
                    self.ullage_rcs()
                    self.mode = "Orbit Insertion"

            if self.mode == "Orbit Insertion":
                self.control.rcs = False
                if (self.circ_dv() < 10) or (self.orbital_period(self.parking_orbit_alt + self.radius_eq,
                                                                 self.mu) < self.period()):
                    self.control.throttle = 0
                    self.mode = "Orbit"

            if self.circ_dv() > 500: time.sleep(.1)

            ui.gravity_turn(self.mode)

        self.control.rcs = True
        self.ap.disengage()
        self.control.sas = True
        time.sleep(2)
Exemple #33
0
import socket
import threading
import select

import random
from UI import UI

myUI = UI(300,300)
myUI.start()

SERVER_IP = "127.0.0.1"
TCP1_PORT = 5005

clisock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clisock.connect((SERVER_IP, TCP1_PORT))
oldtext=''
#print 'Connection address:', addr
#servsock=clisock.getpeername()
while True:
    text = myUI.sendtextout()
    if text != oldtext:
        clisock.send(text)
        data = clisock.recv(1024)
    myUI.changetext(data)
    text = oldtext
clisock.close()




Exemple #34
0
import json
import threading
from Log import Log
from Game import Game
from UI import UI

# Global random stuff
log_path = '/home/sebastian/.PlayOnLinux/wineprefix/hearthstone/drive_c/Program Files/Hearthstone/Hearthstone_Data/output_log.txt'

last_info = ""
exit = False

# Create UI-object
cur_ui = UI(log_path)

# Starting a thread for output
output_thread = threading.Thread(target=cur_ui.output_thread)
output_thread.start()

# Get inputs in current thread
cur_ui.input_thread()
Exemple #35
0
class Player:
    IDLE = 0
    IDLE_START = 22
    IDLE_END = 23

    RUNNING = 1
    RUNNING_START = 0
    RUNNING_END = 15

    JUMPING = 2
    JUMPING_START = 16
    JUMPING_END = 21

    RIGHT = 0
    LEFT = 1

    def __init__(self, x, y, w, h, image=ResourcePaths.character_sprite_sheet):
        self.pos = Vector(x, y)
        self.dv = Vector(0, 0)
        self.direction = self.LEFT
        self.grounded = False
        self.w = w
        self.h = h
        self.tick_count = 0
        self.state = self.IDLE
        self.live_image = simplegui.load_image(ResourcePaths.heart)
        self.image = simplegui.load_image(image)
        self.cols = self.image.get_width() // self.w
        self.rows = self.image.get_height() // self.h
        self.sprite_index = 22
        self.last_point_standing = self.pos
        self.lives = 2#50
        self.player_sound = Sound()
        self.ui = UI()

    def draw(self, canvas, camera_dims, offset=0):
        x_pos = self.pos.x - offset.x
        y_pos = self.pos.y - offset.y
        canvas.draw_image(self.image, self.get_index_pos()
                          , (self.image.get_width() / self.cols, self.image.get_height() / self.rows)
                          , (x_pos, y_pos), (self.w, self.h))
        if self.lives < 0:
            return self.ui.game_over(canvas, camera_dims)
        else:
            return States.STATES[1]

    def get_index_pos(self):
        index = self.sprite_index + (0 if self.direction == self.RIGHT else 24)
        x_pos = (index % self.cols) * (self.image.get_width() / self.cols)
        y_pos = ((index // self.cols) % self.rows) * (self.image.get_height() / self.rows)
        
        # adding extra half distance for draw:
        x_pos += (self.image.get_width() / self.cols) / 2
        y_pos += (self.image.get_height() / self.rows) / 2
        return x_pos, y_pos

    def draw_lives(self, canvas):
        for n in range(self.lives):
            canvas.draw_image(self.live_image,
                              (self.live_image.get_width() / 2, self.live_image.get_height() / 2),
                              (self.live_image.get_width(), self.live_image.get_height()),
                              (((n % 15) * (Unit.UNIT * 0.6)) + Unit.UNIT, (Unit.UNIT / 2) * (1 + (n // 15))),
                              (Unit.UNIT / 2, Unit.UNIT / 2)
                              )

    def set_state(self, state):
        if state == self.IDLE:
            self.state = self.IDLE

        elif state == self.RUNNING:
            self.state = self.RUNNING

        elif state == self.JUMPING:
            self.state = self.JUMPING

    def tick(self):
        self.tick_count += 1
        if self.tick_count % 4 == 0:
            self.sprite_index += 1
        mid = ((self.cols * self. rows) // 2)
        mid = mid if mid > 0 else 1
        real_index = (self.sprite_index % mid) + 1
        if self.state == self.IDLE and real_index > self.IDLE_END:
            self.sprite_index = self.IDLE_START
        elif self.state == self.RUNNING and real_index > self.RUNNING_END:
            self.sprite_index = self.RUNNING_START
        elif self.state == self.JUMPING and real_index > self.JUMPING_END:
            self.sprite_index = self.JUMPING_START
        self.pos.add(self.dv)

    def in_camera(self, camera):
        # define the bounds for the camera object, minimum and maximum are both a little flexible
        # the UNIT size is added to the bounds, thus rendering anything which is any amount in span
        camera_max_x = camera.pos.x + camera.span[0] + camera.UNIT
        camera_max_y = camera.pos.y + camera.span[1] + camera.UNIT
        camera_min_x = camera.pos.x - camera.UNIT
        camera_min_y = camera.pos.y - camera.UNIT

        # quick logic to see if in bounds, then returns true or false.
        in_x_bound = (self.x >= camera_min_x) and (self.x <= camera_max_x)
        in_y_bound = (self.y >= camera_min_y) and (self.y <= camera_max_y)
        return in_x_bound and in_y_bound

    def set_checkpoint(self):
        current_tile_pos = Vector(((self.pos.x // Unit.UNIT) - 0.5) * Unit.UNIT, ((self.pos.y // Unit.UNIT) + 0.5) * Unit.UNIT)
        self.last_point_standing = current_tile_pos

    def revive(self, camera):
        self.player_sound.play_death()
        self.lives -= 1
        if self.lives > 0:
            self.dv.y = 0
            # Swap between these to decide whether respawn is on
            # self.pos = self.last_point_standing
            self.pos = Vector(400, 300)
            camera.dv.y = 0
            camera.set_relative_pos(self.pos)
Exemple #36
0
from UI import UI

ui = UI()
ui.main_dialog()
Exemple #37
0
 def create_main_window(self, api):
     apiManager = APIManager(api)
     follower = Follower(apiManager)
     self.ui = UI(follower)
Exemple #38
0
from Battle import Battle
from Units import *
from LoadMod import LoadMod

if __name__ == "__main__":
    lang = 'en'
    mods = []
    units = [
        Angel, BoneDragon, Crossbowman, Cyclops, Devil, Fury, Gryphon, Hydra,
        Lich, Shaman, Skeleton
    ]
    army1 = []
    army2 = []

    os.system("cls")
    UI.print_greeting(lang=lang)
    while True:
        UI.print_help(lang=lang)
        UI.print_prompt(lang=lang)
        cmd = input()
        os.system("cls")
        if cmd == '4' or cmd.lower() == 'exit':
            UI.print_exit(lang=lang)
            input()
            exit()
        elif cmd == '2' or cmd.lower() == 'battle':
            if len(army1) < 1 or len(army2) < 1:
                UI.print_not_enough_stacks(lang=lang)
                continue
            b_army1 = BattleArmy(
                *list(map(lambda x: BattleUnitsStack(x), army1)))
Exemple #39
0
from Repository import Repository
from PathFinder import PathFinder
from Service import Service
from UI import UI

repository = Repository("ll\\tsp.txt", "ll\\tsp_solution.txt")
pathFinder = PathFinder(repository)
service = Service(pathFinder)
ui = UI(service)
ui.start()
Exemple #40
0
def main():
    NC = NoteControl("test.ini")
    window = UI(NC)
    window.main()
Exemple #41
0
 def __init__(self):
     self.UI = UI()
     self.pdf_splitter = PDFSplitter(self.UI)
     self.pdf_encrypt = PDFEncrypt(self.UI)
     self.pdf_merger = PDFMerger(self.UI)
     self.main_loop = self.UI.root.mainloop
Exemple #42
0
'''
Created on Jan 27, 2016

@author: LenovoM
'''
from Domain.Route import *
from Repository.Repository import *
from Controller.Controller import *
from UI.UI import *
from Domain.income import *
from datetime import time

repo=Repositoryy()
inc=Incomee()
ctrl=Controllerr(repo)
ui=UI(ctrl,inc)
ui.menu()
Exemple #43
0
def main():
    NC = NoteControl("test.ini")
    window = UI(NC)
    window.main()
Exemple #44
0
db.add(Discipline("FPcurs"))
db.add(Discipline("FPlab"))
db.add(Discipline("FPseminar"))
db.add(Discipline("Logica"))
db.add(Discipline("ASC"))
db.add(Discipline("Algebra"))
db.add(Discipline("Analiza"))
a = input("Press 1 for nonfile or 2 for file.")
if int(a) == 2:
    undoCtrl = UndoController()
    sc = StudentController(fsb, undoCtrl)

    gc = GradeController(fgb, undoCtrl)
    dc = DisciplineController(db)
    sts = StatisticsController(gc, sc, dc)
    ui = UI(gc, sc, dc, undoCtrl, sts)
    ui.mainMenu()

elif int(a) == 1:
    sb.add(Student(1, "Darius"))
    sb.add(Student(2, "Paul"))
    sb.add(Student(3, "Mark"))
    gb.add(Grade("FPcurs", 1, "arthur", 10))

    gb.add(Grade("FPseminar", 2, "iuliana", 10))
    gb.add(Grade("FPlab", 3, "arthur", 10))
    undoCtrl = UndoController()
    sc = StudentController(sb, undoCtrl)

    gc = GradeController(gb, undoCtrl)
    dc = DisciplineController(db)
Exemple #45
0
    def mask(self, frame, lowHue, lowSat, lowVal, highHue, highSat, highVal):
        #this is the limit threshold the lowest from the average value and the highest from the average value
        try:
            kernelDilation = np.ones((3, 3), np.uint8)  #kernel for dilation
            kernelErosion = np.ones((2, 2), np.uint8)  #kernel for erosion

            #get mask for each chanel separately
            lower_blue = np.array([lowHue, lowSat - 255, lowVal - 255])
            upper_blue = np.array([highHue, highSat + 255, highVal + 255])
            mask1 = cv2.inRange(frame, lower_blue, upper_blue)
            mask1 = cv2.erode(mask1, kernelErosion, iterations=1)
            mask1 = cv2.dilate(mask1, kernelDilation, iterations=2)

            lower_blue = np.array([lowHue - 255, lowSat, lowVal - 255])
            upper_blue = np.array([highHue + 255, highSat, highVal + 255])
            mask2 = cv2.inRange(frame, lower_blue, upper_blue)

            lower_blue = np.array([lowHue - 255, lowSat - 255, lowVal - 25])
            upper_blue = np.array([highHue + 255, highSat + 255, highVal + 25])
            mask3 = cv2.inRange(frame, lower_blue, upper_blue)
            mask3 = cv2.dilate(mask3, kernelDilation, iterations=2)

            # get intersection of hue and value channels
            masks = cv2.bitwise_and(mask1, mask3)
            masks = cv2.erode(masks, kernelErosion, iterations=1)
            masks = cv2.dilate(masks, kernelDilation, iterations=2)

            from main import isShow
            interface = UI()
            if isShow[3]:
                interface.showWindow('hue', mask1)
            elif interface.isOpen('hue'):
                interface.closeWindow('hue')
            if isShow[4]:
                interface.showWindow('sat', mask2)
            elif interface.isOpen('sat'):
                interface.closeWindow('sat')
            if isShow[5]:
                interface.showWindow('val', mask3)
            elif interface.isOpen('val'):
                interface.closeWindow('val')

        except Exception as e:
            print(e)
            return frame

        return masks
Exemple #46
0
from Repository import Repository
from UI import UI
from Graph import Graph

operations = Repository()
ui = UI(operations)
ui.start()



"""grap=Graph.randomGraph(10,5)

#grap=Graph.loadFile()
print(grap)

grap.DFS()"""
Exemple #47
0
 def setUp(self):
     self.mock = mockFollower()
     self.ui = UI(self.mock)
Exemple #48
0
from UI import UI

if __name__ == "__main__":
    UI()
Exemple #49
0
from UI import UI
import Tkinter as tk

root = tk.Tk()
root.geometry("650x490+300+100")
fer = UI(root)
fer.mainloop()
Exemple #50
0
from Game import Game
from UI import UI

g = Game()
ui = UI(g)
ui.start()
Exemple #51
0
import threading, queue
from UI import UI
#from hive.core.mesh import mesh
#from hive.core.swarm import swarm


class UIThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        print("UI init")

    def run(self):
        global interface
        interface.startUI()


logQueue = queue.Queue()
droneQueue = queue.Queue()
commandQueue = queue.Queue()
handlerQueue = queue.Queue()
interface = UI.InitializeUI(logQueue, droneQueue, commandQueue, handlerQueue)
uithread = UIThread()
uithread.start()
logQueue.put("Drone 1 Connected.")
logQueue.put("Drone 2 Connected.")
logQueue.put("Drone 3 Connected.")
logQueue.put("Drone 4 Connected.")
logQueue.put("Drone 5 Connected.")
logQueue.put("All Drones Connected.")
logQueue.put("Preset U Selected.")
def main():
    ui = UI.UI()
    ui.run_app()
Exemple #53
0
def main():
    app = wx.App()
    UI(None, "encode-decode")
    app.MainLoop()
# Author: JUAN MANUEL SUAREZ AGUIRRE
# Date:   20201-3-23

import sys

sys.path.append("..")
from UI import UI

if __name__ == "__main__":
    UI.menu()
Exemple #55
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jan  6 13:13:56 2020

@author: YWu

readme_1:
    1. format is (tool, film) : [number of points, interested cols, [first row, step]]
    2. Please use a different film name for 625pts. For example, w625
    3. 
"""

from format import Format
from read_excel_data import Read_Excel
from UI import UI
            
if __name__ == '__main__':
    run = UI()
from UI import UI

ui = UI()
ui.main()