def start(_exit: bool = False) -> None: show_ui = True if "-h" in sys.argv or "--help" in sys.argv: print(f"Usage: {os.path.basename(sys.argv[0])}") print("Flags:") print(" -h, --help\tShow this message") print(" -n, --no-ui\tRun the program without showing a UI") return elif "-n" in sys.argv or "--no-ui" in sys.argv: show_ui = False app = QApplication(sys.argv) logo = QIcon(LOGO) main_window = MainWindow() ui = main_window.ui main_window.setWindowIcon(logo) tray = QSystemTrayIcon(logo, app) tray.activated.connect(main_window.systray_clicked) menu = QMenu() action_exit = QAction("Exit") action_exit.triggered.connect(app.exit) menu.addAction(action_exit) tray.setContextMenu(menu) ui.text.textChanged.connect(partial(queue_text_change, ui)) ui.command.textChanged.connect(partial(update_button_command, ui)) ui.keys.textChanged.connect(partial(update_button_keys, ui)) ui.write.textChanged.connect(partial(update_button_write, ui)) ui.change_brightness.valueChanged.connect(partial(update_change_brightness, ui)) ui.switch_page.valueChanged.connect(partial(update_switch_page, ui)) ui.imageButton.clicked.connect(partial(select_image, main_window)) ui.removeButton.clicked.connect(partial(remove_image, main_window)) ui.settingsButton.clicked.connect(partial(show_settings, main_window)) api.streamdesk_keys.key_pressed.connect(handle_keypress) items = api.open_decks().items() if len(items) == 0: print("Waiting for Stream Deck(s)...") while len(items) == 0: time.sleep(3) items = api.open_decks().items() for deck_id, deck in items: ui.device_list.addItem(f"{deck['type']} - {deck_id}", userData=deck_id) dimmers[deck_id] = Dimmer( api.get_display_timeout(deck_id), api.get_brightness(deck_id), partial(change_brightness, deck_id), ) dimmers[deck_id].reset() build_device(ui) ui.device_list.currentIndexChanged.connect(partial(build_device, ui)) ui.pages.currentChanged.connect(partial(change_page, ui)) ui.actionExport.triggered.connect(partial(export_config, main_window)) ui.actionImport.triggered.connect(partial(import_config, main_window)) ui.actionExit.triggered.connect(app.exit) timer = QTimer() timer.timeout.connect(partial(sync, ui)) timer.start(1000) api.render() tray.show() if show_ui: main_window.show() if _exit: return else: app.exec_() api.close_decks() sys.exit()
def start(_exit: bool = False, _show_ui: bool = True) -> None: app = QApplication(sys.argv) logo = QIcon(LOGO) main_window = MainWindow() ui = main_window.ui main_window.setWindowIcon(logo) tray = QSystemTrayIcon(logo, app) tray.activated.connect(main_window.systray_clicked) menu = QMenu() action_exit = QAction("Exit") action_exit.triggered.connect(app.exit) menu.addAction(action_exit) tray.setContextMenu(menu) ui.text.textChanged.connect(partial(queue_text_change, ui)) ui.command.textChanged.connect(partial(update_button_command, ui)) ui.keys.textChanged.connect(partial(update_button_keys, ui)) ui.write.textChanged.connect(partial(update_button_write, ui)) ui.change_brightness.valueChanged.connect( partial(update_change_brightness, ui)) ui.switch_page.valueChanged.connect(partial(update_switch_page, ui)) ui.imageButton.clicked.connect(partial(select_image, main_window)) ui.brightness.valueChanged.connect(partial(set_brightness, ui)) items = api.open_decks().items() if len(items) == 0: print("Waiting for Stream Deck(s)...") while len(items) == 0: time.sleep(3) items = api.open_decks().items() for deck_id, deck in items: ui.device_list.addItem(f"{deck['type']} - {deck_id}", userData=deck_id) build_device(ui) ui.device_list.currentIndexChanged.connect(partial(build_device, ui)) ui.pages.currentChanged.connect(partial(change_page, ui)) ui.actionExport.triggered.connect(partial(export_config, main_window)) ui.actionImport.triggered.connect(partial(import_config, main_window)) ui.actionExit.triggered.connect(app.exit) timer = QTimer() timer.timeout.connect(partial(sync, ui)) timer.start(1000) api.render() tray.show() if _show_ui: main_window.show() if _exit: return else: app.exec_() api.close_decks() sys.exit()
def start(_exit: bool = False) -> None: show_ui = True if "-h" in sys.argv or "--help" in sys.argv: print(f"Usage: {os.path.basename(sys.argv[0])}") print("Flags:") print(" -h, --help\tShow this message") print(" -n, --no-ui\tRun the program without showing a UI") return elif "-n" in sys.argv or "--no-ui" in sys.argv: show_ui = False app = QApplication(sys.argv) logo = QIcon(LOGO) main_window = MainWindow() ui = main_window.ui main_window.setWindowIcon(logo) tray = QSystemTrayIcon(logo, app) tray.activated.connect(main_window.systray_clicked) menu = QMenu() action_dim = QAction("Dim display (toggle)") action_dim.triggered.connect(dim_all_displays) action_configure = QAction("Configure...") action_configure.triggered.connect(main_window.bring_to_top) menu.addAction(action_dim) menu.addAction(action_configure) menu.addSeparator() action_exit = QAction("Exit") action_exit.triggered.connect(app.exit) menu.addAction(action_exit) tray.setContextMenu(menu) ui.text.textChanged.connect(partial(queue_text_change, ui)) ui.font_Size.valueChanged.connect(partial(update_font_size, ui)) ui.command.textChanged.connect(partial(update_button_command, ui)) ui.keys.textChanged.connect(partial(update_button_keys, ui)) ui.write.textChanged.connect(partial(update_button_write, ui)) ui.change_brightness.valueChanged.connect( partial(update_change_brightness, ui)) ui.switch_page.valueChanged.connect(partial(update_switch_page, ui)) ui.imageButton.clicked.connect(partial(select_image, main_window)) ui.removeButton.clicked.connect(partial(remove_image, main_window)) ui.settingsButton.clicked.connect(partial(show_settings, main_window)) ui.font_Color.addItem("white") ui.font_Color.addItem("black") ui.font_Color.addItem("blue") ui.font_Color.addItem("red") ui.font_Color.addItem("green") ui.font_Color.addItem("purple") ui.font_Color.addItem("cyan") ui.font_Color.addItem("magenta") ui.font_Color.currentTextChanged.connect(partial(update_font_color, ui)) ui.selected_font.addItem("Goblin_One") ui.selected_font.addItem("Open_Sans") ui.selected_font.addItem("Roboto") ui.selected_font.addItem("Lobster") ui.selected_font.addItem("Anton") ui.selected_font.addItem("Pacifico") ui.selected_font.currentTextChanged.connect( partial(update_selected_font, ui)) ui.text_Align.addItem("left") ui.text_Align.addItem("center") ui.text_Align.addItem("right") ui.text_Align.currentTextChanged.connect(partial(update_text_align, ui)) api.streamdesk_keys.key_pressed.connect(handle_keypress) items = api.open_decks().items() if len(items) == 0: print("Waiting for Stream Deck(s)...") while len(items) == 0: time.sleep(3) items = api.open_decks().items() for deck_id, deck in items: ui.device_list.addItem(f"{deck['type']} - {deck_id}", userData=deck_id) ui.target_device.addItem(deck_id) dimmers[deck_id] = Dimmer( api.get_display_timeout(deck_id), api.get_brightness(deck_id), partial(change_brightness, deck_id), ) dimmers[deck_id].reset() build_device(ui) ui.device_list.currentIndexChanged.connect(partial(build_device, ui)) ui.target_device.currentTextChanged.connect( partial(update_target_device, ui)) ui.pages.currentChanged.connect(partial(change_page, ui)) ui.actionExport.triggered.connect(partial(export_config, main_window)) ui.actionImport.triggered.connect(partial(import_config, main_window)) ui.actionCut.triggered.connect(partial(cut_button, main_window)) ui.actionCopy.triggered.connect(partial(copy_button, main_window)) ui.actionCut.setShortcuts([QKeySequence.Cut, QKeySequence("Shift+Del")]) ui.actionCopy.setShortcuts( [QKeySequence.Copy, QKeySequence("Ctrl+Insert")]) ui.actionPaste.setShortcuts( [QKeySequence.Paste, QKeySequence("Shift+Insert")]) ui.actionDelete.setShortcuts([QKeySequence.Delete]) ui.actionPaste.triggered.connect(partial(paste_button, main_window)) ui.actionDelete.triggered.connect(partial(delete_button, main_window)) ui.actionMultiPaste.triggered.connect( partial(multi_paste_Button, main_window)) ui.actionExit.triggered.connect(app.exit) timer = QTimer() timer.timeout.connect(partial(sync, ui)) timer.start(1000) api.render() tray.show() if show_ui: main_window.show() if _exit: return else: app.exec_() api.close_decks() sys.exit()