def init_gui(self): # Qrect(pos_x, pos_y, size_x, size_y) # QMargins(left, top, right, bottom) self.setFixedSize(window_width, window_height) self.setWindowTitle("Window UwU") self.top_layout = self.create_grid_layout_widget( margin=QMargins(15, 15, 15, 15), bg_color=green, offset_x=0, offset_y=0, width=window_width, height=tlh ) self.bottom_layout = self.create_grid_layout_widget( margin=QMargins(15, 0, 15, 15), bg_color=yellow, offset_x=0, offset_y=tlh, width=window_width, height=window_height - tlh ) self.top_layout[0].addWidget(make_line_edit("Namespace: ", self.top_layout[1])) self.top_layout[0].addWidget(make_line_edit("Block Name: ", self.top_layout[1])) self.top_layout[0].addWidget(make_line(self.top_layout[1])) self.bottom_layout[0].addWidget(self.settings_tab_widget(self.bottom_layout[1])) self.bottom_layout[0].addWidget(make_line(self.bottom_layout[1])) self.bottom_layout[0].addWidget(self.generate_button(self.bottom_layout[1]))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # ---- UI ---- self.setWindowTitle(self.tr("Accounts")) self.mainlayout = QVBoxLayout() self.mainlayout.setContentsMargins(QMargins(0, 0, 0, 0)) # ---- Content ---- # Toolbar self.accounts_toolbar = AccountsToolBar(self) self.mainlayout.addWidget(self.accounts_toolbar) # Layout self.accounts_layout = AccountsLayout() self.accounts_layout.setContentsMargins(QMargins(0, 0, 0, 0)) self.mainlayout.addWidget(self.accounts_layout) self.setLayout(self.mainlayout) # ---- Functionality ---- # Refresh self.accounts_toolbar.refresh_action.triggered.connect( self.refreshBalances) self.accounts_toolbar.add_account_dialog.accountAdded.connect( self.refreshBalances) self.accounts_toolbar.remove_account_dialog.remove_account_warning.accountRemoved.connect( self.refreshBalances)
def paint(self, painter: QPainter, option: 'QStyleOptionViewItem', index: QModelIndex) -> None: painter.setRenderHint(QPainter.Antialiasing, True) painter_box_rect = option.rect.marginsRemoved(QMargins(1, 1, 1, 1)) painter_pix_rect = option.rect.marginsRemoved(QMargins(10, 10, 10, 10)) try: painter.save() try: painter.setClipRect(painter_box_rect, Qt.IntersectClip) if option.state & QStyle.State_Selected: painter.fillRect(painter_box_rect, option.palette.highlight()) painter.setPen(option.palette.highlight().color()) else: painter.setPen(option.palette.alternateBase().color()) painter.drawRect(painter_box_rect) finally: painter.restore() try: pix = self._get_media_pixmap(index.data(), option, painter_pix_rect.size()) except Exception as ex: c = option.palette.text().color() c.setAlphaF(.15) painter.fillRect(painter_pix_rect, QBrush(c, Qt.DiagCrossPattern)) if not isinstance(ex, KeyError): import traceback traceback.print_exc() else: painter.drawPixmap(painter_pix_rect, pix, pix.rect()) except: import traceback traceback.print_exc()
def readSettings(self): # shadow/margin shadow = QSettings().value("musicview/shadow", True, bool) oldshadow, self.dropShadowEnabled = self.dropShadowEnabled, shadow self.pageLayout().setMargins( QMargins(6, 6, 6, 6) if shadow else QMargins(1, 1, 1, 1)) changed = shadow != oldshadow # kinetic scrolling kinetic = QSettings().value("musicview/kinetic_scrolling", True, bool) self.kineticPagingEnabled = kinetic self.kineticScrollingEnabled = kinetic # scrollbar visibility scrollbars = QSettings().value("musicview/show_scrollbars", True, bool) policy = Qt.ScrollBarAsNeeded if scrollbars else Qt.ScrollBarAlwaysOff oldpolicy = self.horizontalScrollBarPolicy() self.setHorizontalScrollBarPolicy(policy) self.setVerticalScrollBarPolicy(policy) if policy != oldpolicy: changed = True if not self.pageCount(): return # if margin or scrollbar visibility was changed, relayout if changed: if self._viewMode: self.fitPageLayout() self.updatePageLayout() # set certain preferences to the existing renderers renderers = set(page.renderer for page in self.pageLayout() if page.renderer) pages = set(page for page in self.pageLayout() if not page.renderer) changed = False # paper color; change the existing renderer paperColor = textformats.formatData('editor').baseColors['paper'] # if a page has no renderer, adjust the page itself :-) for rp in itertools.chain(renderers, pages): if rp.paperColor != paperColor: changed = True rp.paperColor = paperColor # render backend preference if renderers and popplerqt5: import qpageview.poppler renderBackend, printRenderBackend = getPopplerBackends() for r in renderers: if isinstance(r, qpageview.poppler.PopplerRenderer): r.printRenderBackend = printRenderBackend if r.renderBackend != renderBackend: changed = True r.renderBackend = renderBackend if changed: self.rerender()
def __init__(self, parent=None, **kwds): super().__init__(parent, **kwds) self._view = None self.setOrientation(constants.Vertical) self.pageLayout().spacing = 1 self.pageLayout().setMargins(QMargins(0, 0, 0, 0)) self.pageLayout().setPageMargins(QMargins(4, 4, 4, 20)) self.setLayoutFontHeight() self.currentPageNumberChanged.connect(self.viewport().update)
def __init__(self, *args, **kwargs): super(NavigationBar, self).__init__(*args, **kwargs) main_layout = QHBoxLayout() main_layout.setContentsMargins(QMargins( 2, 0, 0, 0)) # 左侧2px与centerWidget的border一致 # 菜单栏 self.menu_bar = QMenuBar(self) main_layout.addWidget(self.menu_bar, alignment=Qt.AlignLeft) main_layout.addStretch() # 用户信息栏 self.user_bar = QWidget(self) user_bar_layout = QHBoxLayout() user_bar_layout.setContentsMargins(QMargins(0, 0, 8, 0)) user_bar_layout.setSpacing(8) self.username_button = QPushButton("登录", self) setattr(self.username_button, 'is_logged', 0) self.username_button.setFocusPolicy(Qt.NoFocus) user_bar_layout.addWidget(self.username_button) self.logout_button = QPushButton(self) self.logout_button.hide() self.logout_button.setFocusPolicy(Qt.NoFocus) user_bar_layout.addWidget(self.logout_button) self.user_bar.setLayout(user_bar_layout) main_layout.addWidget(self.user_bar) self.setLayout(main_layout) # 设置菜单 self.set_menus(SYSTEM_MENUS) # 样式属性,大小等 self.setFixedHeight(NAVIGATION_BAR_HEIGHT) self.logout_button.setFixedSize(NAVIGATION_BAR_HEIGHT - 10, NAVIGATION_BAR_HEIGHT - 10) self.username_button.setCursor(Qt.PointingHandCursor) self.logout_button.setCursor(Qt.PointingHandCursor) self.setAttribute(Qt.WA_StyledBackground, True) self.setObjectName('navigationBar') self.username_button.setObjectName("usernameButton") self.logout_button.setObjectName("logoutButton") self.menu_bar.setObjectName("menuBar") self.setStyleSheet( "#navigationBar{background-color:rgb(34,102,175)}" "#usernameButton{border:none;}" "#usernameButton:hover{border:none;color:rgb(255,255,255)}" "#logoutButton{border-image:url(media/icons/logout.png);}" "#logoutButton:hover{border-image:url(media/icons/logout_hover.png);}" "#menuBar{background-color:rgb(34,102,175);color:rgb(255,255,255)}" "#menuBar::item{background-color:rgb(34,102,175);border:1px solid rgb(34,142,155);padding:0 5px;margin:0 1px}" "#menuBar::item:selected{background-color:rgb(34,132,200);color:rgb(255,255,255)}" "#menuBar::item:pressed{background:rgb(34,142,175)}")
def __init__(self, app, callback=None, input_placeholder='', function_box=False, flags=None, *args, **kwargs): super().__init__(flags, *args, **kwargs) layout = QVBoxLayout() self.app = app self.function_content = '' self.setContentsMargins(QMargins(0, 0, 0, 0)) layout.setContentsMargins(QMargins(0, 0, 0, 0)) self.list = QListWidget() self.list.setStyleSheet(''' QListWidget::item:hover { color: white; background-color: rgba(255, 255, 255, 5); } QListWidget::item:selected { color: white; background-color: rgba(255, 255, 255, 5); } ''') bar = QScrollBar() bar.setMaximumHeight(0) bar.setMaximumWidth(0) self.list.setHorizontalScrollBar(bar) self.list.model().rowsInserted.connect(self.on_row_inserted) layout.addWidget(self.list) box = QHBoxLayout() box.setContentsMargins(QMargins(3, 3, 3, 3)) if callback is not None: self.input = QConsoleInputWidget(self, callback) self.input.setPlaceholderText(input_placeholder) box.addWidget(self.input) if function_box: function_btn = QPushButton('ƒ') function_btn.setMinimumWidth(25) function_btn.clicked.connect(self.js_function_box) box.addWidget(function_btn) box_widget = QWidget() box_widget.setLayout(box) layout.addWidget(box_widget) self.setLayout(layout)
def __init__(self, title, file, *args, **kwargs): super(PDFContentPopup, self).__init__(*args, **kwargs) self.setAttribute(Qt.WA_DeleteOnClose) self.file = file self.file_name = title # auth doc type self.setWindowTitle(title) self.resize(925, 600) # self.download = QPushButton("下载PDF", self) # self.download.setIcon(QIcon('media/download-file.png')) self.setWindowIcon(QIcon("media/reader.png")) # scroll scroll_area = QScrollArea() scroll_area.setContentsMargins(QMargins(0, 0, 0, 0)) scroll_area.setParent(self) scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) # content self.page_container = QWidget(self) container_layout = QVBoxLayout() # 页面布局 # 计算大小(设置了label范围890-895) container_layout.setContentsMargins(QMargins(10, 5, 10, 5)) # 右边 页面距离10 self.page_container.setLayout(container_layout) layout = QVBoxLayout() # 主布局 layout.setContentsMargins(QMargins(0, 0, 0, 0)) layout.setParent(self) # initial data self.add_pages() # add to show scroll_area.setWidget(self.page_container) scroll_area.setStyleSheet("border:none") scroll_area.horizontalScrollBar().setStyleSheet( "QScrollBar:horizontal{background:transparent;height:10px;margin:0px;}" "QScrollBar:horizontal:hover{background:rgba(0,0,0,30);border-radius:5px}" "QScrollBar::handle:horizontal{background:rgba(0,0,0,50);height:10px;border-radius:5px;border:none}" "QScrollBar::handle:horizontal:hover{background:rgba(0,0,0,100)}" "QScrollBar::add-page:horizontal{height:10px;background:transparent;}" "QScrollBar::sub-page:horizontal{height:10px;background:transparent;}" "QScrollBar::sub-line:horizontal{width:0px}" "QScrollBar::add-line:horizontal{width:0px}") scroll_area.verticalScrollBar().setStyleSheet( "QScrollBar:vertical{background: transparent; width:10px;margin: 0px;}" "QScrollBar:vertical:hover{background:rgba(0,0,0,30);border-radius:5px}" "QScrollBar::handle:vertical{background: rgba(0,0,0,50);width:10px;border-radius:5px;border:none}" "QScrollBar::handle:vertical:hover{background:rgba(0,0,0,100)}" "QScrollBar::add-page:vertical{width:10px;background:transparent;}" "QScrollBar::sub-page:vertical{width:10px;background:transparent;}" "QScrollBar::sub-line:vertical{height:0px}" "QScrollBar::add-line:vertical{height:0px}") # add layout # layout.addWidget(self.download, alignment=Qt.AlignLeft) layout.addWidget(scroll_area) self.setLayout(layout)
def computeLayerOffsetMargins(self): offsetMargins = QMargins() for layer in self.mLayers: offset = layer.offset() offsetMargins = maxMargins( QMargins(math.ceil(-offset.x()), math.ceil(-offset.y()), math.ceil(offset.x()), math.ceil(offset.y())), offsetMargins) return offsetMargins
def setControlMargins(self, *margins): """Set the controls points on the margins around `rect` """ if len(margins) > 1: margins = QMargins(*margins) else: margins = margins[0] if isinstance(margins, int): margins = QMargins(margins, margins, margins, margins) if self.__margins != margins: self.__margins = margins self.__pointsLayout()
def __init__(self, *args, **kwargs): super(FrameLessWindowUI, self).__init__(*args, **kwargs) main_layout = QVBoxLayout() main_layout.setContentsMargins( QMargins(self.MARGIN, self.MARGIN, self.MARGIN, self.MARGIN)) main_layout.setSpacing(0) self.setWindowIcon(QIcon("media/logo.png")) self.setWindowTitle("分析决策系统") # 基本事件属性设置 self.setMouseTracking(True) self._pressed = False self._direction = None self._mouse_pos = None self.title_bar = TitleBarUI(self) # 窗口标题栏 main_layout.addWidget(self.title_bar, alignment=Qt.AlignTop) self.navigation_bar = NavigationBar(self) # 菜单和用户状态栏 main_layout.addWidget(self.navigation_bar, alignment=Qt.AlignTop) self.center_widget = QMainWindow() # 模块窗体显示窗口 self.center_widget.setContentsMargins(QMargins(2, 0, 2, 2)) main_layout.addWidget(self.center_widget) self.setLayout(main_layout) # 样式,属性,大小设置 self.title_bar.installEventFilter(self) # 安装事件过滤进入标题栏还原鼠标样式 self.navigation_bar.installEventFilter(self) self.center_widget.installEventFilter(self) self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowSystemMenuHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint) available_size = QDesktopWidget().availableGeometry( ) # 用户的桌面信息,来改变自身窗体大小 available_width, available_height = available_size.width( ), available_size.height() self.resize(available_width * 0.75, available_height * 0.8) self.setMaximumSize(available_width, available_height) # 最大为用户桌面大小 self.setMinimumSize(available_width * 0.5, available_height * 0.5) # 最小为用户桌面大小的一半 self.setAttribute(Qt.WA_TranslucentBackground, True) # 窗口透明 self.center_widget.setAutoFillBackground(True) # 被窗口透明影响,自动填充 self.center_widget.setObjectName("centerWidget") self.setStyleSheet( "#centerWidget{background-color:rgb(255,255,255);border:2px solid rgb(34,102,175);border-top:none;" "border-bottom-right-radius:5px;border-bottom-left-radius:5px}")
def resizeEvent(self, event): super(MainView, self).resizeEvent(event) margin_k = self.k_view.chart().margins() margin_v = self.v_view.chart().margins() width_k = self.k_view.chart().plotArea().width() width_v = self.v_view.chart().plotArea().width() sub = width_k - width_v if sub > 0: self.k_view.chart().setMargins( QMargins(margin_k.left() + sub, margin_k.top(), margin_k.right(), margin_k.bottom())) else: self.v_view.chart().setMargins( QMargins(margin_v.left() - sub, margin_v.top(), margin_v.right(), margin_v.bottom()))
def update_margins(self): margin_k = self.k_view.chart().margins() margin_v = self.v_view.chart().margins() width_k = self.k_view.chart().plotArea().width() width_v = self.v_view.chart().plotArea().width() sub = width_k - width_v if sub > 0: self.k_view.chart().setMargins( QMargins(margin_k.left() + sub, margin_k.top(), margin_k.right(), margin_k.bottom())) else: self.v_view.chart().setMargins( QMargins(margin_v.left() - sub, margin_v.top(), margin_v.right(), margin_v.bottom())) self.update()
def __init__(self, app, flags=None, *args, **kwargs): super().__init__(flags, *args, **kwargs) layout = QVBoxLayout() self.app = app self.js_script = '' self.setContentsMargins(QMargins(0, 0, 0, 0)) layout.setContentsMargins(QMargins(0, 0, 0, 0)) self.list = QListWidget() self.list.setStyleSheet(''' QListWidget::item:hover { color: white; background-color: transparent; } QListWidget::item:selected { color: white; background-color: transparent; } ''') bar = QScrollBar() bar.setMaximumHeight(0) bar.setMaximumWidth(0) self.list.setHorizontalScrollBar(bar) self.list.model().rowsInserted.connect(self.on_row_inserted) layout.addWidget(self.list) js_box = QHBoxLayout() js_box.setContentsMargins(QMargins(3, 3, 3, 3)) self.input = JsInput(self) self.input.setPlaceholderText('$>') js_box.addWidget(self.input) function_btn = QPushButton('ƒ') function_btn.setMinimumWidth(25) function_btn.clicked.connect(self.js_function_box) js_box.addWidget(function_btn) js_box_widget = QWidget() js_box_widget.setLayout(js_box) layout.addWidget(js_box_widget) self.setLayout(layout)
def __init__(self, window: "OctogonWindow"): super().__init__() self.setContentsMargins(QMargins(0, 0, 0, 0)) self.setSpacing(0) self.btn_scoreboard = QPushButton("scoreboard", parent=window) self.btn_scoreboard.clicked.connect(lambda: self.set_tab(0)) self.btn_overlays = QPushButton("overlays", parent=window) self.btn_overlays.clicked.connect(lambda: self.set_tab(1)) # the pages self.widget_scoreboard = QWidget(window) self.widget_scoreboard.setLayout(ScoreboardLayout(window)) self.widget_overlays = QWidget(window) self.widget_overlays.setLayout(OverlaysLayout(window)) # the stackedlayout containing the pages self.widget_stack = QStackedWidget(window) self.widget_stack.addWidget(self.widget_scoreboard) self.widget_stack.addWidget(self.widget_overlays) self.addWidget(self.btn_scoreboard, 0, 0) self.addWidget(self.btn_overlays, 0, 1) self.addWidget(self.widget_stack, 1, 0, 1, 2) self.set_tab(0)
def __init__(self, *args, **kwargs): super(UserExtensionUI, self).__init__(*args, **kwargs) main_layout = QVBoxLayout() main_layout.setContentsMargins(QMargins(0, 0, 0, 0)) option_layout = QHBoxLayout() option_layout.addWidget(QLabel("用户类型:", self)) self.user_type_combobox = QComboBox(self) option_layout.addWidget(self.user_type_combobox) self.query_button = QPushButton("查询", self) option_layout.addWidget(self.query_button) self.phone_edit = QLineEdit(self) self.phone_edit.setPlaceholderText("在此输入手机号查询用户") option_layout.addWidget(self.phone_edit) self.message_label = QLabel(self) option_layout.addWidget(self.message_label) option_layout.addStretch() main_layout.addLayout(option_layout) self.user_table = QTableWidget(self) self.user_table.verticalHeader().hide() self.user_table.setColumnCount(4) self.user_table.setHorizontalHeaderLabels(["编号", "手机", "微信ID", ""]) self.user_table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents) main_layout.addWidget(self.user_table) self.setLayout(main_layout) self.message_label.setObjectName("messageLabel") self.setStyleSheet( "#messageLabel{color:rgb(233,66,66)}" )
def __init__(self, PaperSize, Orientation): _jpPrintSection.Report = self _jpPrintItem.Report = self _jpPrintGroup.Report = self _jpPrintItem.TotalPagesCalculated = False self.PaperSize = PaperSize self.Orientation = Orientation self.Margins: QMargins = QMargins(0, 0, 0, 0) self.ReportHeader = _jpSectionReportHeader() self.ReportFooter = _jpSectionReportFooter() self.PageHeader = _jpSectionPageHeader() self.PageFooter = _jpSectionPageFooter() self.Detail = _jpSectionDetail() self.ReportHeader.Report = self self.ReportFooter.Report = self self.PageHeader.Report = self self.PageFooter.Report = self self.Detail.Report = self self.Copys = 1 self._CurrentPage = 0 self._CurrentCopys = 0 self.__PageCount = 0 self.__Groups = [] self.__DataSource = {} self.__Errors = [] self.__Printer: QPrinter = None self.__PageHeight = None self.__Calculated = False self.__Reseted = False self.__SectionPrintBeginY = 0 self.__ExecNewPageTimes = 0
def __init__(self, reference, parent=None): super().__init__(parent) self.comboBox = QComboBox(self) self.comboBox.setEditable(True) self.comboBox.lineEdit().setMaxLength(1024) self.comboBox.setMinimumWidth(120) self.comboBox.setInsertPolicy(QComboBox.NoInsert) self.model = reference.model self.proxyModel = self.model.proxyModel() self.comboBox.setModel(self.proxyModel) self.comboBox.setModelColumn(self.model.fieldIndex('value')) self.comboBox.setCurrentIndex(-1) self.reference = reference self.reference.changed.connect(self.setText) layout = QHBoxLayout() layout.addWidget(self.comboBox) layout.addWidget(reference.button(self)) layout.setContentsMargins(QMargins()) self.setLayout(layout) self.dependents = []
def getQMargins(self) -> QMargins: m = QMargins() m.setTop(self.top) m.setLeft(self.left) m.setRight(self.right) m.setBottom(self.bottom) return m
def pageMargins(self): """Return our page margins as a QMargins object, intialized from _pageMargins""" try: return self._pm except AttributeError: self._pm = QMargins(*self._pageMargins) return self._pm
def on_btnSetMargin_clicked(self): mgs=QMargins() mgs.setLeft(self.ui.spinMarginLeft.value()) mgs.setRight(self.ui.spinMarginRight.value()) mgs.setTop(self.ui.spinMarginTop.value()) mgs.setBottom(self.ui.spinMarginBottom.value()) self.__chart.setMargins(mgs)
def initChart(self, xAxis): self._chart = QChart() #调整边距 self._chart.layout().setContentsMargins(0, 0, 0, 0) #外界 self._chart.setMargins(QMargins(3, 0, 3, 0)) #内界 self._chart.setBackgroundRoundness(0) self._chart.setBackgroundVisible(False) #设置主题 self._chart.setTheme(QChart.ChartThemeBlueIcy) # 抗锯齿 self.setRenderHint(QPainter.Antialiasing) # 开启动画效果 self._chart.setAnimationOptions(QChart.SeriesAnimations) self.categories = xAxis self._series = QPercentBarSeries(self._chart) self._chart.addSeries(self._series) axis_x = QBarCategoryAxis(self._chart) axis_x.append(self.categories) axis_x.setLabelsAngle(280) axis_y = QValueAxis(self._chart) axis_y.setTitleText("比例") axis_y.setRange(0, 100) self._chart.addAxis(axis_x, Qt.AlignBottom) self._chart.addAxis(axis_y, Qt.AlignLeft) self._series.attachAxis(axis_x) self._series.attachAxis(axis_y) self.setChart(self._chart)
def __init__(self, menus, *args, **kwargs): super(LeftChildrenMenuWidget, self).__init__(*args, **kwargs) layout = QGridLayout() layout.setAlignment(Qt.AlignTop | Qt.AlignLeft) layout.setContentsMargins(QMargins(10, 10, 10, 10)) layout.setSpacing(10) # 增加button按钮 row, col = 0, 0 for menu_item in menus: button = QPushButton(menu_item["name"], self) setattr(button, "menu_id", menu_item["id"]) button.setObjectName("pushButton") button.setFixedSize(110, 22) button.clicked.connect(self.menu_selected) layout.addWidget(button, row, col) col += 1 if col >= 3: col = 0 row += 1 self.setLayout(layout) self.setStyleSheet( "#pushButton{border:none;background-color:rgb(225,225,225)}" "#pushButton:hover{border:none;background-color:rgb(205,205,205)}" )
def __init__(self, parent=None): super(QtProgressBarCustom, self).__init__(parent) self.setStyleSheet("background-color: rgb(40,40,40); color: white") self.bar_width = 400 self.bar_height = 30 self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.setMinimumWidth(self.bar_width) self.setMinimumHeight(self.bar_height + 10) self.pxmapBar = QPixmap(self.bar_width, self.bar_height) self.pxmapBar.fill(Qt.darkBlue) self.lblBar = QLabel() self.lblBar.setPixmap(self.pxmapBar) layoutH = QHBoxLayout() layoutH.addWidget(self.lblBar) layoutH.setContentsMargins(QMargins(0, 0, 0, 0)) self.setLayout(layoutH) self.setAutoFillBackground(True) self.current_progress = 0.0 self.message = "Classification" self.flag_perc = True
def __init__(self, vharfbuzz, size, buf): self.vharfbuzz = vharfbuzz self.size = size self.buf = buf self.setup_font() self.margins = QMargins(25, 25, 25, 25) super(QVHarfbuzzWidget, self).__init__()
def logout(self): """Возвращает пользователя в меню регистрации/входа после выхода из аккаунта""" try: self.client_socket.sendall( zlib.compress( self.coder.encrypt( bytes(json.dumps({ 'action': 'sign_out', 'user': { 'account_name': self.login } }), encoding='utf8')))) self.t.join(0.05) except Exception as E: print(E) self.client_socket.close() width = self.size().width() height = self.size().height() is_full_screen = self.isFullScreen() uic.loadUi('ui/reg.ui', self) self.recolor() widget = QWidget(self) widget.setLayout(self.gridLayout) self.setCentralWidget(widget) self.resize(width, height) if is_full_screen: self.showFullScreen() x, y = self.size().width() // 4, self.size().height() // 4 self.gridLayout.setContentsMargins(QMargins(x, y, x, y)) self.bull = True self.pushButton.clicked.connect(self.authorize) self.pushButton_2.clicked.connect(self.register)
def __init__(self, parent=None): super().__init__(parent) self.lineEdit = LineEdit(parent) buttonLoad = QPushButton(createIcon('world.png'), '', parent) buttonLoad.setFixedWidth(25) buttonLoad.setToolTip(self.tr("Open specified URL")) buttonLoad.clicked.connect(self.clickedButtonLoad) style = QApplication.style() icon = style.standardIcon(QStyle.SP_DialogOpenButton) self.buttonOpen = QPushButton(icon, '', parent) self.buttonOpen.setFixedWidth(25) self.buttonOpen.setToolTip(self.tr("Select file from disc")) self.buttonOpen.clicked.connect(self.clickedButtonOpen) layout = QHBoxLayout() layout.addWidget(self.lineEdit) layout.addWidget(self.buttonOpen) layout.addWidget(buttonLoad) layout.setContentsMargins(QMargins()) self.setLayout(layout)
def resizeEvent(self, event): """Создаёт отступы от краёв окна входа/регистрации в размере четверти от его длины и ширины""" QMainWindow.resizeEvent(self, event) if self.bull: x, y = self.size().width() // 4, self.size().height() // 4 self.gridLayout.setContentsMargins(QMargins(x, y, x, y))
def margins(self): """Return our margins as a QMargins object, intialized from _margins""" try: return self._m except AttributeError: self._m = QMargins(*self._margins) return self._m
def initChart(self, xAxis): self._chart = QChart() # 调整边距 self._chart.layout().setContentsMargins(0, 0, 0, 0) # 外界 self._chart.setMargins(QMargins(3, 0, 3, 0)) # 内界 self._chart.setBackgroundRoundness(0) self._chart.setBackgroundVisible(False) # 设置主题 self._chart.setTheme(QChart.ChartThemeBlueIcy) # 抗锯齿 self.setRenderHint(QPainter.Antialiasing) # 开启动画效果 self._chart.setAnimationOptions(QChart.SeriesAnimations) self.categories = xAxis self._series = QBarSeries(self._chart) self._chart.addSeries(self._series) self._chart.createDefaultAxes() # 创建默认的轴 self._axis_x = QBarCategoryAxis(self._chart) self._axis_x.append(self.categories) self._axis_y = QValueAxis(self._chart) self._axis_y.setTitleText("任务数") self._axis_y.setRange(0, 10) self._chart.setAxisX(self._axis_x, self._series) self._chart.setAxisY(self._axis_y, self._series) # chart的图例 legend = self._chart.legend() legend.setVisible(True) self.setChart(self._chart)