def iconize_controls(self): Lumberjack.info('< MainApp > - -> (iconize_controls)') homeIcon = qta.icon('fa.home', color='white') self.actionHome.setIcon(homeIcon) wrenchIcon = qta.icon('fa.wrench', color='white') self.actionSettings.setIcon(wrenchIcon) bankIcon = qta.icon('fa.bank', color='white') self.actionListBankAccounts.setIcon(bankIcon) contractIcon = QIcon(':/app_icons/rc/handshake_icon.svg') self.actionListContracts.setIcon(contractIcon) atIcon = qta.icon('fa.at', color='white') self.actionListEmailAddresses.setIcon(atIcon) envelopeIcon = qta.icon('fa.envelope', color='white') self.actionListLetters.setIcon(envelopeIcon) relationIcon = qta.icon('fa.group', color='white') self.actionListRelations.setIcon(relationIcon) transactionIcon = qta.icon('fa.money', color='white') self.actionListTransactions.setIcon(transactionIcon) userIcon = qta.icon('fa.user', color='white') self.actionListUsers.setIcon(userIcon) helpIcon = qta.icon('fa.question', color='white') self.actionHelp.setIcon(helpIcon) aboutIcon = qta.icon('fa.info', color='white') self.actionAbout.setIcon(aboutIcon)
def __init__(self, app): super(MainWindow, self).__init__() self.app = app self.button_lock = False self.ui = Ui_MainWindow() self.ui.setupUi(self) # TODO Move this shit into the ui setup method for button in self.BUTTONS: button = getattr(self.ui, button) button.locks = {} self.ui.flowLayout = FlowLayout(self.ui.scrollAreaWidgetContents) self.ui.searchButton.clicked.connect(self.search) self.ui.refreshButton.clicked.connect(self.refresh_button_handler) self.ui.saveButton.clicked.connect(self.app.update_config) self.ui.cancelButton.clicked.connect(self.app.load_config) self.ui.nextButton.clicked.connect(self.next_page) self.ui.prevButton.clicked.connect(self.prev_page) self.ui.directories.clicked.connect(self.browse) self.ui.sortButton.clicked.connect(self.app.sort) self.ui.searchButton.setText("") self.ui.searchButton.setIcon(qta.icon("fa.search", color="#F1F1F1", scale_factor=.9)) self.ui.nextButton.setText("") self.ui.nextButton.setIcon(qta.icon("fa.forward", color="#F1F1F1", scale_factor=.9)) self.ui.prevButton.setText("") self.ui.prevButton.setIcon(qta.icon("fa.backward", color="#F1F1F1", scale_factor=.9)) self.configure_combo_box() self.update_completer() self.status_messenger = CQSpinner(self.ui.scrollArea) position = self.frameGeometry() position.moveCenter( QtGui.QDesktopWidget().availableGeometry().center()) self.show() self.raise_()
def __init__(self): super(main_window, self).__init__() # Set up the user interface from Designer. self.ui = Ui_MainWindow() self.ui.setupUi(self) #Creating some variables for dinamic QR: self.qr_version = 7 self.ui.versionLcd.display(self.qr_version) #Connecting the buttons: self.ui.quitButton.clicked.connect(self.close_app) self.ui.runButton.clicked.connect(self.create_qrcode) self.ui.loadButton.clicked.connect(self.open_file) self.ui.saveButton.clicked.connect(self.save_file) self.ui.saveButton.setDisabled(True) self.ui.downButton.clicked.connect(self.down_version) self.ui.upButton.clicked.connect(self.up_version) # Get icons by name. fa_exit = qta.icon('fa.times', options=[{'scale_factor': 0.8, 'color': 'white'}]) fa_cogs = qta.icon('fa.cogs', options=[{'scale_factor': 0.8, 'color': 'white'}]) fa_folder = qta.icon('fa.folder-open-o', options=[{'scale_factor': 0.8, 'color': 'black'}]) fa_floppy = qta.icon('fa.floppy-o', options=[{'scale_factor': 0.8, 'color': 'black'}]) self.ui.quitButton.setIcon(fa_exit) self.ui.saveButton.setIcon(fa_floppy) self.ui.runButton.setIcon(fa_cogs) self.ui.loadButton.setIcon(fa_folder)
def initalize_gui(self): self.ui.review1.setStyleSheet("background-color: DarkCyan;color: black") self.ui.recommendButton.setStyleSheet("background-color: Tomato;color: black") self.ui.review1.setIcon(qta.icon('fa.flag')) self.ui.recommendButton.setIcon(qta.icon('fa.bullseye')) self.setup_mov_list() self.ui.progressInfo.setVisible(False) self.ui.progressBar.setVisible(False) self.showClickedItem(self.ui.listWidget.item(0))
def update_box(self, text=None): if text: if self._show_icons: self.button_icon.setIcon(qta.icon('fa.remove')) self.button_icon.setProperty('_remove', True) else: if self._show_icons: self.button_icon.setIcon(qta.icon('fa.search')) self.button_icon.setProperty('_remove', False) self._empty = not bool(text) self.button_icon.setDisabled(self._empty)
def _url_validated(self, worker, valid, error): item = worker.item channel = item.data(Qt.DisplayRole).strip().lower() channel = worker.url if valid: temp = list(self._temp_channels) temp.append(channel) self._temp_channels = tuple(temp) item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) item.setCheckState(Qt.Checked) item.setData(Qt.DisplayRole, channel) item.setData(Qt.DecorationRole, QIcon()) else: item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable) item.setData(Qt.DisplayRole, channel) item.setCheckState(Qt.Unchecked) item.setIcon(qta.icon('fa.warning')) item.setToolTip("The channel seems to be invalid.") self.list.editItem(item) self.list.itemChanged.connect(self.edit_channel) self.button_add.setDisabled(False) self.button_delete.setDisabled(False)
def __init__(self): super(StatusWidget, self).__init__() self.button_weird = QtGui.QPushButton(' ready') self.button_weird.setObjectName('linkbutton') self.spin_icon = qta.icon('fa.spinner', color='red', animation=qta.Spin(self.button_weird)) self.button_weird.setIcon(self.spin_icon) self.label = QtGui.QLabel('busy') self.label.setObjectName('small') self.label.setStyleSheet('color: {0};'.format(COLOR_PALETTE['primary'])) self.label_mov = QtGui.QLabel() self.movie = QtGui.QMovie('gui/icons/loader-ring.gif') self.movie.setScaledSize(QtCore.QSize(20,20)) self.label_mov.setMovie(self.movie) self.movie.start() self.label_mov.hide() status_layout = QtGui.QHBoxLayout() status_layout.addWidget(self.label_mov) status_layout.addWidget(self.label) self.setLayout(status_layout) self.active_identities = dict(root=(0, 'ready')) self.last_identity = 'root'
def icon(theme_name='', path='', qta_name='', qta_options=None, use_qta=None): """ Creates an icon from qtawesome, from theme or from path. :param theme_name: icon name in the current theme (GNU/Linux only) :param path: path of the icon (from file system or qrc) :param qta_name: icon name in qtawesome :param qta_options: the qtawesome options to use for controlling icon rendering. If None, QTA_OPTIONS are used. :param use_qta: True to use qtawesome, False to use icon from theme/path. None to use the global setting: USE_QTAWESOME. :returns: QtGui.QIcon """ ret_val = None if use_qta is None: use_qta = USE_QTAWESOME if qta_options is None: qta_options = QTA_OPTIONS if qta is not None and use_qta is True: ret_val = qta.icon(qta_name, **qta_options) else: if theme_name and path: ret_val = QtGui.QIcon.fromTheme(theme_name, QtGui.QIcon(path)) elif theme_name: ret_val = QtGui.QIcon.fromTheme(theme_name) elif path: ret_val = QtGui.QIcon(path) return ret_val
def __init__(self): super().__init__() self.button_go = QtGui.QToolButton() self.button_go.setIcon(qta.icon('fa.bars', color='white', scale_factor=1.0)) self.button_go.setMaximumWidth(40) self.button_go.setMinimumWidth(40) self.button_go.setMinimumHeight(40) self.button_go.setMinimumHeight(40) self.q_menu = QtGui.QMenu() with open('gui/styles/style_template.css', 'r', encoding='utf-8') as fh: src = Template(fh.read()) src = src.substitute(COLOR_PALETTE) # print (src) self.q_menu.setStyleSheet(src) # subwindow_menu.setStyleSheet(fh.read()) self.q_menu.setMinimumWidth(140) self.q_menu.setMaximumWidth(140) self.button_go.setMenu(self.q_menu) self.button_go.setPopupMode(QtGui.QToolButton.InstantPopup) self.hbox = QtGui.QHBoxLayout() self.hbox.setContentsMargins(0, 0, 0, 0) self.hbox.addWidget(self.button_go) self.setContentsMargins(0, 0, 0, 0) self.setLayout(self.hbox)
def get_icon(name): """Return a QIcon from a specified icon name.""" if name in FA_ICONS: args, kwargs = FA_ICONS[name] return qta.icon(*args, **kwargs) elif name in GWHAT_ICONS: return QIcon(os.path.join(DIRNAME, GWHAT_ICONS[name])) else: return QIcon()
def __init__(self): super().__init__() h_icon = qta.icon('fa.home',scale_factor=1.5,active='fa.legal') h_tab = self.addTab(h_icon, 'HOME') self.addTab('GEOMETRY ') self.addTab('MEASUREMENT ') self.addTab('ANALYSIS ') self.addTab('ANIMATION ') self.setContentsMargins(0, 0, 0, 0)
def __init__(self): super().__init__() self.button_go = QtGui.QToolButton() self.button_go.setText('START') self.button_go.setMaximumWidth(140) self.button_go.setMinimumWidth(140) self.q_menu = QtGui.QMenu() with open('gui/styles/style_template.css', 'r', encoding='utf-8') as fh: src = Template(fh.read()) src = src.substitute(COLOR_PALETTE) self.q_menu.setStyleSheet(src) self.q_menu.setMinimumWidth(140) self.q_menu.setMaximumWidth(140) self.button_go.setMenu(self.q_menu) self.button_go.setPopupMode(QtGui.QToolButton.InstantPopup) self.button_open = QtGui.QPushButton(qta.icon('fa.folder-open-o'), 'open') self.button_open.setObjectName('linkbutton') self.button_open.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.button_save = QtGui.QPushButton(qta.icon('fa.save'), 'save') self.button_save.setObjectName('linkbutton') self.button_save.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) # self.button_go.setView(QtGui.QListView()) # self.button_go.setStyleSheet("QComboBox QAbstractItemView::item { min-height: 35px; min-width: 50px; }"); self.button_settings = QtGui.QPushButton(qta.icon('fa.cogs'), 'settings') self.button_settings.setObjectName('linkbutton') self.button_settings.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.hbox = QtGui.QHBoxLayout() self.hbox.addWidget(self.button_go) self.hbox.addStretch() self.hbox.addWidget(self.button_open) self.hbox.addWidget(self.button_save) self.hbox.addWidget(self.button_settings) self.setLayout(self.hbox)
def __init__(self, parent=None, forwards=True): super(QControlButton, self).__init__(parent) # icon_type = "forward" if forwards else "backward" # icon = "fa.%s" % icon_type # options = {"color": "#F1F1F1"} # self.icon = qta.icon(["fa.square-o", icon], options=[options, options]) icon_type = "right" if forwards else "left" icon = qta.icon("fa.chevron-circle-%s" % icon_type, color="#F1F1F1") self.setIcon(icon)
def __init__(self): QDialog.__init__(self) Lumberjack.info('spawning a << TerminationDialog >>') self.setupUi(self) style.set_window_style(self) errorIcon = qta.icon('fa.times-circle', color='#FF1744') errorPixmap = errorIcon.pixmap(50, 50) self.iconContainer.setPixmap(errorPixmap) self.buttonBox.accepted.connect(self.on_accept) self.buttonBox.rejected.connect(self.on_reject)
def gridRowHelper(self, label_txt, info_txt=None): """Helper to construct the widgets that make up the config UI grid rows. Returns (label, info, line_edit) elements. """ label = QtWidgets.QLabel(label_txt) if info_txt: info = QtWidgets.QToolButton() info.setIcon(qta.icon('fa.question')) info.clicked.connect(lambda: self.parent.show_message(info_txt)) else: info = None line_edit = QtWidgets.QLineEdit() return label, info, line_edit
def icon(name, resample=False, icon_path=None): theme = CONF.get('main', 'icon_theme') if theme == 'spyder 3': if not _resource['loaded']: qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json', directory=_resource['directory']) _resource['loaded'] = True args, kwargs = _qtaargs[name] return qta.icon(*args, **kwargs) elif theme == 'spyder 2': icon = get_icon(name + '.png', resample=resample) if icon_path: icon_path = osp.join(icon_path, name + '.png') if osp.isfile(icon_path): icon = QIcon(icon_path) return icon if icon is not None else QIcon()
def _refresh_tasks_list(self, drop_popup=True): # Get tasks self.device_task.blockSignals(True) tasks_tmp = map(bytes.decode, dq.get_daq_tasks()) tasks = list(tasks_tmp).copy() self.device_task.clear() self.device_task.addItem('- Choose task -') for item in tasks: self.device_task.addItem(item) self.device_task.addItem(qta.icon('fa.refresh', scale_factor=0.65, color=COLOR_PALETTE['primaryhex']), 'refresh ') if drop_popup: self.device_task.showPopup() self.device_task.blockSignals(False)
def beautify(self, Form): Form.setWindowOpacity(0.95) palette = QPalette() path = os.path.join('tools', 'win.jpg') palette.setBrush(QPalette.Background, QBrush(QPixmap(path))) Form.setPalette(palette) # icon iconpath = os.path.join('tools', 'amg.jpg') Form.setWindowIcon(QIcon(iconpath)) spin_icon = qtawesome.icon('fa5s.ban', color='black') self.pushButton.setIcon(spin_icon) # 设置pushbutton格式 self.pushButton.setStyleSheet('''QPushButton{border:none;} QPushButton:hover{color:white; border:2px solid #F3F3F5; border-radius:35px; background:darkGray;}''')
def __init__(self, parent=None, prefix=_vaca_prefix): """Init.""" BaseObject.__init__(self, prefix) SiriusMainWindow.__init__(self, parent) self.prefix = prefix self.setObjectName('SIApp') self.setWindowTitle('Orbit Interlock Control Window') color = get_appropriate_color('SI') self.setWindowIcon( qta.icon('mdi.currency-sign', 'mdi.alarm-light', options=[ dict(scale_factor=1, color=color), dict(scale_factor=0.45, color=color), ])) self._setupUi() self.setFocusPolicy(Qt.StrongFocus)
def __init__(self, parent=None): """Init.""" super().__init__(parent) self._macreport = MacReport() self._macreport.connector.timeout = 5 * 60 self.setWindowIcon(qta.icon('fa.book', color='gray')) self.setWindowTitle('Machine Reports') self._fsi = '{:8d}' self._fs1 = '{:8.3f}' self._fs2 = '{:8.3f} ± {:8.3f}' self._fst1 = '{:02d}h{:02d}' self._fst2 = '{:02d}h{:02d} ± {:02d}h{:02d}' self._update_task = None self._setupUi() self.setFocusPolicy(Qt.StrongFocus) self.setFocus(True)
def icon(name, scale_factor=None, resample=False, icon_path=None): theme = CONF.get('appearance', 'icon_theme') if theme == 'spyder 3': if not _resource['loaded']: qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json', directory=_resource['directory']) _resource['loaded'] = True args, kwargs = _qtaargs[name] if scale_factor is not None: kwargs['scale_factor'] = scale_factor return qta.icon(*args, **kwargs) elif theme == 'spyder 2': icon = get_icon(name + '.png', resample=resample) if icon_path: icon_path = osp.join(icon_path, name + '.png') if osp.isfile(icon_path): icon = QIcon(icon_path) return icon if icon is not None else QIcon()
def stopRecord(self): self.stackedWidget.currentWidget().voiceButton.setIcon( qta.icon('fa.microphone')) self.recorder.stop() print('录音结束') to = self.userListWidget.selectedItems()[0].text() if to != self.name: self.client.add_msg(msgtype.FILE, '', { 'to': to, 'filename': self.voiceFileName }) item = QListWidgetItem() item.setSizeHint(QSize(200, 80)) item.setBackground(QColor('#F19483')) fileWidget = FileWidget(self.voiceFileName, 0) fileWidget.fileButton.setObjectName(self.voiceFileName) fileWidget.fileButton.clicked.connect(self.playVoice) self.stackedWidget.currentWidget().msgList.addItem(item) self.stackedWidget.currentWidget().msgList.setItemWidget( item, fileWidget)
def setup(self, text, icon, path): lay = QtWidgets.QHBoxLayout() fileBtn = QtWidgets.QPushButton() close = QtWidgets.QPushButton() lay.setContentsMargins(QtCore.QMargins(0, 0, 10, 0)) fileBtn.setText(text) fileBtn.setIcon(icon) #fileBtn.Align(QtCore.Qt.AlignLeft) fileBtn.setObjectName("openFilesTab") close.setIcon(qta.icon("fa.times", color="white")) close.setObjectName("quitBtn") close.setMaximumWidth(20) OpenFileTab.filePath = path self.setLayout(lay) lay.addWidget(fileBtn) lay.addWidget(close) self.setMaximumWidth(150)
def __init__(self, window, parent, parent_hud, image_display, modules): # store some references self.window = window self.parent_hud = parent_hud self.ImageDisplay = image_display self.modules = modules # create mask display self.MaskDisplay = BigPaintableImageDisplay(parent) self.drawPathItem = QtWidgets.QGraphicsPathItem(parent) self.drawPathItem.setBrush(QtGui.QBrush(QtGui.QColor(255, 255, 255))) self.drawPathItem.setZValue(20) # the mask_type chooser (the buttons for the different mask colors) self.maskTypeChooser = MaskTypeChooser(self, parent_hud) # draw path to display last drawn stroke (only used in auto_update=False mode) self.drawPath = self.drawPathItem.path() self.drawPathItem.setPath(self.drawPath) self.drawPathItem.setZValue(10) # a cursor to display the currently used brush color and size self.DrawCursor = QtWidgets.QGraphicsPathItem(parent) self.DrawCursor.setZValue(10) self.DrawCursor.setVisible(False) self.UpdateDrawCursorDisplay() # a button to display/hide the mask interface self.buttonMask = QtWidgets.QPushButton() self.buttonMask.setCheckable(True) self.buttonMask.setIcon(qta.icon("fa.paint-brush")) self.buttonMask.setToolTip("add/edit mask for current frame") self.buttonMask.clicked.connect(self.ToggleInterfaceEvent) self.window.layoutButtons.addWidget(self.buttonMask) # set the mask opacity to 0.5 self.changeOpacity(0.5) self.closeDataFile() self.tool_group = MaskToolGroup(self, self.parent_hud, image_display)
def __init__(self): QMainWindow.__init__(self) loadUi("ui_source_client/client_panel.ui", self) # 加载面板文件,使用qt designer开发 self.setWindowTitle("学生端控制软件 -樱桃智库") icon_info = qta.icon('fa.envira', color='#1fa831') self.setWindowIcon(icon_info) #设置窗口的图标 self.setFixedSize(630, 225) # 设置窗口固定尺寸 self.stu_file = '' # 学生文件为空 self.file_name = '' # 准备上传的文件名 self.mem_percent = None # 内存百分比 self.cpu_count = None # cpu数量 self.cpu_percent = None # cpu百分比 self.pushButton.clicked.connect(self.connect_server) # 点击链接服务器的操作 self.toolButton.clicked.connect(self.file_dialog) # 点击选择文件的操作 self.pushButton_2.clicked.connect(self.send_file) # 点击发送文件的操作 self.pushButton_3.clicked.connect(self.hands_up) # 学生举手操作 self.con = configparser.ConfigParser() # 创建配置文件对象 self.con.read(CONFIG_FILE, encoding='utf-8') # 读取文件 self.ip_init_lst = eval(self.con.get('server', 'url')) # 获取所有的url,必须将获取的str转换为列表 self.port_init_lst = eval(self.con.get('server', 'port')) # 获取所有的端口 self.init_lineedit(self.lineEdit, self.ip_init_lst) # ip 输入位置自动补全 self.init_lineedit(self.lineEdit_2, self.port_init_lst) # port位置自动补全 ip_regex = QRegExp( "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b" ) # ip的正则表达式 ip_validator = QRegExpValidator(ip_regex, self.lineEdit) self.lineEdit.setValidator(ip_validator) self.lineEdit_2.setValidator(QIntValidator()) self.statusbar.showMessage("软件版本 v0.0.1", 5000) # 多线程取设备信息 self.device_thread = DeviceInfo([1]) # 多线程去获取 self.device_thread.signal.connect(self.device_callback) self.device_thread.start() # 启动线程
def icon(name, resample=False, icon_path=None): theme = CONF.get('main', 'icon_theme') if theme == 'ezcad 3': if not _resource['loaded']: print('Loading iconic fonts...') qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json', directory=_resource['directory']) qta.load_font('ezcad', 'ezcad.ttf', 'ezcad-charmap.json', directory=_resource['directory']) _resource['loaded'] = True args, kwargs = _qtaargs[name] return qta.icon(*args, **kwargs) elif theme == 'ezcad 2': icon = get_icon(name + '.png', resample=resample) if icon_path: icon_path = osp.join(icon_path, name + '.png') if osp.isfile(icon_path): icon = QIcon(icon_path) return icon if icon is not None else QIcon() else: raise ValueError("Unknown icon theme.")
def __init__(self, parent=None, prefix=VACA_PREFIX): super().__init__(parent) self.setObjectName('ASApp') self.setWindowTitle('Efficiency Monitor') color = get_appropriate_color('AS') self.setWindowIcon(qta.icon('mdi.percent-outline', color=color)) self._prefix = prefix self._eff_list = ( # ('LI-SI Inj', 'AS-Glob:AP-CurrInfo:InjEff-Mon', 'magenta'), ('BO-SI Inj', 'SI-Glob:AP-CurrInfo:InjEff-Mon', 'blue'), ('TS', 'TS-Glob:AP-CurrInfo:TranspEff-Mon', 'black'), ('BO Ramp', 'BO-Glob:AP-CurrInfo:RampEff-Mon', 'green'), # ('LI-BO Inj', 'BO-Glob:AP-CurrInfo:InjEff-Mon', 'darkRed'), ('TB', 'TB-Glob:AP-CurrInfo:TranspEff-Mon', 'darkCyan'), ('LI', 'LI-Glob:AP-CurrInfo:TranspEff-Mon', 'red'), ) self._app = QApplication.instance() font = self._app.font() font.setPointSize(32) self._app.setFont(font) self._setupUi()
def updateFileMenu(self): self.fileMenu.clear() self.addActions(self.fileMenu, self.fileMenuActions[:-1]) current = self.filename recentFiles = [] for fname in self.recentFiles: if fname != current and QFile.exists(fname): recentFiles.append(fname) if recentFiles: self.fileMenu.addSeparator() for i, fname in enumerate(recentFiles): action = QAction( qtawesome.icon("fa.folder-open"), "&{0}{1}".format(i + 1, QFileInfo(fname).fileName()), self) action.setData(QVariant(fname)) action.triggered[bool].connect(self.loadFile) self.fileMenu.addAction(action) self.fileMenu.addSeparator() self.fileMenu.addAction(self.fileMenuActions[-1])
def create_ui(self): cfg = config.ConfigNode.get_all() for ns in sorted(config.ConfigNode.default_namespaces): w = QWidget() wlayout = QFormLayout(w) for k, n in sorted(cfg[ns].items()): if not n.hidden: help_w = QPushButton(qta.icon("fa.question-circle"), "") help_w.setFlat(True) help_w.setToolTip(n.description) help_w.setToolTipDuration(9999999999) q = QWidget() q_l = QHBoxLayout(q) q_l.addWidget(help_w) q_l.addWidget(QLabel(k)) wlayout.addRow(q, self.get_setting_input(k, n)) sarea = QScrollArea(self) sarea.setWidget(w) sarea.setWidgetResizable(True) sarea.setBackgroundRole(QPalette.Light) self.addTab(sarea, ns)
def __init__(self, parent, prefs, statusbar): super(MergeFiltersDialog, self).__init__(parent) self.setupUi(self) self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self.__force_clone) self.__process_spinner = None self.configFilePicker.setIcon(qta.icon('fa5s.folder-open')) self.outputDirectoryPicker.setIcon(qta.icon('fa5s.folder-open')) self.processFiles.setIcon(qta.icon('fa5s.save')) self.refreshGitRepo.setIcon(qta.icon('fa5s.sync')) self.userSourceDirPicker.setIcon(qta.icon('fa5s.folder-open')) self.clearUserSourceDir.setIcon(qta.icon('fa5s.times', color='red')) self.copyOptimisedButton.setIcon(qta.icon('fa5s.copy')) self.copyErrorsButton.setIcon(qta.icon('fa5s.copy')) self.__preferences = prefs self.statusbar = statusbar self.optimised.setVisible(False) self.copyOptimisedButton.setVisible(False) self.optimisedLabel.setVisible(False) config_file = self.__preferences.get(BEQ_CONFIG_FILE) if config_file is not None and len(config_file) > 0 and os.path.exists(config_file): self.configFile.setText(os.path.abspath(config_file)) self.outputDirectory.setText(self.__preferences.get(BEQ_MERGE_DIR)) os.makedirs(self.outputDirectory.text(), exist_ok=True) for t in MinidspType: self.minidspType.addItem(t.display_name) minidsp_type = self.__preferences.get(BEQ_MINIDSP_TYPE) if minidsp_type is not None and len(minidsp_type) > 0: self.minidspType.setCurrentText(minidsp_type) self.__beq_dir = self.__preferences.get(BEQ_DOWNLOAD_DIR) extra_dir = self.__preferences.get(BEQ_EXTRA_DIR) if extra_dir is not None and len(extra_dir) > 0 and os.path.exists(extra_dir): self.userSourceDir.setText(os.path.abspath(extra_dir)) self.__delete_legacy_dir() self.__beq_repos = self.__preferences.get(BEQ_REPOS).split('|') for r in self.__beq_repos: self.beqRepos.addItem(r) self.update_beq_count() self.__enable_process()
def bindMenuActions(self): """Menu click actions register""" self.ui.actionExit.setIcon(self.style().standardIcon( QStyle.SP_MessageBoxCritical)) self.ui.actionExit.triggered.connect(self.menuActionExit) self.ui.actionAbout.setIcon(self.style().standardIcon( QStyle.SP_FileDialogInfoView)) self.ui.actionAbout.triggered.connect(self.menuActionAbout) self.ui.actionOnlineManual.setIcon(self.style().standardIcon( QStyle.SP_TitleBarContextHelpButton)) self.ui.actionOnlineManual.triggered.connect(self.menuActionManual) self.ui.actionDonate.setIcon(qta.icon('fa5s.donate')) self.ui.actionDonate.triggered.connect(self.menuActionDonate) self.ui.actionReportIssue.setIcon(self.style().standardIcon( QStyle.SP_MessageBoxWarning)) self.ui.actionReportIssue.triggered.connect(self.menuActionIssue)
def __init__(self, parent=None, prefix=''): """Initialize object.""" super().__init__(parent) self.setWindowTitle('Booster Energy Ramping') self.setObjectName('BOApp') cor = get_appropriate_color(section='BO') self.setWindowIcon(qta.icon( 'mdi.escalator', scale_factor=1.5, color=cor)) self.prefix = prefix self.ramp_config = None self._undo_stack = QUndoStack(self) self._tunecorr_configname = 'BO.V05.04.M0' self._chromcorr_configname = 'BO.V05.04.M0' self._setupUi() self._connSignals() self._addActions() self.setFocusPolicy(Qt.StrongFocus)
def __init__(self, devname, parent=None): """Receive a parent and a pulsed mangnet name.""" super().__init__(parent) self._devname = _PVName(devname) self._section = self._devname.sec self._prefix = _VACA_PREFIX self._pdev = self._devname.substitute(prefix=self._prefix) self.setObjectName(self._section + 'App') self.setWindowIcon( qta.icon('mdi.current-ac', color=util.get_appropriate_color(self._section))) self._create_pvs() self._setup_ui() self.setStyleSheet(""" #pulses_box, #pwrstate_box { max-width: 8em; } """) self.setFocusPolicy(Qt.StrongFocus)
def __init__(self, parent=None, all_tickers=None): super(SearchWindow, self).__init__(parent=parent) self.setupUi(self) self.all_tickers = all_tickers self.signal = signal.EventHandler() self.busy = busy_indicator.BusyIndicator(parent=self) self.ticker = None self.compagny = None search_icon = qta.icon('mdi.access-point-network') self.label.setPixmap( QtGui.QPixmap("../ui/imgs/search.jpg").scaled(25, 25)) # self.label.setIcon(search_icon) self.searchline.textChanged.connect(self.filter_treewidget) self.treeWidget.clicked.connect(self.get_item_value) self.build_columns() self.build_rows()
def goto_range(self): try: self.Range = WScreenShot(self.Init, self.chooseRange) # 范围界面 # 判断当前翻译运行状态,若为开始则切换为停止 if self.Init.mode == True: self.open_settin() self.data["sign"] = 1 # 重置运行状态标志符 self.save_settin() # 改变翻译键的图标为停止图标 self.Init.StartButton.setIcon( qtawesome.icon('fa.play', color='white')) self.Range.show() # 打开范围界面 self.Init.show() # 翻译界面会被顶掉,再次打开 if not self.thread_hotKey.isAlive(): self.thread_hotKey.start() except Exception: print_exc()
def __init__(self, parent, actionName=None, text="", faIconName=None, faIconColor=None, icon=None, checkable=False, tooltip=None, slot=None, shortCut=None, userData=None, **kwargs): """ Creates a TriggerAction with the given name, text and icon. If slot is not None then the signal QAction.triggered is connected to it. Args: actionName: (str)The action name text: (str)Action text faIconName: (str)qtawesome icon name icon: (QIcon) used if faIconName=None checkable: (bool)if this action is checkable tooltip: (str) The tooltip text slot: (slot) the slot to connect qtw.QAction.triggered signal shortCut: (QKeySequence) the short cut key userData: User data for specific purposes """ qtw.QAction.__init__(self, parent) if actionName: self.setObjectName(str(actionName)) if faIconName: icon = qta.icon(faIconName, color=faIconColor) if icon is not None: self.setIcon(icon) self.setCheckable(checkable) self.setText(str(text)) if tooltip: self.setToolTip(tooltip) if slot: self.triggered.connect(slot) if shortCut is not None: self.setShortcut(shortCut) self._userData = userData
def __init__(self, parent: QtWidgets, canvas: Canvas): """ A widget to display all curently used colors and let the user switch them. Args: parent: the parent widget canvas: the figure's canvas element """ QtWidgets.QWidget.__init__(self) # initialize color artist dict self.color_artists = {} # add update push button self.button_update = QtWidgets.QPushButton(qta.icon("fa.refresh"), "update") self.button_update.clicked.connect(self.updateColors) # add color chooser layout self.layout_right = QtWidgets.QVBoxLayout(self) self.layout_right.addWidget(self.button_update) self.layout_colors = QtWidgets.QVBoxLayout() self.layout_right.addLayout(self.layout_colors) self.layout_colors2 = QtWidgets.QVBoxLayout() self.layout_right.addLayout(self.layout_colors2) self.layout_buttons = QtWidgets.QVBoxLayout() self.layout_right.addLayout(self.layout_buttons) self.button_save = QtWidgets.QPushButton("Save Colors") self.button_save.clicked.connect(self.saveColors) self.layout_buttons.addWidget(self.button_save) self.button_load = QtWidgets.QPushButton("Load Colors") self.button_load.clicked.connect(self.loadColors) self.layout_buttons.addWidget(self.button_load) self.canvas = canvas # add a text widget to allow easy copy and paste self.colors_text_widget = QtWidgets.QTextEdit() self.colors_text_widget.setAcceptRichText(False) self.layout_colors2.addWidget(self.colors_text_widget) self.colors_text_widget.textChanged.connect(self.colors_changed)
def __init__(self, parent=None, prefix=VACA_PREFIX): """Init.""" super().__init__(parent) self._prefix = prefix # window settings self.setObjectName('ASApp') self.setWindowTitle('Sirius Launcher') self.setWindowIcon( qta.icon('mdi.rocket', color=get_appropriate_color('AS'))) screens = QApplication.screens() screen_idx = 3 if len(screens) == 8 else 0 topleft = screens[screen_idx].geometry().topLeft() self.move(topleft.x(), topleft.y() + 20) self.setWindowFlags(Qt.WindowStaysOnTopHint) # menubar menubar = get_object(ismenubar=True) menubar.setNativeMenuBar(False) self.setMenuBar(menubar) self._setupUi() # connect window signals connect_newprocess(self, 'sirius-hla-as-ap-monitor.py', parent=self, signal=self.showMonitor) connect_newprocess(self, 'sirius-hla-si-ap-genstatus.py', parent=self, signal=self.showStatus) connect_newprocess(self, 'sirius-hla-li-eg-control.py', parent=self, signal=self.showEgun) # set focus policy self.setFocus(True) self.setFocusPolicy(Qt.StrongFocus)
def setupUi(self): """创建UI """ self.setMinimumSize(0, self.Radius) self.setMaximumSize(0xFFFFF, self.Radius) layout = QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) # 左侧 添加4个对应的空白占位 for name in ('widgetMinimum', 'widgetMaximum', 'widgetNormal', 'widgetClose'): widget = QWidget(self) widget.setMinimumSize(self.Radius, self.Radius) widget.setMaximumSize(self.Radius, self.Radius) widget.setObjectName('TitleBar_%s' % name) widget.setWindowFlags(Qt.FramelessWindowHint) setattr(self, name, widget) layout.addWidget(widget) layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.labelTitle = QLabel(self, alignment=Qt.AlignCenter) self.labelTitle.setObjectName('TitleBar_labelTitle') layout.addWidget(self.labelTitle) layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) # 最小化,最大化,还原,关闭按钮 str = [ 'fa.window-minimize', 'fa.window-maximize', 'fa.window-restore', 'fa.times' ] for name, text in (('buttonMinimum', 0), ('buttonMaximum', 1), ('buttonNormal', 2), ('buttonClose', 3)): button = QPushButton(self) button.setIcon(qta.icon(str[text], scale_factor=1)) button.setMinimumSize(self.Radius, self.Radius) button.setMaximumSize(self.Radius, self.Radius) button.setObjectName('TitleBar_%s' % name) setattr(self, name, button) layout.addWidget(button)
def setupUI(self): self.firstBlock_layout = QFormLayout() self.chooseURLButton = QPushButton('点击选择保存路径') self.chooseURLButton.setIcon(icon('fa5.file', color='cadetblue')) self.chooseURLButton.setIconSize(QSize(27, 27)) self.chooseURLButton.clicked.connect(self.on_urlbtn_clicked) self.chooseURLButton.setObjectName('urlbtn') self.get_directory_path = 'C:/' self.URLLabel = QLabel(self.get_directory_path) self.URLLabel.setWordWrap(True) self.URLLabel.setObjectName('content') self.firstBlock_layout.addRow(self.chooseURLButton, self.URLLabel) self.firstBlock_filename_label = QLabel('文件名') self.firstBlock_filename_label.setObjectName('content') self.firstBlock_filename_input = QLineEdit() self.firstBlock_filename_input.setDragEnabled(True) self.firstBlock_filename_input.setClearButtonEnabled(True) self.firstBlock_layout.addRow(self.firstBlock_filename_label, self.firstBlock_filename_input) self.firstBlock_waittime_label = QLabel('缓冲时间') self.firstBlock_waittime_label.setObjectName('content') self.firstBlock_waittime_input = QLineEdit() self.firstBlock_waittime_input.setDragEnabled(True) self.firstBlock_waittime_input.setClearButtonEnabled(True) self.firstBlock_layout.addRow(self.firstBlock_waittime_label, self.firstBlock_waittime_input) self.save_btn = QPushButton('保存更改') self.save_btn.setFixedWidth(200) self.save_btn.clicked.connect(self.savebtnclick) hbox1 = QVBoxLayout() hbox1.setContentsMargins(10, 10, 10, 10) hbox1.addStretch(1) hbox1.addLayout(self.firstBlock_layout) hbox1.addWidget(self.save_btn, alignment=Qt.AlignCenter) hbox1.addStretch(1) self.setLayout(hbox1) self.readSetting()
def __init__(self, core): super(ImportWidget, self).__init__() self.core = core self.main_layout = QHBoxLayout() self.back_button = QPushButton(icon("mdi.keyboard-backspace", color="white"), self.tr("Back")) self.right_layout = QVBoxLayout() self.right_layout.addWidget(self.back_button) self.right_layout.addStretch(1) self.main_layout.addLayout(self.right_layout) self.back_button.setFixedWidth(75) self.layout = QVBoxLayout() self.title = QLabel("<h2>Import Game</h2") self.layout.addWidget(self.title) self.import_one_game = QLabel(f"<h3>{self.tr('Import existing game')}</h3>") self.layout.addWidget(self.import_one_game) self.import_game_info = QLabel(self.tr("Select path to game")) self.layout.addWidget(self.import_game_info) self.path_edit = PathEdit(os.path.expanduser("~"), QFileDialog.DirectoryOnly) self.layout.addWidget(self.path_edit) self.import_button = QPushButton(self.tr("Import Game")) self.layout.addWidget(self.import_button) self.import_button.clicked.connect(self.import_game) self.layout.addStretch(1) self.auto_import = QLabel(f"<h3>{self.tr('Auto import all existing games')}</h3>") self.layout.addWidget(self.auto_import) self.auto_import_button = QPushButton(self.tr("Import all games from Epic Games Launcher")) self.auto_import_button.clicked.connect(self.import_games_prepare) self.layout.addWidget(self.auto_import_button) self.layout.addStretch(1) self.main_layout.addLayout(self.layout) # self.main_layout.addStretch(1) self.setLayout(self.main_layout)
def __init__(self): super(login_UI, self).__init__() self.setupUi(self) self.m_flag = False self.setFixedSize(self.width(), self.height()) self.setWindowFlag(QtCore.Qt.FramelessWindowHint) # 隐藏边框 # self.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint) # 窗口始终置顶 self.pushButton_close.setIcon(qtawesome.icon('fa.close', color='blank')) self.pushButton_close.clicked.connect(self.close) self.pushButton_bottom.clicked.connect( lambda: openBrowser(defines.Login_bottom_url)) self.pushButton_bottom.setText(defines.Login_bottom) self.pushButton_bottom.setToolTip(f"点击查看我的B站主页") self.label_version.setText(f"当前版本:{defines.version}") self.label_version.setToolTip(f"当前版本:{defines.version}") try: self.login_Thread = Login_Thread() self.login_Thread.thread_signal.connect(self.setQrcode) self.login_Thread.start() except Exception as e: print(f"Video Thread: {e}")
def addChild(self, parent_item: QtWidgets.QWidget, entry: Artist, row=None): """ add a child to a tree view node """ if parent_item is None: parent_item = self.model # add item item = myTreeWidgetItem(self.getNameOfEntry(entry)) item.expanded = False item.entry = entry item.setIcon(self.getIconOfEntry(entry)) item.setEditable(False) item.sort = self.getEntrySortRole(entry) if parent_item is None: if row is None: row = self.model.rowCount() self.model.insertRow(row) self.model.setItem(row, 0, item) else: if row is None: parent_item.appendRow(item) else: parent_item.insertRow(row, item) self.setItemForEntry(entry, item) # add dummy child if self.queryToExpandEntry(entry) is not None and len( self.queryToExpandEntry(entry)): child = QtGui.QStandardItem("loading") child.entry = None child.setEditable(False) child.setIcon(qta.icon("fa.hourglass-half")) item.appendRow(child) item.expanded = False return item
def __on_ws_message(self, msg): ''' Handles messages from the device. :param msg: the message. ''' if msg.startswith('mso '): logger.debug(f"Processing mso {msg}") self.__on_mso(json.loads(msg[4:])) elif msg.startswith('msoupdate '): logger.debug(f"Processing msoupdate {msg}") self.__on_msoupdate(json.loads(msg[10:])) else: logger.warning(f"Unknown message {msg}") msg_box = QMessageBox(QMessageBox.Critical, 'Unknown Message', f"Received unexpected message from {self.ipAddress.text()}") msg_box.setDetailedText(f"<code>{msg}</code>") msg_box.setTextFormat(Qt.RichText) msg_box.exec() if self.__spinner is not None: stop_spinner(self.__spinner, self.syncStatus) self.__spinner = None self.syncStatus.setIcon(qta.icon('fa5s.times', color='red'))
def __init__(self, parent_hud: QtWidgets.QGraphicsPathItem, image_display: BigImageDisplay, window: "ClickPointsWindow") -> None: QtWidgets.QGraphicsRectItem.__init__(self, parent_hud) self.window = window self.image = image_display self.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.setScale(self.window.scale_factor) self.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))) self.setPos(-140 * self.window.scale_factor, (-140 - 20) * self.window.scale_factor) self.setZValue(19) self.hist = QtWidgets.QGraphicsPathItem(self) self.hist.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0, 0))) self.hist.setBrush(QtGui.QBrush(QtGui.QColor(255, 255, 255, 128))) self.hist.setPos(0, 110) self.conv = QtWidgets.QGraphicsPathItem(self) self.conv.setPen(QtGui.QPen(QtGui.QColor(255, 0, 0, 128), 2)) self.conv.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 0))) self.conv.setPos(0, 110) self.sliders = {} self.button_brightness = QtWidgets.QPushButton() self.button_brightness.setCheckable(True) self.button_brightness.setIcon(qta.icon("fa.adjust")) self.button_brightness.setToolTip("display brightness/gamma adjust") self.button_brightness.clicked.connect(self.ToggleInterfaceEvent) self.window.layoutButtons.addWidget(self.button_brightness) self.hidden = False self.ToggleInterfaceEvent(hidden=True) self.current_layer = 0
def get_icon(self, icon: dict) -> QtGui.QIcon: """Get the icon for the given icon from the toolbar config :param icon: The icon from the config :type icon: dict :return: The icon :rtype: QtGui.QIcon """ if not icon: return icon if not isinstance(icon, dict): return None icon_type = icon.get("type", None) icon_value = icon.get("value") icon_options = icon.get("options", [{}]) if icon_type not in ["font", "resources"]: return None if icon_type == "font": return qta.icon(icon_value, options=icon_options) else: # resources return QtGui.QIcon(icon_value)
def icon(self, name, scale_factor=None, resample=False): theme = CONF.get('appearance', 'icon_theme') if theme == 'spyder 3': try: # Try to load the icons from QtAwesome if not self._resource['loaded']: qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json', directory=self._resource['directory']) self._resource['loaded'] = True args, kwargs = self._qtaargs[name] if scale_factor is not None: kwargs['scale_factor'] = scale_factor return qta.icon(*args, **kwargs) except KeyError: # Load custom icons icon = QIcon(self.get_icon(name)) return icon if icon is not None else QIcon() elif theme == 'spyder 2': icon = self.get_icon(name, resample=resample) return icon if icon is not None else QIcon()
def _init_toolbar(self): for text, tooltip_text, fa_icon, callback, checked in self.toolitems: if text is None: self.addSeparator() else: if fa_icon: a = self.addAction(qta.icon(fa_icon), text, getattr(self, callback)) else: a = self.addAction(text, getattr(self, callback)) self._actions[callback] = a if checked is not None: a.setCheckable(True) a.setChecked(checked) if tooltip_text is not None: a.setToolTip(tooltip_text) self.buttons = {} # Add the x,y location widget at the right side of the toolbar # The stretch factor is 1 which means any resizing of the toolbar # will resize this label instead of the buttons. if self.coordinates: self.locLabel = QtWidgets.QLabel("", self) self.locLabel.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTop) self.locLabel.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.Expanding, QtWidgets.QSizePolicy.Ignored)) labelAction = self.addWidget(self.locLabel) labelAction.setVisible(True) # reference holder for subplots_adjust window self.adj_window = None # Adjust icon size or they are too small in PyQt5 by default self.setIconSize(QtCore.QSize(24, 24))
def create_action(parent, text, on_triggered=None, shortcut=None, shortcut_context=None, icon_name=None): """Create a QAction based on the give properties :param parent: The parent object :param text: Text string to display :param on_triggered: An optional slot to call on the triggered signal :param shortcut: An optional shortcut :param shortcut_context: An optional context for the supplied shortcut. Only applies if a shortcut has been given :param icon_name: The name of the qt awesome uri for an icon. :return: A new QAction object """ action = QAction(text, parent) if on_triggered is not None: action.triggered.connect(on_triggered) if shortcut is not None: action.setShortcut(shortcut) if shortcut_context is not None: action.setShortcutContext(shortcut_context) if icon_name is not None: action.setIcon(qta.icon(icon_name)) return action
def __init__(self, parent=None): super(CQSpinner, self).__init__(parent) self.default_icon = qta.icon("fa.refresh", color="#F1F1F1", animation=qta.Spin(self)) self.warning_icon = qta.icon("fa.warning", color="#F1F1F1")
def set_empty_star(self): self.setPixmap(qta.icon("fa.star-o", color=self.COLOR).pixmap(*self.PXMSIZE))
def set_full_star(self): self.setPixmap(qta.icon("fa.star", color=self.COLOR).pixmap(*self.PXMSIZE))
def __init__(self): super(AwesomeExample, self).__init__() # Get icons by name. fa_icon = qta.icon('fa.flag') fa_button = QtGui.QPushButton(fa_icon, 'Font Awesome!') asl_icon = qta.icon('ei.asl') elusive_button = QtGui.QPushButton(asl_icon, 'Elusive Icons!') # Styling styling_icon = qta.icon('fa.music', active='fa.legal', color='blue', color_active='orange') music_button = QtGui.QPushButton(styling_icon, 'Styling') # Render a label with this font label = QtGui.QLabel(unichr(0xf19c) + ' ' + 'Label') label.setFont(qta.font('fa', 16)) # Stack icons camera_ban = qta.icon('fa.camera', 'fa.ban', options=[{'scale_factor': 0.5, 'active': 'fa.legal'}, {'color': 'red', 'opacity': 0.7}]) stack_button = QtGui.QPushButton(camera_ban, 'Stack') stack_button.setIconSize(QtCore.QSize(32, 32)) # Spin icons spin_button = QtGui.QPushButton(' Spinning icon') spin_icon = qta.icon('fa.spinner', color='red', animation=qta.Spin(spin_button)) spin_button.setIcon(spin_icon) # Pulse icons pulse_button = QtGui.QPushButton(' Pulsing icon') pulse_icon = qta.icon('fa.spinner', color='green', animation=qta.Pulse(pulse_button)) pulse_button.setIcon(pulse_icon) # Stacked spin icons stack_spin_button = QtGui.QPushButton('Stack spin') options = [{'scale_factor': 0.4, 'animation': qta.Spin(stack_spin_button)}, {'color': 'blue'}] stack_spin_icon = qta.icon('ei.asl', 'fa.square-o', options=options) stack_spin_button.setIcon(stack_spin_icon) stack_spin_button.setIconSize(QtCore.QSize(32, 32)) # Stack and offset icons saveall = qta.icon('fa.save', 'fa.save', options=[{'scale_factor': 0.8, 'offset': (0.2, 0.2), 'color': 'gray'}, {'scale_factor': 0.8}]) saveall_button = QtGui.QPushButton(saveall, 'Stack, offset') # Layout vbox = QtGui.QVBoxLayout() widgets = [fa_button, elusive_button, music_button, stack_button, saveall_button, spin_button, pulse_button, stack_spin_button, label] for w in widgets: vbox.addWidget(w) self.setLayout(vbox) self.setWindowTitle('Awesome') self.show()
def get_icon(*names, **kwargs): """Return a QIcon corresponding to the icon name. See qtawesome.icon documentation for a full list of options. """ return qta.icon(*names, **kwargs)
def data(self, index, role): if not index.isValid(): return QVariant() elif role == Qt.TextAlignmentRole: return Qt.AlignCenter elif role not in (Qt.DisplayRole, Qt.EditRole, Qt.DecorationRole): return QVariant() row = self.results[index.row()] name = self.fields[index.column()][2] # IDEA - This could be done better. Need to ponder a bit.. if self.fields[index.column()][3].get('type', False): field_type = self.fields[index.column()][3]['type'] if field_type == 'currency': if role == Qt.EditRole: return getattr(row, name) value = getattr(row, name) if value is None: return None value = str(value) value = '€ {},{}'.format(value[:-2], value[-2:]) return value if field_type == 'recurrence': if role == Qt.EditRole: return getattr(row, name) value = getattr(row, name) if value is None: return None for key in value: parrot = '{} {}'.format(str(value[key]), key) return parrot if field_type == 'debit': Lumberjack.info('< AlchemicalTableModel > - -> (data) debit type') if role == Qt.EditRole: return getattr(row, name) if role == Qt.DisplayRole: return '' value = getattr(row, name) if value is None: return None if role == Qt.DecorationRole: Lumberjack.info('< AlchemicalTableModel > - -> (data)Qt.DecorationRole') if value: parrot = qta.icon('fa.plus', color='#00E676') else: parrot = qta.icon('fa.minus', color='#FF1744') return parrot # TODO - create function for displaying scanfile present icon. if role == Qt.DecorationRole: return QVariant() if '.' in name: foreign_column = name.split('.') foreign_item = getattr(row, foreign_column[0]) if role == Qt.EditRole: print('TableModel - data -- EditRole for foreignkey with index: ', index) return foreign_item else: if foreign_item is None: return None return getattr(foreign_item, foreign_column[1]) if role == Qt.EditRole: print('TableModel - data -- EditRole for index: ', index) print('TableModel - data -- EditRole with value: ', getattr(row, name)) print('TableModel - data -- EditRole with value: ', type(getattr(row, name))) return getattr(row, name) return str(getattr(row, name))
def __init__(self, desktop_widget, parent_geometry, main_window_handle): """Constructor, builds the GUI.""" super(MainWindow, self).__init__() self.desktop_widget = desktop_widget self.parent_geometry = parent_geometry self.main_window_handle = main_window_handle self.about_window = AboutWindow() # -- Create the main, central widget. Inside # are side-menu-bar and stacked widget. # search for operating system language and set it as program language # dodal miha self._lang = self.setLocale() self.preferences = DEFAULTS.copy() # -- Stacked widget is used to -- stack widgets. In the # beginning the welcome widget is open. self.stacked_widget = QtGui.QStackedWidget() # self.stacked_widget.setContentsMargins(25, 25, 25, 25) self.stacked_widget.setContentsMargins(0, 0, 0, 0) # .. Opened widgets are put in here. self.open_stack = dict() # -- Side-menu-bar is made with a QListWidget. # thread_status_bar = QtCore.QThread() self.status_bar = StatusWidget() self.menu = MainMenuTabbed() font = self.menu.font() font.setPointSize(8) font.setFamily('Verdana') self.menu.setFont(font) self.menu.currentChanged.connect(lambda: self._on_item_clicked(self.menu.currentIndex)) self.menu_basic = MainMenuDrop() self.menu_basic.q_menu.addAction(qta.icon('fa.folder-open', scale_factor=1.0, color='white'), 'Open project', self.Open) self.menu_basic.q_menu.addAction('Save as ...', self.SaveAs) self.menu_basic.q_menu.addAction(qta.icon('fa.floppy-o', scale_factor=1.0, color='white'), 'Save', self.Save) self.menu_basic.q_menu.addSeparator() self.menu_basic.q_menu.addAction('Import uff', self.ImportUff) # self.menu_basic.q_menu.addAction('Export uff', self.ExportUff) self.menu_basic.q_menu.addAction('Export data', self.export_data) self.menu_basic.q_menu.addSeparator() self.menu_basic.q_menu.addAction(qta.icon('fa.cog', scale_factor=1.0, color='white'), 'Preferences', self.OpenPreferences) self.menu_basic.q_menu.addSeparator() self.menu_basic.q_menu.addAction(qta.icon('fa.info-circle', scale_factor=1.0, color='white'), 'About', self.about_window.show) self.menu_basic.q_menu.addAction('Exit', self.main_window_handle.close) self.hmenubox = QtGui.QHBoxLayout() self.hmenubox.setContentsMargins(0, 0, 0, 0) self.hmenubox.setSpacing(0) self.hmenubox.addWidget(self.menu_basic) self.hmenubox.addStretch(1) self.hmenubox.addWidget(self.menu) self.hmenubox.addStretch(1) self.hmenubox.addWidget(self.status_bar) self.hmenubox.addStretch(1) self.vbox_gobal = QtGui.QVBoxLayout() self.vbox_gobal.setContentsMargins(0, 0, 0, 0) self.vbox_gobal.setSpacing(0) bg_widget = QtGui.QWidget() bg_widget.setLayout(self.hmenubox) bg_widget.setContentsMargins(0,0,0,0) self.vbox_gobal.addWidget(bg_widget) self.vbox = QtGui.QVBoxLayout() self.vbox.setContentsMargins(0, 0, 0, 0) self.vbox.setSpacing(0) self.vbox.addWidget(self.stacked_widget) self.hbox = QtGui.QHBoxLayout() self.hbox.setContentsMargins(0, 0, 0, 0) self.hbox.setSpacing(0) self.vbox_left = QtGui.QVBoxLayout() self.vbox_left.setContentsMargins(0, 0, 0, 0) self.vbox_left.setSpacing(0) self.hbox.addLayout(self.vbox_left) self.hbox.addLayout(self.vbox) self.vbox_gobal.addLayout(self.hbox) self.vbox_gobal.setContentsMargins(0, 0, 0, 0) self.vbox_gobal.setSpacing(0) self.setLayout(self.vbox_gobal) # -------------------------------------------------------------------------------------------------------Miha # self.setGeometry(50, 50, 500, 1200) # -- Initialize the data object. self.modaldata_object = modaldata.ModalData() # -- Save file default. self.savefileset = False self.savefile = None # --Export file default self.exportfileset = False self.exportfile = None self._load_all_widgets() # self.setStyleSheet('background-color: red;') # self.stacked_widget.setContentsMargins(-10, -10, -10, -10) self.overlayed = QtGui.QSizeGrip(self) # self.overlayed.setAttribute(QtCore.Qt.WA_TranslucentBackground) # self.overlayed.setAutoFillBackground(True) self.overlayed.setStyleSheet('border-image: url(gui/icons/icon_size_grab_4.png) 0 0 0 0 stretch stretch; border-width: 0px;') # self.overlayed.setStyleSheet('background-color: red;') # self.overlayed.setMaximumSize(15, 15) self.overlayed.resize(15, 15) # self.overlayed.move(self.parent_geometry().width()-100, self.parent_geometry().height()-50) # self.overlayed.move(self.parent_geometry().width()-200, self.parent_geometry().height()-150) self.layout()
def init_gui(self): QtGui.QWidget.__init__(self, parent=None) # button for opening dicom directory self.button_load = QtGui.QPushButton(qtawesome.icon('fa.folder-open-o'), '') self.button_run = QtGui.QPushButton('Fit Data') self.button_draw_roi = QtGui.QPushButton('Draw ROI') self.button_exclude_slice = QtGui.QPushButton('Exclude Slice') # first/last prev/next buttons for scrolling through the dicoms self.button_image_fwd = QtGui.QPushButton(qtawesome.icon('fa.chevron-right'), '') self.button_image_fwd.setObjectName('slice_fwd') self.button_image_bwd = QtGui.QPushButton(qtawesome.icon('fa.chevron-left'), '') self.button_image_bwd.setObjectName('slice_bwd') self.button_image_first = QtGui.QPushButton(qtawesome.icon('fa.step-backward'), '') self.button_image_first.setObjectName('slice_first') self.button_image_last = QtGui.QPushButton(qtawesome.icon('fa.step-forward'), '') self.button_image_last.setObjectName('slice_last') self.slice_label = QtGui.QLabel('(00/00)') # set whether the ROI should apply to a single slice or all of the slices self.combo_roi_scope = QtGui.QComboBox() self.combo_roi_scope.addItems(['This Slice','All Slices']) self.combo_roi_scope.setCurrentIndex(0) # choose ROI shape self.combo_roi_style = QtGui.QComboBox() self.combo_roi_style.addItems(['Polygon','Circle', 'Ellipse']) self.combo_roi_style.setCurrentIndex(0) # fit either a basic T1, or basic T2 fit self.combo_relax_label = QtGui.QLabel('Fit Type') self.combo_relax = QtGui.QComboBox() self.combo_relax.addItems(['T1', 'T2']) self.combo_relax.setCurrentIndex(0) self.roi_area_label = QtGui.QLabel('ROI Area: 0 (pixels) / 0.00 (mm^2)') self.plot_im = ROISelectPlot(self) self.color_plot_im = ColourROISelectPlot(self) self.plot_graph = T2CurvePlot(self) layout_top = QtGui.QHBoxLayout() layout_top.addSpacing(10) layout_top.addWidget(self.button_load) layout_top.addStretch() layout_top.addWidget(QtGui.QLabel('Change Slice:')) layout_top.addWidget(self.button_image_first) layout_top.addWidget(self.button_image_bwd) layout_top.addWidget(self.button_image_fwd) layout_top.addWidget(self.button_image_last) layout_top.addWidget(self.slice_label) layout_top.addStretch() layout_top.addWidget(QtGui.QLabel('ROI Style:')) layout_top.addWidget(self.combo_roi_style) layout_top.addWidget(QtGui.QLabel('Apply ROI to:')) layout_top.addWidget(self.combo_roi_scope) layout_top.addWidget(self.button_draw_roi) layout_top.addWidget(self.button_exclude_slice) layout_top.addStretch() layout_top.addWidget(self.combo_relax_label) layout_top.addWidget(self.combo_relax) layout_top.addWidget(self.button_run) layout_top.addSpacing(10) layout_mid = QtGui.QHBoxLayout() layout_mid.addWidget(self.plot_im) layout_mid.addWidget(self.color_plot_im) layout_mid.addWidget(self.plot_graph) self.vmin_window_slider = QtGui.QSlider(orientation=QtCore.Qt.Horizontal, minimum=0, maximum=100) self.vmin_window_slider.setValue(5) self.vmax_window_slider = QtGui.QSlider(orientation=QtCore.Qt.Horizontal, minimum=0, maximum=100) self.vmax_window_slider.setValue(95) layout_ROI_calc = QtGui.QHBoxLayout() layout_ROI_calc.addWidget(self.roi_area_label) layout_slider1 = QtGui.QHBoxLayout() layout_slider1.addWidget(QtGui.QLabel('Window Min:')) layout_slider1.addSpacing(3) layout_slider1.addWidget(self.vmin_window_slider) layout_slider2 = QtGui.QHBoxLayout() layout_slider2.addWidget(QtGui.QLabel('Window Max:')) layout_slider2.addWidget(self.vmax_window_slider) layout_main = QtGui.QVBoxLayout() layout_main.addLayout(layout_top) layout_main.addLayout(layout_mid) layout_main.addLayout(layout_ROI_calc) layout_main.addLayout(layout_slider1) layout_main.addLayout(layout_slider2) self.setLayout(layout_main) self.button_load.pressed.connect(self.choose_dir) self.button_run.pressed.connect(self.process_data) self.button_draw_roi.pressed.connect(self.start_roi) self.button_exclude_slice.pressed.connect(self.exclude_current_slice) self.button_image_first.pressed.connect(self.change_image) self.button_image_last.pressed.connect(self.change_image) self.button_image_fwd.pressed.connect(self.change_image) self.button_image_bwd.pressed.connect(self.change_image) self.vmin_window_slider.valueChanged.connect(self.set_image_window) self.vmax_window_slider.valueChanged.connect(self.set_image_window)
def __create_buttonbar(self): """ Creates the button bar at the bottom of the explorer """ # General buttonbar widget buttonbar = QtWidgets.QWidget() buttonbar_hbox = QtWidgets.QHBoxLayout(buttonbar) buttonbar.setLayout(buttonbar_hbox) # Refresh button - always visible self.refresh_icon = qta.icon('fa.refresh', color='green') self.refresh_button = QtWidgets.QPushButton(self.refresh_icon, _('Refresh')) self.refresh_icon_spinning = qta.icon( 'fa.refresh', color='green', animation=qta.Spin(self.refresh_button)) self.refresh_button.setIconSize(self.button_icon_size) self.refresh_button.clicked.connect(self.__clicked_refresh_tree) self.refresh_button.setToolTip(_(u"Refresh")) self.refresh_button.setDisabled(True) # Other buttons, depend on config settings of OSF explorer self.new_folder_icon = QtGui.QIcon.fromTheme( 'folder-new', qta.icon('ei.folder-sign') ) self.new_folder_button = QtWidgets.QPushButton(self.new_folder_icon, _('New folder')) self.new_folder_button.setIconSize(self.button_icon_size) self.new_folder_button.clicked.connect(self.__clicked_new_folder) self.new_folder_button.setToolTip(_(u"Create a new folder at the currently" " selected location")) self.new_folder_button.setDisabled(True) self.delete_icon = QtGui.QIcon.fromTheme( 'edit-delete', qta.icon('fa.trash') ) self.delete_button = QtWidgets.QPushButton(self.delete_icon, _('Delete')) self.delete_button.setIconSize(self.button_icon_size) self.delete_button.clicked.connect(self.__clicked_delete) self.delete_button.setToolTip(_(u"Delete the currently selected file or " "folder")) self.delete_button.setDisabled(True) self.download_icon = QtGui.QIcon.fromTheme( 'go-down', qta.icon('fa.cloud-download') ) self.download_button = QtWidgets.QPushButton(self.download_icon, _('Download')) self.download_button.setIconSize(self.button_icon_size) self.download_button.clicked.connect(self._clicked_download_file) self.download_button.setToolTip(_(u"Download the currently selected file")) self.download_button.setDisabled(True) self.upload_icon = QtGui.QIcon.fromTheme( 'go-up', qta.icon('fa.cloud-upload') ) self.upload_button = QtWidgets.QPushButton(self.upload_icon, _('Upload')) self.upload_button.clicked.connect(self.__clicked_upload_file) self.upload_button.setIconSize(self.button_icon_size) self.upload_button.setToolTip(_(u"Upload a file to the currently selected" " folder")) self.upload_button.setDisabled(True) # Set up the general button bar layouts buttonbar_hbox.addWidget(self.refresh_button) buttonbar_hbox.addStretch(1) # Add default buttons to default widget buttonbar_hbox.addWidget(self.new_folder_button) buttonbar_hbox.addWidget(self.delete_button) buttonbar_hbox.addWidget(self.download_button) buttonbar_hbox.addWidget(self.upload_button) # Make sure the button bar is vertically as small as possible. buttonbar.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) # Store the above buttons (except refresh) into a variable which later # can be used to customize button set configurations self.buttonsets = { 'default': [] } self.buttonsets['default'].append(self.new_folder_button) self.buttonsets['default'].append(self.delete_button) self.buttonsets['default'].append(self.upload_button) self.buttonsets['default'].append(self.download_button) buttonbar.layout().setContentsMargins(0, 0, 0, 0) return buttonbar
def __init__(self, manager, icon_size=None): """ Constructor Parameters ---------- manager : manager.ConnectionManager The object taking care of all the communication with the OSF iconsize : QtCore.QSize (default: None) The size of the icon to use for the osf logo and user photo, if not passed a size of 40x40 is used. """ super(UserBadge, self).__init__() # button texts self.login_text = _("Log in") self.logout_text = _("Log out") self.logging_in_text = _("Logging in") self.logging_out_text = _("Logging out") self.manager = manager if isinstance(icon_size, QtCore.QSize): # Size of avatar and osf logo display image self.icon_size = icon_size else: self.icon_size = QtCore.QSize(40,40) # Set up general window # self.resize(200,40) self.setWindowTitle(_("User badge")) # Set Window icon if not os.path.isfile(osf_logo_path): print("ERROR: OSF logo not found at {}".format(osf_logo_path)) self.osf_logo_pixmap = QtGui.QPixmap(osf_logo_path).scaled(self.icon_size) self.osf_icon = QtGui.QIcon(osf_logo_path) self.setWindowIcon(self.osf_icon) # Login button self.login_button = QtWidgets.QPushButton(self) self.login_button.clicked.connect(self.__clicked_login) self.login_button.setIconSize(self.icon_size) self.login_button.setFlat(True) self.user_button = QtWidgets.QPushButton(self) self.user_button.setIconSize(self.icon_size) self.logged_in_menu = QtWidgets.QMenu(self.login_button) visit_osf_icon = QtGui.QIcon.fromTheme('web-browser', qta.icon('fa.globe')) self.logged_in_menu.addAction( visit_osf_icon, _(u"Visit osf.io"), self.__open_osf_website) logout_icon = QtGui.QIcon.fromTheme('system-log-out', qta.icon('fa.sign-out')) self.logged_in_menu.addAction(logout_icon, _(u"Log out"), self.__clicked_logout) self.user_button.setMenu(self.logged_in_menu) self.user_button.hide() self.user_button.setFlat(True) # Spinner icon self.spinner = qta.icon('fa.refresh', color='green', animation=qta.Spin(self.login_button)) # Init user badge as logged out self.handle_logout() # Set up layout layout = QtWidgets.QGridLayout(self) layout.addWidget(self.login_button, 1, 1) layout.addWidget(self.user_button, 1, 1) self.login_button.setContentsMargins(0, 0, 0, 0) self.user_button.setContentsMargins(0, 0, 0, 0) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0)
def get_icon(self, datatype, name): """ Returns a QIcon for the passed datatype. Retrieves the curren theme icon for a certain object (project, folder) or filetype. Uses the file extension to determine the file type. Parameters ---------- datatype : string The kind of object, which can be project, folder or file name : string The name of the object, which is the project's, folder's or file's name Returns ------- QtGui.QIcon The icon for the current file/object type """ providers = { 'osfstorage' : osf_blacklogo_path, 'github' : 'web-github', 'dropbox' : 'dropbox', 'googledrive' : 'web-google-drive', 'box' : 'web-microsoft-onedrive', 'cloudfiles' : 'web-microsoft-onedrive', 'dataverse' : 'web-microsoft-onedrive', 'figshare' : 'web-microsoft-onedrive', 's3' : 'web-microsoft-onedrive', } if datatype.lower() in ['public project','private project', \ 'readonly project']: if datatype.lower() == 'public project': return qta.icon('fa.cube', 'fa.globe', options=[ {}, {'scale_factor': 0.75, 'offset': (0.2, 0.20), 'color': 'green'}]) elif datatype.lower() == "readonly project": return qta.icon('fa.cube', 'fa.lock', options=[ {}, {'scale_factor': 0.75, 'offset': (0.2, 0.20), 'color': 'red'}]) else: return qta.icon('fa.cube') if datatype in ['folder','folder-open']: # Providers are also seen as folders, so if the current folder # matches a provider's name, simply show its icon. if name in providers: return QtGui.QIcon.fromTheme( providers[name], QtGui.QIcon(osf_blacklogo_path) ) else: return QtGui.QIcon.fromTheme( datatype, QtGui.QIcon(osf_blacklogo_path) ) elif datatype == 'file': # check for OpenSesame extensions first. If this is not an OS file # use fileinspector to determine the filetype if check_if_opensesame_file(name): filetype = 'opera-widget-manager' else: filetype = fileinspector.determine_type(name,'xdg') return QtGui.QIcon.fromTheme( filetype, QtGui.QIcon.fromTheme( 'text-x-generic', QtGui.QIcon(osf_blacklogo_path) ) ) return QtGui.QIcon(osf_blacklogo_path)