def __init__(self, phl_obj=None, simp_widg=None, parent=None, upper_label=None): super(ParamMainWidget, self).__init__() self.command_lst = [[None]] self.lst_pair = [] try: self.my_phl_obj = phl_obj self.simp_widg_in = simp_widg except BaseException as e: # We don't want to catch bare exceptions but don't know # what this was supposed to catch. Log it. logger.info("Caught unknown exception #1 type %s: %s", type(e).__name__, e) logger.info("\n\n\n something went wrong here wiht the phil object \n\n\n") self.build_param_widget() label_font = QFont() sys_font_point_size = label_font.pointSize() label_font.setPointSize(sys_font_point_size + 2) self.step_label = QLabel(str(upper_label)) self.step_label.setFont(label_font) self._vbox = QVBoxLayout() self._vbox.addWidget(self.step_label) self._vbox.addWidget(self.dual_level_tab) self.setLayout(self._vbox)
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=None): super(ExportPage, 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("Export")) step_label.setFont(label_font) out_file_label = QLabel(str("mtz output name:")) self.simple_lin = QLineEdit(self) self.simple_lin.textChanged.connect(self.update_command) self.check_scale = QCheckBox("Output Scaled Intensities") self.check_scale.setChecked(False) self.check_scale.stateChanged.connect(self.update_command) self.warning_label = QLabel(str(" ")) self.warning_label.setWordWrap(True) main_v_box.addWidget(step_label) main_v_box.addWidget(out_file_label) main_v_box.addWidget(self.simple_lin) main_v_box.addWidget(self.check_scale) main_v_box.addStretch() main_v_box.addWidget(self.warning_label) main_v_box.addStretch() self.setLayout(main_v_box) self.fist_time = False # self.show() self.simple_lin.setText("integrated.mtz")
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, parent=None): super(ReindexTable, self).__init__(parent) self.cellClicked.connect(self.opt_clicked) self.v_sliderBar = self.verticalScrollBar() self.h_sliderBar = self.horizontalScrollBar() self.tmp_sel = None sys_font = QFont() self.sys_font_point_size = sys_font.pointSize()
def setMonospaced(self): try: rangeLow = range(self.STYLE_DEFAULT) except AttributeError: rangeLow = range(32) try: rangeHigh = range(self.STYLE_LASTPREDEFINED + 1, self.STYLE_MAX + 1) except AttributeError: rangeHigh = range(40, 128) try: font = QFont('Bitstream Vera Sans,11,-1,5,50,0,0,0,0,0') except: return # no font. bail. for style in rangeLow + rangeHigh: self.SendScintilla(self.SCI_STYLESETFONT, style, font.family().latin1()) self.SendScintilla(self.SCI_STYLESETSIZE, style, font.pointSize())
def __init__(self, parent=None): super(MaskPage, 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("Apply Mask")) step_label.setFont(label_font) self.my_scroll_area = QScrollArea() self.my_scroll_area.setWidgetResizable(True) self.my_inner_widget = InnerMask(self) self.my_scroll_area.setWidget(self.my_inner_widget) main_v_box.addWidget(step_label) main_v_box.addWidget(self.my_scroll_area) self.setLayout(main_v_box) self.my_widget = self self.show()
def __init__(self, parent=None): super(BeamCentrPage, 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("Modify Geometry")) step_label.setFont(label_font) self.data_bc_label = QLabel(str("empty Data ... for now")) main_v_box.addWidget(step_label) main_v_box.addStretch() main_v_box.addWidget(self.data_bc_label) main_v_box.addStretch() self.setLayout(main_v_box) self.command_lst = [["modify_geometry"]] self.show() self.my_widget = self
def phil_list2gui(self, lst_phil_obj): sys_font = QFont() sys_font_point_size = sys_font.pointSize() inde_step = 4 self.lst_label_widg = [] self.lst_var_widg = [] non_added_lst = [] for nm, obj in enumerate(lst_phil_obj): if isinstance(obj, ScopeData): tmp_str = " " * int(obj.indent * inde_step) + str(obj.name) # print tmp_str tmp_widg = QLabel(tmp_str) tmp_widg.setAutoFillBackground(True) # tmp_widg.setPalette(self.plt_scp) tmp_widg.setFont( QFont("Monospace", sys_font_point_size, QFont.Bold)) tmp_widg.style_orign = "color: rgba(85, 85, 85, 255)" tmp_widg.setStyleSheet(tmp_widg.style_orign) tooltip = self._tooltip_from_phil_object(obj) if tooltip: tmp_widg.setToolTip(tooltip) self.bg_box.addWidget(tmp_widg) tmp_widg.test_flag = "Yes" self.lst_label_widg.append(tmp_widg) else: tmp_h_box = QHBoxLayout() indent = str(obj.full_path()).count(".") tmp_str = " " * indent * inde_step + str(obj.name) tmp_label = QLabel(tmp_str) tmp_label.setAutoFillBackground(True) # tmp_label.setPalette(self.plt_obj) tmp_label.style_orign = "color: rgba(0, 0, 0, 255)" tmp_label.setStyleSheet(tmp_label.style_orign) tmp_label.setFont(QFont("Monospace", sys_font_point_size)) tmp_h_box.addWidget(tmp_label) self.lst_label_widg.append(tmp_label) if obj.type.phil_type == "bool": tmp_widg = MyQComboBox() tmp_widg.tmp_lst = [] tmp_widg.tmp_lst.append("True") tmp_widg.tmp_lst.append("False") tmp_widg.tmp_lst.append("Auto") # tmp_widg.setFocusPolicy(Qt.StrongFocus) for lst_itm in tmp_widg.tmp_lst: tmp_widg.addItem(lst_itm) if str(obj.extract()) == "True": tmp_widg.setCurrentIndex(0) tmp_str += " True" elif str(obj.extract()) == "False": tmp_widg.setCurrentIndex(1) tmp_str += " False" elif str(obj.extract()) == "Auto": tmp_widg.setCurrentIndex(2) tmp_str += " Auto" else: tmp_str = None # logger.info("tmp_widg.tmp_lst =", tmp_widg.tmp_lst) # logger.info("tmp_str =", tmp_str) tmp_widg.currentIndexChanged.connect(self.combobox_changed) elif obj.type.phil_type == "choice": # remember to ask david about the issue here # tmp_widg = QComboBox() # tmp_widg.tmp_lst=[] # pos = 0 # found_choise = False # for num, opt in enumerate(obj.words): # opt = str(opt) # if(opt[0] == "*"): # found_choise = True # opt = opt[1:] # pos = num # tmp_str += " " + opt # tmp_widg.tmp_lst.append(opt) # for lst_itm in tmp_widg.tmp_lst: # tmp_widg.addItem(lst_itm) # tmp_widg.setCurrentIndex(pos) # tmp_widg.currentIndexChanged.connect(self.combobox_changed) # if(found_choise == False): # tmp_str = None # non_added_lst.append(str(obj.full_path())) # begins pathed version tmp_widg = MyQComboBox() tmp_widg.tmp_lst = [] pos = 0 found_choise = False for num, opt in enumerate(obj.words): opt = str(opt) if opt[0] == "*": found_choise = True opt = opt[1:] pos = num tmp_str += " " + opt tmp_widg.tmp_lst.append(opt) if not found_choise: tmp_str += " " + str( obj.extract()) for lst_itm in tmp_widg.tmp_lst: tmp_widg.addItem(lst_itm) tmp_widg.setCurrentIndex(pos) tmp_widg.currentIndexChanged.connect(self.combobox_changed) # ends pathed version else: tmp_widg = QLineEdit() tmp_widg.setText("") tmp_widg.str_defl = None tmp_widg.textChanged.connect(self.spnbox_changed) # tmp_widg.tmp_lst = None tmp_str += " " + str( obj.extract()) if tmp_str is not None: tmp_widg.local_path = str(obj.full_path()) # tmp_h_box.addStretch() tooltip = self._tooltip_from_phil_object(obj) if tooltip: tmp_widg.setToolTip(tooltip) tmp_h_box.addWidget(tmp_widg) self.lst_var_widg.append(tmp_widg) self.bg_box.addLayout(tmp_h_box) # debugging = ''' logger.debug("Non added parameters:") for lin_to_print in non_added_lst: logger.debug(lin_to_print)