def __init__(self, parent: QtWidgets.QWidget): super().__init__(parent) self.set_attribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose) self._main_layout = QtWidgets.QVBoxLayout(self) self._button_layout = QtWidgets.QHBoxLayout() self._text_label = QtWidgets.QLabel(self) font = QtGui.QFont() font.set_point_size(18) self._text_label.font = font self._changelog_label = QtWidgets.QLabel(self) font = QtGui.QFont() font.set_point_size(10) self._changelog_label.font = font self._changelog_browser = QtWidgets.QTextBrowser(self) self._download_button = QtWidgets.QPushButton(self) self._download_button.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self._skip_button = QtWidgets.QPushButton(self) self._skip_button.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self._button_layout.add_widget(self._skip_button) self._button_layout.add_widget(self._download_button) self._main_layout.add_widget(self._text_label) self._main_layout.add_widget(self._changelog_label) self._main_layout.add_widget(self._changelog_browser) self._main_layout.add_layout(self._button_layout)
def __init__(self, parent: QtWidgets.QWidget): super().__init__(parent) self.set_attribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose) self._main_layout = QtWidgets.QVBoxLayout(self) self._button_layout = QtWidgets.QHBoxLayout() self._text_label = QtWidgets.QLabel(self) font = QtGui.QFont() font.set_point_size(10) self._text_label.font = font self._error_label = QtWidgets.QLabel(self) font = QtGui.QFont() font.set_point_size(10) self._error_label.font = font self._error_label.word_wrap = True self._close_label = QtWidgets.QLabel(self) font = QtGui.QFont() font.set_point_size(10) self._close_label.font = font self._main_layout.add_widget(self._text_label) self._main_layout.add_widget(self._error_label) self._main_layout.add_widget(self._close_label)
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) quit = QtWidgets.QPushButton("&Quit") quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold)) self.connect(quit, QtCore.SIGNAL("clicked()"), qApp, QtCore.SLOT("quit()")) angle = LCDRange() angle.setRange(5, 70) force = LCDRange() force.setRange(10, 50) cannonField = CannonField() self.connect(angle, QtCore.SIGNAL("valueChanged(int)"), cannonField.setAngle) self.connect(cannonField, QtCore.SIGNAL("angleChanged(int)"), angle.setValue) self.connect(force, QtCore.SIGNAL("valueChanged(int)"), cannonField.setForce) self.connect(cannonField, QtCore.SIGNAL("forceChanged(int)"), force.setValue) shoot = QtWidgets.QPushButton("&Shoot") shoot.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold)) self.connect(shoot, QtCore.SIGNAL("clicked()"), cannonField.shoot) topLayout = QtWidgets.QHBoxLayout() topLayout.addWidget(shoot) topLayout.addStretch(1) leftLayout = QtWidgets.QVBoxLayout() leftLayout.addWidget(angle) leftLayout.addWidget(force) gridLayout = QtWidgets.QGridLayout() gridLayout.addWidget(quit, 0, 0) gridLayout.addLayout(topLayout, 0, 1) gridLayout.addLayout(leftLayout, 1, 0) gridLayout.addWidget(cannonField, 1, 1, 2, 1) gridLayout.setColumnStretch(1, 10) self.setLayout(gridLayout) angle.setValue(60) force.setValue(25) angle.setFocus()
def data(self, index, role): """Returns data about an index.""" if not index.isValid(): return None if role in (qtc.Qt.DisplayRole, qtc.Qt.ToolTipRole): if index.column() == 0: return index.internalPointer().title if index.column() == 1: return index.internalPointer().author if index.column() == 2: return index.internalPointer().updated.astimezone().strftime('%a %b %d, %Y %I:%M %p') elif role == qtc.Qt.FontRole: font = qtg.QFont() font.setPointSize(settings["font_size"]) if index.internalPointer().unread is True: font.setBold(True) return font elif role == qtc.Qt.ForegroundRole: if index.internalPointer().flag is True: return qtg.QColor(qtc.Qt.red) return None
def __init__(self, parent=None): ''' ''' super().__init__(parent) self.parent = parent # table properties self.setObjectName(u"tblProgram") font = QtGui.QFont() font.setPointSize(9) self.setFont(font) self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.setEditTriggers(QtWidgets.QAbstractItemView.AnyKeyPressed | QtWidgets.QAbstractItemView.DoubleClicked | QtWidgets.QAbstractItemView.EditKeyPressed | QtWidgets.QAbstractItemView.SelectedClicked) self.setSelectionMode(QtWidgets.QAbstractItemView.ContiguousSelection) self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.setGridStyle(QtCore.Qt.DashLine) self.horizontalHeader().setMinimumSectionSize(50) self.horizontalHeader().setHighlightSections(False) self.verticalHeader().setVisible(True) self.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Fixed) self.verticalHeader().setDefaultSectionSize(12) self.setShowGrid(False)
def __init__(self, verify, prompt, window_title, default_text): qtw.QDialog.__init__( self, None, qtc.Qt.WindowCloseButtonHint | qtc.Qt.WindowTitleHint) self.setObjectName(window_title) self.verify_function = verify layout = qtw.QGridLayout() layout.addWidget(qtw.QLabel(prompt), 0, 0, 1, 2) self.input_field = qtw.QLineEdit() self.input_field.setText(default_text) self.input_field.selectAll() layout.addWidget(self.input_field, 1, 0, 1, 2) buttons = qtw.QDialogButtonBox(qtw.QDialogButtonBox.Ok | qtw.QDialogButtonBox.Cancel) buttons.accepted.connect(self.verify_response) buttons.rejected.connect(self.reject) layout.addWidget(buttons, 2, 1, 1, 1) self.error_label = qtw.QLabel("") self.error_label.setMinimumWidth( qtg.QFontMetrics(qtg.QFont()).horizontalAdvance("Verify Failed")) layout.addWidget(self.error_label, 2, 0, 1, 1) layout.setSizeConstraint(qtw.QLayout.SetFixedSize) self.setLayout(layout) self.show()
def __init__(self, parent, scene): super(Port, self).__init__(parent) self.radius_ = 5 self.margin = 2 path = QtGui.QPainterPath() path.addEllipse(-self.radius_, -self.radius_, 2 * self.radius_, 2 * self.radius_) self.setPath(path) self.setFlag(QtWidgets.QGraphicsPathItem.ItemSendsScenePositionChanges) self.font = QtGui.QFont() self.font_metrics = QtGui.QFontMetrics(self.font) self.port_text_height = self.font_metrics.height() self._is_output = False self._name = None self.margin = 2 self.m_node = None self.connection = None self.text_path = QtGui.QPainterPath()
def __init__(self): """ Initialise the class """ QtWidgets.QWidget.__init__(self) # Create the main layout self.main_layout = QtWidgets.QVBoxLayout() # Get the stylesheet if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" self.stylesheet = open(resource_path(self.stylesheet_path)).read() # Create widgets self.info_label = QtWidgets.QLabel() self.label_text = "Converts ROI names into their equivalent FMA IDs." self.info_label.setText(self.label_text) self.info_label.setAlignment(QtCore.Qt.AlignCenter) self.font = QtGui.QFont() self.font.setPointSize(14) self.info_label.setFont(self.font) self.main_layout.addWidget(self.info_label) self.setLayout(self.main_layout)
def draw_annotation(self, opts): x1 = self.image_generator.sec2pixels(opts.get("start", 0)) x2 = self.image_generator.sec2pixels(opts.get("end", 0)) y1 = self.freq2pixels(opts.get("max_freq", 0)) y2 = self.freq2pixels(opts.get("min_freq", 0)) text = opts.get("text", "") buffer = opts.get("vertical_buffer", 1) top_offset = opts.get("top_offset", 0) bottom_offset = opts.get("bottom_offset", 0) if y2 - y1 <= 0: y1 = 0 y2 = self.spectrogram_scene.height() - 2 if buffer: v_offset = buffer * y2 / 100 y1 += v_offset + top_offset y2 -= v_offset - bottom_offset if text: font = QtGui.QFont(opts.get("text_font", ""), opts.get("text_fontsize", 12)) font_height = QtGui.QFontMetrics(font).height() y1 += font_height coords = (x1, y1, x2 - x1, y2 - y1) opts["coords"] = coords rect = AnnotatedRectItem(opts) self.spectrogram_scene.addItem(rect)
def __init__(self, parent: QtWidgets.QWidget): super().__init__(parent) self.main_layout = QtWidgets.QVBoxLayout(self) self.info_label = QtWidgets.QLabel(self) font = QtGui.QFont() font.set_point_size(15) self.info_label.font = font self.text_browser = QtWidgets.QTextBrowser(self) self.text_browser.open_external_links = True self.button_layout = QtWidgets.QHBoxLayout() self.quit_button = QtWidgets.QPushButton(self) self.save_button = QtWidgets.QPushButton(self) self.quit_button.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.save_button.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.button_layout.add_widget(self.save_button) self.button_layout.add_widget(self.quit_button) self.main_layout.add_widget(self.info_label) self.main_layout.add_widget(self.text_browser) self.main_layout.add_layout(self.button_layout) self.set_modal(True)
def __init__(self, profile_name, profile): super().__init__(None) self.layout = QtWidgets.QHBoxLayout(self) main_section = QtWidgets.QVBoxLayout(self) profile_title = QtWidgets.QLabel( f"{t('Profile_window')}: {profile_name}") profile_title.setFont(QtGui.QFont("helvetica", 10, weight=70)) main_section.addWidget(profile_title) for k, v in profile.dict().items(): if k not in setting_types.keys(): item_1 = QtWidgets.QLabel(" ".join(str(k).split("_")).title()) item_2 = QtWidgets.QLabel(str(v)) item_2.setMaximumWidth(150) inner_layout = QtWidgets.QHBoxLayout() inner_layout.addWidget(item_1) inner_layout.addWidget(item_2) main_section.addLayout(inner_layout) self.layout.addLayout(main_section) splitter = QtWidgets.QWidget() splitter.setMaximumWidth(1) splitter.setStyleSheet("background-color: #999999") self.layout.addWidget(splitter) for setting_name in setting_types.keys(): setting = getattr(profile, setting_name) if setting: self.layout.addWidget(self.profile_widget(setting)) self.setMinimumWidth(780) self.setLayout(self.layout)
def __init__(self, *args): vxgui.IntegratedWidget.__init__(self, 'Log', *args) self.setLayout(QtWidgets.QHBoxLayout()) self.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) self.txe_log = QtWidgets.QTextEdit() self.font = QtGui.QFont() self.font.setPointSize(10) self.font.setFamily('Courier') self.txe_log.setReadOnly(True) # self.format = QtGui.QTextBlockFormat() # self.format.setIndent(10) # self.txe_log.textCursor().setBlockFormat(self.format) self.txe_log.setWordWrapMode(QtGui.QTextOption.WrapMode.NoWrap) self.layout().addWidget(self.txe_log) # Set initial log line count self.logccount = 0 self.loglevelname_limit = 30 # Set timer for updating of log self.timer_logging = QtCore.QTimer() self.timer_logging.timeout.connect(self.print_log) self.timer_logging.start(50)
def data(self, in_index, role): if not in_index.isValid(): return None node = in_index.internalPointer() if type(node) is Feed: if role in (qtc.Qt.DisplayRole, qtc.Qt.ToolTipRole): if in_index.column() == 0: return node.user_title if node.user_title is not None else node.title if in_index.column() == 1: return node.unread_count # must be a folder else: if role == qtc.Qt.DisplayRole: if in_index.column() == 0: return node.title if in_index.column() == 1: return None if role == qtc.Qt.FontRole: font = qtg.QFont() font.setPointSize(settings["font_size"]) if type(node) is Feed and node.unread_count > 0: font.setBold(True) return font return None
def __init__(self): super(Widget, self).__init__() layout = QtWidgets.QVBoxLayout(self) blank = QtWidgets.QLabel( 'Thanks <b>dbunk</b>!! �<br>Thanks <b>Keith Kyzivat</b>!') blank.setFont(QtGui.QFont('', 25)) blank.setMinimumSize(500, 200) layout.addWidget(blank) self.check = QtWidgets.QCheckBox('i wanna be hovered!') self.check.installEventFilter(self) self.check_allow_leave = False """add whole checkbox so it extends horizontally [(x) check label text ] """ layout.addWidget(self.check) """or add in sub layout so it just occupies the text label space [(x) check label text][blank widget ] """ # hlayout = QtWidgets.QHBoxLayout() # hlayout.addWidget(self.check) # hlayout.addWidget(QtWidgets.QWidget()) # hlayout.setStretch(1, 1) # layout.addLayout(hlayout) self.check.setStyleSheet(STYLE)
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) quit = QtWidgets.QPushButton("Quit") quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold)) self.connect(quit, QtCore.SIGNAL("clicked()"), qApp, QtCore.SLOT("quit()")) angle = LCDRange() angle.setRange(5, 70) cannonField = CannonField() self.connect(angle, QtCore.SIGNAL("valueChanged(int)"), cannonField.setAngle) self.connect(cannonField, QtCore.SIGNAL("angleChanged(int)"), angle.setValue) gridLayout = QtWidgets.QGridLayout() gridLayout.addWidget(quit, 0, 0) gridLayout.addWidget(angle, 1, 0) gridLayout.addWidget(cannonField, 1, 1, 2, 1) gridLayout.setColumnStretch(1, 10) self.setLayout(gridLayout) angle.setValue(60) angle.setFocus()
def __init__(self, task_id, main): super().__init__() self.main = main self.id = task_id # create layouts self.layout = QtWidgets.QVBoxLayout(self) self.actionLayout = QtWidgets.QHBoxLayout() # font self.font = QtGui.QFont() self.font.setItalic(main.tasks_data[task_id]["is_complete"]) self.font.setStrikeOut(main.tasks_data[task_id]["is_complete"]) # description text self.descriptionText = QtWidgets.QTextEdit( main.tasks_data[task_id]["description"]) self.descriptionText.setFont(self.font) self.descriptionText.textChanged.connect( lambda: main.update_task_description( task_id, self.descriptionText.toPlainText())) self.layout.addWidget(self.descriptionText) # complete toggle self.completeToggle = QtWidgets.QRadioButton("is done") self.completeToggle.setChecked(main.tasks_data[task_id]["is_complete"]) self.completeToggle.toggled.connect(self.toggle_is_complete) self.actionLayout.addWidget(self.completeToggle) # delete button self.deleteButton = QtWidgets.QPushButton("Delete") self.deleteButton.clicked.connect(lambda: main.delete_task(self.id)) self.actionLayout.addWidget(self.deleteButton) self.layout.addLayout(self.actionLayout)
def paintEvent(self, event: QtGui.QPaintEvent) -> None: width = self.width - self.progress_width height = self.height - self.progress_width margin = int(self.progress_width / 2) value = (self.value * 360) / self.max_value paint = QtGui.QPainter() paint.begin(self) paint.setRenderHint(QtGui.QPainter.Antialiasing) paint.setFont(QtGui.QFont(self.font_family, self.font_size)) rect = QtCore.QRect(0, 0, self.width, self.height) paint.setPen(Qt.NoPen) paint.drawRect(rect) pen = QtGui.QPen() pen.setColor(QtGui.QColor(self.progress_color)) pen.setWidth(self.progress_width) if self.progress_rounded_cap: pen.setCapStyle(Qt.RoundCap) paint.setPen(pen) paint.drawArc(margin, margin, width, height, -90 * 16, int(-value * 16)) pen.setColor(QtGui.QColor(self.text_color)) paint.setPen(pen) paint.drawText(rect, Qt.AlignCenter, f"{self.value}{self.suffix}") paint.end()
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) quit = QtWidgets.QPushButton("Quit") quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold)) self.connect(quit, QtCore.SIGNAL("clicked()"), qApp, QtCore.SLOT("quit()")) grid = QtWidgets.QGridLayout() previousRange = None layout = QtWidgets.QVBoxLayout() layout.addWidget(quit) layout.addLayout(grid) self.setLayout(layout) for row in range(3): for column in range(3): lcdRange = LCDRange() grid.addWidget(lcdRange, row, column) if previousRange: self.connect(lcdRange, QtCore.SIGNAL("valueChanged(int)"), previousRange.setValue) previousRange = lcdRange
def __init__(self): """ Initialise the class """ QtWidgets.QWidget.__init__(self) # Create the main layout self.main_layout = QtWidgets.QVBoxLayout() # Get the stylesheet if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" self.stylesheet = open(resource_path(self.stylesheet_path)).read() # Create QLabel to display information, and text and font self.info_label = QtWidgets.QLabel() self.text_font = QtGui.QFont() text_info = "SUV2ROI can currently only be performed on PET images " \ "that are stored in units of Bq/mL and that are decay " \ "corrected. For best results, please ensure only one set " \ "of compliant PET images is present in each dataset that " \ "you wish to perform SUV2ROI on. For more information " \ "on SUV2ROI functionality, see the User Manual." self.text_font.setPointSize(12) self.info_label.setText(text_info) self.info_label.setFont(self.text_font) self.info_label.setWordWrap(True) self.main_layout.addWidget(self.info_label) self.create_table_view() self.setLayout(self.main_layout)
def minimumSizeHint(self): font = QtGui.QFont(self.font()) font.setPointSize(font.pointSize() - 1) fm = QtGui.QFontMetricsF(font) return QtCore.QSize( int(fm.horizontalAdvance(FractionSlider.WSTRING) * self.__denominator), int((fm.height() * 4) + FractionSlider.YMARGIN), )
def setupInfoTextItem(self, fontSize=12, color=None): self.infoTextFont = QtGui.QFont("", fontSize) self.infoTextItem.setFont(self.infoTextFont) if not color: color = QtGui.QColor(0, 0, 0) elif not isinstance(color, QtGui.QColor): color = QtGui.QColor(color) self.setTextColor(color)
def _init_font(self, family="Times", size=10, is_bold=False, is_italic=False): font = qtg.QFont(family, size) font.setBold(is_bold) font.setItalic(is_italic) self.setFont(font)
def _build_ui(self): self.thumb = Thumb(part_id=self.item_id, parent=self) self.label_widget = QtWidgets.QLabel(self.label, parent=self) self.label_widget.setAlignment(QtCore.Qt.AlignCenter) self.label_widget.setWordWrap(True) font = QtGui.QFont("Decorative", FONT_SIZE) self.label_widget.setFont(font) self.label_widget.setMinimumWidth(THUMB_SIZE) self.label_widget.setMaximumWidth(THUMB_SIZE)
def paintEvent(self, event=None): font = QtGui.QFont(self.font()) font.setPointSize(font.pointSize() - 1) fm = QtGui.QFontMetricsF(font) fracWidth = fm.horizontalAdvance(FractionSlider.WSTRING) indent = fm.boundingRect("9").width() / 2.0 if not X11: fracWidth *= 1.5 span = self.width() - (FractionSlider.XMARGIN * 2) value = self.__numerator / float(self.__denominator) painter = QtGui.QPainter(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setRenderHint(QtGui.QPainter.TextAntialiasing) painter.setPen(self.palette().color(QtGui.QPalette.Mid)) painter.setBrush(self.palette().brush(QtGui.QPalette.AlternateBase)) painter.drawRect(self.rect()) segColor = QtGui.QColor(QtCore.Qt.green).darker(120) segLineColor = segColor.darker() painter.setPen(segLineColor) painter.setBrush(segColor) painter.drawRect( FractionSlider.XMARGIN, FractionSlider.YMARGIN, span, fm.height() ) textColor = self.palette().color(QtGui.QPalette.Text) segWidth = span / self.__denominator segHeight = fm.height() * 2 nRect = fm.boundingRect(FractionSlider.WSTRING) x = FractionSlider.XMARGIN yOffset = segHeight + fm.height() for i in range(self.__denominator + 1): painter.setPen(segLineColor) painter.drawLine(x, FractionSlider.YMARGIN, x, segHeight) painter.setPen(textColor) y = segHeight rect = QtCore.QRectF(nRect) rect.moveCenter(QtCore.QPointF(x, y + fm.height() / 2.0)) painter.drawText(rect, QtCore.Qt.AlignCenter, "{}".format(i)) y = yOffset rect.moveCenter(QtCore.QPointF(x, y + fm.height() / 2.0)) painter.drawText( rect, QtCore.Qt.AlignCenter, "{}".format(self.__denominator) ) painter.drawLine( QtCore.QPointF(rect.left() + indent, y), QtCore.QPointF(rect.right() - indent, y) ) x += segWidth span = int(span) y = FractionSlider.YMARGIN - 0.5 triangle = [ QtCore.QPointF(value * span, y), QtCore.QPointF((value * span) + (2 * FractionSlider.XMARGIN), y), QtCore.QPointF((value * span) + FractionSlider.XMARGIN, fm.height()), ] painter.setPen(QtCore.Qt.yellow) painter.setBrush(QtCore.Qt.darkYellow) painter.drawPolygon(QtGui.QPolygonF(triangle))
def __init__(self): super(PatientWeightDialog, self).__init__() # Class variables self.patient_weight_message = "Patient weight is needed for SUV2ROI " self.patient_weight_message += "conversion.\nPlease enter patient " self.patient_weight_message += "weight in kg." # Get stylesheet if platform.system() == 'Darwin': self.stylesheet_path = "res/stylesheet.qss" else: self.stylesheet_path = "res/stylesheet-win-linux.qss" self.stylesheet = open(resource_path(self.stylesheet_path)).read() self.setWindowIcon( QtGui.QIcon("res/images/btn-icons/onkodicom_icon.png")) buttonBox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) self.patient_weight_message_label = QLabel(self.patient_weight_message) self.patient_weight_prompt = QLabel("Patient Weight:") self.patient_weight_entry = QLineEdit() self.text_font = QtGui.QFont() self.text_font.setPointSize(11) # Set button object names buttonBox.button(QDialogButtonBox.Ok).setProperty( "QPushButtonClass", "success-button") buttonBox.button(QDialogButtonBox.Cancel).setProperty( "QPushButtonClass", "fail-button") # Set stylesheets buttonBox.setStyleSheet(self.stylesheet) self.patient_weight_message_label.setFont(self.text_font) self.patient_weight_message_label.setStyleSheet(self.stylesheet) self.patient_weight_prompt.setMinimumHeight(36) self.patient_weight_prompt.setMargin(4) self.patient_weight_prompt.setFont(self.text_font) self.patient_weight_prompt.setAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignHCenter) self.patient_weight_prompt.setStyleSheet(self.stylesheet) self.patient_weight_entry.setStyleSheet(self.stylesheet) # Input dialog layout entry_layout = QFormLayout(self) entry_layout.addRow(self.patient_weight_message_label) entry_layout.addRow(self.patient_weight_prompt, self.patient_weight_entry) entry_layout.addWidget(buttonBox) buttonBox.accepted.connect(self.accepting) buttonBox.rejected.connect(self.rejecting) self.setWindowTitle("Enter Patient Weight")
def __init__(self, parent=None): QtWidgets.QWidget.__init__(self, parent) self.setFixedSize(200, 120) self.quit = QtWidgets.QPushButton("Quit", self) self.quit.setGeometry(62, 40, 75, 30) self.quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold)) self.connect(self.quit, QtCore.SIGNAL("clicked()"), qApp, QtCore.SLOT("quit()"))
def initUI(self): QtWidgets.QToolTip.setFont(QtGui.QFont('SansSerif', 10)) self.setToolTip("This is a <b>QWidget</b> widget") btn = QtWidgets.QPushButton("Button", self) btn.setToolTip("This is a <b>QPushButton</b> widget") btn.resize(btn.sizeHint()) btn.move(50, 50) self.setGeometry(300, 300, 250, 150) self.setWindowTitle("Tooltips") self.show()
def __init__(self, itemMenu, parent=None): super(DiagramScene, self).__init__(parent) self.myItemMenu = itemMenu self.myMode = self.MoveItem self.myItemType = DiagramItem.Step self.line = None self.textItem = None self.myItemColor = QtCore.Qt.white self.myTextColor = QtCore.Qt.black self.myLineColor = QtCore.Qt.black self.myFont = QtGui.QFont()
def __init__(self, parent: QtWidgets.QWidget): super().__init__(parent) self.set_attribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose) self.info_label = QtWidgets.QLabel(self) font = QtGui.QFont() font.set_point_size(18) self.info_label.font = font self.journal_combo = QtWidgets.QComboBox(self) self.journal_combo.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed ) self.journal_combo.size_adjust_policy = ( QtWidgets.QComboBox.SizeAdjustPolicy.AdjustToContents ) self.new_journal_button = QtWidgets.QPushButton(self) self.new_journal_button.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed ) self.save_route_button = QtWidgets.QPushButton(self) self.save_route_button.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed ) self.quit_button = QtWidgets.QPushButton(self) self.quit_button.size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed ) self.button_layout = QtWidgets.QHBoxLayout() self.button_layout.add_widget(self.journal_combo) self.button_layout.add_widget(self.new_journal_button) self.button_layout.add_spacer_item( QtWidgets.QSpacerItem( 1, 1, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed ) ) self.button_layout.add_widget( self.save_route_button, alignment=QtCore.Qt.AlignmentFlag.AlignRight ) self.button_layout.add_widget( self.quit_button, alignment=QtCore.Qt.AlignmentFlag.AlignRight ) self.main_layout = QtWidgets.QVBoxLayout(self) self.main_layout.add_widget( self.info_label, alignment=QtCore.Qt.AlignmentFlag.AlignCenter ) self.main_layout.add_layout(self.button_layout)
def paintEvent(self, event): painter = QtGui.QPainter(self) if self.gameEnded: painter.setPen(QtCore.Qt.black) painter.setFont(QtGui.QFont("Courier", 48, QtGui.QFont.Bold)) painter.drawText(self.rect(), QtCore.Qt.AlignCenter, "Game Over") self.paintCannon(painter) self.paintBarrier(painter) if self.isShooting(): self.paintShot(painter) if not self.gameEnded: self.paintTarget(painter)