def setupIcons(self): self.plusRemoteModuleDirectoryPath = slicer.modules.plusremote.path.replace( "PlusRemote.py", "") self.recordIcon = QIcon(self.plusRemoteModuleDirectoryPath + '/Resources/Icons/icon_Record.png') self.stopIcon = QIcon(self.plusRemoteModuleDirectoryPath + '/Resources/Icons/icon_Stop.png') self.waitIcon = QIcon(self.plusRemoteModuleDirectoryPath + '/Resources/Icons/icon_Wait.png') self.visibleOffIcon = QIcon(":Icons\VisibleOff.png") self.visibleOnIcon = QIcon(":Icons\VisibleOn.png")
def fillLastMeldCombo(self): """fill the drop down list with all possible melds. If the drop down had content before try to preserve the current index. Even if the meld changed state meanwhile.""" with BlockSignals(self.cbLastMeld ): # we only want to emit the changed signal once showCombo = False idx = self.cbLastMeld.currentIndex() if idx < 0: idx = 0 indexedMeld = str(self.cbLastMeld.itemData(idx)) self.cbLastMeld.clear() self.__meldPixMaps = [] if not self.game.winner: return if self.cbLastTile.count() == 0: return lastTile = Internal.scene.computeLastTile() winnerMelds = [ m for m in self.game.winner.hand.melds if len(m) < 4 and lastTile in m ] assert len(winnerMelds), 'lastTile %s missing in %s' % ( lastTile, self.game.winner.hand.melds) if len(winnerMelds) == 1: self.cbLastMeld.addItem(QIcon(), '', str(winnerMelds[0])) self.cbLastMeld.setCurrentIndex(0) return showCombo = True self.__fillLastMeldComboWith(winnerMelds, indexedMeld, lastTile) self.lblLastMeld.setVisible(showCombo) self.cbLastMeld.setVisible(showCombo) self.cbLastMeld.currentIndexChanged.emit(0)
def __init__(self, parent=None): super(ImportPage, self).__init__(parent=None) main_v_box = QVBoxLayout() label_font = QFont() sys_font_point_size = label_font.pointSize() label_font.setPointSize(sys_font_point_size + 2) step_label = QLabel(str("Import")) step_label.setFont(label_font) self.simple_lin = QLineEdit(self) self.simple_lin.textChanged.connect(self.update_command) self.x_spn_bx = QSpinBox() self.x_spn_bx.setMaximum(99999) self.x_spn_bx.setSpecialValueText(" ") self.y_spn_bx = QSpinBox() self.y_spn_bx.setMaximum(99999) self.y_spn_bx.setSpecialValueText(" ") self.x_spn_bx.valueChanged.connect(self.x_beam_changed) self.y_spn_bx.valueChanged.connect(self.y_beam_changed) self.chk_invert = QCheckBox("Invert rotation axis") self.chk_invert.stateChanged.connect(self.inv_rota_changed) self.opn_fil_btn = QPushButton(" \n Select file(s) \n ") main_path = get_main_path() self.opn_fil_btn.setIcon(QIcon(main_path + "/resources/import.png")) self.opn_fil_btn.setIconSize(QSize(80, 48)) main_v_box.addWidget(step_label) main_v_box.addWidget(self.opn_fil_btn) main_v_box.addWidget(self.simple_lin) self.b_cetre_label = QLabel("\n\n Beam centre") main_v_box.addWidget(self.b_cetre_label) cent_hbox = QHBoxLayout() self.x_label = QLabel(" X: ") cent_hbox.addWidget(self.x_label) cent_hbox.addWidget(self.x_spn_bx) self.y_label = QLabel(" Y: ") cent_hbox.addWidget(self.y_label) cent_hbox.addWidget(self.y_spn_bx) # cent_hbox.addWidget(QLabel(" \n ")) cent_hbox.addStretch() main_v_box.addLayout(cent_hbox) main_v_box.addWidget(self.chk_invert) main_v_box.addStretch() self.opn_fil_btn.clicked.connect(self.open_files) self.defa_dir = str(os.getcwd()) self.setLayout(main_v_box) # self.show() self.reset_par()
def __init__(self, action, parent=None): super(QToolButton, self).__init__(parent=parent) self.action = action # Load the icon for this action tmp_ico = QIcon() # TODO(nick): Switch to proper package resource loading? main_path = get_main_path() tmp_ico.addFile(os.path.join(main_path, action.icon), mode=QIcon.Normal) tmp_ico.addFile( os.path.join(main_path, action.icon_disabled), mode=QIcon.Disabled ) self.setIcon(tmp_ico) self.setIconSize(QSize(31, 30)) self.setToolTip(action.tooltip) self.setText(action.label) sys_font = QFont() small_font_size = sys_font.pointSize() - 2 self.setFont(QFont("Helvetica", small_font_size, QFont.Light)) # self.setFont(QFont("Monospace", small_font_size, QFont.Bold)) self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
def __init__(self, parent, logic, parameterList=None, widgetClass=None): Guidelet.__init__(self, parent, logic, parameterList, widgetClass) logging.debug('ProstateTRUSNavGuidelet.__init__') moduleDirectoryPath = slicer.modules.prostatetrusnav.path.replace( 'ProstateTRUSNav.py', '') # Set up main frame. self.sliceletDockWidget.setObjectName('ProstateTRUSNavPanel') self.sliceletDockWidget.setWindowTitle('ProstateTRUSNav') self.mainWindow.setWindowTitle('ProstateTRUSNavigation') self.mainWindow.windowIcon = QIcon( moduleDirectoryPath + '/Resources/Icons/ProstateTRUSNav.png') # Set needle and cautery transforms and models self.setupScene() # Setting button open on startup. self.ultrasoundCollapsibleButton.setProperty('collapsed', False)
def __fillLastMeldComboWith(self, winnerMelds, indexedMeld, lastTile): """fill last meld combo with prepared content""" winner = self.game.winner faceWidth = winner.handBoard.tileset.faceSize.width() * 0.5 faceHeight = winner.handBoard.tileset.faceSize.height() * 0.5 restoredIdx = None for meld in winnerMelds: pixMap = QPixmap(faceWidth * len(meld), faceHeight) pixMap.fill(Qt.transparent) self.__meldPixMaps.append(pixMap) painter = QPainter(pixMap) for element in meld: painter.drawPixmap( 0, 0, winner.handBoard.tilesByElement(element)[0].pixmapFromSvg( QSize(faceWidth, faceHeight), withBorders=False)) painter.translate(QPointF(faceWidth, 0.0)) self.cbLastMeld.addItem(QIcon(pixMap), '', str(meld)) if indexedMeld == str(meld): restoredIdx = self.cbLastMeld.count() - 1 if not restoredIdx and indexedMeld: # try again, maybe the meld changed between concealed and exposed indexedMeld = indexedMeld.lower() for idx in range(self.cbLastMeld.count()): meldContent = str(self.cbLastMeld.itemData(idx)) if indexedMeld == meldContent.lower(): restoredIdx = idx if lastTile not in meldContent: lastTile = lastTile.swapped assert lastTile in meldContent with BlockSignals(self.cbLastTile ): # we want to continue right here idx = self.cbLastTile.findData(lastTile) self.cbLastTile.setCurrentIndex(idx) break if not restoredIdx: restoredIdx = 0 self.cbLastMeld.setCurrentIndex(restoredIdx) self.cbLastMeld.setIconSize(QSize(faceWidth * 3, faceHeight))
def __fillLastTileComboWith(self, lastTiles, winnerTiles): """fill last meld combo with prepared content""" self.comboTilePairs = lastTiles idx = self.cbLastTile.currentIndex() if idx < 0: idx = 0 indexedTile = self.cbLastTile.itemData(idx) restoredIdx = None self.cbLastTile.clear() if not winnerTiles: return pmSize = winnerTiles[0].board.tileset.faceSize pmSize = QSize(pmSize.width() * 0.5, pmSize.height() * 0.5) self.cbLastTile.setIconSize(pmSize) QPixmapCache.clear() self.__tilePixMaps = [] shownTiles = set() for tile in winnerTiles: if tile.tile in lastTiles and tile.tile not in shownTiles: shownTiles.add(tile.tile) self.cbLastTile.addItem( QIcon(tile.pixmapFromSvg(pmSize, withBorders=False)), '', tile.tile) if indexedTile is tile.tile: restoredIdx = self.cbLastTile.count() - 1 if not restoredIdx and indexedTile: # try again, maybe the tile changed between concealed and exposed indexedTile = indexedTile.exposed for idx in range(self.cbLastTile.count()): if indexedTile is self.cbLastTile.itemData(idx).exposed: restoredIdx = idx break if not restoredIdx: restoredIdx = 0 self.cbLastTile.setCurrentIndex(restoredIdx) self.prevLastTile = self.computeLastTile()
def __init__(self): super(MainWidget, self).__init__() self.my_pop = None # Any child popup windows. Only bravais_table ATM self.storage_path = sys_arg.directory refresh_gui = False # Load the previous state of DUI, if present dui_files_path = os.path.join(self.storage_path, "dui_files") if os.path.isfile(os.path.join(dui_files_path, "bkp.pickle")): try: self.idials_runner = load_previous_state(dui_files_path) except Exception as e: # Something went wrong - tell the user then close msg = traceback.format_exc() logger.error("ERROR LOADING PREVIOUS DATA:\n%s", msg) raise_from(DUIDataLoadingError(msg), e) refresh_gui = True else: # No dui_files path - start with a fresh state if not os.path.isdir(dui_files_path): os.mkdir(dui_files_path) self.idials_runner = Runner() self.gui2_log = {"pairs_list": []} self.cli_tree_output = TreeShow() self.cli_tree_output(self.idials_runner) self.cur_html = None self.cur_pick = None self.cur_json = None self.cur_log = None self.cur_cmd_name = "None" main_box = QVBoxLayout() self.centre_par_widget = ControlWidget() self.centre_par_widget.pass_sys_arg_object_to_import(sys_arg) self.stop_run_retry = StopRunRetry() self.tree_out = TreeNavWidget() left_control_box = QHBoxLayout() left_top_control_box = QVBoxLayout() left_top_control_box.addWidget(self.centre_par_widget) left_top_control_box.addStretch() left_control_box.addLayout(left_top_control_box) centre_control_box = QVBoxLayout() v_control_splitter = QSplitter() v_control_splitter.setOrientation(Qt.Vertical) v_control_splitter.addWidget(self.tree_out) v_control_splitter.addWidget(self.centre_par_widget.step_param_widg) centre_control_box.addWidget(v_control_splitter) centre_control_box.addWidget(self.stop_run_retry) left_control_box.addLayout(centre_control_box) dummy_left_widget = QWidget() dummy_h_layout = QHBoxLayout() dummy_h_layout.addLayout(left_control_box) dummy_left_widget.setLayout(dummy_h_layout) dummy_left_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) h_main_splitter = QSplitter() h_main_splitter.setOrientation(Qt.Horizontal) h_main_splitter.addWidget(dummy_left_widget) self.cli_out = CliOutView() self.web_view = WebTab() self.img_view = MyImgWin() self.ext_view = OuterCaller() self.info_widget = InfoWidget() self.output_info_tabs = QTabWidget() self.output_info_tabs.addTab(self.img_view, "Image") self.output_info_tabs.addTab(self.cli_out, "Log") self.output_info_tabs.addTab(self.web_view, "Report") self.output_info_tabs.addTab(self.ext_view, "Tools") self.output_info_tabs.addTab(self.info_widget, "Experiment") self.view_tab_num = 0 self.output_info_tabs.currentChanged.connect(self.tab_changed) self.img_view.mask_applied.connect(self.pop_mask_list) self.img_view.predic_changed.connect(self.tab_changed) self.img_view.bc_applied.connect(self.pop_b_centr_coord) self.img_view.new_pars_applied.connect(self.pass_parmams) # self.ext_view.pass_parmam_lst.connect(self.pass_parmams) self.centre_par_widget.finished_masking.connect(self.img_view.unchec_my_mask) self.centre_par_widget.click_mask.connect(self.img_view.chec_my_mask) self.centre_par_widget.finished_b_centr.connect(self.img_view.unchec_b_centr) self.centre_par_widget.click_b_centr.connect(self.img_view.chec_b_centr) v_info_splitter = QSplitter() v_info_splitter.setOrientation(Qt.Vertical) v_info_splitter.addWidget(self.output_info_tabs) h_main_splitter.addWidget(v_info_splitter) main_box.addWidget(h_main_splitter) self.txt_bar = Text_w_Bar() main_box.addWidget(self.txt_bar) self.connect_all() self.custom_thread = CommandThread() self.custom_thread.finished.connect(self.update_after_finished) self.custom_thread.str_fail_signal.connect(self.after_failed) self.custom_thread.str_print_signal.connect(self.cli_out.add_txt) self.custom_thread.str_print_signal.connect(self.txt_bar.setText) self.custom_thread.busy_box_on.connect(self.pop_busy_box) self.custom_thread.busy_box_off.connect(self.close_busy_box) self.main_widget = QWidget() self.main_widget.setLayout(main_box) self.setCentralWidget(self.main_widget) self.setWindowTitle("CCP4 DUI - {}: {}".format(__version__, dui_files_path)) self.setWindowIcon(QIcon(self.stop_run_retry.dials_logo_path)) self.just_reindexed = False self.user_stoped = False self.reconnect_when_ready() self.my_pop = None if refresh_gui: self.refresh_my_gui()
def __init__(self, parent=None): super(StopRunRetry, self).__init__() main_path = get_main_path() ctrl_box = QHBoxLayout() self.repeat_btn = QPushButton("\n Retry \n", self) re_try_icon_path = str(main_path + "/resources/re_try.png") re_try_grayed_path = str(main_path + "/resources/re_try_grayed.png") tmp_ico = QIcon() tmp_ico.addFile(re_try_icon_path, mode=QIcon.Normal) tmp_ico.addFile(re_try_grayed_path, mode=QIcon.Disabled) self.repeat_btn.setIcon(tmp_ico) self.repeat_btn.setIconSize(QSize(50, 38)) ctrl_box.addWidget(self.repeat_btn) self.run_btn = QPushButton("\n Run \n", self) self.dials_logo_path = str( main_path + "/resources/DIALS_Logo_smaller_centred.png" ) dials_grayed_path = str( main_path + "/resources/DIALS_Logo_smaller_centred_grayed.png" ) tmp_ico = QIcon() tmp_ico.addFile(self.dials_logo_path, mode=QIcon.Normal) tmp_ico.addFile(dials_grayed_path, mode=QIcon.Disabled) self.run_btn.setIcon(tmp_ico) self.run_btn.setIconSize(QSize(50, 50)) ctrl_box.addWidget(self.run_btn) self.stop_btn = QPushButton("\n Stop \n", self) stop_logo_path = str(main_path + "/resources/stop.png") stop_grayed_path = str(main_path + "/resources/stop_grayed.png") tmp_ico = QIcon() tmp_ico.addFile(stop_logo_path, mode=QIcon.Normal) tmp_ico.addFile(stop_grayed_path, mode=QIcon.Disabled) self.stop_btn.setIcon(tmp_ico) self.stop_btn.setIconSize(QSize(50, 38)) ctrl_box.addWidget(self.stop_btn) self.setLayout(ctrl_box)