示例#1
0
 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)
示例#2
0
    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)}")
示例#3
0
    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)
示例#4
0
    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
示例#5
0
 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)
示例#6
0
    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()
示例#7
0
    def __init__(self, client):
        super().__init__()
        self.client = client

        self.create_menu()

        self.setCentralWidget(CentralWidget(self.client, self.on_logout))

        margins = QMargins()
        margins.setLeft(5)
        self.setContentsMargins(margins)

        self.show()
示例#8
0
    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}")
示例#9
0
 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()
示例#10
0
 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()))
示例#11
0
    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)
示例#12
0
 def __init__(self, name, x, y, width, height):
     super().__init__(Layer.TileLayerType, name, x, y, width, height)
     self.mMaxTileSize = QSize(0, 0)
     self.mGrid = QVector()
     for i in range(width * height):
         self.mGrid.append(Cell())
     self.mOffsetMargins = QMargins()
示例#13
0
    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)}"
        )
示例#14
0
    def __init__(self, parent=None):
        super(RectZoomMoveView, self).__init__(parent)
        self.setChart(QChart())
        self.chart().setMargins(QMargins(5, 5, 5, 5))
        self.chart().setContentsMargins(-10, -10, -10, -10)
        self.chart().setTitle(" ")
        self.relationState = True

        # Define two rectangles for background and drawing respectively
        self.parentRect = QGraphicsRectItem(self.chart())

        self.parentRect.setFlag(QGraphicsItem.ItemClipsChildrenToShape, True)
        self.parentRect.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
        self.RangeItem = RectRangeItem(parent=self.parentRect)
        self.RangeItem.setZValue(998)
        pen = QPen(Qt.gray)
        pen.setWidth(1)
        self.parentRect.setPen(pen)
        self.parentRect.setZValue(997)

        self.scene().addItem(self.parentRect)
        self.scene().addItem(self.RangeItem)

        self.RangeItem.hide()
        self.m_chartRectF = QRectF()
        self.m_rubberBandOrigin = QPointF(0, 0)
        self.dataLength = 0

        self.RangeItem.selectedChange.connect(self.changeFromRectItem)

        self.BtnsWidget = ViewButtonsWidget(self)
        self.BtnsWidget.refreshBtn.clicked.connect(self.updateView)
        self.BtnsWidget.RelationSig.connect(self.setRelationState)
        self.BtnsWidget.dateRangeEdit.dateRangeSig.connect(self.changDateRect)
示例#15
0
 def __init__(self, host, history, history_size, *args, **kwargs):
     super(MainWindow, self).__init__(*args, **kwargs)
     self.host = host
     self.history = history
     self.history_size = history_size
     self.setupUi(self)
     self.setWindowFlag(Qt.WindowStaysOnTopHint)
     self.position_to_dock()
     self.series_delay = QLineSeries()
     self.series_loss = QLineSeries()
     self.axis_X = QDateTimeAxis()  # pylint: disable=invalid-name
     self.axis_X.setTickCount(3)
     self.axis_X.setFormat("HH:mm")
     self.axis_X.setTitleText("Time")
     self.chart = QChart()
     self.chart.addSeries(self.series_delay)
     self.chart.addSeries(self.series_loss)
     self.chart.setTitle(f"Connection to {self.host}")
     self.init_series(self.series_delay, "Delay ms")
     self.init_series(self.series_loss, "Loss %")
     self.chart.legend().setVisible(False)
     self.chart.legend().setAlignment(Qt.AlignBottom)
     self.chart.layout().setContentsMargins(0, 0, 0, 0)
     self.chart.setBackgroundRoundness(0)
     self.chart.setMargins(QMargins(0, 0, 0, 0))
     self.chartWidget.setChart(self.chart)
     self.chartWidget.setRenderHint(QPainter.Antialiasing)
示例#16
0
    def __init__(self, parent=None, dev=None):
        super(ActionWidget, self).__init__(parent)
        self.setStyleSheet("background-color: black;")
        vbox = QVBoxLayout()
        self.dev = dev
        self.action = ActionLabel(self)
        self.timerlabel = TimerLabel(self)
        vbox.addWidget(self.action)
        vbox.addWidget(self.timerlabel)
        vbox.setContentsMargins(QMargins(0, 0, 0, 0))
        self.setLayout(vbox)
        # Workers
        self.threadpool = QThreadPool()
        self.quit_thread = False
        self._active_listen = True
        # Timer
        self._interval_done = True
        self._interval_time = 0
        self._timer = QTimer()
        self._timer.timeout.connect(self.iterate)
        # Sound
        self.timer_sound = QSound(TIMER_FX)
        self.interval_sound = QSound(TIMER_FX3)
        # Button
        self._button = None
        # ON EXIT
        self.thread_done = False

        self.start_action_signal()
示例#17
0
 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)
示例#18
0
 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
示例#19
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 = []
示例#20
0
    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)
示例#21
0
    def __init__(self, parent=None):
        super(QtInfoWidget, self).__init__(parent)

        self.setStyleSheet("background-color: rgb(40,40,40); color: white")

        fnt = QFont("Times", 8)
        self.lblMessage = QLabel(
            "To begin, open an existing project or load a map.")
        self.lblMessage.setAlignment(Qt.AlignLeft)
        self.lblMessage.setMaximumHeight(50)
        self.lblMessage.setFont(fnt)
        self.lblMessage.setWordWrap(True)
        self.lblMessage.setStyleSheet("color: rgb(255,255,255)")

        layoutV = QVBoxLayout()
        layoutV.addWidget(self.lblMessage)

        self.groupBox = QGroupBox("Information/Warnings")
        self.groupBox.setFont(fnt)
        self.groupBox.setLayout(layoutV)

        layout = QVBoxLayout()
        layout.addWidget(self.groupBox)
        layout.setContentsMargins(QMargins(0, 0, 0, 0))
        self.setLayout(layout)

        self.setAutoFillBackground(True)
示例#22
0
    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
示例#23
0
 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__()
示例#24
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)}"
        )
示例#25
0
    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)
示例#26
0
    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)
示例#27
0
 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
示例#28
0
 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))
示例#29
0
 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)
示例#30
0
 def __init__(self, songInfo_list: list, parent=None):
     super().__init__(songInfo_list, SongCardType.ALBUM_INTERFACE_SONG_CARD,
                      parent, QMargins(30, 430, 30, 0))
     # 创建歌曲卡
     self.__createSongCards()
     # 初始化
     self.__initWidget()
示例#31
0
 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
示例#32
0
class TileLayer(Layer):
    ##
    # Constructor.
    ##
    def __init__(self, name, x, y, width, height):
        super().__init__(Layer.TileLayerType, name, x, y, width, height)
        self.mMaxTileSize = QSize(0, 0)
        self.mGrid = QVector()
        for i in range(width * height):
            self.mGrid.append(Cell())
        self.mOffsetMargins = QMargins()

    def __iter__(self):
        return self.mGrid.__iter__()
        
    ##
    # Returns the maximum tile size of this layer.
    ##
    def maxTileSize(self):
        return self.mMaxTileSize

    ##
    # Returns the margins that have to be taken into account while drawing
    # this tile layer. The margins depend on the maximum tile size and the
    # offset applied to the tiles.
    ##
    def drawMargins(self):
        return QMargins(self.mOffsetMargins.left(),
                        self.mOffsetMargins.top() + self.mMaxTileSize.height(),
                        self.mOffsetMargins.right() + self.mMaxTileSize.width(),
                        self.mOffsetMargins.bottom())

    ##
    # Recomputes the draw margins. Needed after the tile offset of a tileset
    # has changed for example.
    #
    # Generally you want to call Map.recomputeDrawMargins instead.
    ##
    def recomputeDrawMargins(self):
        maxTileSize = QSize(0, 0)
        offsetMargins = QMargins()
        i = 0
        while(i<self.mGrid.size()):
            cell = self.mGrid.at(i)
            tile = cell.tile
            if tile:
                size = tile.size()
                if (cell.flippedAntiDiagonally):
                    size.transpose()
                offset = tile.offset()
                maxTileSize = maxSize(size, maxTileSize)
                offsetMargins = maxMargins(QMargins(-offset.x(),
                                                     -offset.y(),
                                                     offset.x(),
                                                     offset.y()),
                                            offsetMargins)
            i += 1

        self.mMaxTileSize = maxTileSize
        self.mOffsetMargins = offsetMargins
        if (self.mMap):
            self.mMap.adjustDrawMargins(self.drawMargins())

    ##
    # Returns whether (x, y) is inside this map layer.
    ##
    def contains(self, *args):
        l = len(args)
        if l==2:
            x, y = args
            return x >= 0 and y >= 0 and x < self.mWidth and y < self.mHeight
        elif l==1:
            point = args[0]
            return self.contains(point.x(), point.y())

    ##
    # Calculates the region of cells in this tile layer for which the given
    # \a condition returns True.
    ##
    def region(self, *args):
        l = len(args)
        if l==1:
            condition = args[0]
            region = QRegion()
            for y in range(self.mHeight):
                for x in range(self.mWidth):
                    if (condition(self.cellAt(x, y))):
                        rangeStart = x
                        x += 1
                        while(x<=self.mWidth):
                            if (x == self.mWidth or not condition(self.cellAt(x, y))):
                                rangeEnd = x
                                region += QRect(rangeStart + self.mX, y + self.mY,
                                                rangeEnd - rangeStart, 1)
                                break
                            x += 1

            return region
        elif l==0:
            ##
            # Calculates the region occupied by the tiles of this layer. Similar to
            # Layer.bounds(), but leaves out the regions without tiles.
            ##
            return self.region(lambda cell:not cell.isEmpty())

    ##
    # Returns a read-only reference to the cell at the given coordinates. The
    # coordinates have to be within this layer.
    ##
    def cellAt(self, *args):
        l = len(args)
        if l==2:
            x, y = args
            return self.mGrid.at(x + y * self.mWidth)
        elif l==1:
            point = args[0]
            return self.cellAt(point.x(), point.y())

    ##
    # Sets the cell at the given coordinates.
    ##
    def setCell(self, x, y, cell):
        if (cell.tile):
            size = cell.tile.size()
            if (cell.flippedAntiDiagonally):
                size.transpose()
            offset = cell.tile.offset()
            self.mMaxTileSize = maxSize(size, self.mMaxTileSize)
            self.mOffsetMargins = maxMargins(QMargins(-offset.x(),
                                                 -offset.y(),
                                                 offset.x(),
                                                 offset.y()),
                                        self.mOffsetMargins)
            if (self.mMap):
                self.mMap.adjustDrawMargins(self.drawMargins())

        self.mGrid[x + y * self.mWidth] = cell

    ##
    # Returns a copy of the area specified by the given \a region. The
    # caller is responsible for the returned tile layer.
    ##
    def copy(self, *args):
        l = len(args)
        if l==1:
            region = args[0]
            if type(region) != QRegion:
                region = QRegion(region)
            area = region.intersected(QRect(0, 0, self.width(), self.height()))
            bounds = region.boundingRect()
            areaBounds = area.boundingRect()
            offsetX = max(0, areaBounds.x() - bounds.x())
            offsetY = max(0, areaBounds.y() - bounds.y())
            copied = TileLayer(QString(), 0, 0, bounds.width(), bounds.height())
            for rect in area.rects():
                for x in range(rect.left(), rect.right()+1):
                    for y in range(rect.top(), rect.bottom()+1):
                        copied.setCell(x - areaBounds.x() + offsetX,
                                        y - areaBounds.y() + offsetY,
                                        self.cellAt(x, y))
            return copied
        elif l==4:
            x, y, width, height = args

            return self.copy(QRegion(x, y, width, height))

    ##
    # Merges the given \a layer onto this layer at position \a pos. Parts that
    # fall outside of this layer will be lost and empty tiles in the given
    # layer will have no effect.
    ##
    def merge(self, pos, layer):
        # Determine the overlapping area
        area = QRect(pos, QSize(layer.width(), layer.height()))
        area &= QRect(0, 0, self.width(), self.height())
        for y in range(area.top(), area.bottom()+1):
            for x in range(area.left(), area.right()+1):
                cell = layer.cellAt(x - pos.x(), y - pos.y())
                if (not cell.isEmpty()):
                    self.setCell(x, y, cell)

    ##
    # Removes all cells in the specified region.
    ##
    def erase(self, area):
        emptyCell = Cell()
        for rect in area.rects():
            for x in range(rect.left(), rect.right()+1):
                for y in range(rect.top(), rect.bottom()+1):
                    self.setCell(x, y, emptyCell)

    ##
    # Sets the cells starting at the given position to the cells in the given
    # \a tileLayer. Parts that fall outside of this layer will be ignored.
    #
    # When a \a mask is given, only cells that fall within this mask are set.
    # The mask is applied in local coordinates.
    ##
    def setCells(self, x, y, layer, mask = QRegion()):
        # Determine the overlapping area
        area = QRegion(QRect(x, y, layer.width(), layer.height()))
        area &= QRect(0, 0, self.width(), self.height())
        if (not mask.isEmpty()):
            area &= mask
        for rect in area.rects():
            for _x in range(rect.left(), rect.right()+1):
                for _y in range(rect.top(), rect.bottom()+1):
                    self.setCell(_x, _y, layer.cellAt(_x - x, _y - y))

    ##
    # Flip this tile layer in the given \a direction. Direction must be
    # horizontal or vertical. This doesn't change the dimensions of the
    # tile layer.
    ##
    def flip(self, direction):
        newGrid = QVector()
        for i in range(self.mWidth * self.mHeight):
            newGrid.append(Cell())
        for y in range(self.mHeight):
            for x in range(self.mWidth):
                dest = newGrid[x + y * self.mWidth]
                if (direction == FlipDirection.FlipHorizontally):
                    source = self.cellAt(self.mWidth - x - 1, y)
                    dest = source
                    dest.flippedHorizontally = not source.flippedHorizontally
                elif (direction == FlipDirection.FlipVertically):
                    source = self.cellAt(x, self.mHeight - y - 1)
                    dest = source
                    dest.flippedVertically = not source.flippedVertically

        self.mGrid = newGrid

    ##
    # Rotate this tile layer by 90 degrees left or right. The tile positions
    # are rotated within the layer, and the tiles themselves are rotated. The
    # dimensions of the tile layer are swapped.
    ##
    def rotate(self, direction):
        rotateRightMask = [5, 4, 1, 0, 7, 6, 3, 2]
        rotateLeftMask  = [3, 2, 7, 6, 1, 0, 5, 4]
        if direction == RotateDirection.RotateRight:
            rotateMask = rotateRightMask
        else:
            rotateMask = rotateLeftMask
        newWidth = self.mHeight
        newHeight = self.mWidth
        newGrid = QVector(newWidth * newHeight)
        for y in range(self.mHeight):
            for x in range(self.mWidth):
                source = self.cellAt(x, y)
                dest = source
                mask = (dest.flippedHorizontally << 2) | (dest.flippedVertically << 1) | (dest.flippedAntiDiagonally << 0)
                mask = rotateMask[mask]
                dest.flippedHorizontally = (mask & 4) != 0
                dest.flippedVertically = (mask & 2) != 0
                dest.flippedAntiDiagonally = (mask & 1) != 0
                if (direction == RotateDirection.RotateRight):
                    newGrid[x * newWidth + (self.mHeight - y - 1)] = dest
                else:
                    newGrid[(self.mWidth - x - 1) * newWidth + y] = dest

        t = self.mMaxTileSize.width()
        self.mMaxTileSize.setWidth(self.mMaxTileSize.height())
        self.mMaxTileSize.setHeight(t)
        self.mWidth = newWidth
        self.mHeight = newHeight
        self.mGrid = newGrid

    ##
    # Computes and returns the set of tilesets used by this tile layer.
    ##
    def usedTilesets(self):
        tilesets = QSet()
        i = 0
        while(i<self.mGrid.size()):
            tile = self.mGrid.at(i).tile
            if tile:
                tilesets.insert(tile.tileset())
            i += 1
        return tilesets

    ##
    # Returns whether this tile layer has any cell for which the given
    # \a condition returns True.
    ##
    def hasCell(self, condition):
        i = 0
        for cell in self.mGrid:
            if (condition(cell)):
                return True
            i += 1
        return False

    ##
    # Returns whether this tile layer is referencing the given tileset.
    ##
    def referencesTileset(self, tileset):
        i = 0
        while(i<self.mGrid.size()):
            tile = self.mGrid.at(i).tile
            if (tile and tile.tileset() == tileset):
                return True
            i += 1
        return False

    ##
    # Removes all references to the given tileset. This sets all tiles on this
    # layer that are from the given tileset to null.
    ##
    def removeReferencesToTileset(self, tileset):
        i = 0
        while(i<self.mGrid.size()):
            tile = self.mGrid.at(i).tile
            if (tile and tile.tileset() == tileset):
                self.mGrid.replace(i, Cell())
            i += 1

    ##
    # Replaces all tiles from \a oldTileset with tiles from \a newTileset.
    ##
    def replaceReferencesToTileset(self, oldTileset, newTileset):
        i = 0
        while(i<self.mGrid.size()):
            tile = self.mGrid.at(i).tile
            if (tile and tile.tileset() == oldTileset):
                self.mGrid[i].tile = newTileset.tileAt(tile.id())
            i += 1

    ##
    # Resizes this tile layer to \a size, while shifting all tiles by
    # \a offset.
    ##
    def resize(self, size, offset):
        if (self.size() == size and offset.isNull()):
            return
        newGrid = QVector()
        for i in range(size.width() * size.height()):
            newGrid.append(Cell())
        # Copy over the preserved part
        startX = max(0, -offset.x())
        startY = max(0, -offset.y())
        endX = min(self.mWidth, size.width() - offset.x())
        endY = min(self.mHeight, size.height() - offset.y())
        for y in range(startY, endY):
            for x in range(startX, endX):
                index = x + offset.x() + (y + offset.y()) * size.width()
                newGrid[index] = self.cellAt(x, y)

        self.mGrid = newGrid
        self.setSize(size)

    ##
    # Offsets the tiles in this layer within \a bounds by \a offset,
    # and optionally wraps them.
    #
    # \sa ObjectGroup.offset()
    ##
    def offsetTiles(self, offset, bounds, wrapX, wrapY):
        newGrid = QVector()
        for i in range(self.mWidth * self.mHeight):
            newGrid.append(Cell())
        for y in range(self.mHeight):
            for x in range(self.mWidth):
                # Skip out of bounds tiles
                if (not bounds.contains(x, y)):
                    newGrid[x + y * self.mWidth] = self.cellAt(x, y)
                    continue

                # Get position to pull tile value from
                oldX = x - offset.x()
                oldY = y - offset.y()
                # Wrap x value that will be pulled from
                if (wrapX and bounds.width() > 0):
                    while oldX < bounds.left():
                        oldX += bounds.width()
                    while oldX > bounds.right():
                        oldX -= bounds.width()

                # Wrap y value that will be pulled from
                if (wrapY and bounds.height() > 0):
                    while oldY < bounds.top():
                        oldY += bounds.height()
                    while oldY > bounds.bottom():
                        oldY -= bounds.height()

                # Set the new tile
                if (self.contains(oldX, oldY) and bounds.contains(oldX, oldY)):
                    newGrid[x + y * self.mWidth] = self.cellAt(oldX, oldY)
                else:
                    newGrid[x + y * self.mWidth] = Cell()

        self.mGrid = newGrid

    def canMergeWith(self, other):
        return other.isTileLayer()

    def mergedWith(self, other):
        o = other
        unitedBounds = self.bounds().united(o.bounds())
        offset = self.position() - unitedBounds.topLeft()
        merged = self.clone()
        merged.resize(unitedBounds.size(), offset)
        merged.merge(o.position() - unitedBounds.topLeft(), o)
        return merged

    ##
    # Returns the region where this tile layer and the given tile layer
    # are different. The relative positions of the layers are taken into
    # account. The returned region is relative to this tile layer.
    ##
    def computeDiffRegion(self, other):
        ret = QRegion()
        dx = other.x() - self.mX
        dy = other.y() - self.mY
        r = QRect(0, 0, self.width(), self.height())
        r &= QRect(dx, dy, other.width(), other.height())
        for y in range(r.top(), r.bottom()+1):
            for x in range(r.left(), r.right()+1):
                if (self.cellAt(x, y) != other.cellAt(x - dx, y - dy)):
                    rangeStart = x
                    while (x <= r.right() and self.cellAt(x, y) != other.cellAt(x - dx, y - dy)):
                        x += 1

                    rangeEnd = x
                    ret += QRect(rangeStart, y, rangeEnd - rangeStart, 1)

        return ret

    ##
    # Returns True if all tiles in the layer are empty.
    ##
    def isEmpty(self):
        i = 0
        while(i<self.mGrid.size()):
            if (not self.mGrid.at(i).isEmpty()):
                return False
            i += 1
        return True

    ##
    # Returns a duplicate of this TileLayer.
    #
    # \sa Layer.clone()
    ##
    def clone(self):
        return self.initializeClone(TileLayer(self.mName, self.mX, self.mY, self.mWidth, self.mHeight))

    def begin(self):
        return self.mGrid.begin()
    
    def end(self):
        return self.mGrid.end()
        
    def initializeClone(self, clone):
        super().initializeClone(clone)
        clone.mGrid = self.mGrid
        clone.mMaxTileSize = self.mMaxTileSize
        clone.mOffsetMargins = self.mOffsetMargins
        return clone