Python qtpy.QtGui.QFont() Examples

The following are 25 code examples of qtpy.QtGui.QFont(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qtpy.QtGui , or try the search function .
Example #1
Source File: uiKLine.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def create_plot_item(self, name):
        """生成PlotItem对象"""
        vb = CustomViewBox()
        plotItem = pg.PlotItem(viewBox = vb, name=name ,axisItems={'bottom': self.axisTime})
        plotItem.setMenuEnabled(False)
        plotItem.setClipToView(True)
        plotItem.hideAxis('left')
        plotItem.showAxis('right')
        plotItem.setDownsampling(mode='peak')
        plotItem.setRange(xRange = (0,1),yRange = (0,1))
        plotItem.getAxis('right').setWidth(60)
        plotItem.getAxis('right').setStyle(tickFont = QtGui.QFont("Roman times",10,QtGui.QFont.Bold))
        plotItem.getAxis('right').setPen(color=(255, 255, 255, 255), width=0.8)
        plotItem.showGrid(True, True)
        plotItem.hideButtons()
        return plotItem

    # ---------------------------------------------------------------------- 
Example #2
Source File: console_widget.py    From qtconsole with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def reset_font(self):
        """ Sets the font to the default fixed-width font for this platform.
        """
        if sys.platform == 'win32':
            # Consolas ships with Vista/Win7, fallback to Courier if needed
            fallback = 'Courier'
        elif sys.platform == 'darwin':
            # OSX always has Monaco
            fallback = 'Monaco'
        else:
            # Monospace should always exist
            fallback = 'Monospace'
        font = get_font(self.font_family, fallback)
        if self.font_size:
            font.setPointSize(self.font_size)
        else:
            font.setPointSize(QtWidgets.QApplication.instance().font().pointSize())
        font.setStyleHint(QtGui.QFont.TypeWriter)
        self._set_font(font) 
Example #3
Source File: logger_tab.py    From cutelog with MIT License 6 votes vote down vote up
def data_internal(self, index, record, role):
        result = None
        if role == Qt.DisplayRole:
            if index.column() == self.columnCount(INVALID_INDEX) - 1:
                result = record._cutelog
            else:
                column = self.table_header[index.column()]
                if column.name == 'asctime':
                    result = record.asctime
        elif role == Qt.SizeHintRole:
            result = QSize(1, CONFIG.logger_row_height)
        elif role == Qt.FontRole:
            result = QFont(CONFIG.logger_table_font, CONFIG.logger_table_font_size)
        elif role == Qt.ForegroundRole:
            if not self.dark_theme:
                result = QColor(Qt.black)
            else:
                result = QColor(Qt.white)
        elif role == Qt.BackgroundRole:
            if not self.dark_theme:
                color = QColor(Qt.lightGray)
            else:
                color = QColor(Qt.darkGray)
            result = QBrush(color, Qt.BDiagPattern)
        return result 
Example #4
Source File: levels_preset_dialog.py    From cutelog with MIT License 6 votes vote down vote up
def get_preview_items(self, level):
        previewItem = QTableWidgetItem("Log message")
        previewItem.setBackground(QBrush(level.bg, Qt.SolidPattern))
        previewItem.setForeground(QBrush(level.fg, Qt.SolidPattern))
        previewItemDark = QTableWidgetItem("Log message")
        previewItemDark.setBackground(QBrush(level.bgDark, Qt.SolidPattern))
        previewItemDark.setForeground(QBrush(level.fgDark, Qt.SolidPattern))
        font = QFont(CONFIG.logger_table_font, CONFIG.logger_table_font_size)
        fontDark = QFont(font)
        if 'bold' in level.styles:
            font.setBold(True)
        if 'italic' in level.styles:
            font.setItalic(True)
        if 'underline' in level.styles:
            font.setUnderline(True)
        if 'bold' in level.stylesDark:
            fontDark.setBold(True)
        if 'italic' in level.stylesDark:
            fontDark.setItalic(True)
        if 'underline' in level.stylesDark:
            fontDark.setUnderline(True)
        previewItem.setFont(font)
        previewItemDark.setFont(fontDark)
        return previewItem, previewItemDark 
Example #5
Source File: util.py    From qtconsole with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def get_font(family, fallback=None):
    """Return a font of the requested family, using fallback as alternative.

    If a fallback is provided, it is used in case the requested family isn't
    found.  If no fallback is given, no alternative is chosen and Qt's internal
    algorithms may automatically choose a fallback font.

    Parameters
    ----------
    family : str
      A font name.
    fallback : str
      A font name.

    Returns
    -------
    font : QFont object
    """
    font = QtGui.QFont(family)
    # Check whether we got what we wanted using QFontInfo, since exactMatch()
    # is overly strict and returns false in too many cases.
    font_info = QtGui.QFontInfo(font)
    if fallback is not None and font_info.family() != family:
        font = QtGui.QFont(fallback)
    return font 
Example #6
Source File: qt_range_slider_popup.py    From napari with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, value='', parent=None, get_pos=None):
        super().__init__(value, parent=parent)
        self.fm = QFontMetrics(QFont("", 0))
        self.setObjectName('slice_label')
        self.min_width = 30
        self.max_width = 200
        self.setCursor(Qt.IBeamCursor)
        self.setValidator(QDoubleValidator())
        self.textChanged.connect(self._on_text_changed)
        self._on_text_changed(value)

        self.get_pos = get_pos
        if parent is not None:
            self.min_width = 50
            self.slider = parent.slider
            self.setAlignment(Qt.AlignCenter) 
Example #7
Source File: qt_dims.py    From napari with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _resize_axis_labels(self):
        """When any of the labels get updated, this method updates all label
        widths to the width of the longest label. This keeps the sliders
        left-aligned and allows the full label to be visible at all times,
        with minimal space, without setting stretch on the layout.
        """
        fm = QFontMetrics(QFont("", 0))
        labels = self.findChildren(QLineEdit, 'axis_label')
        newwidth = max([fm.boundingRect(lab.text()).width() for lab in labels])

        if any(self._displayed_sliders):
            # set maximum width to no more than 20% of slider width
            maxwidth = self.slider_widgets[0].width() * 0.2
            newwidth = min([newwidth, maxwidth])
        for labl in labels:
            labl.setFixedWidth(newwidth + 10) 
Example #8
Source File: qt_dims.py    From napari with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _resize_slice_labels(self):
        """When the size of any dimension changes, we want to resize all of the
        slice labels to width of the longest label, to keep all the sliders
        right aligned.  The width is determined by the number of digits in the
        largest dimensions, plus a little padding.
        """
        width = 0
        for ax, maxi in enumerate(self.dims.max_indices):
            if self._displayed_sliders[ax]:
                length = len(str(int(maxi)))
                if length > width:
                    width = length
        # gui width of a string of length `width`
        fm = QFontMetrics(QFont("", 0))
        width = fm.boundingRect("8" * width).width()
        for labl in self.findChildren(QWidget, 'slice_label'):
            labl.setFixedWidth(width + 6) 
Example #9
Source File: dependencies.py    From conda-manager with MIT License 5 votes vote down vote up
def data(self, index, role=Qt.DisplayRole):
        """Override Qt method"""
        if not index.isValid() or not 0 <= index.row() < len(self._rows):
            return to_qvariant()
        row = index.row()
        column = index.column()

        # Carefull here with the order, this has to be adjusted manually
        if self._rows[row] == row:
            name, unlink, link, fetch = [u'', u'', u'', u'']
        else:
            name, unlink, link, fetch = self._rows[row]

        if role == Qt.DisplayRole:
            if column == 0:
                return to_qvariant(name)
            elif column == 1:
                return to_qvariant(unlink)
            elif column == 2:
                return to_qvariant(link)
            elif column == 3:
                return to_qvariant(fetch)
        elif role == Qt.TextAlignmentRole:
            if column in [0]:
                return to_qvariant(int(Qt.AlignLeft | Qt.AlignVCenter))
            elif column in [1, 2, 3]:
                return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
        elif role == Qt.ForegroundRole:
            return to_qvariant()
        elif role == Qt.FontRole:
            font = QFont()
            if row in self._bold_rows:
                font.setBold(True)
                return to_qvariant(font)
            else:
                font.setBold(False)
                return to_qvariant(font)
        return to_qvariant() 
Example #10
Source File: spinbox.py    From pyrpl with GNU General Public License v3.0 5 votes vote down vote up
def set_min_size(self):
        """
        sets the min size for content to fit.
        """
        font = QtGui.QFont("", 0)
        font_metric = QtGui.QFontMetrics(font)
        pixel_wide = font_metric.width("0"*self.max_num_letter)
        self.line.setFixedWidth(pixel_wide) 
Example #11
Source File: console_widget.py    From qtconsole with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _set_font(self, font):
        """ Sets the base font for the ConsoleWidget to the specified QFont.
        """
        font_metrics = QtGui.QFontMetrics(font)
        self._control.setTabStopWidth(
            self.tab_width * font_metrics.boundingRect(' ').width()
        )

        self._completion_widget.setFont(font)
        self._control.document().setDefaultFont(font)
        if self._page_control:
            self._page_control.document().setDefaultFont(font)

        self.font_changed.emit(font) 
Example #12
Source File: script.py    From Pyslvs-UI with GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(_ScriptBrowser, self).__init__(parent)
        self.setLineWrapMode(QTextEdit.NoWrap)
        self.setFont(QFont("Consolas"))
        self.setReadOnly(True)
        self.zoomIn(3) 
Example #13
Source File: preview.py    From Pyslvs-UI with GNU Affero General Public License v3.0 5 votes vote down vote up
def __draw_link(self, name: str, points: Sequence[int]) -> None:
        """Draw link function.

        The link color will be the default color.
        """
        pen = QPen(Qt.black if self.monochrome else color_qt('blue'))
        pen.setWidth(self.link_width)
        self.painter.setPen(pen)
        brush = color_qt('dark-gray') if self.monochrome else LINK_COLOR
        brush.setAlphaF(0.70)
        self.painter.setBrush(brush)
        qpoints = tuple(
            QPointF(self.pos[i][0], -self.pos[i][1]) * self.zoom
            for i in points if self.pos[i] and (not isnan(self.pos[i][0]))
        )
        if len(qpoints) == len(points):
            self.painter.drawPolygon(*qpoints)
        self.painter.setBrush(Qt.NoBrush)
        if self.show_point_mark and name != VLink.FRAME and qpoints:
            pen.setColor(Qt.darkGray)
            self.painter.setPen(pen)
            self.painter.setFont(QFont('Arial', self.font_size))
            cen_x = sum(self.pos[i][0] for i in points if self.pos[i])
            cen_y = sum(self.pos[i][1] for i in points if self.pos[i])
            self.painter.drawText(
                QPointF(cen_x, -cen_y) * self.zoom / len(points),
                f"[{name}]"
            ) 
Example #14
Source File: wdiag.py    From pyCGNS with GNU Lesser General Public License v2.1 5 votes vote down vote up
def addDiagEntry(self, parent, diag, top=False):
        dit = QTreeWidgetItem(parent, (self._data.message(diag),))
        ft = QFont(OCTXT._Table_Font)
        if top:
            ft.setBold(True)
        dit.setFont(0, ft)
        if diag.level == CGM.CHECK_FAIL:
            dit.setIcon(0, self.IC(QW.I_C_SFL))
        if diag.level == CGM.CHECK_WARN:
            dit.setIcon(0, self.IC(QW.I_C_SWR))
        if diag.key not in self._filterItems:
            self._filterItems[diag.key] = [dit]
        else:
            self._filterItems[diag.key].insert(0, dit)
        return dit 
Example #15
Source File: wdiag.py    From pyCGNS with GNU Lesser General Public License v2.1 5 votes vote down vote up
def addPathEntry(self, parent, path, state, top=False):
        it = QTreeWidgetItem(parent, (path,))
        ft = QFont(OCTXT._Table_Font)
        if top:
            ft.setBold(True)
        it.setFont(0, ft)
        if state == CGM.CHECK_FAIL:
            it.setIcon(0, self.IC(QW.I_C_SFL))
        if state == CGM.CHECK_WARN:
            it.setIcon(0, self.IC(QW.I_C_SWR))
        return it 
Example #16
Source File: wpattern.py    From pyCGNS with GNU Lesser General Public License v2.1 5 votes vote down vote up
def reset(self):
        tlvcols = 4
        tlvcolsnames = ['S', 'Pattern', 'P', 'Comment']
        v = self.patternTable
        v.setColumnCount(tlvcols)
        lh = v.horizontalHeader()
        lv = v.verticalHeader()
        h = tlvcolsnames
        n = len(h)
        for i in range(n):
            hi = QTableWidgetItem(h[i])
            v.setHorizontalHeaderItem(i, hi)
        for profkey in self._profiles:
            prof = self._profiles[profkey]
            for k in prof:
                pentry = prof[k]
                v.setRowCount(v.rowCount() + 1)
                r = v.rowCount() - 1
                it1 = QTableWidgetItem(self.IC(QW.I_EMPTY), '')
                it2 = QTableWidgetItem(k)
                it2.setFont(QFont("Courier"))
                it3 = QTableWidgetItem(profkey)
                it4 = QTableWidgetItem(pentry[2])
                v.setItem(r, 0, it1)
                v.setItem(r, 1, it2)
                v.setItem(r, 2, it3)
                v.setItem(r, 3, it4)
        self.patternTable.resizeColumnsToContents()
        self.patternTable.resizeRowsToContents()
        plist = []
        for i in range(len(plist)):
            v.resizeColumnToContents(i)
        for i in range(v.rowCount()):
            v.resizeRowToContents(i)
        self._initialized = True 
Example #17
Source File: datatree.py    From spyder-unittest with MIT License 5 votes vote down vote up
def __init__(self, parent=None):
        """Constructor."""
        QAbstractItemModel.__init__(self, parent)
        self.abbreviator = Abbreviator()
        self.is_dark_interface = False
        self.testresults = []
        try:
            self.monospace_font = parent.window().editor.get_plugin_font()
        except AttributeError:  # If run standalone for testing
            self.monospace_font = QFont("Courier New")
            self.monospace_font.setPointSize(10) 
Example #18
Source File: QComplexWidgets.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def selectFont(self):
        """ open a font select dialog """
        font0 = QtGui.QFont()
        font0.setFamily(self.target.get_fontname())
        font0.setWeight(self.convertMplWeightToQtWeight(self.target.get_weight()))
        font0.setItalic(self.target.get_style() == "italic")
        font0.setPointSizeF(self.target.get_fontsize())
        font, x = QtWidgets.QFontDialog.getFont(font0, self)

        for element in self.target_list:
            element.set_fontname(font.family())
            element.figure.change_tracker.addChange(element, ".set_fontname(\"%s\")" % (element.get_fontname(),))

            if font.weight() != font0.weight():
                weight = self.convertQtWeightToMplWeight(font.weight())
                element.set_weight(weight)
                element.figure.change_tracker.addChange(element, ".set_weight(\"%s\")" % (weight,))

            if font.pointSizeF() != font0.pointSizeF():
                element.set_fontsize(font.pointSizeF())
                element.figure.change_tracker.addChange(element, ".set_fontsize(%f)" % (font.pointSizeF(),))

            if font.italic() != font0.italic():
                style = "italic" if font.italic() else "normal"
                element.set_style(style)
                element.figure.change_tracker.addChange(element, ".set_style(\"%s\")" % (style,))

        self.target.figure.canvas.draw()
        self.setTarget(self.target_list) 
Example #19
Source File: QComplexWidgets.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def convertQtWeightToMplWeight(self, weight: int) -> str:
        """ convert a Qt weight value to a string for use in matmplotlib """
        weight_dict = {QtGui.QFont.Normal: 'normal', QtGui.QFont.Bold: 'bold', QtGui.QFont.ExtraBold: 'heavy',
                       QtGui.QFont.Light: 'light', QtGui.QFont.Black: 'ultrabold', QtGui.QFont.ExtraLight: 'ultralight'}
        if weight in weight_dict:
            return weight_dict[weight]
        return "normal" 
Example #20
Source File: QComplexWidgets.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def convertMplWeightToQtWeight(self, weight: str) -> int:
        """ convert a font weight string to a weight enumeration of Qt """
        weight_dict = {'normal': QtGui.QFont.Normal, 'bold': QtGui.QFont.Bold, 'heavy': QtGui.QFont.ExtraBold,
                       'light': QtGui.QFont.Light, 'ultrabold': QtGui.QFont.Black, 'ultralight': QtGui.QFont.ExtraLight}
        if weight in weight_dict:
            return weight_dict[weight]
        return weight_dict["normal"] 
Example #21
Source File: uiKLine.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def __init__(self, xdict, *args, **kwargs):
        pg.AxisItem.__init__(self, *args, **kwargs)
        self.minVal = 0 
        self.maxVal = 0
        # 序列 <= > 时间
        self.xdict  = OrderedDict()
        self.xdict.update(xdict)
        # 时间 <=> 序列
        self.tdict  = OrderedDict([(v,k) for k,v in xdict.items()])
        self.x_values = np.asarray(xdict.keys())
        self.x_strings = list(xdict.values())
        self.setPen(color=(255, 255, 255, 255), width=0.8)
        self.setStyle(tickFont = QtGui.QFont("Roman times",10,QtGui.QFont.Bold),autoExpandTextSpace=True) 
Example #22
Source File: qt_dict_table.py    From napari with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def set_data(self, data: List[dict], headers: Optional[List[str]] = None):
        """Set the data in the table, given a list of dicts.

        Parameters
        ----------
        data : List[dict]
            A list of dicts where each dict in the list is a row, and each key
            in the dict is a header, by default None.  (call set_data later to
            add data)
        headers : list of str, optional
            If provided, will be used in order as the headers of the table. All
            items in ``headers`` must be present in at least one of the dicts.
            by default headers will be the set of all keys in all dicts in
            ``source``
        """
        if not isinstance(data, list) or any(
            not isinstance(i, dict) for i in data
        ):
            raise ValueError("'data' argument must be a list of dicts")
        nrows = len(data)
        _headers = sorted(set().union(*data))
        if headers:
            for h in headers:
                if h not in _headers:
                    raise ValueError(
                        f"Argument 'headers' got item '{h}', which was "
                        "not found in any of the items in 'data'"
                    )
            _headers = headers
        self.setRowCount(nrows)
        self.setColumnCount(len(_headers))
        for row, elem in enumerate(data):
            for key, value in elem.items():
                value = value or ''
                try:
                    col = _headers.index(key)
                except ValueError:
                    continue
                item = QTableWidgetItem(value)
                # underline links
                if email_pattern.match(value) or url_pattern.match(value):
                    font = QFont()
                    font.setUnderline(True)
                    item.setFont(font)
                self.setItem(row, col, item)

        self.setHorizontalHeaderLabels(_headers)
        self.resize_to_fit() 
Example #23
Source File: uiBasicIO.py    From uiKLine with MIT License 4 votes vote down vote up
def initBasicUi(self):
        """初始化界面"""
        # 根据配置文件生成输入框界面
        self.groupInput = QGroupBox()
        self.groupInput.setTitle(u'')
        gridup = QGridLayout()
        i = 0
        for className in self.classDict:
            classIndex = i
            # 标题和输入框
            for name in self.classDict[className]:
                width   = self.widthDict[name]
                qLabel  = self.labelDict[name]
                qEdit   = self.editDict[name]
                gridup.addWidget(qLabel, 1, i)
                gridup.addWidget(qEdit, 2, i)
                gridup.setColumnStretch(i, width)
                i+=1
            # 分类标题
            qcLabel = QLabel(className)
            qcLabel.setAlignment(QtCore.Qt.AlignCenter)
            qcLabel.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))
            gridup.addWidget(qcLabel, 0, classIndex,1,i-classIndex)
            # 分隔符
            for j in xrange(0,3):
                qcSplit = QLabel(u'|')
                qcSplit.setAlignment(QtCore.Qt.AlignCenter)
                gridup.addWidget(qcSplit, j, i)
            i+=1
        self.groupInput.setLayout(gridup)

        # 根据配置文件生成按钮界面
        self.groupProcess = QGroupBox()
        self.groupProcess.setTitle(u'')
        griddown = QGridLayout()
        i = 0
        for className in self.bClassDict:
            classIndex = i
            # 标题和输入框
            for name in self.bClassDict[className]:
                width   = self.bWidthDict[name]
                qButton = self.buttonDict[name]
                griddown.addWidget(qButton, 1, i)
                griddown.setColumnStretch(i, width)
                i+=1
            # 分类标题
            qcLabel = QLabel(className)
            qcLabel.setAlignment(QtCore.Qt.AlignCenter)
            qcLabel.setFont(QFont("Roman times",10,QtGui.QFont.Bold))
            griddown.addWidget(qcLabel, 0, classIndex,1,i-classIndex)
            # 分隔符
            for j in xrange(0,2):
                qcSplit = QLabel(u'|')
                qcSplit.setAlignment(QtCore.Qt.AlignCenter)
                griddown.addWidget(qcSplit, j, i)
            i+=1
        self.groupProcess.setLayout(griddown) 
Example #24
Source File: settings_dialog.py    From cutelog with MIT License 4 votes vote down vote up
def load_from_config(self):
        # Appearance page
        self.darkThemeDefaultCheckBox.setChecked(CONFIG['dark_theme_default'])

        self.loggerTableFont.setCurrentFont(QFont(CONFIG['logger_table_font']))
        self.loggerTableFontSize.setValue(CONFIG['logger_table_font_size'])
        self.textViewFont.setCurrentFont(QFont(CONFIG['text_view_dialog_font']))
        self.textViewFontSize.setValue(CONFIG['text_view_dialog_font_size'])
        self.loggerTableRowHeight.setValue(CONFIG['logger_row_height'])
        self.excIndicationComboBox.setCurrentIndex(CONFIG['exception_indication'])
        self.timeFormatLine.setText(CONFIG['time_format_string'])
        self.timeFormatLine.setValidator(self.time_format_validator)
        self.timeFormatLine.textChanged.connect(self.time_format_valid)

        # Search
        self.searchOpenDefaultCheckBox.setChecked(CONFIG['search_open_default'])
        self.searchRegexDefaultCheckBox.setChecked(CONFIG['search_regex_default'])
        self.searchCaseSensitiveDefaultCheckBox.setChecked(CONFIG['search_casesensitive_default'])
        self.searchWildcardDefaultCheckBox.setChecked(CONFIG['search_wildcard_default'])

        # Server page
        self.listenHostLine.setText(CONFIG['listen_host'])
        self.listenPortLine.setValidator(QIntValidator(0, 65535, self))
        self.listenPortLine.setText(str(CONFIG['listen_port']))
        self.singleTabCheckBox.setChecked(CONFIG['single_tab_mode_default'])
        self.extraModeCheckBox.setChecked(CONFIG['extra_mode_default'])
        if MSGPACK_SUPPORT:
            self.serializationFormatCombo.addItem("msgpack")
        if CBOR_SUPPORT:
            self.serializationFormatCombo.addItem("cbor")
        i = self.serializationFormatCombo.findText(CONFIG['default_serialization_format'])
        if i != -1:
            self.serializationFormatCombo.setCurrentIndex(i)

        # Advanced page
        self.logLevelLine.setValidator(QIntValidator(0, 1000, self))
        self.logLevelLine.setText(str(CONFIG['console_logging_level']))
        self.benchmarkCheckBox.setChecked(CONFIG['benchmark'])
        self.benchmarkIntervalLine.setValidator(QDoubleValidator(0, 1000, 9, self))
        self.benchmarkIntervalLine.setText(str(CONFIG['benchmark_interval']))
        self.lightThemeNativeCheckBox.setChecked(CONFIG['light_theme_is_native'])
        self.server_restart_needed = False 
Example #25
Source File: uiBasicIO.py    From uiKLine with MIT License 4 votes vote down vote up
def initBasicUi(self):
        """初始化界面"""
        # 根据配置文件生成输入框界面
        self.groupInput = QGroupBox()
        self.groupInput.setTitle(u'')
        gridup = QGridLayout()
        i = 0
        for className in self.classDict:
            classIndex = i
            # 标题和输入框
            for name in self.classDict[className]:
                width   = self.widthDict[name]
                qLabel  = self.labelDict[name]
                qEdit   = self.editDict[name]
                gridup.addWidget(qLabel, 1, i)
                gridup.addWidget(qEdit, 2, i)
                gridup.setColumnStretch(i, width)
                i+=1
            # 分类标题
            qcLabel = QLabel(className)
            qcLabel.setAlignment(QtCore.Qt.AlignCenter)
            qcLabel.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))
            gridup.addWidget(qcLabel, 0, classIndex,1,i-classIndex)
            # 分隔符
            for j in xrange(0,3):
                qcSplit = QLabel(u'|')
                qcSplit.setAlignment(QtCore.Qt.AlignCenter)
                gridup.addWidget(qcSplit, j, i)
            i+=1
        self.groupInput.setLayout(gridup)

        # 根据配置文件生成按钮界面
        self.groupProcess = QGroupBox()
        self.groupProcess.setTitle(u'')
        griddown = QGridLayout()
        i = 0
        for className in self.bClassDict:
            classIndex = i
            # 标题和输入框
            for name in self.bClassDict[className]:
                width   = self.bWidthDict[name]
                qButton = self.buttonDict[name]
                griddown.addWidget(qButton, 1, i)
                griddown.setColumnStretch(i, width)
                i+=1
            # 分类标题
            qcLabel = QLabel(className)
            qcLabel.setAlignment(QtCore.Qt.AlignCenter)
            qcLabel.setFont(QFont("Roman times",10,QtGui.QFont.Bold))
            griddown.addWidget(qcLabel, 0, classIndex,1,i-classIndex)
            # 分隔符
            for j in xrange(0,2):
                qcSplit = QLabel(u'|')
                qcSplit.setAlignment(QtCore.Qt.AlignCenter)
                griddown.addWidget(qcSplit, j, i)
            i+=1
        self.groupProcess.setLayout(griddown)