def initMenuBar(self): global darkTheme, lightTheme self.menuBar = QMenuBar() self.themeMenu = QMenu("Theme Menu") self.lightThemeAction = QAction("Light Theme") self.lightThemeAction.triggered.connect( lambda: apply_stylesheet(self.app, lightTheme)) self.themeMenu.addAction(self.lightThemeAction) self.darkThemeAction = QAction("Dark Theme") self.darkThemeAction.triggered.connect( lambda: apply_stylesheet(self.app, darkTheme)) self.themeMenu.addAction(self.darkThemeAction) self.menuBar.addMenu(self.themeMenu) self.gameMenu = QMenu("New Game") self.makeNewOnePlayerGameAction = QAction("New 1 player game.") self.makeNewOnePlayerGameAction.triggered.connect( lambda: self.makeNewOnePlayerGame()) self.gameMenu.addAction(self.makeNewOnePlayerGameAction) self.makeNewTwoPlayerGameAction = QAction("New 2 player game.") self.makeNewTwoPlayerGameAction.triggered.connect( lambda: self.makeNewTwoPlayerGame()) self.gameMenu.addAction(self.makeNewTwoPlayerGameAction) self.menuBar.addMenu(self.gameMenu) self.mainWindow.setMenuBar(self.menuBar)
def setup_module(): QtWidgets.QApplication.instance() apply_stylesheet(app, theme="light_cyan.xml", invert_secondary=True) setup_matplotlib() os.makedirs("./.temp", exist_ok=True) service_process.start() time.sleep(5)
def __init__(self): """ Sets up the Qt UI. """ super().__init__() QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts) signal.signal(signal.SIGINT, signal.SIG_DFL) # fix SIGINT handling - cleanly exit on ctrl+c self.app = QApplication.instance() or QApplication([]) try: import qt_material qt_material.apply_stylesheet(self.app, 'light_blue.xml') except ImportError: pass self.ui_file = QtCore.QFile(os.path.dirname(os.path.realpath(__file__)) + '/qt.ui') self.loader = QUiLoader() self.loader.registerCustomWidget(ViewSBQTreeWidget) self.loader.registerCustomWidget(ViewSBHexView) self.window = self.loader.load(self.ui_file) # type: QMainWindow # Swap columns 0 and 5 to put the expand arrow on the summary column. self.window.usb_tree_widget.header().swapSections(self.COLUMN_SUMMARY, self.COLUMN_SEQUENCE) self.window.usb_tree_widget.header().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.window.update_timer = QtCore.QTimer() self.window.update_timer.timeout.connect(self._update) self.window.usb_tree_widget.currentItemChanged.connect(self._tree_current_item_changed) self.window.usb_tree_widget = self.window.usb_tree_widget self.window.usb_tree_widget.sortByColumn(0, Qt.SortOrder.AscendingOrder)
def main(): app = QApplication(sys.argv) apply_stylesheet(app, theme='dark_yellow.xml', invert_secondary=True) mainApp = MainApp() mainApp.show() mainApp.start() app.exec_()
def __init__(self, model, login_controller): super().__init__() self._model = model self._login_controller = login_controller self._ui = Ui_Login() self._ui.setupUi(self) self._navigationView = NavigationView() apply_stylesheet(self._navigationView, theme='dark_cyan.xml') self._navigationStudentView = NavigationStudentView() apply_stylesheet(self._navigationStudentView, theme='dark_cyan.xml') # connect widgets to controller self._ui.UsernameLineEdit.textChanged.connect( self._login_controller.change_username) self._ui.PasswordLineEdit.textChanged.connect( self._login_controller.change_password) self._ui.LoginButton.clicked.connect( lambda: self._login_controller.login(True)) self._ui.label.hide() # listen for model event signals self._model.login_button_clicked.connect(self.on_login_button_clicked) self._model.username_changed.connect(self.on_username_changed) self._model.password_changed.connect(self.on_password_changed)
def initUI(self): global darkTheme, lightTheme if isDark(): apply_stylesheet(self.app, darkTheme) else: apply_stylesheet(self.app, lightTheme) self.lab = QLabel(text="", parent=self.win) self.lab.adjustSize( ) # It is a kind of better to do this to avoid bugs. self.wid = QWidget() vlayout = QVBoxLayout() self.win.setLayout(vlayout) vlayout.addWidget(self.lab) vlayout.addWidget(self.wid) # Making a widget to store buttons. layout = QGridLayout() self.wid.setLayout(layout) self.buttons = [] for i in range(3): self.buttons.append([]) for j in range(3): self.buttons[i].append(QPushButton()) self.buttons[i][j].clicked.connect( lambda _, i=i, j=j: self.onPress(i, j)) layout.addWidget(self.buttons[i][j], i, j)
def main() -> None: """Creates and launches the app.""" app = QtWidgets.QApplication(sys.argv) my_main_window = MyMainWindow.create_my_main_window() apply_stylesheet(app, theme="dark_cyan.xml") my_main_window.setWindowState(QtCore.Qt.WindowMaximized) my_main_window.show() sys.exit(app.exec_())
def main(): app = QApplication(sys.argv) apply_stylesheet(app, theme='dark_teal.xml') window = MainWindow() window.show() sys.exit(app.exec())
def main(): app = QApplication(sys.argv) apply_stylesheet(app, theme=g.config["theme"]) mainwindow = MainWindow() mainwindow.show() mainwindow.ready() app.exec() json.dump(g.config, open('config.json', encoding='utf-8', mode='w')) sys.exit()
def changeTheme(self, i): theme = self.ui.themeSelector.currentText() apply_stylesheet(self.parent, theme=theme) if theme.find('dark') != -1: QIcon.setThemeName('mpp-dark') else: QIcon.setThemeName('mpp') self.parent.repaint()
def window(): app = QApplication(sys.argv) win = Window() win.show() # win.showMaximized() apply_stylesheet(app, theme='dark_amber.xml') sys.exit(app.exec_())
def switch_theme(self): """ Switches application theme from light to dark and vise-versa """ if self.light_theme: apply_stylesheet(self, os.path.join(self.base_path, 'stylesheets', 'colors_dark.xml')) self.tree_viewer.setStyleSheet(self.theme_dark_table) else: apply_stylesheet(self, os.path.join(self.base_path, 'stylesheets', 'colors_light.xml'), invert_secondary=True) self.tree_viewer.setStyleSheet(self.theme_light_table) self.light_theme = not self.light_theme
def __init__(self, path: str): super().__init__() self.base_path = path self.outer = QHBoxLayout() self.net: dict[str, dict] = {} self.place_num = 0 self._net_loaded = False self.togglable_elements: List[QWidget] = [] self.light_theme = True sys.excepthook = error_handling apply_stylesheet(self, os.path.join(path, 'stylesheets', 'colors_light.xml'), invert_secondary=True) self.init_ui()
def __init__(self, sys_argv): super(App, self).__init__(sys_argv) self._model = Model() self._mainView = MainView() self._loginController = LoginController(self._model) self._loginView = LoginView(self._model, self._loginController) apply_stylesheet(self._loginView, theme='dark_cyan.xml') self._mainView.setScreen(self._loginView) self._mainView.show()
def main(): app = QtWidgets.QApplication(sys.argv) window = MainWindow() try: theme = defaults.get_value("theme") except FileNotFoundError: theme = defaults.defaults["theme"] if theme != "System": apply_stylesheet(app, theme=styles[theme]) window.show() app.exec_()
def main(): app = QtWidgets.QApplication(sys.argv) window = Main() try: theme = defaults.get_value("theme") # Установка темы Qt5-приложения except FileNotFoundError: theme = defaults.defaults["theme"] if theme != "System": apply_stylesheet(app, theme=styles[theme]) window.show() app.exec_() speak.tts_d.close()
def run(): app = QApplication(sys.argv) app.setApplicationDisplayName("Triangle calculator app") app.setApplicationName("ExamApp") apply_stylesheet(app, theme="dark_amber.xml") widget = QTabWidget() triangle_tab = TriangleAreaCalculator(widget) segment_tab = SegmentLengthCalculator(widget) widget.addTab(triangle_tab, "Triangle") widget.addTab(segment_tab, "Segment") widget.resize(800, 600) widget.show() sys.exit(app.exec_())
def setup_application(argv: List[str]) -> QApplication: app = QApplication(argv) # Extra stylesheets extra = { # Button colors 'danger': '#dc3545', 'warning': '#ffc107', 'success': '#17a2b8', # Font 'font_family': 'Roboto', } apply_stylesheet(app, theme=str(resource_path(Path('assets/planvec-theme.xml'))), extra=extra) stylesheet = app.styleSheet() with open(resource_path(Path('assets/custom.css'))) as file: app.setStyleSheet(stylesheet + file.read().format(**os.environ)) return app
def setup_app(): QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_DisableHighDpiScaling) app = QtWidgets.QApplication(sys.argv) pixmap = QtGui.QPixmap(os.path.join(QGRAIN_ROOT_PATH, "assets", "icon.png")) create_necessary_folders() app.setWindowIcon(QtGui.QIcon(pixmap)) app.setApplicationVersion(QGRAIN_VERSION) from qt_material import apply_stylesheet apply_stylesheet(app, theme=os.path.join(QGRAIN_ROOT_PATH, "assets", "default_theme.xml"), invert_secondary=True, extra=EXTRA) setup_matplotlib() setup_language(app, "en") return app
def progress(self): global counter # SET VALUE TO PROGRESS BAR self.progress_bar.setValue(counter) # CLOSE SPLASH SCREE AND OPEN APP if counter > 100: # STOP TIMER self.timer.stop() # SHOW MAIN WINDOW apply_stylesheet( app, theme='dark_amber.xml') # Setting Theme of Application window_stack.show() # Displaying the Window Stack self.close() # close splash screen counter += 1 # Increasing the Progressbar Percentage
def init(): LOCAL_DIR = path.dirname(path.realpath(__file__)) app = QtWidgets.QApplication([]) if platform.system() != 'Linux' or APPIMAGE: apply_stylesheet(app, theme='dark_blue.xml') stylesheet = app.styleSheet() with open(LOCAL_DIR + '/custom.css') as file: app.setStyleSheet(stylesheet + file.read().format(**os.environ)) defaultLocale = QLocale.system().name() if defaultLocale == 'es_ES': defaultLocale = 'es' translator = QTranslator() translator.load(LOCAL_DIR + "/locales/" + defaultLocale + ".qm") app.installTranslator(translator) window = MainWindow() window.retranslateUi(window) window.show() app.exec_()
def main() -> None: """""" kill_subprocess() freeze_support() QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) app = QApplication(sys.argv) app.processEvents() app.setQuitOnLastWindowClosed(False) app.lastWindowClosed.connect(kill_subprocess) app.lastWindowClosed.connect(kill_childs) app.lastWindowClosed.connect(lambda: app.quit()) os.environ['BCISTREAM_DPI'] = str(app.screens()[0].physicalDotsPerInch()) extra = {'danger': '#dc3545', 'warning': '#e2a963', 'success': '#17a2b8', 'font_family': 'Roboto', 'font_size': 'unset', } if ConfigManager().get('framework', 'theme', 'light') == 'light': apply_stylesheet(app, theme='light_cyan_500.xml', invert_secondary=True, extra=extra, parent='bci_framework_qt_material') else: apply_stylesheet(app, theme='dark_cyan.xml', extra=extra, parent='bci_framework_qt_material') stylesheet = app.styleSheet() with open(os.path.join(os.path.dirname(__file__), 'custom.css')) as file: app.setStyleSheet(stylesheet + file.read().format(**os.environ)) generate_icons() frame = BCIFramework() frame.main.showMaximized() app.exec_()
def init(): LOCAL_DIR = path.dirname(path.realpath(__file__)) app = QtWidgets.QApplication([]) config = conf.getConf() if config['theme'] != 'system': apply_stylesheet(app, theme=config['theme']) stylesheet = app.styleSheet() with open(LOCAL_DIR + '/custom.css') as file: app.setStyleSheet(stylesheet + file.read().format(**environ)) defaultLocale = QLocale.system().name() if defaultLocale == 'es_ES': defaultLocale = 'es' translator = QTranslator() translator.load(LOCAL_DIR + "/locales/" + defaultLocale + ".qm") app.installTranslator(translator) window = MainWindow() window.retranslateUi(window) window.show() app.exec_()
def __init__(self): QtWidgets.QMainWindow.__init__(self, flags=QtCore.Qt.WindowType.Window) # Fix icon issues on windows systems if sys.platform == 'win32': # Explicitly set app-id as suggested by https://stackoverflow.com/a/1552105 appid = u'vxpy.application.0.0.1' # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(appid) # Set offsets row2_yoffset = 0 row2_xoffset = 0 side_window_borders = 5 x_spacing = 5 # Set icon iconpath = os.path.join(str(vxpy.__path__[0]), 'vxpy_icon.svg') self.setWindowIcon(QtGui.QIcon(iconpath)) self.subwindows = [] # Set up main window self.setWindowTitle('vxPy - vision experiments in Python') # Setup central widget self.setCentralWidget(QtWidgets.QWidget(parent=self, f=QtCore.Qt.WindowType.Widget)) self.centralWidget().setLayout(QtWidgets.QHBoxLayout()) # Control widgets self.control_wdgt = QtWidgets.QWidget() self.control_wdgt.setLayout(QtWidgets.QHBoxLayout()) self.centralWidget().layout().addWidget(self.control_wdgt) # Main monitoring widget self.monitoring_wdgt = QtWidgets.QWidget() self.monitoring_wdgt.setLayout(QtWidgets.QVBoxLayout()) self.centralWidget().layout().addWidget(self.monitoring_wdgt) # Process monitor self.process_monitor = core_widgets.ProcessMonitorWidget(self) self.process_monitor.create_hooks() self.monitoring_wdgt.layout().addWidget(self.process_monitor) # Recordings self.recordings = core_widgets.RecordingWidget(self) self.recordings.create_hooks() self.control_wdgt.layout().addWidget(self.recordings) # Protocols} self.protocols = core_widgets.Protocols(self) self.protocols.create_hooks() self.control_wdgt.layout().addWidget(self.protocols) # Logger self.log_display = core_widgets.LoggingWidget(self) self.monitoring_wdgt.layout().addWidget(self.log_display) # Set geometry self.setMinimumHeight(500) screen = vxipc.Process.app.screens()[config.CONF_GUI_SCREEN] self.screenGeo = screen.geometry() width, height = self.screenGeo.width(), self.screenGeo.height() xpos, ypos = self.screenGeo.x(), self.screenGeo.y() self.move(xpos, ypos) self.resize(width-side_window_borders, height // 2 if height <= 1080 else 540) # Optional sub windows titlebar_height = 40 bottom_height_offset = 80 # if sys.platform == 'win32': # titlebar_height = 40 # bottom_height_offset = 120 # else: # titlebar_height = 0 # bottom_height_offset = 120 main_window_height = self.size().height() + titlebar_height addon_window_default_dims = (600, 600) # Addon widget window if any addons are selected in config self.addon_widget_window = None if any([config.CONF_DISPLAY_USE, config.CONF_CAMERA_USE, config.CONF_IO_USE]) and bool(config.CONF_GUI_ADDONS): # Create windowed tab self.addon_widget_window = vxgui.AddonWindow(self) for process_name, addons in config.CONF_GUI_ADDONS.items(): self.addon_widget_window.create_addon_tabs(process_name) # Create hooks self.addon_widget_window.create_hooks() # Place and resize addon widget self.addon_widget_window.move(xpos + row2_xoffset, ypos + main_window_height + row2_yoffset) if height - self.size().height() - addon_window_default_dims[1] > bottom_height_offset: addon_height = addon_window_default_dims[1] else: addon_height = height - self.size().height() - bottom_height_offset self.addon_widget_window.resize(addon_window_default_dims[0], addon_height) # Add subwindow self.subwindows.append(self.addon_widget_window) # Add Plotter self.plotter = core_widgets.PlottingWindow(self) self.plotter.setMinimumHeight(300) # Place and resize addon_win_width = self.addon_widget_window.size().width() if self.addon_widget_window is not None else 0 self.plotter.move(xpos + row2_xoffset + addon_win_width + x_spacing, ypos + self.size().height() + titlebar_height + row2_yoffset) if height - self.size().height() - addon_window_default_dims[1] > bottom_height_offset: plotter_height = addon_window_default_dims[1] else: plotter_height = height - self.size().height() - bottom_height_offset self.plotter.resize(width - addon_win_width - x_spacing, plotter_height) self.plotter.create_hooks() self.subwindows.append(self.plotter) # Setup menubar self.setMenuBar(QtWidgets.QMenuBar()) # Windows actions self.menu_windows = QtWidgets.QMenu('Windows') self.menuBar().addMenu(self.menu_windows) self.window_toggles = [] for subwin in self.subwindows: self.window_toggles.append(QtGui.QAction(f'Toggle {subwin.windowTitle()}')) self.window_toggles[-1].triggered.connect(subwin.toggle_visibility) self.menu_windows.addAction(self.window_toggles[-1]) # Processes actions self.menu_process = QtWidgets.QMenu('Processes') self.menuBar().addMenu(self.menu_process) # Restart display module if config.CONF_DISPLAY_USE: self.menu_process.restart_display = QtGui.QAction('Restart display') self.menu_process.restart_display.triggered.connect(self.restart_display) self.menu_process.addAction(self.menu_process.restart_display) self.menu_process.restart_display.setShortcut('Ctrl+Alt+Shift+d') self.menu_process.restart_display.setAutoRepeat(False) # Restart camera module if config.CONF_CAMERA_USE: self.menu_process.restart_camera = QtGui.QAction('Restart camera') self.menu_process.restart_camera.triggered.connect(self.restart_camera) self.menu_process.addAction(self.menu_process.restart_camera) self.menu_process.restart_camera.setShortcut('Ctrl+Alt+Shift+c') self.menu_process.restart_camera.setAutoRepeat(False) # Set theme extra = {'density_scale': '-3', } apply_stylesheet(vxipc.Process.app, theme='dark_amber.xml', invert_secondary=False, extra=extra)
print("%s entries" % len(data)) for r, d in enumerate(data): #r: row number, d: data for this row - 'SHOT', 'TASK', 'VERSION', 'COMMENTS', 'NOTES' # self.setRowHeight(r,24) for i, c in enumerate(ls_header): # i: column index, c: column title # SHOT: String | TASK: String with completer | VERSION: Integer | COMMENTS: String | NOTES: String setCell(obj_table, d, r, c, i) obj_table.scrollToBottom() # ------------------------------------------------------------------------------ # Instancing and Regestering # ------------------------------------------------------------------------------ try: if nuke.GUI: nukescripts.registerWidgetAsPanel( 'mod_ShotStatusTracker.Core_ShotStatusTracker', 'Shot Status Tracker', 'jiangovfx.ShotStatusTracker') except: app = QtWidgets.QApplication(sys.argv) try: apply_stylesheet(app, theme='dark_teal.xml') except: print("Qt-Material not imported") ShotStatusTracker = Core_ShotStatusTracker() ShotStatusTracker.run() app.exec_()
# ------------------------machine learn --------------- @pyqtSlot() def on_predict_clicked(self): predict_json = [ self.company_size_predict.value(), self.education_predict.currentText(), self.work_city_predict.text(), self.work_type_predict.currentText(), self.exp_predict.value(), self.kw_predict.text() ] label, prob, log_prob = get_predict_result(predict_json) if label[0]: self.lcdNumber.display(6000 + 6000 * prob[0][1]) else: self.lcdNumber.display(6000 - 6000 * prob[0][1]) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) # setup stylesheet apply_stylesheet( app, theme='dark_yellow.xml') #light_teal dark_teal light_yellow lcdFontId = QFontDatabase.addApplicationFont('ui/NotoSerifSC-Light.otf') app.setFont(QFont(QFontDatabase.applicationFontFamilies(lcdFontId)[0])) app.setWindowIcon(QIcon('ui/favicon.ico')) win = Window() win.show() sys.exit(app.exec())
'success': '#17a2b8', # Font 'font_family': 'monoespace', 'font_size': '13px', 'line_height': '13px', } ######################################################################## class RuntimeStylesheets(QMainWindow): # ---------------------------------------------------------------------- def __init__(self): """""" super().__init__() self.main = QUiLoader().load('main_window_extra.ui', self) self.main.pushButton_danger.setProperty('class', 'danger') self.main.pushButton_warning.setProperty('class', 'warning') self.main.pushButton_success.setProperty('class', 'success') if __name__ == "__main__": app = QApplication() apply_stylesheet(app, theme='light_blue.xml', extra=extra) frame = RuntimeStylesheets() frame.main.show() app.exec_()
# Start PySide2 gui app = QApplication(sys.argv) # Set application name app.setApplicationName("UniqueBible.app") app.setApplicationDisplayName("UniqueBible.app") # When application name is changed app.applicationNameChanged.connect(nameChanged) # Assign a function to save configurations when the app is closed. app.aboutToQuit.connect(exitApplication) # Apply window style if config.windowStyle and config.windowStyle in QStyleFactory.keys(): app.setStyle(config.windowStyle) # Apply theme style if config.qtMaterial and config.qtMaterialTheme: apply_stylesheet(app, theme=config.qtMaterialTheme) config.theme = "dark" if config.qtMaterialTheme.startswith("dark_") else "default" else: app.setPalette(Themes.getPalette()) # Active verse number colour #config.activeVerseNoColour = config.activeVerseNoColourDark if config.theme == "dark" else config.activeVerseNoColourLight # Assign mainWindow to config.mainWindow, to make it acessible from user customised user script config.mainWindow = MainWindow() # Check screen size availableGeometry = app.desktop().availableGeometry(config.mainWindow) setupMainWindow(availableGeometry) # A container of functions to be run after UBA loaded history records on startup # This offers a way for startup plugins to run codes after history records being loaded.
""""The main file for the CSC111 term project. See report for usage instructions. Tested on Windows 10, Python 3.9.1, 64 bit. """ import sys from PySide6.QtWidgets import QApplication from qt_material import apply_stylesheet from configuration import Config import initialization import interface as ui if __name__ == '__main__': initialization.create_project_dirs() config = Config() app = QApplication(sys.argv) apply_stylesheet(app, theme='dark_purple.xml') # Assigning the window to a variable seems to be required. ex = ui.MainWindow(config) sys.exit(app.exec_())
T0 = 1000 if __name__ == "__main__": # ---------------------------------------------------------------------- def take_screenshot(): pixmap = frame.main.grab() pixmap.save(os.path.join('screenshots', f'{theme}.png')) print(f'Saving {theme}') try: theme = sys.argv[2] QTimer.singleShot(T0, take_screenshot) QTimer.singleShot(T0 * 2, app.closeAllWindows) except: theme = 'default' # Set theme on in itialization apply_stylesheet(app, theme + '.xml', invert_secondary=('light' in theme and 'dark' not in theme), extra=extra) frame = RuntimeStylesheets() frame.main.show() app.exec_()