def __init__(self, level): self.level = level pg.init() self.height, self.width = c.BOARD_SIZE[self.level] self.window = pg.display.set_mode((self.width, self.height)) pg.display.set_caption(c.TITLE) icon = pg.image.load(resource_path('icon.png')) pg.display.set_icon(icon) pg.font.init() self.fonts = { 'grid_font': pg.font.Font(resource_path('FreeSansBold.ttf'), 20), 'panel_font': pg.font.SysFont("lucidaconsole", 30), 'menu_font': pg.font.SysFont("dejavuserif", 10), 'large_menu_font': pg.font.SysFont("dejavuserif", 20) } self.ms = minesweeper.Minesweeper(level=self.level) self.flag = pg.image.load(resource_path('flag.bmp')) self.tp_btn_pos = int((self.width - c.TILESIZE) / 2) self.tp_bt_col = c.YELLOW self.timer_pos = int((self.width - 5 * c.TILESIZE) / 4) self.mine_pos = int(3 * (self.width - c.TILESIZE) / 4) self.scores = Scores(self.height, self.width, self.fonts, "HIGH SCORES") self.diff_choice = Difficulties(self.height, self.width, self.fonts, "SET DIFFICULTY", self.level) self.down = False self.show_scores = False self.show_diff_choice = False self.reset = False self.menu = False self.on = True
def __init__(self, label: str, float_fmt: str = '{:.3f}', conn: remotecontroller.RemoteController = None, parent=None): """ ValueGroupBox constructor :param label: name of the GroupBox :param conn: RemoteController instance to connect to :param parent: [optional] parent class """ super(ValueGroupBox, self).__init__(parent) self.setTitle(f"{label.capitalize()} control") self.label = label self.conn = conn # prepare a template string using another template string :) self.valLabelTemplate = string.Template( f"Current $label: <b>{float_fmt}</b>").safe_substitute(label=label) self.valLabel = QLabel() self.refreshVal() refreshButton = PicButton( util.resource_path('../img/refresh.png'), util.resource_path('../img/refresh_hover.png'), util.resource_path('../img/refresh_pressed.png')) refreshButton.clicked.connect(self.refreshVal) self.writeLine = QLineEdit() self.writeLine.setPlaceholderText(f"Enter new '{label}'") self.writeLine.setValidator(QDoubleValidator( )) # we can set a Locale() to correctly process floats self.writeLine.setToolTip("Float value") writeButton = QPushButton( QIcon(self.style().standardIcon(QStyle.SP_DialogApplyButton)), 'Send') writeButton.clicked.connect(self.writeButtonClicked) hBox1 = QHBoxLayout() hBox1.addWidget(self.valLabel) hBox1.addStretch() # need to not distort the button when resizing hBox1.addSpacing(25) hBox1.addWidget(refreshButton) hBox2 = QHBoxLayout() hBox2.addWidget(self.writeLine) hBox2.addWidget(writeButton) vBox1 = QVBoxLayout() vBox1.addLayout(hBox1) vBox1.addLayout(hBox2) self.setLayout(vBox1)
def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "Metro de Atenas")) self.Metro_Atenas.setText(_translate("MainWindow", "Metro de Atenas")) self.stations.setText(_translate("MainWindow", "Estaciones:")) self.distances.setText(_translate("MainWindow", "Distancia:")) self.time.setText(_translate("MainWindow", "Tiempo:")) item = self.stations_list.horizontalHeaderItem(0) item.setText(_translate("MainWindow", "Numero")) item = self.stations_list.horizontalHeaderItem(1) item.setText(_translate("MainWindow", "Parada")) self.actionHelp.setText(_translate("MainWindow", "Help")) self.action.setText(_translate("MainWindow", "Us")) self.selection_container = QtWidgets.QFrame(self.image_container) self.selection_container.setGeometry(QtCore.QRect(740, 0, 301, 181)) font = QtGui.QFont() font.setFamily("Trebuchet MS") self.selection_container.setFont(font) self.selection_container.setFrameShape(QtWidgets.QFrame.NoFrame) self.selection_container.setFrameShadow(QtWidgets.QFrame.Plain) self.selection_container.setObjectName("selection_container") self.origin_comboBox = QtWidgets.QComboBox(self.selection_container) self.origin_comboBox.setGeometry(QtCore.QRect(90, 60, 211, 31)) font = QtGui.QFont() font.setFamily("Trebuchet MS") font.setPointSize(13) self.origin_comboBox.setFont(font) self.origin_comboBox.setObjectName("origin_comboBox") self.destiny_comboBox = QtWidgets.QComboBox(self.selection_container) self.destiny_comboBox.setGeometry(QtCore.QRect(90, 150, 211, 31)) font = QtGui.QFont() font.setFamily("Trebuchet MS") font.setPointSize(13) self.destiny_comboBox.setFont(font) self.destiny_comboBox.setCurrentText("") self.destiny_comboBox.setObjectName("destiny_comboBox") self.destiny_icon = QtWidgets.QLabel(self.selection_container) self.destiny_icon.setGeometry(QtCore.QRect(10, 120, 61, 61)) self.destiny_icon.setText("") self.destiny_icon.setPixmap( QtGui.QPixmap(resource_path("image/flag-color.png"))) self.destiny_icon.setScaledContents(True) self.destiny_icon.setObjectName("destiny_icon") self.origin_icon = QtWidgets.QLabel(self.selection_container) self.origin_icon.setGeometry(QtCore.QRect(10, 30, 61, 61)) self.origin_icon.setFrameShape(QtWidgets.QFrame.NoFrame) self.origin_icon.setText("") self.origin_icon.setPixmap( QtGui.QPixmap(resource_path("image/mapa-color.png"))) self.origin_icon.setScaledContents(True) self.origin_icon.setObjectName("origin_icon")
def spawn_server(): os.system("killall CAV_server > /dev/null 2>&1") os.system("killall -9 vlc > /dev/null 2>&1") time.sleep(1) from util import resource_path proc = subprocess.Popen( resource_path("CAV_server"), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) for line in iter(proc.stdout.readline, ""): if b"npm ERR!" in line: print(colored(line, "red")) print( f"[{colored('-','red')}] An error has occured while starting the server\nRestarting the server" ) os.system("killall node") os.system("killall npm") sys.exit(-1) if b"Press CTRL-C to stop" in line: break time.sleep(1)
def __init__(self, text: str, status: str = 'Warning', parent=None): """ MessageWindow constructor :param text: string to show :param status: string representing message urgency ('Info', 'Warning' or 'Error') :param parent: [optional] parent class """ super(MessageWindow, self).__init__(parent) self.setWindowTitle(status) self.setWindowIcon(QIcon(util.resource_path('../img/error.png'))) if status == 'Info': self.setIcon(QMessageBox.Information) elif status == 'Warning': self.setIcon(QMessageBox.Warning) elif status == 'Error': self.setIcon(QMessageBox.Critical) self.setText(text) self.setStandardButtons(QMessageBox.Ok) self.exec_()
def createFile(self, port): try: f = open(resource_path('res/port.txt'), 'w') f.write(str(port)) f.close() except Exception as e: print('create_file ', e)
def spawn_server(): try: subprocess.Popen('taskkill /IM "CAV_server.exe" /F', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).wait() except: pass time.sleep(1) from util import resource_path proc = subprocess.Popen( resource_path('CAV_server.exe'), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) for line in iter(proc.stdout.readline, ""): if b"npm ERR!" in line: print(colored(line, "red")) print( f"[{colored('-','red')}] An error has occured while starting the server\nRestarting the server" ) os.system("taskkill /IM node /F") os.system("taskkll /IM npm /F") sys.exit(-1) if b"Press CTRL-C to stop" in line: break time.sleep(1)
def setupUi(self, Help_Window): Help_Window.setObjectName("Help_Window") Help_Window.resize(467, 327) Help_Window.setMinimumSize(QtCore.QSize(467, 327)) Help_Window.setMaximumSize(QtCore.QSize(467, 327)) font = QtGui.QFont() font.setFamily("Trebuchet MS") Help_Window.setFont(font) icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap( resource_path("image/1200px-Athens_Metro_Logo.svg.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) Help_Window.setWindowIcon(icon) self.centralwidget = QtWidgets.QWidget(Help_Window) self.centralwidget.setObjectName("centralwidget") self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget) self.verticalLayoutWidget.setGeometry(QtCore.QRect(38, 19, 381, 271)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.pasos = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) self.pasos.setContentsMargins(0, 0, 0, 0) self.pasos.setObjectName("pasos") self.grupo = QtWidgets.QLabel(self.verticalLayoutWidget) font = QtGui.QFont() font.setFamily("Trebuchet MS") font.setPointSize(26) self.grupo.setFont(font) self.grupo.setTextFormat(QtCore.Qt.AutoText) self.grupo.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.grupo.setObjectName("grupo") self.pasos.addWidget(self.grupo) self.aaron = QtWidgets.QLabel(self.verticalLayoutWidget) font = QtGui.QFont() font.setFamily("Trebuchet MS") font.setPointSize(22) self.aaron.setFont(font) self.aaron.setObjectName("aaron") self.pasos.addWidget(self.aaron) self.aaron_2 = QtWidgets.QLabel(self.verticalLayoutWidget) font = QtGui.QFont() font.setFamily("Trebuchet MS") font.setPointSize(22) self.aaron_2.setFont(font) self.aaron_2.setObjectName("aaron_2") self.pasos.addWidget(self.aaron_2) self.fondo = QtWidgets.QFrame(self.centralwidget) self.fondo.setGeometry(QtCore.QRect(0, 0, 571, 441)) self.fondo.setMinimumSize(QtCore.QSize(571, 441)) self.fondo.setMaximumSize(QtCore.QSize(571, 441)) self.fondo.setStyleSheet("background-color: rgb(255, 255, 255);") self.fondo.setFrameShape(QtWidgets.QFrame.StyledPanel) self.fondo.setFrameShadow(QtWidgets.QFrame.Raised) self.fondo.setObjectName("fondo") self.fondo.raise_() self.verticalLayoutWidget.raise_() Help_Window.setCentralWidget(self.centralwidget) self.retranslateUi(Help_Window) QtCore.QMetaObject.connectSlotsByName(Help_Window)
def check(self,fileName): findIt = QuoteManagerModel.dbAction() with open(fileName, 'rb') as f: #read csv file reader = csv.reader(f) rownum = 0 ofile = open(util.resource_path('Data\PO_COST_REPORT.csv'),"wb") writer = csv.writer(ofile) for row in reader: if rownum == 0: line = 'Line' sim = 'SIM' case = 'Case' cost = 'Cost' outRow = (line,sim,case,cost,'\r\n') writer.writerow(outRow) elif rownum == 1: pass else: line = str(row[33]) sim = str(row[35]) #todo create better id and ensure unique (quote#,Sim,Expiry Date?) price = str(row[45]) #todo Add check if all numbers quantity = str(row[44]) neg = str(row[41]) query = '''SELECT pt.stockPrice,pt.case FROM partTable AS pt WHERE pt.sim = '%s'; ''' %(sim) poResult = findIt.dbQuery(query) actualCost = (str(poResult[0][0])) actualCase = (str(poResult[0][1])) quoteQuery = '''SELECT qp.quoteNum, qp.price FROM quotePrice qp WHERE qp.sim = '%s';''' % (sim) quoteResult = findIt.dbQuery(quoteQuery) #ADD IN HERE: quote lookup, find lowest quote, create report if price != actualCost: costMessage = "Error: Vendor Cost is: %s" % (actualCost) else: costMessage = "Cost OK" if (int(quantity) % int(actualCase)) == 0: caseMessage = "Case OK" else: caseMessage = "Warning: Quantity Not Full Case" #todo Add Try Exception here and elsewhere writer = csv.writer(ofile) outRow = (line,sim,caseMessage,costMessage, '\r\n') writer.writerow(outRow) rownum += 1 f.close() ofile.close()
def get_data(): """ :return: DataFrame(kyear, co2, sigma_mean) """ data = pd.read_csv(resource_path("data/disaster_continent.csv"), delimiter=",") return data
class InventoryHelpWindow(TextWindow): PATH = resource_path("data/help/inventory_window.txt") def __init__(self, constants, visible=False): super().__init__(constants, visible, path=InventoryHelpWindow.PATH, next_window=None)
class CraftingHelpWindow(TextWindow): PATH = resource_path("data/help/crafting_window.txt") def __init__(self, constants, visible=False): super().__init__(constants, visible, path=CraftingHelpWindow.PATH, next_window=None)
def fill_comboBoxes(self): icon_circle_red = QtGui.QIcon() icon_circle_green = QtGui.QIcon() icon_circle_blue = QtGui.QIcon() icon_circle_yellow = QtGui.QIcon() icon_circle_red.addPixmap( QtGui.QPixmap(resource_path("image/circle_red.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon_circle_green.addPixmap( QtGui.QPixmap(resource_path("image/circle_green.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon_circle_blue.addPixmap( QtGui.QPixmap(resource_path("image/circle_blue.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon_circle_yellow.addPixmap( QtGui.QPixmap(resource_path("image/circle_yellow.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.origin_comboBox.setToolTip("Origen") self.destiny_comboBox.setToolTip("Destino") self.origin_comboBox.addItem(self.predetermined_text_origin_comboBox) self.destiny_comboBox.addItem(self.predetermined_text_destiny_comboBox) with open(resource_path("data/coordenadas")) as file: for linea in file: palabras = linea.split(",") estacion = palabras[0] linea = int(palabras[3]) if estacion in ['Attiki', 'Omonia', 'Monastiraki', 'Syntagma']: self.origin_comboBox.addItem(icon_circle_yellow, estacion) self.destiny_comboBox.addItem(icon_circle_yellow, estacion) elif linea == 1: self.origin_comboBox.addItem(icon_circle_green, estacion) self.destiny_comboBox.addItem(icon_circle_green, estacion) elif linea == 2: self.origin_comboBox.addItem(icon_circle_red, estacion) self.destiny_comboBox.addItem(icon_circle_red, estacion) elif linea == 3: self.origin_comboBox.addItem(icon_circle_blue, estacion) self.destiny_comboBox.addItem(icon_circle_blue, estacion) self.origin_comboBox.currentTextChanged.connect(self.calculate_route) self.destiny_comboBox.currentTextChanged.connect(self.calculate_route)
def __init__(self, argv: list): """ MainApplication constructor :param argv: the list of command line arguments passed to a Python script """ super(MainApplication, self).__init__(argv) # settings [customized] dictionary self.settings = settings.Settings( defaults=util.resource_path('../defaultSettings.json')) if self.settings['appearance']['theme'] == 'dark': # TODO: warns itself as a deprecated method though no suitable alternative has been suggested self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) # Create a handler function for connection breaks (for example, when a break is occur during the read of some # coefficient from the controller). We need to setup it early here to proper connection initialization process self.connLostSignal.connect(self.connLostHandler) # show this when the connection is broken self.connLostStatusBarLabel = QLabel( "<font color='red'>Connection was lost. Trying to reconnect...</font>" ) # check connection timer, set it when we will know status of the connection self.connCheckTimer = QTimer() self.isOfflineMode = False self.conn = remotecontroller.RemoteController( self.settings['network']['ip'], self.settings['network']['port'], conn_lost_signal=self.connLostSignal) # RemoteController' self-check determines the state of the connection. Such app state determined during the # startup process will remain during all following activities (i.e. app enters the demo mode) and can be changed # only after the restart if self.conn.is_offline_mode: self.isOfflineMode = True print("Offline mode") miscgraphics.MessageWindow( "No connection to the remote controller. App goes to the Offline (demo) mode. " "All values are random. To try to reconnect please restart the app", status='Warning') else: # If connection is present (so no demo mode is needed) then create the timer for connection checking. It # will start on MainWindow' show self.connCheckTimer.timeout.connect(self.connCheckTimerHandler) self.conn.save_current_values() # We can create the MainWindow only after instantiating the RemoteController because it is used for obtaining # values and setting parameters self.mainWindow = MainWindow(app=self) self.mainWindow.show()
def get_port(self): while not self.stopped(): try: f = open(resource_path('res/port.txt')) port = int(f.readline()) f.close() return port except Exception as e: print('get_port ', e) self.sleep(0.3) return 0
def setupMenu(display): world = World() world.on([QUIT, KEYDOWN], quitHandler) # Add the music if pygame.mixer.get_init() is not None: pygame.mixer.music.load(resource_path(os.path.join('assets', 'music', 'BlueBeat.wav'))) if options['MUSIC']: pygame.mixer.music.play(-1) # Add the background image menuImage = 'cityscape.png' background = auxFunctions.create(world, position=(0,0), sprite=menuImage, layer=-2) world.addEntity(background) # The text that goes on top of the world is here. menuText = 'menu.png' text = auxFunctions.create(world, position=(0,0), sprite=menuText, layer=-1) world.addEntity(text) # Add the movable component cursorImage = 'cursor.png' cursor = auxFunctions.create(world, position=(2,22), lastPosition=(2,22), sprite=cursorImage, layer=0) # Which can move (a bit). cursorEventHandler = cursor.addComponent(component.EventHandler()) def move(entity, event): global gamescreen currentPosition = entity.getComponent("Position") if event.key in keys: if keys[event.key] == "Up": if currentPosition.value[1] > 22: currentPosition.value += Vector2(0, -13) elif keys[event.key] == "Down": if currentPosition.value[1] < 48: currentPosition.value += Vector2(0, 13) elif keys[event.key] in ("Interact", "Enter"): if currentPosition.value == Vector2(2,22): worlds["level"] = level01() gamescreen = "level" elif currentPosition.value == Vector2(2,35): worlds["options"] = optionsMenu(display) gamescreen = "options" elif currentPosition.value == Vector2(2,48): sys.exit() else: pass elif keys[event.key] == "Exit": sys.exit() cursorEventHandler.attach(pygame.KEYDOWN, move) world.addEntity(cursor) # world.addSystem(RenderSystem(display)) world.addSystem(InputSystem()) return world
def lookUp(self,quote): findIt = QuoteManagerModel.dbAction() query1 = '''SELECT qs.quoteNum,qs.supplierNum,qs.customerNum,qs.branch,qs.effDate,qs.expDate FROM quoteSummary qs WHERE qs.quoteNum='%s';''' %(quote) query2 = '''SELECT qp.sim,qp.price FROM quotePrice qp WHERE qp.quoteNum = '%s';''' % (quote) result1 = findIt.dbQuery(query1) result2 = findIt.dbQuery(query2) print(result2) quoteNumber = str(result1[0][0]) quoteSupplier = str(result1[0][1]) quoteCustomer = str(result1[0][2]) quoteBranch = str(result1[0][3]) quoteEffective = str(result1[0][4]) quoteExpiry = str(result1[0][5]) quoteExp = quoteExpiry.split() quoteEff = quoteEffective.split() rownum = 0 ofile = open(util.resource_path('Data\Quote_Comments.csv'),"wb") #ofile = open('C:\Users\JB\Desktop\Quote_Comments.csv', "wb") writer = csv.writer(ofile) for row in result2: if rownum == 0: group = 'Group' region = 'Region' branch = 'Branch' simMfr = 'Sim Mfr' simItem = 'Sim Item' seq = 'Seqence No' preset = 'Preset' comment = 'Comment' output = 'Output To PO' start = 'Start Date' end = 'End Date' outRow = (group,region,branch,simMfr,simItem,seq,preset,comment,output,start,end,'\r\n') writer.writerow(outRow) rownum += 1 else: quoteSIM = str(row[0]) simMfrNum = str(quoteSIM[:6]) simItemNum = str(quoteSIM[-5:]) quotePrice = str(row[1]) fullComment = 'Quote: %s Cost: %s Br: %s Expiry: %s'%(quoteNumber,quotePrice,quoteBranch,str(quoteExp[0])) outRow = ('','',quoteBranch,simMfrNum,simItemNum,'10','',fullComment,"",str(quoteEff[0]),str(quoteExp[0]),'\r\n') writer.writerow(outRow) ofile.close()
def __init__(self, parent, title=None): tk.Toplevel.__init__(self, parent) self.transient(parent) self.parent = parent # 设置标题 if title: self.title(title) self.iconbitmap(resource_path('asset/logo.ico')) # 设置模式对话框 self.grab_set() self.key_text = tk.StringVar() self.key_text.set(APIKEY) self.initWidgets()
def load_wordlist(filename): path = resource_path('wordlist/' + filename) with open(path, 'r', encoding='utf-8') as f: s = f.read().strip() s = unicodedata.normalize('NFKD', s) lines = s.split('\n') wordlist = [] for line in lines: line = line.split('#')[0] line = line.strip(' \r') assert ' ' not in line if line: wordlist.append(line) return wordlist
def get_data(): """ :return: DataFrame(kyear, co2, sigma_mean) """ data = pd.read_csv(resource_path("data/co2.csv"), delimiter=";") data.yearBP = data.yearBP * -1 data.yearBP = data.yearBP - data.yearBP.max() data['kyear'] = data.yearBP / 1000 del data['yearBP'] data = data[data.kyear > -380] return data
def __init__(self): # 创建临时目录 if not os.path.exists(CONF.APP_TMP_PATH): os.mkdir(CONF.APP_TMP_PATH) self.settings_path = os.path.join(CONF.APP_TMP_PATH, CONF.SETTINGS) # 加载设置信息 while (True): # 不存在创建 if not os.path.exists(self.settings_path): with open(self.settings_path, 'w') as f: f.write(json.dumps(SETTINGS, indent=2)) init_conf = SETTINGS break else: try: # 存在加载 init_conf = json.loads( open(self.settings_path, "r").read()) break except: os.remove(self.settings_path) self.mw = Tk() self.mw.title(CONF.WIN_TITLE) # 设置图标 self.mw.iconbitmap(resource_path('asset/logo.ico')) # 设置全局样式 self.style = ttk.Style(self.mw) # 创建窗口菜单 self.wmenu = WinMenu(self.mw, self.style) # 创建显示区 self.scr = ImageScreen(self.mw) # 创建操作区 self.dboard = DashBoard(self.mw) # 赋值工具设置 self.dboard.set_font_color(init_conf.get("color")) self.dboard.set_font_size(init_conf.get("fn-size")) self.dboard.set_mark_mode(init_conf.get("mark-mode")) self.dboard.set_text(init_conf.get("mark-text")) set_apikey(init_conf.get("api-key")) self.wmenu.set_iscompress(init_conf.get("iscompress")) # 主题设置 theme = init_conf.get("theme") if init_conf.get( "theme") else CONF.DEFAULT_THEME self.wmenu.set_theme(theme) # 设置窗口初始主题样式 self.style.theme_use(theme) # 固定窗口大小 self.mw.resizable(False, False)
class VictoryWindow(TextWindow): PATH = resource_path("data/story/floor.10.txt") def __init__(self, constants, visible=False): super().__init__(constants, visible, path=VictoryWindow.PATH, next_window=None) def draw(self, game_data, gfx_data): surface = pygame.Surface(self.size.tuple()) all_lines = [] for current in self.lines: if current.strip() == "": all_lines.append(current) else: split_lines = textwrap.wrap(current, 60) all_lines.extend(split_lines) show_lines = all_lines[self.offset:self.offset + self.num_lines] display_menu(gfx_data, show_lines, self.size.tuple(), surface=surface) hours, minutes, seconds = game_data.stats.total_play_time playtime_text = "{}h {}m {}s".format(hours, minutes, seconds) display_text( surface, "This took you {}".format(playtime_text), gfx_data.assets.font_message, (150, 475), ) display_text( surface, "Press Escape to quit, press Space to play again", gfx_data.assets.font_message, (150, 500), ) gfx_data.main.blit(surface, self.pos.tuple()) def handle_key(self, game_data, gfx_data, key_action): keep_playing = key_action.get(EventType.keep_playing) if keep_playing: return None # propagate exit, restart do_exit = key_action.get(EventType.exit) if do_exit: return None # propagate quit event
def dbConnect(self): #fileLoc = os.path.join(os.path.dirname(__file__), 'Data\config.txt') fileLoc = util.resource_path('Data\\config.txt') print(fileLoc) file = open(fileLoc, 'r') path = file.readline() #dbConn = 'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\\JB\\Desktop\\BuyerToolsDB.accdb;' conn = pypyodbc.connect(path.strip()) return conn
def spawn_server(): try: subprocess.Popen('taskkill /IM "CAV_server.exe" /F', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).wait() except: pass time.sleep(1) from util import resource_path subprocess.Popen( resource_path('CAV_server.exe'), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) time.sleep(1)
def send(self): if self.repeatCheckBox.isChecked(): if str(self.sendButton.text()) == 'Stop': self.repeater.stop() self.sendButton.setText('Start') return raw = str(self.sendPlainTextEdit.toPlainText()) data = raw form = 'N' if self.normalRadioButton.isChecked(): if self.actionAppendEol.isChecked(): data += '\n' if self.actionUseCRLF.isChecked(): data = data.replace('\n', '\r\n') elif self.actionUseCR.isChecked(): data = data.replace('\n', '\r') elif self.hexRadioButton.isChecked(): form = 'H' data = translator.from_hex_string(data) else: form = 'E' data = translator.from_extended_string(data) if self.repeatCheckBox.isChecked(): self.repeater.start(data, self.periodSpinBox.value()) self.sendButton.setText('Stop') else: serial.write(data) # record history record = [form, raw, data] if record in self.output_history: self.output_history.remove(record) self.output_history.insert(0, record) self.outputHistoryActions = [] self.outputHistoryMenu.clear() for item in self.output_history: icon = QIcon(resource_path(ICON_LIB[item[0]])) action = self.outputHistoryMenu.addAction(icon, item[1]) self.outputHistoryActions.append(action)
def collect(self): if not self.collections: self.collectMenu.clear() raw = str(self.sendPlainTextEdit.toPlainText()) form = 'N' if self.hexRadioButton.isChecked(): form = 'H' elif self.extendRadioButton.isChecked(): form = 'E' item = [form, raw] if item in self.collections: return self.collections.append(item) icon = QIcon(resource_path(ICON_LIB[form])) action = self.collectMenu.addAction(icon, raw) self.collectActions.append(action)
def remove_collection(self): try: index = self.collectActions.index(self.activeCollectAction) except ValueError: return del self.collectActions[index] del self.collections[index] self.collectMenu.clear() for item in self.collections: icon = QIcon(resource_path(ICON_LIB[item[0]])) action = self.collectMenu.addAction(icon, item[1]) self.collectActions.append(action) save = open(PQCOM_DATA_FILE, 'w') pickle.dump(self.collections, save) save.close()
def retranslateUi(self, Dialog): Dialog.setWindowTitle( QtGui.QApplication.translate("Dialog", "pqcom - About", None, QtGui.QApplication.UnicodeUTF8)) self.textBrowser.setHtml( QtGui.QApplication.translate( "Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:16px; margin-bottom:0px; margin-left:16px; margin-right:16px; -qt-block-indent:0; text-indent:0px;\"><br /><img src=\"" + resource_path("img/pqcom-logo-expanded.png") + "\" height=\"64\" /></p>\n" "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n" "<p style=\" margin-top:16px; margin-bottom:16px; margin-left:16px; margin-right:16px; -qt-block-indent:0; text-indent:0px;\">pqcom, a simple cross platform serial tool.<br /><br />Version: " + str(VERSION) + "<br />Author: Yihui Xiong<br />Home: <a href=\"https://github.com/xiongyihui/pqcom\"><span style=\" text-decoration: underline; color:#0000ff;\">https://github.com/xiongyihui/pqcom</span></a><br />License: MIT</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
def __init__(self, parent=None): """ AboutWindow constructor :param parent: [optional] parent class """ super(AboutWindow, self).__init__(parent) self.setWindowTitle("Info & About") self.setWindowIcon(QIcon(util.resource_path('../img/info.png'))) self.aboutTab = QWidget() self.sysTab = QWidget() self.addTab(self.aboutTab, 'About') self.addTab(self.sysTab, 'System') self.initAboutTabUI() self.initSysTabUI()
def __init__(self): self.file_path = None self.last_open_folder = None self.simulation_data = None # A ScriptOutput object self.script_obj = None # className appears (at least) in Ubuntu sidebar "tooltip" (app name) self.root = tk.Tk(className=TITLE) self.progress = None self.root.style = ttk.Style() self.root.style.theme_use( "alt") # ('clam', 'alt', 'default', 'classic') self.set_title() self.scriptLabel = None self.scriptField = None self._create_widgets() self._bind_accelerators() # Set icon icon_file = util.resource_path('Lemur-icon.gif') img = tk.PhotoImage(file=icon_file) self.root.tk.call('wm', 'iconphoto', self.root._w, img) self.root.minsize(width=500, height=600) self.root.protocol("WM_DELETE_WINDOW", self.file_quit) # When run in bundle, display licene dialog box is_bundle = getattr(sys, 'frozen', False) if is_bundle: LicenseDlg(self) self.root.mainloop() self.root.quit()
def initAboutTabUI(self) -> None: """ Initialize 'About' tab :return: None """ layout = QVBoxLayout() self.aboutTab.setLayout(layout) # prepare logo view: create pixmap, scale it using nicer method iconPixmap = QPixmap(util.resource_path('../img/icon.png')).scaledToWidth(LOGO_SIZE, Qt.SmoothTransformation) iconLabel = QLabel() # QLabel is used to store the pixmap iconLabel.setPixmap(iconPixmap) iconLabel.setAlignment(Qt.AlignCenter) aboutTextBrowser = QTextBrowser() # read-only text holder with rich text support aboutTextBrowser.setHtml(ABOUT_TEXT) aboutTextBrowser.setOpenExternalLinks(True) layout.addSpacing(40) layout.addWidget(iconLabel, Qt.AlignCenter) layout.addSpacing(40) layout.addWidget(aboutTextBrowser)
def ChangeDisableIcon(self): icon = wx.Icon(resource_path("inactive.png"), wx.BITMAP_TYPE_PNG) self.SetIcon(icon)
import component import auxFunctions import entities from collections import OrderedDict from pygame.locals import * from newvector import Vector2 from ecs import * from systems import * from pytmx.util_pygame import load_pygame from util.enums import keys from util import enums from util import resource_path from util import Asset, SpriteData with open(resource_path('options.json'), "r") as f: options = json.load(f) try: pygame.mixer.init() except: options["SOUND"] = False options["MUSIC"] = False print "Pygame mixer failed to initialise, disabling audio!" gamescreen = "menu" worlds = OrderedDict() def quitHandler(event): global gamescreen if event.type == QUIT:
# read a value back to make sure that writing was successful (not really necessary to perform) self.refreshVal() if __name__ == '__main__': """ Use this block for testing purposes (run the module as a standalone script) """ import sys from PyQt5.QtWidgets import QApplication, QWidget app = QApplication(sys.argv) window = QWidget() button = PicButton(util.resource_path('../img/refresh.png'), util.resource_path('../img/refresh_hover.png'), util.resource_path('../img/refresh_pressed.png')) button.clicked.connect(lambda: print("PicButton has been clicked")) valueBox = ValueGroupBox("My value") invokeMessageWindow = QPushButton("Message window") invokeMessageWindow.clicked.connect( lambda: MessageWindow("I am MessageWindow", status='Info')) layout = QHBoxLayout(window) layout.addWidget(button) layout.addWidget(valueBox) layout.addWidget(invokeMessageWindow)
def storage_path(self): return resource_path(STORAGE_PATH)
tokenProvider = TokenProvider() shotBufApp = ShotBufApp(dropboxApi, tokenProvider) appcastReader = AppCastParser("http://shotbuf.com/exe/appcast32.xml") updateChecker = UpdateChecker(appcastReader) frame = ShotBufFrame(None, -1, 'ShotBuf', shotBufApp) tbiicon = CustomTaskBarIcon() tbiicon.parent = frame logging.basicConfig(filename='shotbuf.log',level=logging.DEBUG) logging.info('asdasdasd') stor = resource_path('storage.txt') cert = resource_path('trusted-certs.crt') logging.info(stor) logging.info(cert) def my_handler(type, value, tb): logging.exception("Uncaught exception: {0}".format(str(value))) # Install exception handler sys.excepthook = my_handler def main(): track_event('Launch App') if not shotBufApp.is_logined(): frame.ShowAsTopWindow() track_event('Connect Dropbox')
def __init__(self): self.sections = [] path = util.resource_path("data/story") self.load(path)
import os.path import util from util import resource_path STORAGE_PATH = resource_path('storage.txt') class TokenProvider(object): def get_access_token(self): if not os.path.isfile(STORAGE_PATH): print 'Not file' return None f = open(STORAGE_PATH, 'r') result = f.readline().strip() f.close() return result def set_access_token(self, token): print 'Token set ', type(token), token f = open(STORAGE_PATH, 'w') f.write(token) f.close() def remove_token_storage(self):
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.collections = [] try: saved = open(PQCOM_DATA_FILE, 'r') self.collections = pickle.load(saved) saved.close() except IOError: pass self.input_history = '' self.output_history = [] self.repeater = Repeater() self.setWindowIcon(QIcon(resource_path('img/pqcom-logo.png'))) self.aboutDialog = AboutDialog(self) self.setupDialog = SetupDialog(self) port, baud, bytebits, stopbits, parity = self.setupDialog.get() self.setWindowTitle('pqcom - ' + port + ' ' + str(baud)) self.actionNew.setIcon(QIcon(resource_path('img/new.svg'))) self.actionSetup.setIcon(QIcon(resource_path('img/settings.svg'))) self.actionRun.setIcon(QIcon(resource_path('img/run.svg'))) self.actionHex.setIcon(QIcon(resource_path('img/hex.svg'))) self.actionClear.setIcon(QIcon(resource_path('img/clear.svg'))) self.actionAbout.setIcon(QIcon(resource_path('img/about.svg'))) self.actionUseCR = QAction('EOL - \\r', self) self.actionUseCR.setCheckable(True) self.actionUseLF = QAction('EOL - \\n', self) self.actionUseLF.setCheckable(True) self.actionUseCRLF = QAction('EOL - \\r\\n', self) self.actionUseCRLF.setCheckable(True) self.actionUseCRLF.setChecked(True) eolGroup = QActionGroup(self) eolGroup.addAction(self.actionUseCR) eolGroup.addAction(self.actionUseLF) eolGroup.addAction(self.actionUseCRLF) eolGroup.setExclusive(True) self.actionAppendEol = QAction('Append extra EOL', self) self.actionAppendEol.setCheckable(True) popupMenu = QMenu(self) popupMenu.addAction(self.actionUseCR) popupMenu.addAction(self.actionUseLF) popupMenu.addAction(self.actionUseCRLF) popupMenu.addSeparator() popupMenu.addAction(self.actionAppendEol) self.sendButton.setMenu(popupMenu) self.outputHistoryActions = [] self.outputHistoryMenu = QMenu(self) self.outputHistoryMenu.addAction('None') self.historyButton.setMenu(self.outputHistoryMenu) self.collectActions = [] self.collectMenu = QMenu(self) self.collectMenu.setTearOffEnabled(True) if not self.collections: self.collectMenu.addAction('None') else: for item in self.collections: icon = QIcon(resource_path(ICON_LIB[item[0]])) action = self.collectMenu.addAction(icon, item[1]) self.collectActions.append(action) self.collectButton.setMenu(self.collectMenu) self.collectButton.setIcon(QIcon(resource_path('img/star.svg'))) self.collectMenu.setContextMenuPolicy(Qt.CustomContextMenu) self.connect(self.collectMenu, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_collect_context_menu) self.collectContextMenu = QMenu(self) self.removeCollectionAction = QAction('Remove', self) self.removeAllCollectionsAction = QAction('Remove all', self) self.collectContextMenu.addAction(self.removeCollectionAction) self.collectContextMenu.addAction(self.removeAllCollectionsAction) self.activeCollectAction = None self.removeCollectionAction.triggered.connect(self.remove_collection) self.removeAllCollectionsAction.triggered.connect(self.remove_all_collections) self.sendButton.clicked.connect(self.send) self.repeatCheckBox.toggled.connect(self.repeat) self.actionSetup.triggered.connect(self.setup) self.actionNew.triggered.connect(self.new) self.actionRun.toggled.connect(self.run) self.actionHex.toggled.connect(self.convert) self.actionClear.triggered.connect(self.clear) self.actionAbout.triggered.connect(self.aboutDialog.show) self.outputHistoryMenu.triggered.connect(self.on_history_item_clicked) self.collectButton.clicked.connect(self.collect) self.collectMenu.triggered.connect(self.on_collect_item_clicked) self.serial_failed.connect(self.handle_serial_error) self.data_received.connect(self.display) QShortcut(QtGui.QKeySequence('Ctrl+Return'), self.sendPlainTextEdit, self.send) # self.extendRadioButton.setVisible(False) self.periodSpinBox.setVisible(False)
def __timerGui(self): """ Gui is basically a state machine """ self.online_cam1 = CameraServer.is_online("cam1") self.online_cam2 = CameraServer.is_online("cam2") self.online = CameraServer.is_online("cam1") and CameraServer.is_online("cam2") if self.online_cam1: self.ui.label_video1_online.setText("Cam1: Online") if not self.aligning_cam2 and not self.shooting: self.ui.pushButton_video1_align.setEnabled(True) if self.online_cam2: self.ui.label_video2_online.setText("Cam2: Online") if not self.aligning_cam1 and not self.shooting: self.ui.pushButton_video2_align.setEnabled(True) if not self.online_cam1: self.ui.label_video1_online.setText("Cam1: Offline") self.ui.pushButton_video1_align.setEnabled(False) if not self.online_cam2: self.ui.label_video2_online.setText("Cam2: Offline") self.ui.pushButton_video2_align.setEnabled(False) self.ready = CameraServer.is_ready(); if (self.shooting and not self.online): # Camera lost? self.shooting = False; CameraServer.stop_shooting() if not self.online: self.ui.pushbutton_start.setEnabled(False) self.ui.pushbutton_stop.setEnabled(False) if self.ready and self.online: self.ui.pushbutton_start.setEnabled(True) self.ui.pushbutton_stop.setEnabled(False) if self.shooting and self.online: self.ui.pushbutton_start.setEnabled(False) self.ui.pushbutton_stop.setEnabled(True) if (self.stop_camera_wait): if self.aligning_cam1: self.ui.pushButton_video1_align.setEnabled(False) if not CameraServer.is_shooting(): self.aligning_cam1 = False self.ui.pushButton_video1_align.setEnabled(True) self.stop_camera_wait = False self.videos[0].set_shooting(False) self.ui.pushButton_video1_align.setText("Align Camera") elif self.aligning_cam2: self.ui.pushButton_video2_align.setEnabled(False) if not CameraServer.is_shooting(): self.aligning_cam2 = False self.ui.pushButton_video2_align.setEnabled(True) self.stop_camera_wait = False self.videos[1].set_shooting(False) self.ui.pushButton_video2_align.setText("Align Camera") else: self.ui.pushbutton_stop.setText("Waiting...") self.ui.pushbutton_stop.setEnabled(False) if not CameraServer.is_shooting(): self.stop_camera_wait = False self.shooting = False self.ui.pushbutton_stop.setText("Stop cameras") self.ui.pushbutton_start.setEnabled(True) self.videos[0].set_current_frame_number(1) self.videos[1].set_current_frame_number(1) self.videos[0].set_shooting(False) self.videos[1].set_shooting(False) self.timer.start(20) self.enable_all_gui_elements(True) # Update the video view if CameraServer.is_shooting(): if self.aligning_cam1: frame_number = CameraServer.get_last_image("cam1") if frame_number > 0: self.videos[0].view_frame(frame_number) elif self.aligning_cam2: frame_number = CameraServer.get_last_image("cam2") if frame_number > 0: self.videos[1].view_frame(frame_number) else: if self.ui.checkBox_motion_track.isChecked(): if self.shooting_frame_number_cam1 <= CameraServer.get_last_image("cam1"): start = CameraServer.get_start_timestamp() self.videos[0].setStartTimestamp(start) motion = self.videos[0].view_frame_motion_track(CameraServer.get_last_image("cam1")) if motion is not None: self.check_run("cam1", motion) self.shooting_frame_number_cam1 += 1 if self.shooting_frame_number_cam2 <= CameraServer.get_last_image("cam2"): start = CameraServer.get_start_timestamp() self.videos[1].setStartTimestamp(start) motion = self.videos[1].view_frame_motion_track(CameraServer.get_last_image("cam2")) if motion is not None: self.check_run("cam2", motion) self.shooting_frame_number_cam2 += 1 else: if self.shooting_frame_number_cam1 <= CameraServer.get_last_image("cam1"): start = CameraServer.get_start_timestamp() self.videos[0].setStartTimestamp(start) self.videos[0].view_frame(CameraServer.get_last_image("cam1")) self.shooting_frame_number_cam1 += 1 if self.shooting_frame_number_cam2 <= CameraServer.get_last_image("cam2"): start = CameraServer.get_start_timestamp() self.videos[1].setStartTimestamp(start) self.videos[1].view_frame(CameraServer.get_last_image("cam2")) self.shooting_frame_number_cam2 += 1 if self.run_direction is not None and self.run_abort_timestamp < int(round(time.time() * 1000)): # Abort run self.run_direction = None self.sound_effects["error"].play() if self.run_tell_speed != 0 and self.run_tell_speed_timestamp < int(round(time.time() * 1000)): source = pygame.mixer.Sound(util.resource_path("sounds/numbers/" + str(self.run_tell_speed) + ".ogg")) source.play() self.run_tell_speed = 0 if self.cameras_data and not self.shooting and self.cameras_data.is_data_ok() and not self.aligning_cam1 and not self.aligning_cam2: # Calculate the speed cam1_frame_number = self.videos[0].get_current_frame_number() cam2_frame_number = self.videos[1].get_current_frame_number() self.set_speed(cam1_frame_number, cam2_frame_number)
def retranslateUi(self, Dialog): Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "pqcom - About", None, QtGui.QApplication.UnicodeUTF8)) self.textBrowser.setHtml(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:16px; margin-bottom:0px; margin-left:16px; margin-right:16px; -qt-block-indent:0; text-indent:0px;\"><br /><img src=\"" + resource_path("img/pqcom-logo-expanded.png") + "\" height=\"64\" /></p>\n" "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n" "<p style=\" margin-top:16px; margin-bottom:16px; margin-left:16px; margin-right:16px; -qt-block-indent:0; text-indent:0px;\">pqcom, a simple cross platform serial tool.<br /><br />Version: " + str(VERSION) + "<br />Author: Yihui Xiong<br />Home: <a href=\"https://github.com/xiongyihui/pqcom\"><span style=\" text-decoration: underline; color:#0000ff;\">https://github.com/xiongyihui/pqcom</span></a><br />License: MIT</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
def __init__(self): # Init config self.config = ConfigParser.ConfigParser() if not self.read_config(): exit(0) # Set cameras_directory_base for the server CameraServer.ServerData.cameras_directory_base = self.cameras_directory_base # Data for the cameras self.cameras_data = CamerasData.CamerasData() # none / "Left" / "Right" self.run_direction = None self.run_frame_number_cam1 = None self.run_frame_number_cam2 = None # time to abort run self.run_abort_timestamp = 0 # Camera 1/2 online self.online_cam1 = False self.online_cam2 = False # Both cameras online self.online = False # Everything ready to start cameras self.ready = False # Currently shooting self.shooting = False # Frame number from shooting cameras self.shooting_frame_number_cam1 = 0 self.shooting_frame_number_cam2 = 0 # Waiting for cameras to stop self.stop_camera_wait = False # Distance self.distance = 100 self.run_tell_speed_timestamp = 0 self.run_tell_speed = 0 # Aligning cameras 1/2 self.aligning_cam1 = False self.aligning_cam2 = False # Sound effects self.sound_effects = { "gate-1" : pygame.mixer.Sound(util.resource_path("sounds/gate-1.ogg")), "gate-2" : pygame.mixer.Sound(util.resource_path("sounds/gate-2.ogg")), "error" : pygame.mixer.Sound(util.resource_path("sounds/error.ogg")) } QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowTitle("Sleipnir Velocity") self.anouncements = [] self.model_anouncements = QtGui.QStandardItemModel(self.ui.listView_anouncements) self.update_anouncements() self.ui.label_video1_online.setText("Cam1: Offline") self.ui.label_video2_online.setText("Cam2: Offline") self.ui.verticalSlider_groundlevel.sliderMoved.connect(self.__on_groundlevel_changed) # Initiate the flight number buttons self.radio_buttons_flights = {} self.radio_buttons_flights[0] = self.ui.radioButton_flight_1 self.radio_buttons_flights[1] = self.ui.radioButton_flight_2 self.radio_buttons_flights[2] = self.ui.radioButton_flight_3 self.radio_buttons_flights[3] = self.ui.radioButton_flight_4 self.radio_buttons_flights[4] = self.ui.radioButton_flight_5 self.radio_buttons_flights[5] = self.ui.radioButton_flight_6 self.radio_buttons_flights[6] = self.ui.radioButton_flight_7 self.radio_buttons_flights[7] = self.ui.radioButton_flight_8 self.radio_buttons_flights[8] = self.ui.radioButton_flight_9 self.radio_buttons_flights[9] = self.ui.radioButton_flight_10 self.radio_buttons_flights[10] = self.ui.radioButton_flight_11 self.radio_buttons_flights[11] = self.ui.radioButton_flight_12 self.radio_buttons_flights[12] = self.ui.radioButton_flight_13 self.radio_buttons_flights[13] = self.ui.radioButton_flight_14 self.radio_buttons_flights[14] = self.ui.radioButton_flight_15 self.radio_buttons_flights[15] = self.ui.radioButton_flight_16 self.radio_buttons_flights[16] = self.ui.radioButton_flight_17 self.radio_buttons_flights[17] = self.ui.radioButton_flight_18 self.radio_buttons_flights[18] = self.ui.radioButton_flight_19 self.radio_buttons_flights[19] = self.ui.radioButton_flight_20 for i in xrange(0,20): self.radio_buttons_flights[i].clicked.connect(self.__flight_number_clicked) # [0] - left [1] - right video # Init the videos self.videos = {} self.videos[0] = Video( "cam1", os.path.join(self.cameras_directory_base, "1", "cam1"), self.ui.label_video1, self.ui.pushbutton_video1_playforward, self.ui.pushbutton_video1_playbackward, self.ui.pushbutton_video1_pause, self.ui.pushbutton_video1_find, self.ui.pushbutton_video1_forwardstep, self.ui.pushbutton_video1_backstep, self.ui.slider_video1, self.ui.pushbutton_video1_copy, self.ui.label_time_video1); self.videos[1] = Video( "cam2", os.path.join(self.cameras_directory_base, "1", "cam2"), self.ui.label_video2, self.ui.pushbutton_video2_playforward, self.ui.pushbutton_video2_playbackward, self.ui.pushbutton_video2_pause, self.ui.pushbutton_video2_find, self.ui.pushbutton_video2_forwardstep, self.ui.pushbutton_video2_backstep, self.ui.slider_video2, self.ui.pushbutton_video2_copy, self.ui.label_time_video2); self.videos[0].set_sibling_video(self.videos[1]) self.videos[1].set_sibling_video(self.videos[0]) # Load flight number 1 self.load_flight(1) self.ui.label_speed.setText("") # Start / Stop connects self.ui.pushbutton_start.clicked.connect(self.startCameras) self.ui.pushbutton_stop.clicked.connect(self.stopCameras) # Align cameras connects self.ui.pushButton_video1_align.clicked.connect(self.align_cam1) self.ui.pushButton_video2_align.clicked.connect(self.align_cam2) # distance connect self.ui.lineEdit_distance.setText(str(self.distance)) self.ui.lineEdit_distance.textChanged.connect(self.__on_distance_changed) self.ui.listView_anouncements.clicked.connect(self.__on_anouncement_changed) # Show GUI self.show() self.raise_() # Start camera server CameraServer.start_server() # Run Gui self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.__timerGui) self.timer.start(20)
def make_tutorial_map(self): m = MapFileLoader.make_map(self.constants, 0, resource_path("data/maps/tutorial")) m.tutorial = True return m