def sizeHint(self) -> QSize: orig_size = super(WorldMapLevelSelect, self).sizeHint() scrollbar_width = QScrollBar().sizeHint().width() return orig_size.grownBy( QMargins(scrollbar_width, scrollbar_width, 0, 0))
def initUI(self): self.pacs_ctrl: PACS_ServerCtrl = PACS_OrthancServerCtrl() self.setGeometry(self.left, self.top, self.width, self.height) self.pacs_widget = PACS_MainWidget() self.dicom_widget = Dicom_Browser() # self.liver_support_widget = LiverSupportWidget() self.button_bar = MenuLeftPane() topLayout = QVBoxLayout() topLayout.setAlignment(Qt.AlignTop) topLayout.addWidget(self.button_bar) self.mainWidget = QDockWidget() self.mainWidget.setFeatures(QDockWidget.NoDockWidgetFeatures) self.mainWidget.setTitleBarWidget(QWidget()) self.mainWidget.setWidget(self.dicom_widget) mainLayout = QHBoxLayout(self) mainLayout.setContentsMargins(QMargins(0, 0, 0, 0)) mainLayout.addLayout(topLayout) mainLayout.addWidget(self.mainWidget) self.button_bar.pacs_btn.clicked.connect(self.show_PACSWidget) self.button_bar.dcm_btn.clicked.connect(self.show_DICOMBrowser) # self.button_bar.liv_support_btn.clicked.connect(self.show_liverSupport) self.pacs_widget.dcm_to_browser.connect(self.send_file_to_browser) self.show_PACSWidget()
def paintEvent(self, *args): painter = QPainter(self) painter.setRenderHint(QPainter.HighQualityAntialiasing) r = self.rect() painter.fillRect(r, Qt.white) for element in self.elements: painter.translate(element.bounding_box.topLeft()) element.paint(painter) painter.translate(-element.bounding_box.topLeft()) for wire in self.wires: self._draw_wire(painter, wire) painter.setPen(QPen(Qt.red, 1, Qt.DashLine)) painter.setBrush(Qt.transparent) for element in self.selected_elements: bb = element.bounding_box bb = bb.marginsAdded(QMargins(2, 2, 1, 1)) painter.drawRect(bb) if self.wiring_assistant: painter.setPen(QPen(Qt.red, 1, Qt.PenStyle.DotLine)) for line in self.guidelines: painter.drawLine(line) painter.setPen(QPen(Qt.red, 1, Qt.PenStyle.SolidLine)) for p in self.guidepoints: painter.drawEllipse(p.x() - 4, p.y() - 4, 8, 8) if self.closest_point is not None: p = self.closest_point painter.drawEllipse(p.x() - 4, p.y() - 4, 8, 8)
def __init__(self, parent=None): super(FlowLayout, self).__init__(parent) if parent is not None: self.setContentsMargins(QMargins(0, 0, 0, 0)) self._item_list = []
def creador_chart(self, bseries, nameaxis, valueaxis, titulo, titulo_down=None, titulo_left=None): chart = QtCharts.QChart() chart.setMargins(QMargins(15, 15, 15, 15)) # margenes del graficos chart.setTitle(titulo) chart.addSeries(bseries) chart.setAxisX(nameaxis, bseries) chart.setAxisY(valueaxis, bseries) chart.legend().setVisible(True) # Alieamiento de las etiquetas /-/-/-/ 'AlignTop | AlignBottom | AlignLeft | AlignRight' chart.legend().setAlignment(Qt.AlignTop) # asignar titulos x y chart.axisX().setTitleText(titulo_down) chart.axisY().setTitleText(titulo_left) # animaciones /-/-/-/ 'NoAnimation | SeriesAnimations | AllAnimations | GridAxisAnimations' chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations) return chart
def __init__(self, *args, **kwargs): super(VarietyOptionWidget, self).__init__(*args, **kwargs) layout = QVBoxLayout() layout.setContentsMargins(QMargins(1, 1, 1, 1)) opts_layout = QHBoxLayout() opts_layout.setContentsMargins(QMargins(0, 0, 0, 0)) self.add_button = QPushButton("新建品种", self) opts_layout.addWidget(self.add_button) opts_layout.addStretch() layout.addLayout(opts_layout) # 新建品种的widget self.new_variety_widget = QWidget(self) add_layout = QGridLayout() add_layout.setContentsMargins(QMargins(100, 50, 100, 50)) add_layout.addWidget(QLabel("所属类别:", self), 0, 0) self.belong_group = QComboBox(self) add_layout.addWidget(self.belong_group, 0, 1) add_layout.addWidget(QLabel("属交易所", self), 1, 0) self.belong_exchange = QComboBox(self) add_layout.addWidget(self.belong_exchange, 1, 1) add_layout.addWidget(QLabel("中文名称", self), 2, 0) self.zh_name = QLineEdit(self) add_layout.addWidget(self.zh_name, 2, 1) add_layout.addWidget(QLabel("交易代码", self), 3, 0) self.en_name = QLineEdit(self) add_layout.addWidget(self.en_name, 3, 1) self.commit_new_button = QPushButton("确定提交", self) add_layout.addWidget(self.commit_new_button, 4, 0, 1, 2) self.new_variety_widget.setLayout(add_layout) layout.addWidget(self.new_variety_widget) self.new_variety_widget.hide() # 隐藏新建填写信息的界面 self.variety_table = QTableWidget(self) layout.addWidget(self.variety_table) self.setLayout(layout)
def updateViewportMargins(self): # We form display parameters viewportMargins = QMargins() if (self.m_usePageMode): # Customize Document Size pageWidth = self.m_pageMetrics.pxPageSize().width() pageHeight = self.m_pageMetrics.pxPageSize().height() # Calculate indents for viewport DEFAULT_TOP_MARGIN = 5 DEFAULT_BOTTOM_MARGIN = 0 leftMargin = 0 rightMargin = 0 # If the width of the editor is greater than the width of the page of the document, expand the side margins. if (self.width() > pageWidth): VERTICAL_SCROLLBAR_WIDTH = self.verticalScrollBar().width( ) if self.verticalScrollBar().isVisible() else 0 # ... the width of the viewport frame and the editor itself leftMargin = rightMargin = (self.width() - pageWidth - VERTICAL_SCROLLBAR_WIDTH) / 2 topMargin = DEFAULT_TOP_MARGIN # The lower limit may be greater than the minimum value, for the case # when the whole document and even more fit on the screen bottomMargin = DEFAULT_BOTTOM_MARGIN documentHeight = pageHeight * self.document().pageCount() if ((self.height() - documentHeight) > (DEFAULT_TOP_MARGIN + DEFAULT_BOTTOM_MARGIN)): HORIZONTAL_SCROLLBAR_HEIGHT = self.horizontalScrollBar( ).height() if self.horizontalScrollBar().isVisible() else 0 bottomMargin = self.height( ) - documentHeight - HORIZONTAL_SCROLLBAR_HEIGHT - DEFAULT_TOP_MARGIN # Adjust the indents themselves # rightMargin minus 200 to give space for user notes viewportMargins = QMargins(leftMargin, topMargin, rightMargin, bottomMargin) self.setViewportMargins(viewportMargins) self.aboutUpdateDocumentGeometry()
def initUI(self): self.group = QGroupBox() self.pacs_btn = self.__initButton('PACS Module') self.dcm_btn = self.__initButton('Dicom Browser') # self.liv_support_btn = self.__initButton('Diagnosis Support') boxlayout = QVBoxLayout(self) boxlayout.setAlignment(Qt.AlignTop | Qt.AlignLeft) boxlayout.setContentsMargins(QMargins(0, 0, 0, 0)) boxlayout.setSpacing(0) boxlayout.addWidget(self.pacs_btn) boxlayout.addWidget(self.dcm_btn) # boxlayout.addWidget(self.liv_support_btn) self.group.setLayout(boxlayout) layout = QVBoxLayout(self) layout.setContentsMargins(QMargins(0, 0, 0, 0)) layout.addWidget(self.group)
def __init__(self, parent=None): super().__init__(parent=parent) self.username = parent.user self.left = 10 self.top = 10 self.width = 1200 self.height = 800 self.leftPanelWidth = 250 self.setContentsMargins(QMargins(0, 0, 0, 0)) self.initUI()
def resizeEvent(self, event): super().resizeEvent(event) size = event.size() size = size.grownBy(QMargins(12, 12, 12, 12)) if self.scene(): self.scene().setSceneRect(QRectF(QPointF(12, 12), size)) self._chart.resize(size) for callout in self._callouts: callout.updateGeometry()
def __init__(self, *args): super(QMaxRollout, self).__init__(*args) self._expanded = True self._delayed = False, False self.setSizePolicy( QtW.QSizePolicy(QtW.QSizePolicy.MinimumExpanding, QtW.QSizePolicy.Minimum)) self._full_title = str() self._title = self._full_title self._header_rect = QRect() self._title_bound_rect = QRect() self._base_margin = QMargins(9, 9, 9, 9) self._icon_width = 24 self._storage = QtW.QWidget() self._storage.setVisible(False) self._system_font = QtG.QFont()
def paintEvent(self, paintEvent): painter = QPainter(self) r = self._frame.rect() r -= QMargins(3, 3, 3, 4) painter.drawRect(r) painter.translate(r.width() / 2 + r.left(), r.height() / 2 + r.top()) dp = math.degrees(self._p) pr = r.height() / 90 painter.translate(0, pr * dp) d = math.degrees(self._r) painter.rotate(d) painter.drawLine(-r.width() / 2, 0, r.width() / 2, 0) painter.drawLine(0, r.height() / 2, 0, -r.height() / 2)
def initUI(self): main_widget = MainWidget(self) menu_bar = MenuBar(main_widget) self.setContentsMargins(QMargins(0, 0, 0, 0)) self.setWindowIcon(QtGui.QIcon('img/DPC.png')) self.setWindowTitle(self.title) self.setGeometry(0, 0, 1200, 800) self.setStyleSheet(get_style(self.style_path)) self.setMenuBar(menu_bar) self.statusBar().showMessage('Ready') self.setCentralWidget(main_widget) self.show()
def __init__(self, *args, **kwargs): super(NetPositionUI, self).__init__(*args, **kwargs) main_layout = QVBoxLayout() main_layout.setContentsMargins(QMargins(2, 1, 2, 1)) main_layout.setSpacing(1) # 操作栏 opt_layout = QHBoxLayout() self.interval_days = QSpinBox(self) self.interval_days.setMinimum(1) self.interval_days.setMaximum(30) self.interval_days.setValue(5) self.interval_days.setPrefix("日期间隔 ") self.interval_days.setSuffix(" 天") opt_layout.addWidget(self.interval_days) self.query_button = QPushButton('确定', self) opt_layout.addWidget(self.query_button) self.tip_label = QLabel('左侧可选择间隔天数,确定查询数据. ', self) opt_layout.addWidget(self.tip_label) opt_layout.addStretch() main_layout.addLayout(opt_layout) # 显示数据的表 self.data_table = QTableWidget(self) self.data_table.setFrameShape(QFrame.NoFrame) self.data_table.setEditTriggers(QAbstractItemView.NoEditTriggers) # 不可编辑 self.data_table.setFocusPolicy(Qt.NoFocus) # 去选中时的虚线框 self.data_table.setAlternatingRowColors(True) # 交替行颜色 self.data_table.horizontalHeader().setDefaultSectionSize(85) # 默认的标题头宽 self.data_table.verticalHeader().hide() self.data_table.verticalHeader().setDefaultSectionSize(18) # 设置行高(与下行代码同时才生效) self.data_table.verticalHeader().setMinimumSectionSize(18) main_layout.addWidget(self.data_table) self.setLayout(main_layout) self.tip_label.setObjectName("tipLabel") self.data_table.setObjectName("dataTable") self.data_table.horizontalHeader().setStyleSheet("QHeaderView::section," "QTableCornerButton::section{height:25px;background-color:rgb(243,245,248);font-weight:bold;font-size:13px}") self.setStyleSheet( "#tipLabel{color:rgb(230,50,50);font-weight:bold;}" "#dataTable::item{padding:2px}" "#dataTable{selection-color:rgb(255,255,255);selection-background-color:rgb(51,143,255);alternate-background-color:rgb(245,250,248)}" )
def __init__(self, parent): super(SidePanel, self).__init__(parent) self.main_window = parent self.setLayout(QVBoxLayout()) self.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)) self.setMinimumWidth(70) self.setMaximumWidth(70) self.layout().setContentsMargins(QMargins(0, 10, 10, 10)) # self.layout().setSpacing(0) self.btn_more = QPushButton("Menu") self.btn_undo = QPushButton("<---") self.btn_redo = QPushButton("--->") self.progress_bar = HeuristicBar() self.init_layout()
def _paint_event_override(self, event: QPaintEvent): pen = QPen(QColor(250, 120, 20)) w = 4 m = round(w / 2) pen.setWidth(w) pen.setJoinStyle(Qt.RoundJoin) inner_rect = self.highlight_rect.marginsRemoved(QMargins(m, m, m, m)) p = QPainter() p.begin(self.desk_draw_widget) p.setPen(pen) p.drawLine(self.origin_draw_pos, self.cursor.pos()) p.drawRect(inner_rect) p.end()
def get_grid_border(self, margin=0): def get_raster_length(length, raster): return (int((length + MIN_GRID_MARGIN + raster / 2) / raster) - 1 / 2) * raster left = get_raster_length(self.sceneRect().left(), self._grid_size.width()) right = get_raster_length(self.sceneRect().right(), self._grid_size.width()) top = get_raster_length(self.sceneRect().top(), self._grid_size.height()) bottom = get_raster_length(self.sceneRect().bottom(), self._grid_size.height()) return QRect(left, top, right - left, bottom - top).marginsAdded( QMargins(margin, margin, margin, margin))
def layout_collapse_and_restore(layout, state): for child in layout.children(): layout_collapse_and_restore(child, state) if type(layout) is QtW.QFormLayout(): attribute_store_and_set(layout, state, 0, "verticalSpacing", "setVerticalSpacing") attribute_store_and_set(layout, state, 0, "horizontalSpacing", "setHorizontalSpacing") else: attribute_store_and_set(layout, state, 0, "spacing", "setSpacing") attribute_store_and_set(layout, state, QMargins(0, 0, 0, 0), "contentsMargins", "setContentsMargins") if hasattr(layout, "invalidate"): layout.invalidate()
def paintEvent(self, paintEvent): painter = QPainter(self) r = self.frame.rect() r -= QMargins(0, 0, 1, 1) painter.drawRect(r) c1 = QPoint(r.width() / 4, r.height() / 2) c2 = QPoint(3 * r.width() / 4, r.height() / 2) r1 = (r.height() * 0.90) / 2 rc = (r.height() * 0.1) / 2 painter.drawEllipse(c1, r1, r1) painter.drawEllipse(c2, r1, r1) c1 = QPoint(r.width() / 4 + (self._Sticks['yaw'] * r1), r.height() / 2 - (self._Sticks['gaz'] * r1)) c2 = QPoint(3 * r.width() / 4 + (self._Sticks['roll'] * r1), r.height() / 2 - (self._Sticks['pitch'] * r1)) painter.drawEllipse(c1, rc, rc) painter.drawEllipse(c2, rc, rc)
def handleNewOrderButtonClicked(): grouped = test_data.groupby('order_id') while True: order_number = random.sample(grouped.indices.keys(), 1)[0] currentOrder = grouped.get_group(order_number) self.currentOrderReferenceItems = currentOrder.product_id.tolist( ) self.currentOrderUserId = currentOrder.user_id.iloc[0] if len( self.currentOrderReferenceItems ) > 1 and self.currentOrderUserId in self.supportedUsers: break print(self.currentOrderReferenceItems) orderInfo = f"<b>Order ID: </b>{currentOrder.order_id.iloc[0]}<br>" orderInfo += f"<b>User ID: </b>{self.currentOrderUserId} | <b>DOW: </b>{calendar.day_name[currentOrder.order_dow.iloc[0]]} | <b>Hour of Day: </b>{currentOrder.order_hour_of_day.iloc[0]} | <b>Number of Items: </b>{len(self.currentOrderReferenceItems)}" orderInfo += "<br><b>Items in the Reference Order:</b>" for widget in self.referenceItemsLabels.values(): item = referenceItemsLayout.itemAt(0) widget.setVisible(False) referenceItemsLayout.removeItem(item) del item self.referenceItemsLabels.clear() currentCartItems.clear() self.itemsInCart.clear() self.previousRecommendations.clear() self.numberOfGoodRecommendations = 0 updateCurrentRecommendations(list()) for product in self.currentOrderReferenceItems: refItemName = product_id_to_name[product] refItemLabel = QPushButton(refItemName) refItemLabel.setContentsMargins(QMargins(0, 0, 0, 0)) refItemLabel.setStyleSheet("Text-align:left") refItemLabel.setFlat(False) refItemLabel.clicked.connect( partial(changeCurrentitem, refItemName)) self.referenceItemsLabels[product] = refItemLabel orderInfoLabel.setText( f"<b>Order Information</b><br>{orderInfo}") for referenceItemLabel in self.referenceItemsLabels.values(): referenceItemsLayout.addWidget(referenceItemLabel) runAutoButton.setFocus()
def paintEvent(self, paintEvent): painter = QPainter(self) r = self._frame.rect() r -= QMargins(3, 3, 3, 4) painter.drawRect(r) painter.translate(r.width() / 2 + r.left(), r.height() / 2 + r.top()) painter.drawLine(0, r.height() / 3, 0, -r.height() / 3) painter.rotate(self._y) painter.drawLine(0, -r.height() / 2, 3, -r.height() / 2 + 7) painter.drawLine(-3, -r.height() / 2 + 7, 3, -r.height() / 2 + 7) painter.drawLine(-3, -r.height() / 2 + 7, 0, -r.height() / 2) painter.drawLine(-r.height() / 2, 0, -r.height() / 2 + 5, 0) painter.drawLine(r.height() / 2, 0, r.height() / 2 - 5, 0) painter.drawLine(0, r.height() / 2, 0, r.height() / 2 - 5) for i in range(0, 360, 10): painter.drawLine(0, -r.height() / 2, 0, -r.height() / 2 + 3) painter.rotate(10)
def __init__(self, picinfo, picsize: list = [100, 100], parent=None) -> None: super().__init__(parent=parent) self.picinfo = picinfo # self.checkedLab = QLabel("xxxx", self) # self.checkedLab.move(20, 20) # self.checkedLab.setVisible(False) # 按钮和复选框 self.copyBtn = QPushButton(qta.icon("fa5s.copy"), None, self) self.copyBtn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) # 固定高度,保证宽度 self.copyBtn.clicked.connect(self.copyBtnClicked) self.delBtn = QPushButton(qta.icon("fa5s.trash-alt"), None, self) self.delBtn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.delBtn.clicked.connect(self.delBtnClicked) self.checkBtn = QCheckBox(None, self) self.checkBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # 固定宽高 self.checkBtn.stateChanged.connect(self.checked) # 图片显示 self.picLab = QLabel(parent=self) # self.setPicContent('./tmp/unity-lesson3-4.gif') # 设置默认图片,vscode的默认工作路径为根目录 self.picLab.setScaledContents(True) self.picLab.setFixedSize(*picsize) # 固定图片大小 pichbox = QHBoxLayout() pichbox.addWidget(self.picLab) buttonshbox = QHBoxLayout() buttonshbox.addWidget(self.copyBtn, 1) buttonshbox.addWidget(self.delBtn, 1) buttonshbox.addWidget(self.checkBtn) vbox = QVBoxLayout(self) vbox.setContentsMargins(QMargins(5, 0, 5, 0)) vbox.addLayout(pichbox) vbox.addLayout(buttonshbox)
def __init__(self): super().__init__() self.setMinimumHeight(60) layout = QHBoxLayout() self.setLayout(layout) self.setStatusTip("Display the fuzziers in plot.") self.chart = QtCharts.QChart() self.chart.legend().hide() self.chart.createDefaultAxes() self.chart.layout().setContentsMargins(0, 0, 0, 0) self.chart.setMargins(QMargins()) self.chart.setBackgroundRoundness(2) chart_view = QtCharts.QChartView(self.chart) chart_view.setRenderHint(QPainter.Antialiasing) layout.addWidget(chart_view) layout.setContentsMargins(0, 0, 0, 0)
def _createLineChart(self) -> QtCharts.QChartView: self._chart = QtCharts.QChart() self._chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations) self._chart.setTitle("Détections cumulées") self._chart.legend().setVisible(False) self._chart.setBackgroundBrush(QBrush(QColor("transparent"))) self._chart.setMargins(QMargins(0, 0, 0, 0)) title_font = QFont(Loader.QSSVariable("@font")) title_font.setPointSize(14) self._chart.setTitleFont(title_font) self._chart.setTitleBrush(QBrush(Loader.QSSColor("@dark"))) chart_view = QtCharts.QChartView(self._chart) chart_view.setRenderHint(QPainter.Antialiasing) return chart_view
def paintEvent(self, *args): painter = QPainter(self) painter.setRenderHint(QPainter.HighQualityAntialiasing) r = self.rect() painter.fillRect(r, Qt.white) for element in self.elements: painter.translate(element.bounding_box.topLeft()) element.paint(painter) painter.translate(-element.bounding_box.topLeft()) self._draw_wires(painter) for element in self.elements: for pin in element.pins(): p = pin.position + element.bounding_box.topLeft() self._draw_pin(painter, p) painter.setPen(QPen(Qt.red, 1, Qt.DashLine)) painter.setBrush(Qt.transparent) for element in self.selected_elements: bb = element.bounding_box bb = bb.marginsAdded(QMargins(2, 2, 1, 1)) painter.drawRect(bb) if self.select_rect is not None: painter.setBrush(QColor(0, 0, 255, 64)) painter.setPen(QColor(0, 0, 255, 128)) painter.drawRect(self.select_rect) if self.wiring_mode: painter.setPen(QPen(Qt.red, 1, Qt.PenStyle.DotLine)) for line in self.guidelines: painter.drawLine(line) if self._ghost_wire: self._draw_wire(painter, self._ghost_wire, True) if self.closest_point is not None: p = self.closest_point painter.drawEllipse(p.x() - 4, p.y() - 4, 8, 8)
def __init__(self, *args, **kwargs): super(ContractKeiUI, self).__init__(*args, **kwargs) main_layout = QHBoxLayout() # 使用主layout,让控件自适应窗口改变大小 main_layout.setSpacing(0) self.variety_tree = VarietyTree(self) main_layout.addWidget(self.variety_tree) self.right_widget = QWidget(self) right_layout = QVBoxLayout() right_layout.setContentsMargins(QMargins(1, 1, 1, 1)) opts_layout = QHBoxLayout() opts_layout.addWidget(QLabel("选择合约:", self)) self.contract_combobox = QComboBox(self) opts_layout.addWidget(self.contract_combobox) self.confirm_button = QPushButton("确定", self) opts_layout.addWidget(self.confirm_button) self.tip_button = QPushButton("正在查询数据 ", self) self.tip_button.hide() opts_layout.addWidget(self.tip_button) opts_layout.addStretch() right_layout.addLayout(opts_layout) self.web_container = QWebEngineView(self) right_layout.addWidget(self.web_container) self.right_widget.setLayout(right_layout) main_layout.addWidget(self.right_widget) self.setStretchFactor(1, 2) self.setStretchFactor(2, 8) self.setHandleWidth(1) self.contract_combobox.setMinimumWidth(80) self.setLayout(main_layout) self.tip_button.setObjectName("tipButton") self.setStyleSheet("#tipButton{border:none;color:rgb(230,50,50);font-weight:bold}")
def scene_rect(self, other, margin): """define scene rectangle based on bounding rectangle with margin and other rectangle""" if not isinstance(other, QRect): raise TypeError scene_rect = self.marginsAdded(QMargins(margin, margin, margin, margin)) # bounding rectangle of items within other rectangle if scene_rect.width() < other.width(): # left border of items is within left border of other rectangle if other.left() < scene_rect.left(): width_difference = other.width() - scene_rect.width() scene_rect.moveLeft(scene_rect.left() - width_difference / 2) scene_rect.setWidth(other.width()) if scene_rect.height() < other.height(): if other.top() < scene_rect.top(): height_difference = other.height() - scene_rect.height() scene_rect.moveTop(scene_rect.top() - height_difference / 2) scene_rect.setHeight(other.height()) return scene_rect
def __init__(self, *args, **kwargs): super(UserUI, self).__init__(*args, **kwargs) layout = QVBoxLayout() layout.setContentsMargins(QMargins(3, 3, 3, 3)) opts_layout = QHBoxLayout() opts_layout.addWidget(QLabel("用户角色:", self)) self.user_role_combobox = QComboBox(self) opts_layout.addWidget(self.user_role_combobox) self.search_input = QLineEdit(self) self.search_input.setPlaceholderText("搜索(关键字按Enter搜索)") self.search_input.setAlignment(Qt.AlignCenter) opts_layout.addWidget(self.search_input) layout.addLayout(opts_layout) self.user_table = QTableWidget(self) layout.addWidget(self.user_table) self.setLayout(layout)
def paintEvent(self, paintEvent): painter = QPainter(self) r = self._frame.rect() r -= QMargins(3, 3, 3, 4) painter.drawRect(r) h = len(self._history) if (h > 5): csmp = round(self._length / self._periodicity) xr = r.width() / (self._length / self._periodicity) yr = r.height() / (self._max - self._min) i = csmp #sample count to display c = h - 1 #index to display while (c > 0 and i > 0): x1 = r.left() + xr * i x2 = r.left() + xr * (i - 1) v1 = self._history[c] - self._min v2 = self._history[c - 1] - self._min y1 = r.top() + r.height() - v1 * yr y2 = r.top() + r.height() - v2 * yr painter.drawLine(x1, y1, x2, y2) i -= 1 c -= 1
def __init__(self, parentAxis): parentPlot = parentAxis.parentPlot() #print("PARENT ",parentPlot) super().__init__(parentAxis) self.mAxis = parentAxis self.mDummyTracer = QCPItemTracer(parentPlot) self.mDummyTracer.setVisible(False) self.mDummyTracer.position().setTypeX(QCPItemPosition.ptAxisRectRatio) self.mDummyTracer.position().setTypeY(QCPItemPosition.ptPlotCoords) self.mDummyTracer.position().setAxisRect(self.mAxis.axisRect()) self.mDummyTracer.position().setCoords(1, 0) self.mDummyTracer.position().setAxes(None, self.mAxis) # the arrow end (head) is set to move along with the dummy tracer by setting it as its parent # anchor. Its coordinate system (setCoords) is thus pixels, and this is how the needed horizontal # offset for the tag of the second y axis is achieved. This horizontal offset gets dynamically # updated in AxisTag::updatePosition. the arrow "start" is simply set to have the "end" as parent # anchor. It is given a horizontal offset to the right, which results in a 15 pixel long arrow. spike = QCPLineEnding(QCPLineEnding.esSpikeArrow) self.mArrow = QCPItemLine(parentPlot) self.mArrow.setLayer("overlay") self.mArrow.setClipToAxisRect(False) self.mArrow.setHead(spike) self.mArrow.end().setParentAnchor(self.mDummyTracer.position()) self.mArrow.start().setParentAnchor(self.mArrow.end()) self.mArrow.start().setCoords(15, 0) # The text label is anchored at the arrow start (tail) and has its "position" aligned at the # left, and vertically centered to the text label box. self.mLabel = QCPItemText(parentPlot) self.mLabel.setLayer("overlay") self.mLabel.setClipToAxisRect(False) self.mLabel.setPadding(QMargins(3, 0, 3, 0)) #self.mLabel.setBrush(QBrush(Qt.white)) self.mLabel.setBrush(QBrush(QColor(128, 128, 128, 40))) self.mLabel.setPen(QPen(Qt.blue)) self.mLabel.setPositionAlignment(Qt.AlignLeft | Qt.AlignVCenter) self.mLabel.position().setParentAnchor(self.mArrow.start())