我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用PySide.QtGui.QFont()。
def format(color, style=None): """ Return a QTextCharFormat with the given attributes. :param color: The color to format the text. :param style: [optional] The styling for the text. """ _color = QtGui.QColor() _color.setNamedColor(color) _format = QtGui.QTextCharFormat() _format.setForeground(_color) if style is not None and 'bold' in style: _format.setFontWeight(QtGui.QFont.Bold) if style is not None and 'italic' in style: _format.setFontItalic(True) return _format # Syntax styles that can be shared by all languages
def data(self, index, role): if not index.isValid(): return None row = index.row() column = index.column() if column == 0: if role == QtCore.Qt.CheckStateRole: return QtCore.Qt.Checked if self._checked[row] else QtCore.Qt.Unchecked elif role==QtCore.Qt.FontRole: return QtGui.QFont("Helvetica Neue", 10) else: return None column = column - 1 if role==QtCore.Qt.FontRole: return QtGui.QFont("Helvetica Neue", 10) return self._data[row,column] if role == QtCore.Qt.DisplayRole else None
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(573, 391) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName("verticalLayout") self.table = QtGui.QTableWidget(Dialog) self.table.setObjectName("table") self.table.setColumnCount(0) self.table.setRowCount(0) self.verticalLayout.addWidget(self.table) self.label = QtGui.QLabel(Dialog) font = QtGui.QFont() font.setPointSize(12) font.setWeight(75) font.setItalic(False) font.setBold(True) self.label.setFont(font) self.label.setFrameShape(QtGui.QFrame.NoFrame) self.label.setTextFormat(QtCore.Qt.AutoText) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Manual): Manual.setObjectName(_fromUtf8("Manual")) Manual.resize(740, 450) Manual.setMinimumSize(QtCore.QSize(740, 450)) Manual.setMaximumSize(QtCore.QSize(740, 450)) self.textBrowser = QtGui.QTextBrowser(Manual) self.textBrowser.setGeometry(QtCore.QRect(10, 40, 721, 371)) self.textBrowser.setObjectName(_fromUtf8("textBrowser")) self.label = QtGui.QLabel(Manual) self.label.setGeometry(QtCore.QRect(10, 10, 271, 21)) font = QtGui.QFont() font.setFamily(_fromUtf8("Arial")) font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setObjectName(_fromUtf8("label")) self.manual_bn = QtGui.QPushButton(Manual) self.manual_bn.setGeometry(QtCore.QRect(650, 420, 75, 23)) font = QtGui.QFont() font.setFamily(_fromUtf8("Arial")) self.manual_bn.setFont(font) self.manual_bn.setObjectName(_fromUtf8("manual_bn")) self.retranslateUi(Manual) QtCore.QMetaObject.connectSlotsByName(Manual)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(529, 329) self.selInfoWidget = QtGui.QWidget(Form) self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222)) self.selInfoWidget.setObjectName("selInfoWidget") self.gridLayout = QtGui.QGridLayout(self.selInfoWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") self.selDescLabel = QtGui.QLabel(self.selInfoWidget) self.selDescLabel.setText("") self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.selDescLabel.setWordWrap(True) self.selDescLabel.setObjectName("selDescLabel") self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1) self.selNameLabel = QtGui.QLabel(self.selInfoWidget) font = QtGui.QFont() font.setWeight(75) font.setBold(True) self.selNameLabel.setFont(font) self.selNameLabel.setText("") self.selNameLabel.setObjectName("selNameLabel") self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1) self.selectedTree = DataTreeWidget(self.selInfoWidget) self.selectedTree.setObjectName("selectedTree") self.selectedTree.headerItem().setText(0, "1") self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2) self.hoverText = QtGui.QTextEdit(Form) self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81)) self.hoverText.setObjectName("hoverText") self.view = FlowchartGraphicsView(Form) self.view.setGeometry(QtCore.QRect(0, 0, 256, 192)) self.view.setObjectName("view") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, type_widget): type_widget.setObjectName("type_widget") type_widget.resize(248, 78) self.horizontalLayout_2 = QtGui.QHBoxLayout(type_widget) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.type_icon = QtGui.QLabel(type_widget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.type_icon.sizePolicy().hasHeightForWidth()) self.type_icon.setSizePolicy(sizePolicy) self.type_icon.setObjectName("type_icon") self.horizontalLayout_2.addWidget(self.type_icon) spacerItem = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.line = QtGui.QFrame(type_widget) self.line.setFrameShape(QtGui.QFrame.VLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName("line") self.horizontalLayout_2.addWidget(self.line) spacerItem1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem1) self.type_label = QtGui.QLabel(type_widget) font = QtGui.QFont() font.setFamily("Cantarell") font.setPointSize(10) font.setWeight(75) font.setBold(True) self.type_label.setFont(font) self.type_label.setObjectName("type_label") self.horizontalLayout_2.addWidget(self.type_label) self.retranslateUi(type_widget) QtCore.QMetaObject.connectSlotsByName(type_widget)
def __init__(self, parent=None): super(PriorityWidget, self).__init__(parent) self.color = QtGui.QColor(247, 147, 30, 255) self.font = QtGui.QFont('Helvetica', 12, QtGui.QFont.Bold) self.setToolTip('<b>priority</b><br>use either:<ul><li>LMB to increase - RMB to decrease</li><li>alt+LMB drag to change value</li><li>MMB drag to change value</li></ul><i>move mouse away after changing value<br>to trigger re-sorting</i>') self.active = False self.mouseOver = False self.value = 0 self.allowDrag = False self.setFocusPolicy(QtCore.Qt.TabFocus) self.indicator = DragIndicator(self) self.indicator.setVisible(False) self.indicator.move(0, 15)
def __init__(self, parent, *args): super(AbundTreeView, self).__init__(parent, *args) self.parent = parent font = QtGui.QFont("Monospace") font.setStyleHint(QtGui.QFont.TypeWriter) self.setFont(font) self.setUniformRowHeights(True) self.setItemDelegate(AbundTreeViewDelegate(self))
def paint(self, painter, option, index): if isinstance(index.internalPointer(), AbundTreeElementSummaryItem): option.font.setWeight(QtGui.QFont.Bold) super(AbundTreeViewDelegate, self).paint(painter, option, index)
def _add_table_row(self,items): new_row = self._table.rowCount()+1 self._table.setRowCount(new_row) for i, item in enumerate(items): if type(item) != bool: if i == 4: self.new_item = QtGui.QPushButton('Backup!') self.new_item.clicked.connect(self.handle_manual_backup) self._table.setCellWidget(new_row-1,i,self.new_item) continue elif i == 5 and item != None: if item != '...': new_item = QtGui.QTableWidgetItem('{}'.format(item)) link_font = QtGui.QFont(new_item.font()) link_font.setUnderline(True) new_item.setFont(link_font) new_item.setTextAlignment(QtCore.Qt.AlignCenter) new_item.setForeground(QtGui.QBrush(QtGui.QColor("teal"))) else: new_item = QtGui.QTableWidgetItem('{}'.format(item)) new_item.setTextAlignment(QtCore.Qt.AlignCenter) elif i == 1 and item == None: new_item = QtGui.QTableWidgetItem('no backups') new_item.setForeground(QtGui.QBrush(QtGui.QColor("grey"))) else: new_item = QtGui.QTableWidgetItem(item) new_item.setFlags(QtCore.Qt.ItemIsEnabled) elif type(item) == bool: new_item = QtGui.QTableWidgetItem() if i == 3 and items[2] == False: new_item.setFlags(QtCore.Qt.ItemFlags() != QtCore.Qt.ItemIsEnabled) new_item.setCheckState(QtCore.Qt.Unchecked) else: new_item.setFlags(QtCore.Qt.ItemIsUserCheckable|QtCore.Qt.ItemIsEnabled) new_item.setCheckState(QtCore.Qt.Unchecked if item == False else QtCore.Qt.Checked) self._table.setItem(new_row-1,i,new_item)
def setupUi(self, About): About.setObjectName(_fromUtf8("About")) About.resize(378, 342) About.setMinimumSize(QtCore.QSize(378, 342)) About.setMaximumSize(QtCore.QSize(378, 342)) self.label = QtGui.QLabel(About) self.label.setGeometry(QtCore.QRect(10, 10, 191, 21)) font = QtGui.QFont() font.setFamily(_fromUtf8("Arial")) font.setPointSize(10) font.setBold(False) font.setWeight(50) self.label.setFont(font) self.label.setObjectName(_fromUtf8("label")) self.label_2 = QtGui.QLabel(About) self.label_2.setGeometry(QtCore.QRect(10, 30, 181, 21)) font = QtGui.QFont() font.setFamily(_fromUtf8("Arial")) font.setPointSize(10) font.setBold(False) font.setWeight(50) self.label_2.setFont(font) self.label_2.setObjectName(_fromUtf8("label_2")) self.label_3 = QtGui.QLabel(About) self.label_3.setGeometry(QtCore.QRect(10, 50, 211, 16)) font = QtGui.QFont() font.setFamily(_fromUtf8("Arial")) font.setPointSize(8) font.setItalic(False) self.label_3.setFont(font) self.label_3.setObjectName(_fromUtf8("label_3")) self.label_4 = QtGui.QLabel(About) self.label_4.setGeometry(QtCore.QRect(10, 60, 261, 31)) font = QtGui.QFont() font.setFamily(_fromUtf8("Arial")) font.setPointSize(8) font.setItalic(False) self.label_4.setFont(font) self.label_4.setObjectName(_fromUtf8("label_4")) self.textBrowser = QtGui.QTextBrowser(About) self.textBrowser.setGeometry(QtCore.QRect(10, 90, 361, 211)) self.textBrowser.setObjectName(_fromUtf8("textBrowser")) self.about_bn = QtGui.QPushButton(About) self.about_bn.setGeometry(QtCore.QRect(290, 310, 75, 23)) self.about_bn.setObjectName(_fromUtf8("about_bn")) self.retranslateUi(About) QtCore.QMetaObject.connectSlotsByName(About)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(217, 499) self.gridLayout = QtGui.QGridLayout(Form) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setVerticalSpacing(0) self.gridLayout.setObjectName("gridLayout") self.loadBtn = QtGui.QPushButton(Form) self.loadBtn.setObjectName("loadBtn") self.gridLayout.addWidget(self.loadBtn, 1, 0, 1, 1) self.saveBtn = FeedbackButton(Form) self.saveBtn.setObjectName("saveBtn") self.gridLayout.addWidget(self.saveBtn, 1, 1, 1, 2) self.saveAsBtn = FeedbackButton(Form) self.saveAsBtn.setObjectName("saveAsBtn") self.gridLayout.addWidget(self.saveAsBtn, 1, 3, 1, 1) self.reloadBtn = FeedbackButton(Form) self.reloadBtn.setCheckable(False) self.reloadBtn.setFlat(False) self.reloadBtn.setObjectName("reloadBtn") self.gridLayout.addWidget(self.reloadBtn, 4, 0, 1, 2) self.showChartBtn = QtGui.QPushButton(Form) self.showChartBtn.setCheckable(True) self.showChartBtn.setObjectName("showChartBtn") self.gridLayout.addWidget(self.showChartBtn, 4, 2, 1, 2) self.ctrlList = TreeWidget(Form) self.ctrlList.setObjectName("ctrlList") self.ctrlList.headerItem().setText(0, "1") self.ctrlList.header().setVisible(False) self.ctrlList.header().setStretchLastSection(False) self.gridLayout.addWidget(self.ctrlList, 3, 0, 1, 4) self.fileNameLabel = QtGui.QLabel(Form) font = QtGui.QFont() font.setWeight(75) font.setBold(True) self.fileNameLabel.setFont(font) self.fileNameLabel.setText("") self.fileNameLabel.setAlignment(QtCore.Qt.AlignCenter) self.fileNameLabel.setObjectName("fileNameLabel") self.gridLayout.addWidget(self.fileNameLabel, 0, 1, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, MainDialog): MainDialog.setObjectName("MainDialog") MainDialog.resize(242, 128) self.verticalLayout_2 = QtGui.QVBoxLayout(MainDialog) self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.label = QtGui.QLabel(MainDialog) font = QtGui.QFont() font.setPointSize(20) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.formLayout = QtGui.QFormLayout() self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) self.formLayout.setObjectName("formLayout") self.label_2 = QtGui.QLabel(MainDialog) self.label_2.setObjectName("label_2") self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label_2) self.labelLoLRunning = QtGui.QLabel(MainDialog) self.labelLoLRunning.setStyleSheet("color: rgb(255, 0, 0)") self.labelLoLRunning.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.labelLoLRunning.setObjectName("labelLoLRunning") self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.labelLoLRunning) self.label_3 = QtGui.QLabel(MainDialog) self.label_3.setObjectName("label_3") self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.label_3) self.labelVorpXRunning = QtGui.QLabel(MainDialog) self.labelVorpXRunning.setStyleSheet("color: rgb(255, 0, 0)") self.labelVorpXRunning.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.labelVorpXRunning.setObjectName("labelVorpXRunning") self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.labelVorpXRunning) self.verticalLayout.addLayout(self.formLayout) self.pushButtonStart = QtGui.QPushButton(MainDialog) self.pushButtonStart.setObjectName("pushButtonStart") self.verticalLayout.addWidget(self.pushButtonStart) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.verticalLayout_2.addLayout(self.verticalLayout) self.retranslateUi(MainDialog) QtCore.QMetaObject.connectSlotsByName(MainDialog)
def setupUi(self, Form): """Setting up Log in UI Form """ Form.setObjectName("Form") Form.setFixedSize(400, 300) self.formLayoutWidget = QtGui.QWidget(Form) self.formLayoutWidget.setGeometry(QtCore.QRect(70, 110, 251, 71)) self.formLayoutWidget.setObjectName("formLayoutWidget") self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) self.formLayout.setContentsMargins(0, 0, 0, 0) self.formLayout.setObjectName("formLayout") self.Username = QtGui.QLabel(self.formLayoutWidget) self.Username.setObjectName("Username") self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.Username) self.Password = QtGui.QLabel(self.formLayoutWidget) self.Password.setObjectName("Password") self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.Password) self.iUsername = QtGui.QLineEdit(self.formLayoutWidget) self.iUsername.setObjectName("iUsername") self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.iUsername) self.iPassword = QtGui.QLineEdit(self.formLayoutWidget) self.iPassword.setObjectName("iPassword") self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.iPassword) spacerItem = QtGui.QSpacerItem( 20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.formLayout.setItem(1, QtGui.QFormLayout.LabelRole, spacerItem) self.Login = QtGui.QPushButton(Form) self.Login.setGeometry(QtCore.QRect(210, 220, 75, 23)) self.Login.setObjectName("Login") self.Captslog = QtGui.QLabel(Form) self.Captslog.setGeometry(QtCore.QRect(90, 50, 221, 41)) font = QtGui.QFont() font.setPointSize(30) font.setWeight(75) font.setBold(True) self.Captslog.setFont(font) self.Captslog.setObjectName("Captslog") self.ErrorMessage = QtGui.QLabel(Form) self.ErrorMessage.setGeometry(QtCore.QRect(120, 190, 151, 20)) self.ErrorMessage.setText("") self.ErrorMessage.setAlignment(QtCore.Qt.AlignCenter) self.ErrorMessage.setObjectName("ErrorMessage") self.Signup = QtGui.QPushButton(Form) self.Signup.setGeometry(QtCore.QRect(100, 220, 75, 23)) self.Signup.setObjectName("Signup") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def __init__(self, correlationTable, colorTable,GraphDataStructure): n = len(correlationTable.header) super(CommunityCorrelationTableDisplay, self).__init__(n, n) from collections import defaultdict self.CommunityMode = False self.MouseReleased = True self.colorTable = colorTable self.sortedDict= defaultdict(list) self.newWindowWidget = [] self.Selectionmode = True self.GraphDataStructure = weakref.ref(GraphDataStructure) self.data = self.GraphDataStructure().ThresholdData self.Order = [] self.i = 0 self.newwidget = None self.Brain_Regions = correlationTable.RegionName[0] self.First = True self.g= [] self.isElementsSorted = False self.setMinimumSize(800,400) self.setContentsMargins(0, 0, 0, 0) self.correlationTable = correlationTable self.setVerticalHeaderLabels(self.correlationTable.header) self.setHorizontalHeaderLabels(['\n'.join(name) for name in self.correlationTable.header]) font = QtGui.QFont() font.setPointSize(8) self.horizontalHeader().setFont(font) self.verticalHeader().setFont(font) if n < 50: CellSize= 40 else: CellSize = 4 for i in range(n): self.setColumnWidth(i,CellSize) self.setRowHeight(i, CellSize) self.resizeRowToContents(i) self.horizontalHeaderItem(i).setToolTip(self.correlationTable.header[i]) self.verticalHeaderItem(i).setToolTip(self.correlationTable.header[i]) for i in range(len(self.correlationTable.header)): for j in range(len(self.correlationTable.header)): table_item = QtGui.QTableWidgetItem() self.setItem(i, j, table_item) self.resizeColumnsToContents() self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding) self.setShowGrid(False) self.setStyleSheet("selection-background-color: transparent;") self.setItemDelegate(self.BackgroundDelegate()) self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.itemSelectionChanged.connect(self.handleSelectionChange)
def initUI(self): label = QLabel('HearthPwn.com Sign In', self) font = QtGui.QFont() font.setBold(True) label.setFont(font) label.setAlignment(QtCore.Qt.AlignCenter) self.emailEdit = QLineEdit(self) self.emailEdit.setPlaceholderText("Email") self.emailEdit.setText(self.opts.get("email", "")) self.emailEdit.returnPressed.connect(self.submit) self.emailEdit.setFocus() self.passwordEdit = QLineEdit(self) self.passwordEdit.setEchoMode(QLineEdit.Password) self.passwordEdit.setText(self.opts.get("password", "")) self.passwordEdit.setPlaceholderText("Password") self.passwordEdit.returnPressed.connect(self.submit) self.anonCheckbox = QCheckBox('Log in as anonymous', self) self.anonCheckbox.setChecked(self.opts['--anonymous']) self.anonCheckbox.stateChanged.connect(self.checkboxClicked) self.checkboxClicked() self.loginButton = QPushButton('Login', self) self.loginButton.clicked.connect(self.submit) self.loginButton.setAutoDefault(True) loginLayout = QHBoxLayout() loginLayout.addStretch(1) loginLayout.addWidget(self.loginButton) loginLayout.addStretch(1) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addWidget(label) vbox.addWidget(self.emailEdit) vbox.addWidget(self.passwordEdit) vbox.addWidget(self.anonCheckbox) vbox.addLayout(loginLayout) vbox.addStretch(1) self.setLayout(vbox)
def __init__(self, correlationTable, colorTable,GraphDataStructure): n = len(correlationTable.header) super(CommunityCorrelationTableDisplay, self).__init__(n, n) from collections import defaultdict self.CommunityMode = False self.MouseReleased = True self.colorTable = colorTable self.sortedDict= defaultdict(list) self.newWindowWidget = [] self.Selectionmode = True self.GraphDataStructure = weakref.ref(GraphDataStructure) self.data = self.GraphDataStructure().ThresholdData self.Order = [] self.i = 0 self.newwidget = None self.Brain_Regions = correlationTable.RegionName[0] self.First = True self.g= [] self.isElementsSorted = False self.setMinimumSize(800,400) self.setContentsMargins(0, 0, 0, 0) self.correlationTable = correlationTable self.setVerticalHeaderLabels(self.correlationTable.header) self.setHorizontalHeaderLabels(['\n'.join(name) for name in self.correlationTable.header]) font = QtGui.QFont() font.setPointSize(8) self.horizontalHeader().setFont(font) self.verticalHeader().setFont(font) if n < 50: CellSize= 18 else: CellSize = 4 for i in range(n): self.setColumnWidth(i,CellSize) self.setRowHeight(i, CellSize) # self.resizeRowToContents(i) self.horizontalHeaderItem(i).setToolTip(self.correlationTable.header[i]) self.verticalHeaderItem(i).setToolTip(self.correlationTable.header[i]) for i in range(len(self.correlationTable.header)): for j in range(len(self.correlationTable.header)): table_item = QtGui.QTableWidgetItem() self.setItem(i, j, table_item) # self.resizeColumnsToContents() self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding) self.setShowGrid(False) self.setStyleSheet("selection-background-color: transparent;") self.setItemDelegate(self.BackgroundDelegate()) self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.itemSelectionChanged.connect(self.handleSelectionChange)
def paint(self,painter,option, widget): blackPen = QtGui.QPen() whitePen = QtGui.QPen() blackPen.setWidth(1) whitePen.setWidth(1) blackPen.setColor(QtGui.QColor("black")) whitePen.setColor(QtGui.QColor("white")) if self.isSelected(): gradient = QtGui.QLinearGradient(QtCore.QPointF(0, 0), QtCore.QPointF(0, 20)) gradient.setColorAt(0, QtGui.QColor(220,170,50)) gradient.setColorAt(0.3, QtGui.QColor(220,170,50)) gradient.setColorAt(1, QtGui.QColor(170,150,40)) #brush = QtGui.QBrush(gradient) #brush.setStyle(QtCore.Qt.LinearGradientPattern) brush = QtGui.QBrush(QtGui.QColor(220,160,50)) else: gradient = QtGui.QLinearGradient(QtCore.QPointF(0, 0), QtCore.QPointF(0, 20)) gradient.setColorAt(0, QtGui.QColor(55,55,55)) gradient.setColorAt(0.3, QtGui.QColor(60,60,60)) gradient.setColorAt(1, QtGui.QColor(50,50,50)) #brush = QtGui.QBrush(gradient) #brush.setStyle(QtCore.Qt.LinearGradientPattern) #brush = QtGui.QBrush(QtGui.QColor(50,50,50)) brush = QtGui.QBrush(QtGui.QColor(32,61,74)) font = QtGui.QFont() font.setFamily("Helvetica") font.setStyleStrategy(QtGui.QFont.PreferAntialias) font.setPointSize(14) painter.setBrush(brush) painter.setPen(blackPen) painter.setFont(font) painter.drawRoundedRect(self.rect,5,5) #pen.setColor(QtGui.QColor("white")) if self.scale > 0.75: painter.setPen(whitePen) painter.drawText(self.rect, QtCore.Qt.AlignCenter,self.name())
def __init__(self, parent=None, mode=0): QtWidgets.QMainWindow.__init__(self, parent) #------------------------------ # class variables #------------------------------ self.version = '0.1' self.date = '2017.01.01' self.log = 'no version log in user class' self.help = 'no help guide in user class' self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.memoData['font_size_default'] = QtGui.QFont().pointSize() self.memoData['font_size'] = self.memoData['font_size_default'] self.memoData['last_export'] = '' self.memoData['last_import'] = '' self.name = self.__class__.__name__ self.location = '' if getattr(sys, 'frozen', False): # frozen - cx_freeze self.location = sys.executable else: # unfrozen self.location = os.path.realpath(sys.modules[self.__class__.__module__].__file__) self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png') self.iconPix = QtGui.QPixmap(self.iconPath) self.icon = QtGui.QIcon(self.iconPath) self.fileType='.{0}_EXT'.format(self.name) #------------------------------ # core function variable #------------------------------ self.qui_core_dict = { 'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout', 'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget', 'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox', 'txt': 'QTextEdit', 'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget', 'space': 'QSpacerItem', 'menu' : 'QMenu', 'menubar' : 'QMenuBar', } self.qui_user_dict = {}
def __init__(self, parent=None, mode=0): super_class.__init__(self, parent) #------------------------------ # class variables #------------------------------ self.version = "0.1" self.date = '2017.01.01' self.log = 'no version log in user class' self.help = 'no help guide in user class' self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.memoData['font_size_default'] = QtGui.QFont().pointSize() self.memoData['font_size'] = self.memoData['font_size_default'] self.memoData['last_export'] = '' self.memoData['last_import'] = '' self.location = "" if getattr(sys, 'frozen', False): # frozen - cx_freeze self.location = sys.executable else: # unfrozen self.location = os.path.realpath(sys.modules[self.__class__.__module__].__file__) self.name = self.__class__.__name__ self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png') self.iconPix = QtGui.QPixmap(self.iconPath) self.icon = QtGui.QIcon(self.iconPath) self.fileType='.{0}_EXT'.format(self.name) #------------------------------ # core function variable #------------------------------ self.qui_core_dict = { 'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout', 'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget', 'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox', 'txt': 'QTextEdit', 'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget', 'space': 'QSpacerItem', 'menu' : 'QMenu', 'menubar' : 'QMenuBar', } self.qui_user_dict = {} #------------------------------
def __init__(self, parent=None, mode=0): super_class.__init__(self, parent) #------------------------------ # class variables #------------------------------ self.version = "0.1" self.date = '2017.01.01' self.log = 'no version log in user class' self.help = 'no help guide in user class' self.uiList={} # for ui obj storage self.memoData = {} # key based variable data storage self.memoData['font_size_default'] = QtGui.QFont().pointSize() self.memoData['font_size'] = self.memoData['font_size_default'] self.location = "" if getattr(sys, 'frozen', False): # frozen - cx_freeze self.location = sys.executable else: # unfrozen self.location = os.path.realpath(sys.modules[self.__class__.__module__].__file__) self.name = self.__class__.__name__ self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png') self.iconPix = QtGui.QPixmap(self.iconPath) self.icon = QtGui.QIcon(self.iconPath) self.fileType='.{0}_EXT'.format(self.name) #------------------------------ # core function variable #------------------------------ self.qui_core_dict = { 'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout', 'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget', 'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox', 'txt': 'QTextEdit', 'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget', 'space': 'QSpacerItem', 'menu' : 'QMenu', 'menubar' : 'QMenuBar', } self.qui_user_dict = {} #------------------------------
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(465, 393) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, 20, -1, 20) self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.icon_lb = QtGui.QLabel(Dialog) font = QtGui.QFont() font.setPointSize(20) self.icon_lb.setFont(font) self.icon_lb.setText("") self.icon_lb.setObjectName("icon_lb") self.horizontalLayout.addWidget(self.icon_lb) self.title_lb = QtGui.QLabel(Dialog) font = QtGui.QFont() font.setPointSize(20) self.title_lb.setFont(font) self.title_lb.setObjectName("title_lb") self.horizontalLayout.addWidget(self.title_lb) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.verticalLayout.addLayout(self.horizontalLayout) self.text_link_lb = QtGui.QLabel(Dialog) self.text_link_lb.setObjectName("text_link_lb") self.verticalLayout.addWidget(self.text_link_lb) self.textBrowser = QtGui.QTextBrowser(Dialog) self.textBrowser.setObjectName("textBrowser") self.verticalLayout.addWidget(self.textBrowser) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.donate_btn = QtGui.QPushButton(Dialog) self.donate_btn.setObjectName("donate_btn") self.horizontalLayout_2.addWidget(self.donate_btn) self.verticalLayout.addLayout(self.horizontalLayout_2) self.verticalLayout.setStretch(2, 1) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(1262, 529) self.user_email = QtGui.QLabel(Form) self.user_email.setGeometry(QtCore.QRect(1030, 20, 221, 31)) font = QtGui.QFont() font.setPointSize(12) font.setWeight(75) font.setBold(True) self.user_email.setFont(font) self.user_email.setObjectName("user_email") self.retrieve_button = QtGui.QPushButton(Form) self.retrieve_button.setGeometry(QtCore.QRect(10, 50, 103, 34)) self.retrieve_button.setObjectName("retrieve_button") self.compose_button = QtGui.QPushButton(Form) self.compose_button.setGeometry(QtCore.QRect(140, 50, 103, 34)) self.compose_button.setObjectName("compose_button") self.received_email = QtGui.QTableWidget(Form) self.received_email.setGeometry(QtCore.QRect(10, 90, 821, 431)) self.received_email.setObjectName("received_email") self.received_email.setColumnCount(3) self.received_email.setRowCount(0) item = QtGui.QTableWidgetItem() self.received_email.setHorizontalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.received_email.setHorizontalHeaderItem(1, item) item = QtGui.QTableWidgetItem() self.received_email.setHorizontalHeaderItem(2, item) self.email_body = QtGui.QTextBrowser(Form) self.email_body.setGeometry(QtCore.QRect(840, 120, 411, 401)) self.email_body.setObjectName("email_body") self.label = QtGui.QLabel(Form) self.label.setGeometry(QtCore.QRect(930, 80, 91, 41)) font = QtGui.QFont() font.setPointSize(12) font.setWeight(75) font.setBold(True) self.label.setFont(font) self.label.setObjectName("label") self.app_title = QtGui.QLabel(Form) self.app_title.setGeometry(QtCore.QRect(10, 0, 101, 41)) font = QtGui.QFont() font.setPointSize(18) font.setWeight(75) font.setBold(True) self.app_title.setFont(font) self.app_title.setObjectName("app_title") self.showing_label = QtGui.QLabel(Form) self.showing_label.setGeometry(QtCore.QRect(560, 60, 271, 20)) font = QtGui.QFont() font.setPointSize(12) font.setWeight(75) font.setBold(True) self.showing_label.setFont(font) self.showing_label.setObjectName("showing_label") self.open_browser = QtGui.QPushButton(Form) self.open_browser.setGeometry(QtCore.QRect(1100, 80, 151, 34)) self.open_browser.setObjectName("open_browser") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)