Python PyQt5.QtCore.Qt.Horizontal() Examples

The following are 30 code examples of PyQt5.QtCore.Qt.Horizontal(). 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: window.py    From visma with GNU General Public License v3.0 8 votes vote down vote up
def buttonsLayout(self):
        self.matrix = False
        vbox = QVBoxLayout()
        interactionModeLayout = QVBoxLayout()
        self.interactionModeButton = QtWidgets.QPushButton('visma')
        self.interactionModeButton.clicked.connect(self.interactionMode)
        interactionModeLayout.addWidget(self.interactionModeButton)
        interactionModeWidget = QWidget(self)
        interactionModeWidget.setLayout(interactionModeLayout)
        interactionModeWidget.setFixedSize(275, 50)
        topButtonSplitter = QSplitter(Qt.Horizontal)
        topButtonSplitter.addWidget(interactionModeWidget)
        permanentButtons = QWidget(self)
        topButtonSplitter.addWidget(permanentButtons)
        self.bottomButton = QFrame()
        self.buttonSplitter = QSplitter(Qt.Vertical)
        self.buttonSplitter.addWidget(topButtonSplitter)
        self.buttonSplitter.addWidget(self.bottomButton)
        vbox.addWidget(self.buttonSplitter)
        return vbox 
Example #2
Source File: CSlider.py    From CustomWidgets with GNU General Public License v3.0 7 votes vote down vote up
def mousePressEvent(self, event):
        # 获取上面的拉动块位置
        option = QStyleOptionSlider()
        self.initStyleOption(option)
        rect = self.style().subControlRect(
            QStyle.CC_Slider, option, QStyle.SC_SliderHandle, self)
        if rect.contains(event.pos()):
            # 如果鼠标点击的位置在滑块上则交给Qt自行处理
            super(CSlider, self).mousePressEvent(event)
            return
        if self.orientation() == Qt.Horizontal:
            # 横向,要考虑invertedAppearance是否反向显示的问题
            self.setValue(self.style().sliderValueFromPosition(
                self.minimum(), self.maximum(),
                event.x() if not self.invertedAppearance() else (self.width(
                ) - event.x()), self.width()))
        else:
            # 纵向
            self.setValue(self.style().sliderValueFromPosition(
                self.minimum(), self.maximum(),
                (self.height() - event.y()) if not self.invertedAppearance(
                ) else event.y(), self.height())) 
Example #3
Source File: audio_pan.py    From linux-show-player with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.setLayout(QVBoxLayout())
        self.layout().setAlignment(Qt.AlignTop)

        self.panBox = QGroupBox(self)
        self.panBox.setGeometry(0, 0, self.width(), 80)
        self.panBox.setLayout(QHBoxLayout(self.panBox))
        self.layout().addWidget(self.panBox)

        self.panSlider = QSlider(self.panBox)
        self.panSlider.setRange(-10, 10)
        self.panSlider.setPageStep(1)
        self.panSlider.setOrientation(Qt.Horizontal)
        self.panSlider.valueChanged.connect(self.pan_changed)
        self.panBox.layout().addWidget(self.panSlider)

        self.panLabel = QLabel(self.panBox)
        self.panLabel.setAlignment(Qt.AlignCenter)
        self.panBox.layout().addWidget(self.panLabel)

        self.panBox.layout().setStretch(0, 5)
        self.panBox.layout().setStretch(1, 1)

        self.retransaleUi() 
Example #4
Source File: player.py    From MusicBox with MIT License 7 votes vote down vote up
def setSliders(self):
        """设置进度条君。"""
        self.slider = QSlider(self)
        self.slider.setMinimumHeight(5)
        self.slider.setMinimumWidth(440)
        # 将范围设置成1000滚动时更舒服。
        self.slider.setRange(0, 1000)
        self.slider.setObjectName("slider")
        self.slider.setOrientation(Qt.Horizontal)
        self.slider.sliderReleased.connect(self.sliderEvent)
        self.slider.sliderPressed.connect(self.sliderPressEvent)

        self.volumeSlider = QSlider(self)
        self.volumeSlider.setValue(100)
        self.volumeSlider.setMinimumHeight(5)
        self.volumeSlider.setObjectName("volumeSlider")
        self.volumeSlider.setOrientation(Qt.Horizontal)
        self.volumeSlider.valueChanged.connect(self.volumeChangedEvent) 
Example #5
Source File: playing_mediawidget.py    From linux-show-player with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, cue, **kwargs):
        super().__init__(cue, **kwargs)
        self.setGeometry(0, 0, self.width(), 110)

        self._dbmeter_element = None

        self.seekSlider = QClickSlider(self.gridLayoutWidget)
        self.seekSlider.setOrientation(Qt.Horizontal)
        self.seekSlider.setRange(0, cue.duration)
        self.seekSlider.setFocusPolicy(Qt.NoFocus)
        self.seekSlider.sliderMoved.connect(self._seek)
        self.seekSlider.sliderJumped.connect(self._seek)
        self.seekSlider.setVisible(False)

        self.dbmeter = QDbMeter(self.gridLayoutWidget)
        self.dbmeter.setVisible(False)

        cue.changed('duration').connect(self._update_duration,
                                        Connection.QtQueued) 
Example #6
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 7 votes vote down vote up
def headerData(self, section, orientation, role=Qt.DisplayRole):
                '''The data for the given role and section in the header with
                the specified orientation.

                Args:
                    section (:obj:`int`):
                    orientation (:obj:`Qt.Orientation`):
                    role (:obj:`Qt.DisplayRole`):

                Returns:
                    data
                '''
                if role != Qt.DisplayRole:
                    return None

                if (orientation == Qt.Horizontal) and (section < len(self.header)):
                    return self.header[section]

                return None 
Example #7
Source File: flow_layout.py    From QssStylesheetEditor with GNU General Public License v3.0 7 votes vote down vote up
def doLayout(self, rect, testOnly):
        x = rect.x()
        y = rect.y()
        lineHeight = 0
        for item in self.itemList:
            wid = item.widget()
            spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton,
                                                                Qt.Horizontal)
            spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton,
                                                                Qt.Vertical)
            nextX = x + item.sizeHint().width() + spaceX
            if nextX - spaceX > rect.right() and lineHeight > 0:
                x = rect.x()
                y = y + lineHeight + spaceY
                nextX = x + item.sizeHint().width() + spaceX
                lineHeight = 0
            if not testOnly:
                item.setGeometry(QRect(QPoint(x, y), item.sizeHint()))
            x = nextX
            lineHeight = max(lineHeight, item.sizeHint().height())
        return y + lineHeight - rect.y() 
Example #8
Source File: casc_plugin.py    From CASC with GNU General Public License v2.0 7 votes vote down vote up
def export_all(self):
        filename = QtWidgets.QFileDialog.getSaveFileName(self.parent, 'Save CSV export to...')
        if filename == None:
            return

        num_rows = self.sub_signature_model.rowCount()
        num_columns = self.sub_signature_model.columnCount()
        f = open(filename[0], 'wb')

        csvout = csv.writer(f)
        #   Write header to CSV and then each row
        csvout.writerow([self.sub_signature_model.headerData(x, Qt.Horizontal) for x in xrange(0, num_columns)])
        for row in xrange(0, num_rows):
            column_data = [self.sub_signature_model.index(row, column) for column in xrange(0, num_columns)]
            csvout.writerow([self.sub_signature_model.data(index) for index in column_data])
        print '[CASCPlugin] Exported %d sub signatures to %s' % (num_rows, str(filename[0]))
        f.close() 
Example #9
Source File: miscwidgets.py    From qutebrowser with GNU General Public License v3.0 7 votes vote down vote up
def _load_preferred_size(self) -> None:
        """Load the preferred size of the inspector widget."""
        assert self._position is not None
        full = (self.width() if self.orientation() == Qt.Horizontal
                else self.height())

        # If we first open the inspector with a window size of < 300px
        # (self._SMALL_SIZE_THRESHOLD), we don't want to default to half of the
        # window size as the small window is likely a temporary situation and
        # the inspector isn't very usable in that state.
        self._preferred_size = max(self._SMALL_SIZE_THRESHOLD, full // 2)

        try:
            size = int(configfiles.state['inspector'][self._position.name])
        except KeyError:
            # First start
            pass
        except ValueError as e:
            log.misc.error("Could not read inspector size: {}".format(e))
        else:
            self._preferred_size = int(size) 
Example #10
Source File: idealimagerdialog.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
def createButtonBox(self, cmd_fct):
        def clicked(button):
            command = button.text()
            specsheet = self.specsheet_dict[self.conjugate_type]
            if cmd_fct:
                cmd_fct(self, command, specsheet)
            else:
                print(button.text(), 'button pressed')

        buttonbox = QDialogButtonBox(qt.Horizontal, self)
        buttonbox.addButton('New', QDialogButtonBox.ApplyRole)
        buttonbox.addButton(QDialogButtonBox.Apply)
        buttonbox.addButton('Update', QDialogButtonBox.ApplyRole)
        buttonbox.addButton(QDialogButtonBox.Close)
        for b in buttonbox.buttons():
            b.setAutoDefault(False)
#        buttonbox.setCenterButtons(True)
        buttonbox.clicked.connect(clicked)
        return buttonbox 
Example #11
Source File: customwidget.py    From python with Apache License 2.0 7 votes vote down vote up
def initUI(self):      

        OVER_CAPACITY = 750

        sld = QSlider(Qt.Horizontal, self)
        sld.setFocusPolicy(Qt.NoFocus)
        sld.setRange(1, OVER_CAPACITY)
        sld.setValue(75)
        sld.setGeometry(30, 40, 150, 30)

        self.c = Communicate()        
        self.wid = BurningWidget()
        self.c.updateBW[int].connect(self.wid.setValue)

        sld.valueChanged[int].connect(self.changeValue)
        hbox = QHBoxLayout()
        hbox.addWidget(self.wid)
        vbox = QVBoxLayout()
        vbox.addStretch(1)
        vbox.addLayout(hbox)
        self.setLayout(vbox)

        self.setGeometry(300, 300, 390, 210)
        self.setWindowTitle('Burning widget')
        self.show() 
Example #12
Source File: CColorSlider.py    From CustomWidgets with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, types, parent=None, color=Qt.black):
        """
        :param types:                    渐变类型(0-透明,1-彩虹)
        :param parent:
        """
        super(CColorSlider, self).__init__(Qt.Horizontal, parent)
        self.setObjectName('Custom_Color_Slider')
        self.setCursor(Qt.PointingHandCursor)
        self.valueChanged.connect(self.onValueChanged)
        self._types = types
        self._color = color
        self._isFirstShow = True
        self._imageRainbow = None                       # 彩虹背景图
        self._imageAlphaColor = None                    # 带颜色透明图
        self._imageAlphaTmp = None                      # 透明方格
        self._imageAlpha = None                         # 带颜色透明背景和方格合成图
        self._imageCircle = None                        # 圆形滑块图
        self._imageCircleHover = None                   # 圆形滑块悬停图
        self.setToolTip('彩虹色' if self._types == self.TypeRainbow else '透明度') 
Example #13
Source File: CColorSlider.py    From CustomWidgets with GNU General Public License v3.0 7 votes vote down vote up
def pixelPosToRangeValue(self, pos):
        option = QStyleOptionSlider()
        self.initStyleOption(option)
        gr = self.style().subControlRect(QStyle.CC_Slider,
                                         option, QStyle.SC_SliderGroove, self)
        sr = self.style().subControlRect(QStyle.CC_Slider,
                                         option, QStyle.SC_SliderHandle, self)
        if self.orientation() == Qt.Horizontal:
            sliderLength = sr.width()
            sliderMin = gr.x()
            sliderMax = gr.right() - sliderLength + 1
        else:
            sliderLength = sr.height()
            sliderMin = gr.y()
            sliderMax = gr.bottom() - sliderLength + 1
        return QStyle.sliderValueFromPosition(
            self.minimum(), self.maximum(), pos - sliderMin,
            sliderMax - sliderMin, option.upsideDown) 
Example #14
Source File: main_gui.py    From IDAngr with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def headerData(self, col, orientation, role):
        if orientation == Qt.Horizontal and role == Qt.DisplayRole:
            return self.headerdata[col]
        return None 
Example #15
Source File: ObjList.py    From KStock with GNU General Public License v3.0 6 votes vote down vote up
def headerData(self, section, orientation, role = Qt.DisplayRole):
        if role != Qt.DisplayRole:
            return None
        if ((orientation == Qt.Horizontal) and self.isRowObjects) or ((orientation == Qt.Vertical) and not self.isRowObjects):
            # Display property headers.
            try:
                return self.properties[section]['header']  # Property header.
            except (IndexError, KeyError):
                return None
        else:
            # Display object indices (1-based).
            return (section + 1) if (0 <= section < len(self.objects)) else None 
Example #16
Source File: treemodel.py    From QMusic with GNU Lesser General Public License v2.1 6 votes vote down vote up
def headerData(self, section, orientation, role):
        if orientation == Qt.Horizontal and role == Qt.DisplayRole:
            return self._attr_cols[section].name
        else:
            return None 
Example #17
Source File: webkittab.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def right(self, count=1):
        self._key_press(Qt.Key_Right, count, 'scrollBarMaximum', Qt.Horizontal) 
Example #18
Source File: debugger.py    From CQ-editor with Apache License 2.0 6 votes vote down vote up
def headerData(self, section, orientation, role=Qt.DisplayRole):
        if role == Qt.DisplayRole and orientation == Qt.Horizontal:
            return self.HEADER[section]
        return QAbstractTableModel.headerData(self, section, orientation, role) 
Example #19
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 6 votes vote down vote up
def populate_main_form(self):
        list_view = QtWidgets.QListView()
        list_view.setFixedWidth(115)
        list_view.setModel(self.views_model)

        select = QtCore.QItemSelectionModel.Select
        list_view.selectionModel().select(self.views_model.createIndex(0, 0), select)
        list_view.clicked.connect(self.view_clicked)

        current_view = QtWidgets.QWidget()
        view = self.view_about()
        if not view:
            view = QtWidgets.QBoxLayout()
        current_view.setLayout(view)

        self.splitter = QtWidgets.QSplitter(Qt.Horizontal)
        self.splitter.addWidget(list_view)

        self.splitter.addWidget(current_view)
        self.splitter.setChildrenCollapsible(False)
        self.splitter.show()

        outer_layout = QtWidgets.QHBoxLayout()
        outer_layout.addWidget(self.splitter)

        self.parent.setLayout(outer_layout) 
Example #20
Source File: webkittab.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def to_perc(self, x=None, y=None):
        if x is None and y == 0:
            self.top()
        elif x is None and y == 100:
            self.bottom()
        else:
            for val, orientation in [(x, Qt.Horizontal), (y, Qt.Vertical)]:
                if val is not None:
                    frame = self._widget.page().mainFrame()
                    maximum = frame.scrollBarMaximum(orientation)
                    if maximum == 0:
                        continue
                    pos = int(maximum * val / 100)
                    pos = qtutils.check_overflow(pos, 'int', fatal=False)
                    frame.setScrollBarValue(orientation, pos) 
Example #21
Source File: playbackframe.py    From dunya-desktop with GNU General Public License v3.0 6 votes vote down vote up
def _set_slider(self):
        self.slider.setOrientation(Qt.Horizontal)
        self.hor_layout_bottom.addWidget(self.slider) 
Example #22
Source File: webkittab.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def left(self, count=1):
        self._key_press(Qt.Key_Left, count, 'scrollBarMinimum', Qt.Horizontal) 
Example #23
Source File: custom.py    From heap-viewer with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, labels, parent=None):
        super(TTable, self).__init__(parent)
        self.labels = labels
        self.setColumnCount(len(labels))
        self.setHorizontalHeaderLabels(labels)
        self.verticalHeader().hide()
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.horizontalHeader().model().setHeaderData(0, Qt.Horizontal, 
            Qt.AlignJustify, Qt.TextAlignmentRole)    
        self.horizontalHeader().setStretchLastSection(1)
        self.setSelectionMode(QtWidgets.QTableView.SingleSelection)
        self.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
        self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) 
Example #24
Source File: webview.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, e):
        """Extend paintEvent to emit a signal if the scroll position changed.

        This is a bit of a hack: We listen to repaint requests here, in the
        hope a repaint will always be requested when scrolling, and if the
        scroll position actually changed, we emit a signal.

        QtWebEngine has a scrollPositionChanged signal, so it's not needed
        there.

        Args:
            e: The QPaintEvent.

        Return:
            The superclass event return value.
        """
        frame = self.page().mainFrame()
        new_pos = (frame.scrollBarValue(Qt.Horizontal),
                   frame.scrollBarValue(Qt.Vertical))
        if self._old_scroll_pos != new_pos:
            self._old_scroll_pos = new_pos
            m = (frame.scrollBarMaximum(Qt.Horizontal),
                 frame.scrollBarMaximum(Qt.Vertical))
            perc = (round(100 * new_pos[0] / m[0]) if m[0] != 0 else 0,
                    round(100 * new_pos[1] / m[1]) if m[1] != 0 else 0)
            self.scroll_pos = perc
            self.scroll_pos_changed.emit(*perc)
        # Let superclass handle the event
        super().paintEvent(e) 
Example #25
Source File: citytranslate.py    From meteo-qt with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, city, cities_list, parent=None):
        super(CityTranslate, self).__init__(parent)
        self.city = city
        self.settings = QSettings()
        self.trans_cities_dict = cities_list
        self.layout = QVBoxLayout()
        self.buttonLayout = QHBoxLayout()
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel
        )
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonLayout.addWidget(self.buttonBox)
        self.untranslate_city_label = QLabel(self.find_city_key(self.city))
        self.translate_line = QLineEdit(self.city)
        self.translate_line.selectAll()
        self.translate_line.setMinimumWidth(300)
        self.status_layout = QHBoxLayout()
        self.status_label = QLabel()
        self.status_layout.addWidget(self.status_label)
        self.panel = QGridLayout()
        self.panel.addWidget(self.untranslate_city_label, 0, 0)
        self.panel.addWidget(self.translate_line, 1, 0)
        self.layout.addLayout(self.panel)
        self.layout.addLayout(self.status_layout)
        self.layout.addLayout(self.buttonLayout)
        self.setLayout(self.layout)
        self.setWindowTitle(QCoreApplication.translate('Window title',
                            'City translation', 'City translation dialogue')) 
Example #26
Source File: test_miscwidgets.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def test_adjust_size(self, old_window_size, preferred_size,
                         new_window_size, exp_inspector_size,
                         position, splitter, fake_inspector, qtbot):
        def resize(dim):
            size = (QSize(dim, 666) if splitter.orientation() == Qt.Horizontal
                    else QSize(666, dim))
            splitter.resize(size)
            if splitter.size() != size:
                pytest.skip("Resizing window failed")

        splitter.set_inspector(fake_inspector, position)
        splitter.show()
        resize(old_window_size)

        handle_width = 4
        splitter.setHandleWidth(handle_width)

        splitter_idx = 1
        if position in [inspector.Position.left, inspector.Position.top]:
            splitter_pos = preferred_size - handle_width//2
        else:
            splitter_pos = old_window_size - preferred_size - handle_width//2
        splitter.moveSplitter(splitter_pos, splitter_idx)

        resize(new_window_size)

        sizes = splitter.sizes()
        inspector_size = sizes[splitter._inspector_idx]
        main_size = sizes[splitter._main_idx]
        exp_main_size = new_window_size - exp_inspector_size

        exp_main_size -= handle_width // 2
        exp_inspector_size -= handle_width // 2

        assert (inspector_size, main_size) == (exp_inspector_size,
                                               exp_main_size) 
Example #27
Source File: qmodels.py    From linux-show-player with GNU General Public License v3.0 6 votes vote down vote up
def headerData(self, section, orientation, role=Qt.DisplayRole):
        if role == Qt.DisplayRole and orientation == Qt.Horizontal:
            if section < len(self.columns):
                return self.columns[section]
            else:
                return section + 1
        if role == Qt.SizeHintRole and orientation == Qt.Vertical:
            return 0 
Example #28
Source File: tree_view.py    From vorta with GNU General Public License v3.0 6 votes vote down vote up
def headerData(self, section, orientation, role):
        if orientation == Qt.Horizontal and role == Qt.DisplayRole:
            return self.column_names[section]

        return None 
Example #29
Source File: FilterCvQtContainer.py    From bjtu_BinocularCameraRecord with MIT License 6 votes vote down vote up
def setParameters(self, minValue, maxValue):
        # Creates the slider for the OpenCV filter, with min, max, default and
        # step values
        self.thresh_sld = QSlider(Qt.Horizontal, self)
        self.thresh_sld.setFocusPolicy(Qt.NoFocus)
        self.thresh_sld.setMinimum(minValue)
        self.thresh_sld.setMaximum(maxValue)
        self.thresh_sld.setValue(self.k[0])
        self.thresh_sld.setSingleStep(2) 
Example #30
Source File: sparrow-wifi.py    From sparrow-wifi with GNU General Public License v3.0 6 votes vote down vote up
def initUI(self):
        # self.setGeometry(10, 10, 800, 600)
        self.resize(self.mainWidth, self.mainHeight)
        self.center()
        self.setWindowTitle('Sparrow-WiFi Analyzer')
        self.setWindowIcon(QIcon('wifi_icon.png'))        

        self.createMenu()
        
        self.createControls()

        #self.splitter1 = QSplitter(Qt.Vertical)
        #self.splitter2 = QSplitter(Qt.Horizontal)
        #self.splitter1.addWidget(self.networkTable)
        #self.splitter1.addWidget(self.splitter2)
        #self.splitter2.addWidget(self.Plot24)
        #self.splitter2.addWidget(self.Plot5)
        
        self.setBlackoutColors()
        
        self.setMinimumWidth(800)
        self.setMinimumHeight(400)
        
        self.show()
        
        # Set up GPS check timer
        self.gpsTimer = QTimer()
        self.gpsTimer.timeout.connect(self.onGPSTimer)
        self.gpsTimer.setSingleShot(True)
        
        self.gpsTimerTimeout = 5000
        self.gpsTimer.start(self.gpsTimerTimeout)   # Check every 5 seconds