Example #1
0
    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")
Example #2
0
    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)
Example #3
0
    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)
Example #4
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()
Example #5
0
 def __init__(self, side):
     QGraphicsRectItem.__init__(self, side)
     self.side = side
     self.font = QFont()
     self.font.setPointSize(48)
     self.height = 62
     self.width = 200
     self.msg = None
     self.setText('')
Example #6
0
    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()
Example #7
0
File: board.py Project: KDE/kajongg
 def __init__(self, side):
     QGraphicsRectItem.__init__(self, side)
     self.side = side
     self.font = QFont()
     self.font.setPointSize(48)
     self.height = 62
     self.width = 200
     self.msg = None
     self.setText('')
Example #8
0
 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())
Example #9
0
 def data(self, index, role):  # pylint: disable=no-self-use
     """get data fom model"""
     # pylint: disable=too-many-branches,redefined-variable-type
     # too many branches
     result = None
     if index.isValid():
         item = index.internalPointer()
         if role in (Qt.DisplayRole, Qt.EditRole):
             if index.column() == 1:
                 if isinstance(item, RuleItem) and isinstance(item.rawContent, BoolRule):
                     return ''
             showValue = item.content(index.column())
             if isinstance(showValue, str) and showValue.endswith('.0'):
                 try:
                     showValue = str(int(float(showValue)))
                 except ValueError:
                     pass
             if showValue == '0':
                 showValue = ''
             result = showValue
         elif role == Qt.CheckStateRole:
             if self.isCheckboxCell(index):
                 bData = item.content(index.column())
                 result = Qt.Checked if bData else Qt.Unchecked
         elif role == Qt.TextAlignmentRole:
             result = int(Qt.AlignLeft | Qt.AlignVCenter)
             if index.column() > 0:
                 result = int(Qt.AlignRight | Qt.AlignVCenter)
         elif role == Qt.FontRole and index.column() == 0:
             ruleset = item.ruleset()
             if isinstance(ruleset, PredefinedRuleset):
                 font = QFont()
                 font.setItalic(True)
                 result = font
         elif role == Qt.ToolTipRole:
             tip = '<b></b>%s<b></b>' % i18n(
                 item.tooltip()) if item else ''
             result = tip
     return result
Example #10
0
 def data(self, index, role):  # pylint: disable=no-self-use
     """get data fom model"""
     # pylint: disable=too-many-branches,redefined-variable-type
     # too many branches
     result = None
     if index.isValid():
         item = index.internalPointer()
         if role in (Qt.DisplayRole, Qt.EditRole):
             if index.column() == 1:
                 if isinstance(item, RuleItem) and isinstance(item.rawContent, BoolRule):
                     return toQVariant('')
             showValue = item.content(index.column())
             if isinstance(showValue, unicode) and showValue.endswith('.0'):
                 try:
                     showValue = str(int(float(showValue)))
                 except ValueError:
                     pass
             if showValue == '0':
                 showValue = ''
             result = showValue
         elif role == Qt.CheckStateRole:
             if self.isCheckboxCell(index):
                 bData = item.content(index.column())
                 result = Qt.Checked if bData else Qt.Unchecked
         elif role == Qt.TextAlignmentRole:
             result = int(Qt.AlignLeft | Qt.AlignVCenter)
             if index.column() > 0:
                 result = int(Qt.AlignRight | Qt.AlignVCenter)
         elif role == Qt.FontRole and index.column() == 0:
             ruleset = item.ruleset()
             if isinstance(ruleset, PredefinedRuleset):
                 font = QFont()
                 font.setItalic(True)
                 result = font
         elif role == Qt.ToolTipRole:
             tip = u'<b></b>%s<b></b>' % m18n(
                 item.tooltip()) if item else u''
             result = tip
     return toQVariant(result)
Example #11
0
 def data(self, index, role=None):  # pylint: disable=no-self-use,too-many-branches
     """score table"""
     # pylint: disable=too-many-return-statements
     if not index.isValid():
         return
     column = index.column()
     item = index.internalPointer()
     if role is None:
         role = Qt.DisplayRole
     if role == Qt.DisplayRole:
         if isinstance(item, ScorePlayerItem):
             content = item.content(column)
             if isinstance(content, HandResult):
                 parentRow = item.parent.row()
                 if parentRow == 0:
                     if not content.penalty:
                         content = '%d %s' % (content.points, content.wind)
                 elif parentRow == 1:
                     content = str(content.payments)
                 else:
                     content = str(content.balance)
             return content
         else:
             if column > 0:
                 return ''
             else:
                 return item.content(0)
     if role == Qt.TextAlignmentRole:
         if index.column() == 0:
             return int(Qt.AlignLeft | Qt.AlignVCenter)
         else:
             return int(Qt.AlignRight | Qt.AlignVCenter)
     if role == Qt.FontRole:
         return QFont('Monospaced')
     if role == Qt.ForegroundRole:
         if isinstance(item, ScorePlayerItem) and item.parent.row() == 3:
             content = item.content(column)
             if not isinstance(content, HandResult):
                 return QBrush(ScoreItemDelegate.colors[index.row()])
     if column > 0 and isinstance(item, ScorePlayerItem):
         content = item.content(column)
         # pylint: disable=maybe-no-member
         # pylint thinks content is a str
         if role == Qt.BackgroundRole:
             if content and content.won:
                 return QColor(165, 255, 165)
         if role == Qt.ToolTipRole:
             englishHints = content.manualrules.split('||')
             tooltip = '<br />'.join(i18n(x) for x in englishHints)
             return tooltip
Example #12
0
    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
Example #13
0
    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()
Example #14
0
File: board.py Project: KDE/kajongg
class YellowText(QGraphicsRectItem):

    """a yellow rect with a message, used for claims"""

    def __init__(self, side):
        QGraphicsRectItem.__init__(self, side)
        self.side = side
        self.font = QFont()
        self.font.setPointSize(48)
        self.height = 62
        self.width = 200
        self.msg = None
        self.setText('')

    def setText(self, msg):
        """set the text of self"""
        self.msg = '%s  ' % msg
        metrics = QFontMetrics(self.font)
        self.width = metrics.width(self.msg)
        self.height = metrics.lineSpacing() * 1.1
        self.setRect(0, 0, self.width, self.height)
        self.resetTransform()
        self.setPos(self.side.center())
        rotation = self.side.rotation()
        rotateCenter(self, -rotation)
        xOffset = -self.rect().width() / 2
        yOffset = -self.rect().height() / 2
        if rotation % 180 == 0:
            self.moveBy(xOffset, yOffset * 4)
        else:
            self.moveBy(xOffset, yOffset)

    def paint(self, painter, dummyOption, dummyWidget):
        """override predefined paint"""
        painter.setFont(self.font)
        painter.fillRect(self.rect(), QBrush(QColor('yellow')))
        painter.drawText(self.rect(), self.msg)
Example #15
0
class YellowText(QGraphicsRectItem):

    """a yellow rect with a message, used for claims"""

    def __init__(self, side):
        QGraphicsRectItem.__init__(self, side)
        self.side = side
        self.font = QFont()
        self.font.setPointSize(48)
        self.height = 62
        self.width = 200
        self.msg = None
        self.setText('')

    def setText(self, msg):
        """set the text of self"""
        self.msg = '%s  ' % msg
        metrics = QFontMetrics(self.font)
        self.width = metrics.width(self.msg)
        self.height = metrics.lineSpacing() * 1.1
        self.setRect(0, 0, self.width, self.height)
        self.resetTransform()
        self.setPos(self.side.center())
        rotation = self.side.rotation()
        rotateCenter(self, -rotation)
        xOffset = -self.rect().width() / 2
        yOffset = -self.rect().height() / 2
        if rotation % 180 == 0:
            self.moveBy(xOffset, yOffset * 4)
        else:
            self.moveBy(xOffset, yOffset)

    def paint(self, painter, dummyOption, dummyWidget):
        """override predefined paint"""
        painter.setFont(self.font)
        painter.fillRect(self.rect(), QBrush(QColor('yellow')))
        painter.drawText(self.rect(), self.msg)
Example #16
0
 def adaptedFont(self):
     """Font with the correct point size for the wall"""
     result = QFont()
     size = 80
     result.setPointSize(size)
     tileHeight = self.board.tileset.faceSize.height()
     while QFontMetrics(result).ascent() > tileHeight:
         size -= 1
         result.setPointSize(size)
     return result
Example #17
0
 def __init__(self, app=None):
     super(CliOutView, self).__init__()
     self.setFont(QFont("Monospace", 10, QFont.Bold))
     self.make_green()
    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)
Example #19
0
    def add_opts_lst(self, lst_labels=None, json_path=None, selected_pos=None):

        if lst_labels is None:
            logger.debug("json_path = %s", json_path)
            self.list_labl = ops_list_from_json(json_path)

        n_row = len(self.list_labl)
        logger.debug("n_row = %s", n_row)
        n_col = len(self.list_labl[0])
        logger.debug("n_col = %s", n_col)

        self.setRowCount(n_row)
        self.setColumnCount(n_col - 1)

        alpha_str = " " + u"\u03B1" + " "
        beta_str = " " + u"\u03B2" + " "
        gamma_str = " " + u"\u03B3" + " "

        low_delta_str = u"\u03B4"
        delta_max_str = "max " + low_delta_str

        header_label_lst = [
            delta_max_str,
            "rmsd",
            " min cc",
            "max cc",
            "latt",
            "  a ",
            "  b ",
            "  c ",
            alpha_str,
            beta_str,
            gamma_str,
            "Ok",
        ]

        self.setHorizontalHeaderLabels(header_label_lst)

        self.rec_col = None

        for row, row_cont in enumerate(self.list_labl):
            for col, col_cont in enumerate(row_cont[1:]):
                item = QTableWidgetItem(col_cont)
                item.setFlags(Qt.ItemIsEnabled)
                if col_cont == " Y":
                    item.setBackground(Qt.green)
                    item.setForeground(Qt.black)

                    self.rec_col = col + 1

                elif col_cont == " N":
                    item.setBackground(Qt.red)
                    item.setForeground(Qt.black)

                else:
                    if row == selected_pos:
                        item.setBackground(Qt.blue)
                        item.setForeground(Qt.yellow)

                    else:
                        if float(row) / 2.0 == int(float(row) / 2.0):
                            item.setBackground(QColor(50, 50, 50, 50))

                        else:
                            item.setBackground(Qt.white)

                        item.setForeground(Qt.black)

                item.setFont(QFont("Monospace",
                                   self.sys_font_point_size))  # , QFont.Bold))
                self.setItem(row, col, item)

        self.resizeColumnsToContents()