def __init__(self): super(MainWindow, self).__init__() toolBar = QToolBar() self.addToolBar(toolBar) file_menu = self.menuBar().addMenu('&File') open_auction = QAction(QIcon.fromTheme('document-open'), "&open..", self, shortcut=QKeySequence.Open, triggered=self.open) file_menu.addAction(open_auction) exit_action = QAction(QIcon.fromTheme("application-exit"), "E&xit", self, shortcut="Ctrl+q", triggered=self.close) file_menu.addAction(exit_action) play_menu = self.menuBar().addMenu('&Play') play_icon = QIcon(QPixmap(":/icons/01.png")) # 增加一个Action到toolBar toolBar.addAction(play_icon, "Play") play_action = QAction(play_icon, "E&s", self, shortcut="Ctrl+e", triggered=self.close) play_menu.addAction(play_action)
def setup_ui(self, main_window_instance): self.main_window_instance = main_window_instance self.call_class = MainPageCallClass() self.add_on_options_controller = AddOptions(self) ########################################## # IMPLEMENTATION OF THE MAIN PAGE VIEW # ########################################## if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" self.stylesheet = open(resource_path(self.stylesheet_path)).read() window_icon = QIcon() window_icon.addPixmap(QPixmap(resource_path( "res/images/icon.ico")), QIcon.Normal, QIcon.Off) self.main_window_instance.setMinimumSize(1080, 700) self.main_window_instance.setObjectName("MainOnkoDicomWindowInstance") self.main_window_instance.setWindowIcon(window_icon) self.main_window_instance.setStyleSheet(self.stylesheet) self.setup_central_widget() self.setup_actions() # Create SUV2ROI object and connect signals self.suv2roi = SUV2ROI() self.suv2roi_progress_window = \ ProgressWindow(self.main_window_instance, QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint) self.suv2roi_progress_window.signal_loaded.connect( self.on_loaded_suv2roi)
def __init__(self, parent=None): super(SettingsTree, self).__init__(parent) self._type_checker = TypeChecker() self.setItemDelegate(VariantDelegate(self._type_checker, self)) self.setHeaderLabels(("Setting", "Type", "Value")) self.header().setSectionResizeMode(0, QHeaderView.Stretch) self.header().setSectionResizeMode(2, QHeaderView.Stretch) self.settings = None self.refresh_timer = QTimer() self.refresh_timer.setInterval(2000) self.auto_refresh = False self.group_icon = QIcon() style = self.style() self.group_icon.addPixmap(style.standardPixmap(QStyle.SP_DirClosedIcon), QIcon.Normal, QIcon.Off) self.group_icon.addPixmap(style.standardPixmap(QStyle.SP_DirOpenIcon), QIcon.Normal, QIcon.On) self.key_icon = QIcon() self.key_icon.addPixmap(style.standardPixmap(QStyle.SP_FileIcon)) self.refresh_timer.timeout.connect(self.maybe_refresh)
def store_menu(self): """Toggle between Main view and Store view.""" widgets = (ui.layout_widget_buttons, ui.label_space, ui.label_size) if self.is_link_menu: self.is_link_menu = False ui.label_info.setText(self.main_title) ui.store_btn.setIcon(QIcon(':/icon/store_icon.png')) for i in self.apps_dict: i.setEnabled(False) i.setChecked(False) for i in self.installed_apps: i.setEnabled(True) for i in self.selected_apps: i.setChecked(True) self.enable_buttons() for widget in widgets: widget.show() else: self.is_link_menu = True ui.label_info.setText(self.store_title) ui.store_btn.setIcon(QIcon(':/icon/back_icon.png')) for i in self.apps_dict: i.setEnabled(True) i.setChecked(True) for widget in widgets: widget.hide()
def __init__(self, persepolis_setting): super().__init__() icon = QIcon() self.persepolis_setting = persepolis_setting # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) self.setWindowIcon( QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg'))) self.setWindowTitle( QCoreApplication.translate("setting_ui_tr", 'Preferences')) # set ui direction ui_direction = self.persepolis_setting.value('ui_direction') if ui_direction == 'rtl': self.setLayoutDirection(Qt.RightToLeft) elif ui_direction in 'ltr': self.setLayoutDirection(Qt.LeftToRight) global icons icons = ':/' + str( self.persepolis_setting.value('settings/icons')) + '/' window_verticalLayout = QVBoxLayout(self) self.pressKeyLabel = QLabel(self) window_verticalLayout.addWidget(self.pressKeyLabel) self.capturedKeyLabel = QLabel(self) window_verticalLayout.addWidget(self.capturedKeyLabel) # window buttons buttons_horizontalLayout = QHBoxLayout() buttons_horizontalLayout.addStretch(1) self.cancel_pushButton = QPushButton(self) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) buttons_horizontalLayout.addWidget(self.cancel_pushButton) self.ok_pushButton = QPushButton(self) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) buttons_horizontalLayout.addWidget(self.ok_pushButton) window_verticalLayout.addLayout(buttons_horizontalLayout) # labels self.pressKeyLabel.setText( QCoreApplication.translate("setting_ui_tr", "Press new keys")) self.cancel_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "Cancel")) self.ok_pushButton.setText( QCoreApplication.translate("setting_ui_tr", "OK"))
def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle('PySide6 WebEngineWidgets Example') self.toolBar = QToolBar() self.addToolBar(self.toolBar) self.backButton = QPushButton() self.backButton.setIcon(QIcon(':/qt-project.org/styles/commonstyle/images/left-32.png')) self.backButton.clicked.connect(self.back) self.toolBar.addWidget(self.backButton) self.forwardButton = QPushButton() self.forwardButton.setIcon(QIcon(':/qt-project.org/styles/commonstyle/images/right-32.png')) self.forwardButton.clicked.connect(self.forward) self.toolBar.addWidget(self.forwardButton) self.addressLineEdit = QLineEdit() self.addressLineEdit.returnPressed.connect(self.load) self.toolBar.addWidget(self.addressLineEdit) self.webEngineView = QWebEngineView() self.setCentralWidget(self.webEngineView) initialUrl = 'http://qt.io' self.addressLineEdit.setText(initialUrl) self.webEngineView.load(QUrl(initialUrl)) self.webEngineView.page().titleChanged.connect(self.setWindowTitle) self.webEngineView.page().urlChanged.connect(self.urlChanged)
def __init__(self): super(FindToolBar, self).__init__() self._line_edit = QLineEdit() self._line_edit.setClearButtonEnabled(True) self._line_edit.setPlaceholderText("Find...") self._line_edit.setMaximumWidth(300) self._line_edit.returnPressed.connect(self._find_next) self.addWidget(self._line_edit) self._previous_button = QToolButton() style_icons = ':/qt-project.org/styles/commonstyle/images/' self._previous_button.setIcon(QIcon(style_icons + 'up-32.png')) self._previous_button.clicked.connect(self._find_previous) self.addWidget(self._previous_button) self._next_button = QToolButton() self._next_button.setIcon(QIcon(style_icons + 'down-32.png')) self._next_button.clicked.connect(self._find_next) self.addWidget(self._next_button) self._case_sensitive_checkbox = QCheckBox('Case Sensitive') self.addWidget(self._case_sensitive_checkbox) self._hideButton = QToolButton() self._hideButton.setShortcut(QKeySequence(Qt.Key_Escape)) self._hideButton.setIcon(QIcon(style_icons + 'closedock-16.png')) self._hideButton.clicked.connect(self.hide) self.addWidget(self._hideButton)
def changeIcon(self, icons): icons = ':/' + str(icons) + '/' self.close_pushButton.setIcon(QIcon(icons + 'remove')) self.copy_log_pushButton.setIcon(QIcon(icons + 'clipboard')) self.report_pushButton.setIcon(QIcon(icons + 'about')) self.refresh_log_pushButton.setIcon(QIcon(icons + 'refresh'))
def __init__(self, parent=None): super(Window, self).__init__(parent) self.createTrayIcon() self.createProgramsList() self.createCodeEditPage() self.logsPage = QTextBrowser() self.documentation = QTextBrowser() self.tabWidget = QTabWidget() self.tabWidget.setIconSize(QSize(64, 64)) self.tabWidget.addTab(self.programsListPage, QIcon(":/images/Adventure-Map-icon.png"), "Programs") self.tabWidget.addTab(self.codeEditPage, QIcon(":/images/Sword-icon.png"), "Edit Program") self.tabWidget.addTab(self.logsPage, QIcon(":/images/Spell-Scroll-icon.png"), "Logs") self.tabWidget.addTab(self.documentation, QIcon(":/images/Spell-Book-icon.png"), "Documentation") self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.tabWidget) self.setLayout(self.mainLayout) self.setWindowTitle(APP_NAME) self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.Dialog) self.resize(800, 600) self.systrayHintMsgShowed = False self.firstShow = True self.fromQuit = False
def changeIcon(self, icons): icons = ':/' + str(icons) + '/' self.folder_pushButton.setIcon(QIcon(icons + 'folder')) self.download_later_pushButton.setIcon(QIcon(icons + 'stop')) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) self.ok_pushButton.setIcon(QIcon(icons + 'ok'))
def change_update_check(self): """ Callback after the check for an update was finished. """ if not self._update_check_runner.check_succeed: self.update_status.setPixmap( QIcon(str(pkg_data.ERROR_SYMBOL)).pixmap( QSize(self.update_info.height() * 0.8, self.update_info.height() * 0.8))) self.update_info.setText(self._update_check_runner.err_msg) return if self._update_check_runner.update_available: self.update_status.setPixmap( QIcon(str(pkg_data.WARNING_SYMBOL)).pixmap( QSize(self.update_info.height() * 0.8, self.update_info.height() * 0.8))) self.update_info.setText("An Update is available.") # executed in a top-level script environment e.g. pythonw -m mp3monitoring --gui, ONLY then we can update, otherwise the executable is locked if Path(sys.modules['__main__'].__file__) == Path( sysconfig.get_paths() ['purelib']) / "mp3monitoring" / "__main__.py": self.update_now.show() else: self.update_status.setPixmap( QIcon(str(pkg_data.OK_SYMBOL)).pixmap( QSize(self.update_info.height() * 0.8, self.update_info.height() * 0.8))) self.update_info.setText("MP3 Monitoring is up to date.") self.update_now.hide()
def __init__(self, parent): super().__init__(parent) self.setupUi(self) self.setWindowFlags(self.windowFlags() & ~(Qt.WindowContextHelpButtonHint | Qt.MSWindowsFixedSizeDialogHint)) # set descriptions self.version.setText(static_data.VERSION) self.author.setText( f"<a href=\"{static_data.AUTHOR_GITHUB}\">{static_data.AUTHOR}</a>" ) self.license.setText( "<a href=\"https://github.com/IceflowRE/mp3monitoring/blob/main/LICENSE.md\">GPLv3</a>" ) self.website.setText( f"<a href=\"{static_data.PROJECT_URL}\">Github</a>") # set logo self.logo.setPixmap(QIcon(str(pkg_data.LOGO)).pixmap(QSize(250, 250))) self._update_app_runner = UpdateAppThread() self._update_app_runner.finished.connect(self.update_app_check) self.update_now.clicked.connect(self.update_app) self.update_now.hide() self.update_status.setPixmap( QIcon(str(pkg_data.WAIT_SYMBOL)).pixmap( QSize(self.update_info.height() * 0.8, self.update_info.height() * 0.8))) self._update_check_runner = UpdateCheckThread() self._update_check_runner.finished.connect(self.change_update_check) self._update_check_runner.start()
def __init__(self, *args, **kwargs): super(ProgressWindow, self).__init__(*args, **kwargs) # Setting up progress bar self.progress_bar = QtWidgets.QProgressBar() self.progress_bar.setGeometry(10, 50, 230, 20) self.progress_bar.setMaximum(100) self.setWindowTitle("Loading") self.setFixedSize(248, 80) self.text_field = QLabel("Loading") if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" self.stylesheet = open(resource_path(self.stylesheet_path)).read() window_icon = QIcon() window_icon.addPixmap(QPixmap(resource_path("res/images/icon.ico")), QIcon.Normal, QIcon.Off) self.setWindowIcon(window_icon) self.progress_bar.setStyleSheet(self.stylesheet) self.layout = QVBoxLayout() self.layout.addWidget(self.text_field) self.layout.addWidget(self.progress_bar) self.setLayout(self.layout) self.threadpool = QThreadPool() self.interrupt_flag = threading.Event()
def setup_ui(self, main_window_instance): self.main_window_instance = main_window_instance self.call_class = MainPageCallClass() self.add_on_options_controller = AddOptions(self) ########################################## # IMPLEMENTATION OF THE MAIN PAGE VIEW # ########################################## if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" stylesheet = open(resource_path(self.stylesheet_path)).read() window_icon = QIcon() window_icon.addPixmap(QPixmap(resource_path("res/images/icon.ico")), QIcon.Normal, QIcon.Off) self.main_window_instance.setMinimumSize(1080, 700) self.main_window_instance.setObjectName("MainOnkoDicomWindowInstance") self.main_window_instance.setWindowIcon(window_icon) self.main_window_instance.setStyleSheet(stylesheet) self.setup_central_widget() # Create actions and set menu and tool bars self.action_handler = ActionHandler(self) self.menubar = MenuBar(self.action_handler) self.main_window_instance.setMenuBar(self.menubar) self.toolbar = Toolbar(self.action_handler) self.main_window_instance.addToolBar(QtCore.Qt.TopToolBarArea, self.toolbar) self.main_window_instance.setWindowTitle("OnkoDICOM")
def set_icon(status): if status == 'caps': self.setIcon(QIcon(self.caps_ico)) self.setToolTip('大写') else: self.setIcon(QIcon(self.small_ico)) self.setToolTip('小写')
def initUI(self): exitAction = QAction(QIcon('icons/exit.bmp'), 'Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(self.close) helpAction = QAction(QIcon('icons/help.png'), 'Version', self) helpAction.setShortcut('Ctrl+D') helpAction.setStatusTip('Show application\'s version') helpAction.triggered.connect(self.show_version) qt_version_helpAction = QAction(QIcon('icons/help.png'), "Qt's version", self) qt_version_helpAction.setShortcut('Ctrl+A') qt_version_helpAction.setStatusTip('Show Qt\'s version') qt_version_helpAction.triggered.connect(self.show_qt_version) self.statusBar() menubar = self.menuBar() fileMenu = menubar.addMenu('File') menubar.addMenu('Edit') helpMenu = menubar.addMenu('Help') fileMenu.addAction(exitAction) helpMenu.addAction(helpAction) helpMenu.addSeparator() helpMenu.addAction(qt_version_helpAction) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Menubar') self.show()
def createTabs(self, parent: QTabWidget): # tab_pcs tab_pcs = TabPCS(self.db) parent.addTab(tab_pcs, QIcon(self.icons.CLIP), 'PCS') # tab_db tab_db = TabDB(self.db) parent.addTab(tab_db, QIcon(self.icons.DB), 'Database')
def event(self, ev): """Catch system events.""" if ev.type() == QEvent.PaletteChange: # detect theme switches style = interface_style() # light or dark if style is not None: QIcon.setThemeName(style) else: QIcon.setThemeName("light") # fallback return super().event(ev)
def __init__(self, text): """ Initialises the widget :param text: the window selected """ super(Windowing, self).__init__() self.pt_ct_dict_container = PTCTDictContainer() self.moving_dict_container = MovingDictContainer() if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" self.stylesheet = open(resource_path(self.stylesheet_path)).read() window_icon = QIcon() window_icon.addPixmap(QPixmap(resource_path("res/images/icon.ico")), QIcon.Normal, QIcon.Off) self.setWindowIcon(window_icon) self.setStyleSheet(self.stylesheet) self.text = text self.layout = QVBoxLayout() self.buttons = QHBoxLayout() self.setWindowTitle("Select Views") self.label = QLabel("Select views to apply windowing to:") self.normal = QtWidgets.QCheckBox("DICOM View") self.pet = QtWidgets.QCheckBox("PET/CT: PET") self.ct = QtWidgets.QCheckBox("PET/CT: CT") self.fusion = QtWidgets.QCheckBox("Image Fusion") self.confirm = QtWidgets.QPushButton("Confirm") self.cancel = QtWidgets.QPushButton("Cancel") self.confirm.clicked.connect(self.confirmed) self.confirm.setProperty("QPushButtonClass", "success-button") self.cancel.clicked.connect(self.exit_button) self.cancel.setProperty("QPushButtonClass", "fail-button") self.buttons.addWidget(self.cancel) self.buttons.addWidget(self.confirm) self.layout.addWidget(self.label) self.layout.addWidget(self.normal) if not self.pt_ct_dict_container.is_empty(): self.layout.addWidget(self.pet) self.layout.addWidget(self.ct) if not self.moving_dict_container.is_empty(): self.layout.addWidget(self.fusion) self.layout.addLayout(self.buttons) self.setLayout(self.layout)
def __init__(self, id, name, thumbnail): self._id = id self._name = name img = qimage_argb32_from_png_decoding(thumbnail) self._thumbnail_icon = QIcon() if img.is_null() else QIcon( QPixmap.from_image(img)) super().__init__(self._thumbnail_icon, self._name)
def clickedFavourite(self): # Toggle Icon and DB state of song being favourited # For artists only if self.favouriteButton.isFavourited: self.favouriteButton.isFavourited = False self.favouriteButton.setIcon(QIcon("icons/star.svg")) else: self.favouriteButton.isFavourited = True self.favouriteButton.setIcon( QIcon("icons/star-yellow.svg")) DB.setFavouriteArtist(self.result["artist_id"])
def __init__(self, result, parent=None): QToolButton.__init__(self) self.setParent(parent) self.result = result self.setContentsMargins(0, 0, 0, 0) # Button formatting self.setFixedSize(200, 240) self.setAutoRaise(True) # TODO: change with global themes self.setStyleSheet( "QToolButton:pressed { background-color: rgba(255, 255, 255, 0.1)} QToolButton { background-color: rgba(255, 255, 255, 0.05); border: 1px solid white; color: white}" ) # Set layout settings self.layout = QGridLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) if result["type"] == "artists": # Artist image self.formattedImage(self.window().artistPath + result["artist_path"]) self.formattedLabel(result["artist_name"]) # Favourite button self.favouriteButton = QToolButton() self.favouriteButton.setStyleSheet( "QToolButton:pressed { background-color: rgb(31, 41, 75)} QToolButton { background-color: rgb(25, 33, 60);}" ) # Toggle Favourite Icon depending on DB if self.result["favourited"] == 0: self.favouriteButton.isFavourited = False self.favouriteButton.setIcon(QIcon("icons/star.svg")) else: self.favouriteButton.isFavourited = True self.favouriteButton.setIcon( QIcon("icons/star-yellow.svg")) self.favouriteButton.setIconSize(QSize(30, 30)) self.favouriteButton.setFixedSize(70, 70) self.favouriteButton.clicked.connect(self.clickedFavourite) self.layout.addWidget(self.favouriteButton, 0, 0, Qt.AlignRight | Qt.AlignTop) self.clicked.connect(self.clickedArtist) elif result["type"] == "languages": # Language image self.formattedImage(self.window().languagePath + result["language_path"]) self.formattedLabel(result["language_name"]) self.clicked.connect(self.clickedLanguage) self.setLayout(self.layout)
def __init__(self): super(MainWindow, self).__init__() self.cameraInfo = QCameraInfo.defaultCamera() self.camera = QCamera(self.cameraInfo) self.camera.setCaptureMode(QCamera.CaptureStillImage) self.imageCapture = QCameraImageCapture(self.camera) self.imageCapture.imageCaptured.connect(self.imageCaptured) self.imageCapture.imageSaved.connect(self.imageSaved) self.currentPreview = QImage() toolBar = QToolBar() self.addToolBar(toolBar) fileMenu = self.menuBar().addMenu("&File") shutterIcon = QIcon( os.path.join(os.path.dirname(__file__), "shutter.svg")) self.takePictureAction = QAction(shutterIcon, "&Take Picture", self, shortcut="Ctrl+T", triggered=self.takePicture) self.takePictureAction.setToolTip("Take Picture") fileMenu.addAction(self.takePictureAction) toolBar.addAction(self.takePictureAction) exitAction = QAction(QIcon.fromTheme("application-exit"), "E&xit", self, shortcut="Ctrl+Q", triggered=self.close) fileMenu.addAction(exitAction) aboutMenu = self.menuBar().addMenu("&About") aboutQtAction = QAction("About &Qt", self, triggered=qApp.aboutQt) aboutMenu.addAction(aboutQtAction) self.tabWidget = QTabWidget() self.setCentralWidget(self.tabWidget) self.cameraViewfinder = QCameraViewfinder() self.camera.setViewfinder(self.cameraViewfinder) self.tabWidget.addTab(self.cameraViewfinder, "Viewfinder") if self.camera.status() != QCamera.UnavailableStatus: name = self.cameraInfo.description() self.setWindowTitle("PySide6 Camera Example (" + name + ")") self.statusBar().showMessage("Starting: '" + name + "'", 5000) self.camera.start() else: self.setWindowTitle("PySide6 Camera Example") self.takePictureAction.setEnabled(False) self.statusBar().showMessage("Camera unavailable", 5000)
def set_icon(self): self.setIconSize(QSize(45, 45)) self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) if self.extension in ["txt", "xml", "json", "docx", "xlsx"]: self.setIcon(QIcon(resource_path('icons/Txt.png'))) elif self.extension in ["mp4", "avi", "mpeg", "wmv"]: self.setIcon(QIcon(resource_path('icons/Video.png'))) elif self.extension in ["jpg", "png", "gif"]: self.setIcon(QIcon(resource_path('icons/Immagine.png'))) elif self.extension in ["mp3", "wav", "ogg"]: self.setIcon(QIcon(resource_path('icons/Audio.png'))) else: self.setIcon(QIcon(resource_path('icons/DocGenerico.png')))
def header_check_box_clicked(self, col): '''由表头中的全选框触发''' if col == 0: if self.tableWidget.horizontalHeaderItem( 0).icon().cacheKey() == self.unchecked_cachekey: self.tableWidget.horizontalHeaderItem(0).setIcon( QIcon(QPixmap(self.checked_img))) self.select_all() else: self.tableWidget.horizontalHeaderItem(0).setIcon( QIcon(QPixmap(self.unchecked_img))) self.unchecked_cachekey = self.tableWidget.horizontalHeaderItem( 0).icon().cacheKey() # unchecked_cachekey会变化 self.unselect_all()
def __init__(self, parent=None): super(Pryme2, self).__init__(parent) self.timer_instances = (SimpleTimer(), AlarmClock(), PomoTimer()) self.timer_selection = QComboBox(self) for t in self.timer_instances: self.timer_selection.addItem(t.name) self.timer = self.timer_instances[0] self.commitment_textbox = QLineEdit(self) self.commitment_textbox.setPlaceholderText( 'What do you want to commit?') self.commitment_textbox.setClearButtonEnabled(True) self.commit_done_btn = QPushButton('&Done', self) self.start_btn = QPushButton('&Start', self) self.abort_btn = QPushButton('&Abort', self) self.abort_btn.hide() self.pause_btn = QPushButton('&Pause', self) self.pause_btn.hide() self.resume_btn = QPushButton('&Resume', self) self.resume_btn.hide() self.tray = QSystemTrayIcon(self) self.tray.setIcon(QIcon('pryme-logo.svg')) self.tray.show() self.set_ui() self.set_connection() self.show()
def __init__(self, completed_words): super(Results, self).__init__() self.ui = Ui_Results() self.ui.setupUi(self) # Иконка приложения i_app = QIcon(QPixmap(":/icon.ico")) self.setWindowIcon(i_app) # Для установки стилей self.ui.l_header.setObjectName("header") self.ui.l_grade.setObjectName("grade") self.ui.l_comment.setObjectName("comment") self.ui.pb_menu.setObjectName("context-button") self.ui.pb_again.setObjectName("context-button") self.ui.pb_exit.setObjectName("context-button") self.ui.pb_cont.setObjectName("context-button") # Функционал кнопок self.ui.pb_exit.clicked.connect(self.exit) self.ui.pb_menu.clicked.connect(self.menu) self.ui.pb_again.clicked.connect(self.again) self.ui.pb_cont.clicked.connect(self.repeat) self.completed_words = completed_words # Скрытие кнопки "повторение", если были ошибки в словах global bad_words if len(bad_words) <= 0: self.ui.pb_cont.hide() self.results()
def __init__(self): super(Settings, self).__init__() self.ui = Ui_Settings() self.ui.setupUi(self) self.setAttribute(Qt.WA_QuitOnClose, False) # Закрываем окно, если оно последнее self.ui.pb_save.setObjectName("context-button") self.ui.pb_cancel.setObjectName("context-button") # ВРЕМЕННОЕ СКРЫТИЕ ПУНКТА "УМНОЕ ПРЕДЛОЖЕНИЕ" self.ui.l_8.hide() self.ui.cb_3.hide() self.ui.l_10.hide() self.ui.sb_4.hide() # Иконка приложения i_app = QIcon(QPixmap(":/icon.ico")) self.setWindowIcon(i_app) # Даю функционал кнопкам self.ui.pb_save.clicked.connect(self.save_settings) self.ui.pb_cancel.clicked.connect(self.close) self.ui.cb_1.clicked.connect(lambda x=self.ui.cb_1, y=self.ui.sb_3: self.check_cb_state(x, y)) self.ui.cb_3.clicked.connect(lambda x=self.ui.cb_3, y=self.ui.sb_4: self.check_cb_state(x, y)) # Актуализирую отображение сохранённых раннее настроек self.update_settings()
def __init__(self, app: "MainWindow", parent=None): super(FormationExtrapolator, self).__init__(parent) self.app = app self.setWindowTitle(self.app.settings.WINDOW_TITLE) self.setWindowIcon(QIcon(self.app.settings.WINDOW_ICON)) layout = QVBoxLayout() self.table = QTableWidget(10, 5) self.table.setMinimumWidth(500) self.table.setMinimumHeight(500) self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.table.setFocusPolicy(Qt.NoFocus) self.table.setSelectionMode(QAbstractItemView.NoSelection) self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) labels = ["Formation\nAccumulator", "Formation ID", "Enemies", "Enemy\nFormation", "Preemptable"] for i in range(len(labels)): self.table.setHorizontalHeaderItem(i, QTableWidgetItem(labels[i])) for j in range(self.table.rowCount()): self.table.setCellWidget(j, i, QLabel()) for i in range(self.table.rowCount()): self.table.setVerticalHeaderItem(i, QTableWidgetItem("")) layout.addWidget(self.table) self.setLayout(layout) self.show()
def main_app(base_path, file, file_config): """Run the GUI of xBan The function initiates and resize the application """ app = QApplication(sys.argv) if hasattr(QStyleFactory, "AA_UseHighDpiPixmaps"): app.setAttribute(Qt.AA_UseHighDpiPixmaps) with open(os.path.join(base_path, "xBanStyle.css"), "r") as style_sheet: style = style_sheet.read() app.setWindowIcon(QIcon(os.path.join(base_path, "xBanUI.png"))) xBanApp = xBanWindow(base_path, file, file_config) xBanApp.setStyleSheet(style) # resize and move screen to center primary_screen = QGuiApplication.primaryScreen() if primary_screen: screen_size = primary_screen.availableSize() xBanApp.resize(screen_size.width() / 3, screen_size.height() / 2) xBanApp.move( (screen_size.width() - xBanApp.width()) / 2, (screen_size.height() - xBanApp.height()) / 2, ) app.setStyle("Fusion") sys.exit(app.exec_()) else: main_logger.error("Primary screen not found")