Python PyQt5.QtCore.Qt.AlignBottom() Examples

The following are 28 code examples of PyQt5.QtCore.Qt.AlignBottom(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: lyric.py    From FeelUOwn with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, parent=None):
        super().__init__(parent=parent)

        self._border_radius = 10
        self.label = QLabel('...', self)
        self._size_grip = QSizeGrip(self)
        self._size_grip.setFixedWidth(self._border_radius * 2)

        font = self.font()
        font.setPointSize(24)
        self.label.setFont(font)
        self.label.setAlignment(Qt.AlignBaseline | Qt.AlignVCenter | Qt.AlignHCenter)
        self.label.setWordWrap(False)

        self._layout = QHBoxLayout(self)
        self._layout.setContentsMargins(0, 0, 0, 0)
        self._layout.setSpacing(0)
        self._layout.addSpacing(self._border_radius * 2)
        self._layout.addWidget(self.label)
        self._layout.addWidget(self._size_grip)
        self._layout.setAlignment(self._size_grip, Qt.AlignBottom) 
Example #2
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 6 votes vote down vote up
def init_top_layout(self):
            history = FIRST.server.history(self.metadata_id)
            if (not history
                or ('results' not in history)
                or (self.metadata_id not in history['results'])
                or ('creator' not in history['results'][self.metadata_id])
                or ('history' not in history['results'][self.metadata_id])):
                self.should_show = False
                return

            self.creator = history['results'][self.metadata_id]['creator']
            self.history = history['results'][self.metadata_id]['history']

            title = QtWidgets.QLabel('Revision History')
            title.setStyleSheet('font: 16pt;')
            creator = QtWidgets.QLabel('by: <b>{}</b>'.format(self.creator))
            creator.setAlignment(Qt.AlignRight | Qt.AlignBottom)

            self.top_layout.addWidget(title)
            self.top_layout.addStretch()
            self.top_layout.addWidget(creator) 
Example #3
Source File: ProbeWindow.py    From PyQt with GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, event):
        super(Label, self).paintEvent(event)
        # 中正间画十字
        painter = QPainter(self)
        painter.setPen(Qt.red)
        x = int(self.width() / 2)
        y = int(self.height() / 2)
        painter.drawLine(x, 0, x, self.height())
        painter.drawLine(0, y, self.width(), y)
        if self.ismd:
            # 画坐标点
            pos = QCursor.pos()
            ret = win32gui.GetPixel(win32gui.GetWindowDC(
                win32gui.GetDesktopWindow()), pos.x(), pos.y())
            r, g, b = ret & 0xff, (ret >> 8) & 0xff, (ret >> 16) & 0xff
            print(r, g, b)
            painter.setPen(Qt.white)
            painter.drawText(self.rect(), Qt.AlignLeft |
                             Qt.AlignBottom, '({}, {})\nRGB: ({}, {}, {})\n{}'.format(
                                 pos.x(), pos.y(), r, g, b, QColor(r, g, b).name())) 
Example #4
Source File: lateral_menu.py    From CvStudio with MIT License 6 votes vote down vote up
def __init__(self, parent=None):
        super(LateralMenu, self).__init__(parent)
        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.top_frame = QFrame()
        # size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
        # self.frame.setSizePolicy(size_policy)
        # self.top_frame.setFixedWidth(90)
        self.top_frame.setFrameStyle(QFrame.NoFrame)
        self.top_frame_layout = QVBoxLayout()
        self.top_frame_layout.setContentsMargins(2, 2, 2, 2)
        self.top_frame_layout.setAlignment(Qt.AlignTop)
        self.top_frame.setLayout(self.top_frame_layout)

        self.bottom_frame = QFrame()
        # self.bottom_frame.setFixedWidth(90)
        self.bottom_frame.setFrameStyle(QFrame.NoFrame)
        self.bottom_frame_layout = QVBoxLayout()
        self.bottom_frame_layout.setContentsMargins(2, 2, 2, 2)
        self.bottom_frame_layout.setAlignment(Qt.AlignBottom)
        self.bottom_frame.setLayout(self.bottom_frame_layout)

        self.layout().addWidget(self.top_frame)
        self.layout().addWidget(self.bottom_frame)
        self.items = [] 
Example #5
Source File: frameless.py    From FeelUOwn with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,):
        super().__init__(parent=None)

        self._widget = None
        self._timer = QTimer(self)
        self._old_pos = None
        self._widget = None
        self._size_grip = QSizeGrip(self)
        self._timer.timeout.connect(self.__on_timeout)

        # setup window layout
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
        self._size_grip.setFixedSize(20, 20)
        self._layout = QVBoxLayout(self)
        self._layout.setContentsMargins(0, 0, 0, 0)
        self._layout.setSpacing(0)
        self._layout.addWidget(self._size_grip)
        self._layout.setAlignment(self._size_grip, Qt.AlignBottom | Qt.AlignRight)

        self.setMouseTracking(True) 
Example #6
Source File: HotPlaylist.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def paintEvent(self, event):
        super(CoverLabel, self).paintEvent(event)
        if hasattr(self, "cover_title") and self.cover_title != "":
            # 底部绘制文字
            painter = QPainter(self)
            rect = self.rect()
            # 粗略字体高度
            painter.save()
            fheight = self.fontMetrics().height()
            # 底部矩形框背景渐变颜色
            bottomRectColor = QLinearGradient(
                rect.width() / 2, rect.height() - 24 - fheight,
                rect.width() / 2, rect.height())
            bottomRectColor.setSpread(QGradient.PadSpread)
            bottomRectColor.setColorAt(0, QColor(255, 255, 255, 70))
            bottomRectColor.setColorAt(1, QColor(0, 0, 0, 50))
            # 画半透明渐变矩形框
            painter.setPen(Qt.NoPen)
            painter.setBrush(QBrush(bottomRectColor))
            painter.drawRect(rect.x(), rect.height() - 24 -
                             fheight, rect.width(), 24 + fheight)
            painter.restore()
            # 距离底部一定高度画文字
            font = self.font() or QFont()
            font.setPointSize(8)
            painter.setFont(font)
            painter.setPen(Qt.white)
            rect.setHeight(rect.height() - 12)  # 底部减去一定高度
            painter.drawText(rect, Qt.AlignHCenter |
                             Qt.AlignBottom, self.cover_title) 
Example #7
Source File: DynamicSpline.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.m_step = 0
        self.m_x = 5
        self.m_y = 1
        # 初始化图像
        self.series = QSplineSeries(self)
        green_pen = QPen(Qt.red)
        green_pen.setWidth(3)
        self.series.setPen(green_pen)
        self.axisX = QValueAxis()
        self.axisY = QValueAxis()
        self.series.append(self.m_x, self.m_y)

        self.addSeries(self.series)
        self.addAxis(self.axisX, Qt.AlignBottom)
        self.addAxis(self.axisY, Qt.AlignLeft)
        self.series.attachAxis(self.axisX)
        self.series.attachAxis(self.axisY)
        self.axisX.setTickCount(5)
        self.axisX.setRange(0, 10)
        self.axisY.setRange(-5, 10)

        self.timer = QTimer(self)
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.handleTimeout)
        self.timer.start() 
Example #8
Source File: HorizontalBarChart.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Simple horizontal barchart example')
        # 开启动画效果
        chart.setAnimationOptions(QChart.SeriesAnimations)
        # 添加Series
        series = self.getSeries()
        chart.addSeries(series)
        # 分类
        categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
        # 分类x轴
        axis = QBarCategoryAxis()
        axis.append(categories)
        # 创建默认轴线
        chart.createDefaultAxes()
        # 替换默认y轴
        chart.setAxisY(axis, series)
        # 显示图例
        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom) 
Example #9
Source File: PercentBarChart.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Simple percentbarchart example')
        # 开启动画效果
        chart.setAnimationOptions(QChart.SeriesAnimations)
        # 添加Series
        series = self.getSeries()
        chart.addSeries(series)
        # 分类
        categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
        # 分类x轴
        axis = QBarCategoryAxis()
        axis.append(categories)
        # 创建默认轴线
        chart.createDefaultAxes()
        # 替换默认x轴
        chart.setAxisX(axis, series)
        # 显示图例
        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom) 
Example #10
Source File: ChartThemes.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def createLegendBox(self):
        legendComboBox = QComboBox()

        legendComboBox.addItem("No Legend ", 0)
        legendComboBox.addItem("Legend Top", Qt.AlignTop)
        legendComboBox.addItem("Legend Bottom", Qt.AlignBottom)
        legendComboBox.addItem("Legend Left", Qt.AlignLeft)
        legendComboBox.addItem("Legend Right", Qt.AlignRight)

        return legendComboBox 
Example #11
Source File: BarChart.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(400, 300)
        # 抗锯齿
        self.setRenderHint(QPainter.Antialiasing)

        # 图表
        chart = QChart()
        self.setChart(chart)
        # 设置标题
        chart.setTitle('Simple barchart example')
        # 开启动画效果
        chart.setAnimationOptions(QChart.SeriesAnimations)
        # 添加Series
        series = self.getSeries()
        chart.addSeries(series)
        # 分类
        categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
        # 分类x轴
        axis = QBarCategoryAxis()
        axis.append(categories)
        # 创建默认轴线
        chart.createDefaultAxes()
        # 替换默认x轴
        chart.setAxisX(axis, series)
        # 显示图例
        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom) 
Example #12
Source File: splash.py    From QssStylesheetEditor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, picfile):
        pixmap = QPixmap(picfile)
        # , Qt.WindowStaysOnTopHint)
        super(SplashScreen, self).__init__(pixmap)
        # self.setMask(splash_pix.mask())
        # self.raise_()
        self.labelAlignment = int(Qt.AlignBottom | Qt.AlignHCenter | Qt.AlignAbsolute)
        self.show()
        QApplication.flush() 
Example #13
Source File: HotPlaylist.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def paintEvent(self, event):
        super(CoverLabel, self).paintEvent(event)
        if hasattr(self, "cover_title") and self.cover_title != "":
            # 底部绘制文字
            painter = QPainter(self)
            rect = self.rect()
            # 粗略字体高度
            painter.save()
            fheight = self.fontMetrics().height()
            # 底部矩形框背景渐变颜色
            bottomRectColor = QLinearGradient(
                rect.width() / 2, rect.height() - 24 - fheight,
                rect.width() / 2, rect.height())
            bottomRectColor.setSpread(QGradient.PadSpread)
            bottomRectColor.setColorAt(0, QColor(255, 255, 255, 70))
            bottomRectColor.setColorAt(1, QColor(0, 0, 0, 50))
            # 画半透明渐变矩形框
            painter.setPen(Qt.NoPen)
            painter.setBrush(QBrush(bottomRectColor))
            painter.drawRect(rect.x(), rect.height() - 24 -
                             fheight, rect.width(), 24 + fheight)
            painter.restore()
            # 距离底部一定高度画文字
            font = self.font() or QFont()
            font.setPointSize(8)
            painter.setFont(font)
            painter.setPen(Qt.white)
            rect.setHeight(rect.height() - 12)  # 底部减去一定高度
            painter.drawText(rect, Qt.AlignHCenter |
                             Qt.AlignBottom, self.cover_title) 
Example #14
Source File: graficoCircular.py    From PyQt5 with MIT License 5 votes vote down vote up
def crearLeyendaCaja(self):
        leyendaComboBox = QComboBox()

        leyendaComboBox.addItem("No Leyenda", 0)
        leyendaComboBox.addItem("Leyenda superior", Qt.AlignTop)
        leyendaComboBox.addItem("Leyenda inferior", Qt.AlignBottom)
        leyendaComboBox.addItem("Leyenda izquierda", Qt.AlignLeft)
        leyendaComboBox.addItem("Leyenda derecha", Qt.AlignRight)

        return leyendaComboBox 
Example #15
Source File: mkyara_plugin.py    From mkYARA with GNU General Public License v3.0 5 votes vote down vote up
def populate_form(self):
        self.setWindowTitle('mkYARA :: Generated Yara Rule')
        self.resize(800, 600)
        self.layout = QtWidgets.QVBoxLayout(self)
        self.top_layout = QtWidgets.QHBoxLayout()
        self.bottom_layout = QtWidgets.QHBoxLayout()
        self.bottom_layout.setAlignment(Qt.AlignRight | Qt.AlignBottom)
        # layout.addStretch()

        self.layout.addWidget(QtWidgets.QLabel("Generated Yara rule from 0x{:x} to 0x{:x}".format(self.start_addr, self.end_addr)))
        self.text_edit = QtWidgets.QTextEdit()
        font = QtGui.QFont()
        font.setFamily("Consolas")
        font.setStyleHint(QtGui.QFont.Monospace)
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.text_edit.setFont(font)
        metrics = QtGui.QFontMetrics(font)
        self.text_edit.setTabStopWidth(4 * metrics.width(' '))

        self.text_edit.insertPlainText(self.yara_rule)
        self.layout.addWidget(self.text_edit)

        self.ok_btn = QtWidgets.QPushButton("OK")
        self.ok_btn.setFixedWidth(100)
        self.ok_btn.clicked.connect(self.ok_btn_clicked)
        self.bottom_layout.addWidget(self.ok_btn)

        self.layout.addLayout(self.top_layout)
        self.layout.addLayout(self.bottom_layout) 
Example #16
Source File: ChartView.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def __getAlignment(self, alignment):
        '''
        :param alignment: left|top|right|bottom
        '''
        try:
            return getattr(Qt, "Align" + alignment.capitalize())
        except:
            return Qt.AlignTop
#         if alignment == "left":
#             return Qt.AlignLeft
#         if alignment == "right":
#             return Qt.AlignRight
#         if alignment == "bottom":
#             return Qt.AlignBottom
#         return Qt.AlignTop 
Example #17
Source File: GifSplashScreen.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def createWindow():
        app.w = QWidget()
        # 模拟初始5秒后再显示
        splash.showMessage('等待界面显示', Qt.AlignHCenter | Qt.AlignBottom, Qt.white)
        QTimer.singleShot(3000, lambda: (
            splash.showMessage('初始化完成', Qt.AlignHCenter | Qt.AlignBottom, Qt.white), app.w.show(),
            splash.finish(app.w)))


    # 模拟耗时5秒。但是不能用sleep
    # 可以使用子线程加载耗时的数据
    # 主线程中循环设置UI可以配合QApplication.instance().processEvents() 
Example #18
Source File: color_map.py    From Anki-Night-Mode with GNU General Public License v3.0 5 votes vote down vote up
def init_ui(self, title):
        self.setWindowTitle(_(title))

        btn_add_mapping = create_button('+ Add colors mapping', self.on_add)
        btn_close = create_button('Close', self.close)

        buttons = QHBoxLayout()

        buttons.addWidget(btn_close)
        buttons.addWidget(btn_add_mapping)
        buttons.setAlignment(Qt.AlignBottom)

        body = QVBoxLayout()
        body.setAlignment(Qt.AlignTop)

        header = QLabel(_(
            'Specify how particular colors on your cards '
            'should be swapped when the night mode is on.'
        ))
        header.setAlignment(Qt.AlignCenter)

        mappings = QVBoxLayout()
        mappings.setAlignment(Qt.AlignTop)

        for normal_color, night_color in self.color_map.items():
            mapping = ColorMapping(self, normal_color, night_color)
            mappings.addWidget(mapping)

        self.mappings = mappings

        body.addWidget(header)
        body.addLayout(mappings)
        body.addStretch(1)
        body.addLayout(buttons)
        self.setLayout(body)

        self.setGeometry(300, 300, 350, 300)
        self.show() 
Example #19
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 5 votes vote down vote up
def init_top_layout(self):
            title = QtWidgets.QLabel('Check Function')
            title.setStyleSheet('font: 16pt;')

            description = QtWidgets.QLabel((
                'Query FIRST\'s server for function metadata.\n'
                'If a function within this IDB matches a signature found in '
                'FIRST then it and its metadata will be available for you to '
                'select below to apply to your IDB. Click to select a '
                'function\'s metadata and click again to deselect it.'))
            description.setWordWrap(True)
            description.setStyleSheet('text-size: 90%')

            vbox_text = QtWidgets.QVBoxLayout()
            vbox_text.addWidget(title)
            vbox_text.addWidget(description)

            widget = QtWidgets.QWidget()
            widget.setFixedWidth(100)
            vbox_legend = QtWidgets.QVBoxLayout(widget)
            grid_legend = QtWidgets.QGridLayout()
            style = 'background-color: #{0:06x}; border: 1px solid #c0c0c0;'
            colors = [FIRST.color_applied, FIRST.color_selected]
            text = ['Applied', 'Selected']
            for i in xrange(len(colors)):
                box = QtWidgets.QLabel()
                box.setFixedHeight(10)
                box.setFixedWidth(10)
                box.setStyleSheet(style.format(colors[i].color().rgb() & 0xFFFFFF))
                grid_legend.addWidget(box, i, 0)
                grid_legend.addWidget(QtWidgets.QLabel(text[i]), i, 1)

            vbox_legend.addLayout(grid_legend)
            vbox_legend.setAlignment(Qt.AlignRight | Qt.AlignBottom)
            vbox_legend.setContentsMargins(20, 0, 0, 0)


            self.top_layout.addLayout(vbox_text)
            self.top_layout.addWidget(widget) 
Example #20
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 5 votes vote down vote up
def init_top_layout(self):
            title = QtWidgets.QLabel('Check All Functions')
            title.setStyleSheet('font: 16pt;')

            description = QtWidgets.QLabel((
                'Query FIRST\'s server for function metadata.\n'
                'If a function within this IDB matches a signature found in '
                'FIRST then it and its metadata will be available for you to '
                'select below to apply to your IDB. Select the function you '
                'wish to apply existing metadata to in order to view the '
                'possible matches.'))
            description.setWordWrap(True)
            description.setStyleSheet('text-size: 90%')

            vbox_text = QtWidgets.QVBoxLayout()
            vbox_text.addWidget(title)
            vbox_text.addWidget(description)

            widget = QtWidgets.QWidget()
            widget.setFixedWidth(100)
            vbox_legend = QtWidgets.QVBoxLayout(widget)
            grid_legend = QtWidgets.QGridLayout()
            style = 'background-color: #{0:06x}; border: 1px solid #c0c0c0;'
            colors = [FIRST.color_applied, FIRST.color_selected]
            text = ['Applied', 'Selected']
            for i in xrange(len(colors)):
                box = QtWidgets.QLabel()
                box.setFixedHeight(10)
                box.setFixedWidth(10)
                box.setStyleSheet(style.format(colors[i].color().rgb() & 0xFFFFFF))
                grid_legend.addWidget(box, i, 0)
                grid_legend.addWidget(QtWidgets.QLabel(text[i]), i, 1)

            vbox_legend.addLayout(grid_legend)
            vbox_legend.setAlignment(Qt.AlignRight | Qt.AlignBottom)
            vbox_legend.setContentsMargins(20, 0, 0, 0)


            self.top_layout.addLayout(vbox_text)
            self.top_layout.addWidget(widget) 
Example #21
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 5 votes vote down vote up
def init_top_layout(self):
            title = QtWidgets.QLabel('Mass Function Upload')
            title.setStyleSheet('font: 16pt;')

            description = QtWidgets.QLabel((
                'Upload function prototype to server for others to access.\n'
                'Select the functions you want to upload. Click to select a '
                'function and click again to deselect the function. Once '
                'uploaded you can manage prototypes you\'ve created in the '
                'management window.'))
            description.setWordWrap(True)
            description.setLineWidth(200)
            description.setStyleSheet('text-size: 90%')

            vbox_text = QtWidgets.QVBoxLayout()
            vbox_text.addWidget(title)
            vbox_text.addWidget(description)

            vbox_legend = QtWidgets.QVBoxLayout()
            grid_legend = QtWidgets.QGridLayout()
            style = 'background-color: #{0:06x}; border: 1px solid #c0c0c0;'
            colors = [  FIRST.color_changed, FIRST.color_unchanged,
                        FIRST.color_default, FIRST.color_selected]
            text = ['Changed', 'Unchanged', 'Default', 'Selected']
            for i in xrange(len(colors)):
                box = QtWidgets.QLabel()
                box.setFixedHeight(10)
                box.setFixedWidth(10)
                box.setStyleSheet(style.format(colors[i].color().rgb() & 0xFFFFFF))
                grid_legend.addWidget(box, i, 0)
                grid_legend.addWidget(QtWidgets.QLabel(text[i]), i, 1)

            vbox_legend.addLayout(grid_legend)
            vbox_legend.setAlignment(Qt.AlignRight | Qt.AlignBottom)

            self.top_layout.addLayout(vbox_text)
            self.top_layout.addStretch()
            self.top_layout.addLayout(vbox_legend) 
Example #22
Source File: content.py    From malss with MIT License 4 votes vote down vote up
def set_paragraph(self, h2='', h3='', text='', img=None):
        if h2 != '':
            lbl_h2 = QLabel(h2, self.inner)
            fnt = lbl_h2.font()
            fnt.setPointSize(self.H2_FONT_SIZE)
            lbl_h2.setFont(fnt)
            lbl_h2.setFixedHeight(self.H2_HEIGHT)
            lbl_h2.setAlignment(Qt.AlignBottom)
            lbl_h2.setMargin(self.SIDE_MARGIN)
            self.vbox.addWidget(lbl_h2)

            frm = QFrame(self.inner)
            frm.setFrameShape(QFrame.HLine)
            frm.setContentsMargins(self.SIDE_MARGIN, 0, self.SIDE_MARGIN, 0)
            plt = frm.palette()
            plt.setColor(QPalette.WindowText, Qt.darkGray)
            frm.setPalette(plt)
            self.vbox.addWidget(frm)

        if text != '':
            lbl_txt = QLabel(text, self.inner)
            lbl_txt.setWordWrap(True)
            fnt = lbl_txt.font()
            fnt.setPointSize(self.TEXT_FONT_SIZE)
            lbl_txt.setFont(fnt)
            lbl_txt.setMargin(self.SIDE_MARGIN)
            self.vbox.addWidget(lbl_txt)

        if img is not None:
            if self.params.lang == 'en':
                img += '_en.png'
            else:
                img += '_jp.png'
            pixmap = QPixmap(img)
            if not pixmap.isNull():
                lbl_img = QLabel(self.inner)
                lbl_img.setPixmap(pixmap)
                self.lbl_img_list.append(lbl_img)
                self.pixmap_list.append(pixmap.scaledToWidth(pixmap.width()))
                self.vbox.addWidget(lbl_img)

        self.inner.setLayout(self.vbox) 
Example #23
Source File: TableModel.py    From urh with GNU General Public License v3.0 4 votes vote down vote up
def data(self, index: QModelIndex, role=Qt.DisplayRole):
        if not index.isValid():
            return None

        i = index.row()
        j = index.column()
        if role == Qt.DisplayRole and self.display_data:
            try:
                alignment_offset = self.get_alignment_offset_at(i)
                if j < alignment_offset:
                    return self.ALIGNMENT_CHAR

                if self.proto_view == 0:
                    return self.display_data[i][j - alignment_offset]
                elif self.proto_view == 1:
                    return "{0:x}".format(self.display_data[i][j - alignment_offset])
                elif self.proto_view == 2:
                    return chr(self.display_data[i][j - alignment_offset])
            except IndexError:
                return None

        elif role == Qt.TextAlignmentRole:
            if i in self.first_messages:
                return Qt.AlignHCenter + Qt.AlignBottom
            else:
                return Qt.AlignCenter

        elif role == Qt.BackgroundColorRole:
            return self.background_colors[i, j]

        elif role == Qt.FontRole:
            font = QFont()
            font.setBold(self.bold_fonts[i, j])
            font.setItalic(self.italic_fonts[i, j])
            return font

        elif role == Qt.TextColorRole:
            return self.text_colors[i, j]

        elif role == Qt.ToolTipRole:
            return self.get_tooltip(i, j)
        else:
            return None 
Example #24
Source File: graficoBarras.py    From PyQt5 with MIT License 4 votes vote down vote up
def crearGraficoBarras(self):
        paises = ["EEUU", "China", "Japon", "Alemania", "Reino Unido", "Resto del mundo"]
        valores = [24.32, 14.85, 8.91, 12.54, 7.85, 31.53]
        colores = [Qt.blue, Qt.red, Qt.darkYellow, Qt.gray, Qt.black, Qt.darkCyan]

        grafico = QChart()
        grafico.setMargins(QMargins(30, 30, 30, 30))
        grafico.setTheme(QChart.ChartThemeLight)
        grafico.setTitle("% Distribución del PIB global")
        grafico.setAnimationOptions(QChart.SeriesAnimations)

        for i in range(len(paises)):
            series = QBarSeries()
            
            barSet = QBarSet(paises[i])
            barSet.setColor(colores[i])
            barSet.setLabelColor(Qt.yellow)
            barSet.append(valores[i])
            
            series.append(barSet)
            series.setLabelsVisible(True)
            series.setLabelsAngle(-90)
            # series.setLabelsPrecision(2)
            series.setLabelsFormat("@value %")
            series.setLabelsPosition(QAbstractBarSeries.LabelsCenter)
            
            grafico.addSeries(series)

        axisX = QBarCategoryAxis()
        axisX.append(paises)

        axisY = QValueAxis()
        axisY.setRange(0, 31.53)
        axisY.setTickCount(10)
        axisY.setLabelFormat("%.2f %")
        
        grafico.createDefaultAxes()
        grafico.setAxisX(axisX, None)
        grafico.setAxisY(axisY, None)

        grafico.legend().setVisible(True)
        grafico.legend().setAlignment(Qt.AlignBottom)

        return grafico 
Example #25
Source File: telemetry.py    From sparrow-wifi with GNU General Public License v3.0 4 votes vote down vote up
def createChart(self):
        self.timeChart = QChart()
        titleFont = QFont()
        titleFont.setPixelSize(18)
        titleBrush = QBrush(QColor(0, 0, 255))
        self.timeChart.setTitleFont(titleFont)
        self.timeChart.setTitleBrush(titleBrush)
        self.timeChart.setTitle('Signal (Past ' + str(self.maxPoints) + ' Samples)')
        # self.timeChart.addSeries(testseries)
        # self.timeChart.createDefaultAxes()
        self.timeChart.legend().hide()
        
        # Axis examples: https://doc.qt.io/qt-5/qtcharts-multiaxis-example.html
        newAxis = QValueAxis()
        newAxis.setMin(0)
        newAxis.setMax(self.maxPoints)
        newAxis.setTickCount(11)
        newAxis.setLabelFormat("%d")
        newAxis.setTitleText("Sample")
        self.timeChart.addAxis(newAxis, Qt.AlignBottom)
        
        newAxis = QValueAxis()
        newAxis.setMin(-100)
        newAxis.setMax(-10)
        newAxis.setTickCount(9)
        newAxis.setLabelFormat("%d")
        newAxis.setTitleText("dBm")
        self.timeChart.addAxis(newAxis, Qt.AlignLeft)
        
        chartBorder = Qt.darkGray
        self.timePlot = QChartView(self.timeChart, self)
        self.timePlot.setBackgroundBrush(chartBorder)
        self.timePlot.setRenderHint(QPainter.Antialiasing)
        
        self.timeSeries = QLineSeries()
        pen = QPen(Qt.yellow)
            
        pen.setWidth(2)
        self.timeSeries.setPen(pen)
        self.timeChart.addSeries(self.timeSeries)
        self.timeSeries.attachAxis(self.timeChart.axisX())
        self.timeSeries.attachAxis(self.timeChart.axisY()) 
Example #26
Source File: sparrow-wifi.py    From sparrow-wifi with GNU General Public License v3.0 4 votes vote down vote up
def createCharts(self):
        self.chart24 = QChart()
        self.chart24.setAcceptHoverEvents(True)
        titleFont = QFont()
        titleFont.setPixelSize(18)
        titleBrush = QBrush(QColor(0, 0, 255))
        self.chart24.setTitleFont(titleFont)
        self.chart24.setTitleBrush(titleBrush)
        self.chart24.setTitle('2.4 GHz')
        self.chart24.legend().hide()
        
        # Axis examples: https://doc.qt.io/qt-5/qtcharts-multiaxis-example.html
        self.chart24axisx = QValueAxis()
        self.chart24axisx.setMin(0)
        self.chart24axisx.setMax(16)
        self.chart24axisx.setTickCount(17) # Axis count +1 (at 0 crossing)
        self.chart24axisx.setLabelFormat("%d")
        self.chart24axisx.setTitleText("Channel")
        self.chart24.addAxis(self.chart24axisx, Qt.AlignBottom)
        
        self.chart24yAxis = QValueAxis()
        self.chart24yAxis.setMin(-100)
        self.chart24yAxis.setMax(-10)
        self.chart24yAxis.setTickCount(9)
        self.chart24yAxis.setLabelFormat("%d")
        self.chart24yAxis.setTitleText("dBm")
        self.chart24.addAxis(self.chart24yAxis, Qt.AlignLeft)
        
        chartBorder = Qt.darkGray
        self.Plot24 = QChartView(self.chart24, self)
        self.Plot24.setBackgroundBrush(chartBorder)
        self.Plot24.setRenderHint(QPainter.Antialiasing)

        self.chart5 = QChart()
        self.chart5.setAcceptHoverEvents(True)
        self.chart5.setTitleFont(titleFont)
        self.chart5.setTitleBrush(titleBrush)
        self.chart5.setTitle('5 GHz')
        self.chart5.createDefaultAxes()
        self.chart5.legend().hide()
        
        self.chart5axisx = QValueAxis()
        self.chart5axisx .setMin(30)
        self.chart5axisx .setMax(170)
        self.chart5axisx .setTickCount(15)
        self.chart5axisx .setLabelFormat("%d")
        self.chart5axisx .setTitleText("Channel")
        self.chart5.addAxis(self.chart5axisx , Qt.AlignBottom)
        
        newAxis = QValueAxis()
        newAxis.setMin(-100)
        newAxis.setMax(-10)
        newAxis.setTickCount(9)
        newAxis.setLabelFormat("%d")
        newAxis.setTitleText("dBm")
        self.chart5.addAxis(newAxis, Qt.AlignLeft)
        
        self.Plot5 = QChartView(self.chart5, self)
        self.Plot5.setBackgroundBrush(chartBorder)
        self.Plot5.setRenderHint(QPainter.Antialiasing)
        self.Plot5.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate) 
Example #27
Source File: selector.py    From Anki-Night-Mode with GNU General Public License v3.0 4 votes vote down vote up
def init_ui(self, title):
        self.setWindowTitle(title)

        btn_close = create_button('Close', self.close)

        buttons = QHBoxLayout()

        buttons.addWidget(btn_close)
        buttons.setAlignment(Qt.AlignBottom)

        body = QVBoxLayout()
        body.setAlignment(Qt.AlignTop)

        header = QLabel(_(
            'Select which parts of Anki should be displayed '
            'in eye-friendly, dark colors.\n\n'
            'To disable all dialog windows, '
            'use the "Enable in dialogs" switch which is available in menu.'
        ))
        header.setAlignment(Qt.AlignCenter)

        stylers = QVBoxLayout()
        stylers.setAlignment(Qt.AlignTop)

        for styler in sorted(self.all_stylers, key=lambda s: s.name):
            styler_checkbox = StylerCheckButton(self, styler)
            self.stylers_checkboxes.append(styler_checkbox)
            stylers.addWidget(styler_checkbox)

        self.stylers_layout = stylers

        checked_boxes = sum(1 for checkbox in self.stylers_checkboxes if checkbox.isChecked())
        check_all = QCheckBox(_('Check/uncheck all'), self)
        check_all.setChecked(checked_boxes > len(self.stylers_checkboxes) / 2)
        check_all.stateChanged.connect(self.check_uncheck_all)

        body.addWidget(header)
        body.addWidget(check_all)
        body.addLayout(stylers)
        body.addStretch(1)
        body.addLayout(buttons)
        self.setLayout(body)

        self.setGeometry(300, 300, 350, 300)
        self.show() 
Example #28
Source File: mode.py    From Anki-Night-Mode with GNU General Public License v3.0 4 votes vote down vote up
def init_ui(self, title):
        self.setWindowTitle(title)

        btn_close = create_button('Close', self.close)

        buttons = QHBoxLayout()

        buttons.addWidget(btn_close)
        buttons.setAlignment(Qt.AlignBottom)

        body = QVBoxLayout()
        body.setAlignment(Qt.AlignTop)

        header = QLabel(
            'If you choose an automatic (scheduled) mode '
            'the "ctrl+n" shortcut and menu checkbox for '
            'quick toggle will switch between the manual '
            'and automatic mode (when used for the first '
            'time).'
        )
        header.setWordWrap(True)

        mode_switches = QHBoxLayout()
        mode_switches.addWidget(QLabel('Mode:'))
        self.manual = create_button('Manual', self.on_set_manual)
        self.auto = create_button('Automatic', self.on_set_automatic)
        mode_switches.addWidget(self.manual)
        mode_switches.addWidget(self.auto)

        time_controls = QHBoxLayout()
        time_controls.setAlignment(Qt.AlignTop)

        start_at = TimeEdit(self, self.settings['start_at'], 'From', self.start_update)
        end_at = TimeEdit(self, self.settings['end_at'], 'To', self.end_update)
        time_controls.addWidget(start_at)
        time_controls.addWidget(end_at)

        self.time_controls = time_controls

        self.set_mode(self.settings['mode'], False)

        body.addWidget(header)
        body.addStretch(1)
        body.addLayout(mode_switches)
        body.addLayout(time_controls)
        body.addStretch(1)
        body.addLayout(buttons)
        self.setLayout(body)

        self.setGeometry(300, 300, 470, 255)
        self.show()