def __init__(self, master):
        super(SmoothingControlItems, self).__init__()

        master.button_nosmooth = QPushButton('No Smoothing')
        master.button_lowsmooth = QPushButton('Low Smoothing')
        master.button_midsmooth = QPushButton('Medium Smoothing')
        master.button_highsmooth = QPushButton('High Smoothing')

        master.slider_xsmooth = QSlider(Qt.Horizontal)
        master.slider_ysmooth = QSlider(Qt.Horizontal)
        master.slider_zsmooth = QSlider(Qt.Horizontal)

        master.label_xsmooth = QLabel('')
        master.label_ysmooth = QLabel('')
        master.label_zsmooth = QLabel('')

        layout = QGridLayout()

        for index, button in enumerate(
            (master.button_nosmooth, master.button_lowsmooth,
             master.button_midsmooth, master.button_highsmooth)):
            layout.addWidget(button, 1, index)

        layout.addWidget(master.label_xsmooth, 0, index + 1)
        layout.addWidget(master.label_ysmooth, 0, index + 2)
        layout.addWidget(master.label_zsmooth, 0, index + 3)

        layout.addWidget(master.slider_xsmooth, 1, index + 1)
        layout.addWidget(master.slider_ysmooth, 1, index + 2)
        layout.addWidget(master.slider_zsmooth, 1, index + 3)

        layout.setMargin(5)

        self.setLayout(layout)
Esempio n. 2
0
    def drawSpan(self, painter, rect):
        opt = QStyleOptionSlider()
        QSlider.initStyleOption(self, opt)

        # area
        groove = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderGroove, self)
        if opt.orientation == QtCore.Qt.Horizontal:
            groove.adjust(0, 0, -1, 0)
        else:
            groove.adjust(0, 0, 0, -1)

        # pen & brush
        painter.setPen(QPen(self.gradientLeftColor, 0))
        if opt.orientation == QtCore.Qt.Horizontal:
            self.setupPainter(painter, opt.orientation, groove.center().x(),
                              groove.top(), groove.center().x(),
                              groove.bottom())
        else:
            self.setupPainter(painter, opt.orientation, groove.left(),
                              groove.center().y(), groove.right(),
                              groove.center().y())

        # draw groove
        intersected = QtCore.QRectF(rect.intersected(groove))
        gradient = QLinearGradient(intersected.topLeft(), intersected.topRight())
        gradient.setColorAt(0, self.gradientLeft)
        gradient.setColorAt(1, self.gradientRight)
        painter.fillRect(intersected, gradient)
Esempio n. 3
0
    def __init__(self, parent=None):
        super(XZoomSlider, self).__init__(parent)

        # define the interface
        in_icon = projexui.resources.find('img/zoom_in.png')
        out_icon = projexui.resources.find('img/zoom_out.png')

        self._zoomInButton = QToolButton(self)
        self._zoomInButton.setAutoRaise(True)
        self._zoomInButton.setToolTip('Zoom In')
        self._zoomInButton.setIcon(QIcon(in_icon))

        self._zoomOutButton = QToolButton(self)
        self._zoomOutButton.setAutoRaise(True)
        self._zoomOutButton.setToolTip('Zoom Out')
        self._zoomOutButton.setIcon(QIcon(out_icon))

        self._zoomSlider = QSlider(Qt.Horizontal, self)
        self._zoomSlider.setRange(10, 100)
        self._zoomSlider.setValue(100)

        # define the layout
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self._zoomOutButton)
        layout.addWidget(self._zoomSlider)
        layout.addWidget(self._zoomInButton)

        self.setLayout(layout)

        # create connections
        self._zoomSlider.valueChanged.connect(self.emitZoomAmountChanged)
        self._zoomInButton.clicked.connect(self.zoomIn)
        self._zoomOutButton.clicked.connect(self.zoomOut)
Esempio n. 4
0
    def __init__(self, *args):
        PluginBase.__init__(self, BrickletLinearPoti, *args)
        
        self.lp = self.device

        self.cbe_position = CallbackEmulator(self.lp.get_position,
                                             self.cb_position,
                                             self.increase_error_count)

        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)
        
        self.position_label = PositionLabel('Position: ')
        
        self.current_value = None

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)
        
        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
Esempio n. 5
0
class LinearPoti(PluginBase):
    qtcb_position = pyqtSignal(int)

    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.lp = bricklet_linear_poti.LinearPoti(self.uid)
        self.ipcon.add_device(self.lp)
        self.version = ".".join(map(str, self.lp.get_version()[1]))

        self.qtcb_position.connect(self.cb_position)
        self.lp.register_callback(self.lp.CALLBACK_POSITION, self.qtcb_position.emit)

        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)

        self.position_label = PositionLabel("Position: ")

        self.current_value = 0
        plot_list = [["", Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget("Position", plot_list)

        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)

    def start(self):
        try:
            self.cb_position(self.lp.get_position())
            self.lp.set_position_callback_period(20)
        except ip_connection.Error:
            return

        self.plot_widget.stop = False

    def stop(self):
        try:
            self.lp.set_position_callback_period(0)
        except ip_connection.Error:
            pass

        self.plot_widget.stop = True

    @staticmethod
    def has_name(name):
        return "Linear Poti Bricklet" in name

    def get_current_value(self):
        return self.current_value

    def cb_position(self, position):
        self.current_value = position
        self.slider.setValue(position)
        self.position_label.setText(str(position))
Esempio n. 6
0
    def __init__(self, dockwidget):
        super(Widget, self).__init__(dockwidget)
        self._document = None
        self._fileSelector = QComboBox(editable=True, insertPolicy=QComboBox.NoInsert)
        widgets.drag.ComboDrag(self._fileSelector).role = Qt.UserRole
        self._fileSelector.lineEdit().setReadOnly(True)
        self._fileSelector.lineEdit().setFocusPolicy(Qt.NoFocus)
        self._stopButton = QToolButton()
        self._playButton = QToolButton()
        self._timeSlider = QSlider(Qt.Horizontal, tracking=False,
            singleStep=500, pageStep=5000, invertedControls=True)
        self._display = Display()
        self._tempoFactor = QSlider(Qt.Vertical, minimum=-50, maximum=50,
            singleStep=1, pageStep=5)
        
        grid = QGridLayout(spacing=0)
        self.setLayout(grid)
        
        grid.addWidget(self._fileSelector, 0, 0, 1, 3)
        grid.addWidget(self._stopButton, 1, 0)
        grid.addWidget(self._playButton, 1, 1)
        grid.addWidget(self._timeSlider, 1, 2)
        grid.addWidget(self._display, 2, 0, 1, 3)
        grid.addWidget(self._tempoFactor, 0, 3, 3, 1)
        
        # size policy of combo
        p = self._fileSelector.sizePolicy()
        p.setHorizontalPolicy(QSizePolicy.Ignored)
        self._fileSelector.setSizePolicy(p)
        
        # size policy of combo popup
        p = self._fileSelector.view().sizePolicy()
        p.setHorizontalPolicy(QSizePolicy.MinimumExpanding)
        self._fileSelector.view().setSizePolicy(p)

        self._player = player.Player()
        self._outputCloseTimer = QTimer(interval=60000, singleShot=True,
            timeout=self.closeOutput)
        self._timeSliderTicker = QTimer(interval=200, timeout=self.updateTimeSlider)
        self._fileSelector.activated[int].connect(self.slotFileSelected)
        self._tempoFactor.valueChanged.connect(self.slotTempoChanged)
        self._timeSlider.valueChanged.connect(self.slotTimeSliderChanged)
        self._timeSlider.sliderMoved.connect(self.slotTimeSliderMoved)
        self._player.beat.connect(self.updateDisplayBeat)
        self._player.time.connect(self.updateDisplayTime)
        self._player.stateChanged.connect(self.slotPlayerStateChanged)
        self.slotPlayerStateChanged(False)
        dockwidget.mainwindow().currentDocumentChanged.connect(self.loadResults)
        app.documentLoaded.connect(self.slotUpdatedFiles)
        app.jobFinished.connect(self.slotUpdatedFiles)
        app.aboutToQuit.connect(self.stop)
        midihub.aboutToRestart.connect(self.slotAboutToRestart)
        midihub.settingsChanged.connect(self.clearMidiSettings, -100)
        midihub.settingsChanged.connect(self.readMidiSettings)
        app.documentClosed.connect(self.slotDocumentClosed)
        app.translateUI(self)
        self.readMidiSettings()
        d = dockwidget.mainwindow().currentDocument()
        if d:
            self.loadResults(d)
Esempio n. 7
0
def kinect_simulator(qapp_args=None):
    from PyQt4.QtGui import (
                             QApplication,
                             QWidget, QSpinBox, QHBoxLayout,
                             QSlider, QPushButton)
    import json
    import zmq
    ctx = zmq.Context()
    socket = ctx.socket(zmq.PUB)
    socket.bind(DIRECCION_PUBLICADOR)

    slider1, slider2 = None, None
    if not qapp_args:
        qapp_args = []
    def value_changed(value):
        data = {'mouseX': slider1.value(), 'mouseY': slider2.value()}
        message = json.dumps(data)
        socket.send(message)

    app = QApplication(qapp_args)
    win = QWidget()
    win.setWindowTitle("Send events to kinect")
    layout = QHBoxLayout()
    slider1 = QSlider()
    slider1.setMaximum(1000)
    layout.addWidget(slider1)
    slider2 = QSlider()
    slider1.setMaximum(1000)
    layout.addWidget(slider2)
    slider1.valueChanged[int].connect(value_changed)
    slider2.valueChanged[int].connect(value_changed)
    win.setLayout(layout)
    win.show()

    return app.exec_()
Esempio n. 8
0
    def _clickSeeker(self, event):
        self.seeker.setValue(self.seeker.minimum() + ((self.seeker.maximum()-self.seeker.minimum()) *
                             event.x()) / self.seeker.width())
        event.accept()
        self.config.g2tsg.set_perc_tanooki(self.seeker.sliderPosition())

        QSlider.mousePressEvent(self.seeker, event)
Esempio n. 9
0
    def __init__(self, parent):
        QtGui.QMainWindow.__init__(self, parent)

        self.workSpace = Workspace()

        #  get the status bar to show messages to the user
        self.statusbar = self.statusBar()
        self.statusbar.setSizeGripEnabled(False)

        # action groups of common actions for sound lab window
        self.play_record_actions        = QActionGroup(self)
        self.widgets_visibility_actions = QActionGroup(self)
        self.zoom_actions               = QActionGroup(self)
        self.tools_actions              = QActionGroup(self)
        self.save_images_actions        = QActionGroup(self)

        # play volume bar (disabled for now)
        self.volume_bar = QSlider(QtCore.Qt.Horizontal)
        self.volume_bar.setToolTip(self.tr(u"Volume bar for Play."))
        self.volume_bar.setMaximumWidth(100)
        self.volume_bar.setRange(0, 300)
        self.volume_bar.setValue(100)
        self.volume_bar.valueChanged.connect(self.change_volume)

        # text edit for the signal name on the toolbar
        self.signalNameLineEdit = QtGui.QLineEdit(self)
        self.signalNameLineEdit.setToolTip(self.tr(u"Signal name."))
        self.signalNameLineEdit.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum))

        self.signalPropertiesTextLabel = QtGui.QLabel(self)
        self.signalPropertiesTextLabel.setToolTip(self.tr(u"Signal properties."))
        self.signalPropertiesTextLabel.setAlignment(QtCore.Qt.AlignRight)
        self.signalPropertiesTextLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                                                       QtGui.QSizePolicy.Minimum))
Esempio n. 10
0
    def __init__(
        self,
        parent=None,
        value=1.,
        limits=[0.001, 1000],
        orientation=Qt.Horizontal,
    ):
        QWidget.__init__(self, parent)

        self._val = None
        self.limits = limits

        if orientation == Qt.Horizontal:
            self.mainlayout = QHBoxLayout()
        else:
            self.mainlayout = QVBoxLayout()
        self.setLayout(self.mainlayout)

        #~ self.spinbox = QDoubleSpinBox(decimals = 4, singleStep = .1,
        #~ minimum = self.limits[0], maximum = self.limits[1])
        self.spinbox = pg.SpinBox(decimals=4,
                                  singleStep=.1,
                                  minimum=self.limits[0],
                                  maximum=self.limits[1])
        self.mainlayout.addWidget(self.spinbox)
        self.slider = QSlider(Qt.Horizontal, minimum=0, maximum=100)
        self.mainlayout.addWidget(self.slider)
        self.slider.setMinimumWidth(20)

        self.spinbox.valueChanged.connect(self.spinbox_changed)
        self.slider.valueChanged.connect(self.slider_changed)
        self.setValue(value)
Esempio n. 11
0
 def __init__(self, parent=None):
     # Create our main layout for picking duration and such
     super(MainForm, self).__init__(parent)
     self.setWindowTitle("SelfRestraint")
     # Create widgets such as buttons and slider
     self.editButton  = QPushButton("Edit Blocklist")
     self.startButton = QPushButton("Start")
     self.timeSlider  = QSlider(Qt.Horizontal)
     self.timeLabel   = QLabel('Disabled')
     # Disable start button
     self.startButton.setEnabled(False)
     # Mess with the slider
     self.timeSlider.setTickPosition(QSlider.TicksBelow)
     self.timeSlider.setTickInterval(1)
     # Edit button widths
     self.startButton.setFixedWidth(90)
     self.editButton.setFixedWidth(120)
     self.setFixedSize(600, 150)
     # Create another layout to hold bottom contents
     bottomRow = QHBoxLayout()
     layout = QVBoxLayout()
     # Add to the layout
     layout.addWidget(self.startButton, 0, Qt.AlignHCenter)
     layout.addWidget(self.timeSlider)
     bottomRow.addWidget(self.timeLabel)
     bottomRow.addWidget(self.editButton, 0, Qt.AlignRight)
     layout.addLayout(bottomRow)
     # Set layout
     self.setLayout(layout)
     # Link functions to button and slider
     self.startButton.clicked.connect(backend.startBlock)
     self.timeSlider.valueChanged.connect(self.change)
     self.editButton.clicked.connect(self.openList)
Esempio n. 12
0
 def create_widgets(self, parent, refresh_callback):
     self._refresh_callback = refresh_callback
     self.prefix_label = QLabel()
     font = self.prefix_label.font()
     font.setPointSize(font.pointSize() + self._size_offset)
     self.prefix_label.setFont(font)
     self.button = QPushButton()
     self.button.setIcon(get_icon('settings.png'))
     self.button.setToolTip(
         _("Edit '%s' fit parameter properties") % self.name)
     QObject.connect(self.button, SIGNAL('clicked()'),
                     lambda: self.edit_param(parent))
     self.lineedit = QLineEdit()
     QObject.connect(self.lineedit, SIGNAL('editingFinished()'),
                     self.line_editing_finished)
     self.unit_label = QLabel(self.unit)
     self.slider = QSlider()
     self.slider.setOrientation(Qt.Horizontal)
     self.slider.setRange(0, self.steps - 1)
     QObject.connect(self.slider, SIGNAL("valueChanged(int)"),
                     self.slider_value_changed)
     self.update(refresh=False)
     self.add_widgets([
         self.prefix_label, self.lineedit, self.unit_label, self.slider,
         self.button
     ])
Esempio n. 13
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.lp = bricklet_linear_poti.LinearPoti(self.uid)
        self.ipcon.add_device(self.lp)
        self.version = '.'.join(map(str, self.lp.get_version()[1]))

        self.qtcb_position.connect(self.cb_position)
        self.lp.register_callback(self.lp.CALLBACK_POSITION,
                                  self.qtcb_position.emit)

        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)

        self.position_label = PositionLabel('Position: ')

        self.current_value = 0
        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)

        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
Esempio n. 14
0
    def __init__(self, page):
        super(MusicView, self).__init__(page)
        
        layout = QGridLayout()
        self.setLayout(layout)

        self.magnifierSizeLabel = QLabel()
        self.magnifierSizeSlider = QSlider(Qt.Horizontal, valueChanged=self.changed)
        self.magnifierSizeSlider.setSingleStep(50)
        self.magnifierSizeSlider.setRange(*popplerview.MagnifierSettings.sizeRange)
        self.magnifierSizeSpinBox = QSpinBox()
        self.magnifierSizeSpinBox.setRange(*popplerview.MagnifierSettings.sizeRange)
        self.magnifierSizeSpinBox.valueChanged.connect(self.magnifierSizeSlider.setValue)
        self.magnifierSizeSlider.valueChanged.connect(self.magnifierSizeSpinBox.setValue)
        layout.addWidget(self.magnifierSizeLabel, 0, 0)
        layout.addWidget(self.magnifierSizeSlider, 0, 1)
        layout.addWidget(self.magnifierSizeSpinBox, 0, 2)
        
        self.magnifierScaleLabel = QLabel()
        self.magnifierScaleSlider = QSlider(Qt.Horizontal, valueChanged=self.changed)
        self.magnifierScaleSlider.setSingleStep(50)
        self.magnifierScaleSlider.setRange(*popplerview.MagnifierSettings.scaleRange)
        self.magnifierScaleSpinBox = QSpinBox()
        self.magnifierScaleSpinBox.setRange(*popplerview.MagnifierSettings.scaleRange)
        self.magnifierScaleSpinBox.valueChanged.connect(self.magnifierScaleSlider.setValue)
        self.magnifierScaleSlider.valueChanged.connect(self.magnifierScaleSpinBox.setValue)
        layout.addWidget(self.magnifierScaleLabel, 1, 0)
        layout.addWidget(self.magnifierScaleSlider, 1, 1)
        layout.addWidget(self.magnifierScaleSpinBox, 1, 2)
        
        app.translateUI(self)
Esempio n. 15
0
    def drawSpan(self, painter, rect):
        opt = QStyleOptionSlider()
        QSlider.initStyleOption(self, opt)

        # area
        groove = self.style().subControlRect(QStyle.CC_Slider, opt,
                                             QStyle.SC_SliderGroove, self)
        if opt.orientation == QtCore.Qt.Horizontal:
            groove.adjust(0, 0, -1, 0)
        else:
            groove.adjust(0, 0, 0, -1)

        # pen & brush
        painter.setPen(QPen(self.gradientLeftColor, 0))
        if opt.orientation == QtCore.Qt.Horizontal:
            self.setupPainter(painter, opt.orientation,
                              groove.center().x(), groove.top(),
                              groove.center().x(), groove.bottom())
        else:
            self.setupPainter(painter, opt.orientation, groove.left(),
                              groove.center().y(), groove.right(),
                              groove.center().y())

        # draw groove
        intersected = QtCore.QRectF(rect.intersected(groove))
        gradient = QLinearGradient(intersected.topLeft(),
                                   intersected.topRight())
        gradient.setColorAt(0, self.gradientLeft)
        gradient.setColorAt(1, self.gradientRight)
        painter.fillRect(intersected, gradient)
Esempio n. 16
0
    def __init__(self, name, a, b, callback):
        QWidget.__init__(self)
        self.name = name
        self.callback = callback
        self.a = a
        self.b = b
        self.manually_triggered = False

        self.slider = QSlider()
        self.slider.setRange(0, 1000)
        self.slider.setValue(500)
        self.slider.valueChanged.connect(self.slider_changed)

        self.name_label = QLabel()
        self.name_label.setText(self.name)
        self.name_label.setAlignment(QtCore.Qt.AlignCenter)

        self.value_label = QLabel()
        self.value_label.setText('%2.2f' % (self.slider.value() * self.a + self.b))
        self.value_label.setAlignment(QtCore.Qt.AlignCenter)

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.name_label, 0, 0)
        self.layout.addWidget(self.slider, 1, 0, QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.value_label, 2, 0)
Esempio n. 17
0
 def __init__(self, observed, prop, orientation=Qt.Vertical, parent=None):
     QSlider.__init__(self, orientation, parent)
     # TODO still not happy here
     self.getter = lambda: prop.fget(observed)
     self.setter = lambda x: prop.fset(observed, x)
     observed.register(self.update)
     self.setValue(self.getter())
     self.connect(self, SIGNAL('valueChanged(int)'), self.setter)
Esempio n. 18
0
class LinearPoti(PluginBase):
    qtcb_position = pyqtSignal(int)
    
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Linear Poti Bricklet', version)
        
        self.lp = BrickletLinearPoti(uid, ipcon)
        
        self.qtcb_position.connect(self.cb_position)
        self.lp.register_callback(self.lp.CALLBACK_POSITION,
                                  self.qtcb_position.emit) 
        
        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)
        
        self.position_label = PositionLabel('Position: ')
        
        self.current_value = None

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)
        
        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
        
    def start(self):
        async_call(self.lp.get_position, None, self.cb_position, self.increase_error_count)
        
        async_call(self.lp.set_position_callback_period, 20, None, self.increase_error_count)
        
        self.plot_widget.stop = False
        
    def stop(self):
        async_call(self.lp.set_position_callback_period, 0, None, self.increase_error_count)
        
        self.plot_widget.stop = True

    def get_url_part(self):
        return 'linear_poti'

    @staticmethod
    def has_device_identifier(device_identifier):
        return device_identifier == BrickletLinearPoti.DEVICE_IDENTIFIER

    def get_current_value(self):
        return self.current_value

    def cb_position(self, position):
        self.current_value = position
        self.slider.setValue(position)
        self.position_label.setText(str(position))
Esempio n. 19
0
class LinearPoti(PluginBase):
    def __init__(self, *args):
        PluginBase.__init__(self, BrickletLinearPoti, *args)
        
        self.lp = self.device

        self.cbe_position = CallbackEmulator(self.lp.get_position,
                                             self.cb_position,
                                             self.increase_error_count)

        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)
        
        self.position_label = PositionLabel('Position: ')
        
        self.current_value = None

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)
        
        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
        
    def start(self):
        async_call(self.lp.get_position, None, self.cb_position, self.increase_error_count)
        self.cbe_position.set_period(25)
        
        self.plot_widget.stop = False
        
    def stop(self):
        self.cbe_position.set_period(0)
        
        self.plot_widget.stop = True

    def destroy(self):
        pass

    def get_url_part(self):
        return 'linear_poti'

    @staticmethod
    def has_device_identifier(device_identifier):
        return device_identifier == BrickletLinearPoti.DEVICE_IDENTIFIER

    def get_current_value(self):
        return self.current_value

    def cb_position(self, position):
        self.current_value = position
        self.slider.setValue(position)
        self.position_label.setText(str(position))
Esempio n. 20
0
 def __init__(self, observed, prop,
              orientation=Qt.Vertical, parent=None):
     QSlider.__init__(self, orientation, parent)
     # TODO still not happy here
     self.getter = lambda: prop.fget(observed)
     self.setter = lambda x: prop.fset(observed, x)
     observed.register(self.update)
     self.setValue(self.getter())
     self.connect(self, SIGNAL('valueChanged(int)'), self.setter)
Esempio n. 21
0
    def _clickVolume(self, event):
        self.volume.setValue(self.volume.minimum() +
                            ((self.volume.maximum()-self.volume.minimum()) * (self.volume.height() - event.y()))
                             / self.volume.height())
        event.accept()
        vol = self.volume.sliderPosition()/100.0
        self.config.g2tsg.set_volume_tanooki(vol)

        QSlider.mousePressEvent(self.volume, event)
Esempio n. 22
0
 def __init__(self):
     QWidget.__init__(self)
     self.setFixedSize(200, 120)
     lcd = QLCDNumber(self)
     lcd.setSegmentStyle(QLCDNumber.Flat)
     lcd.move(60, 20)
     slider = QSlider(Qt.Horizontal, self)
     slider.setGeometry(10, 70, 150, 20)
     qApp = QCoreApplication.instance()
     self.connect(slider, SIGNAL("valueChanged(int)"), lcd, SLOT("display(int)"))
Esempio n. 23
0
   def mousePressEvent(self, event):
      if event.button() == Qt.LeftButton:
         if self.orientation == Qt.Vertical:
            self.setValue(self.minimum() + ((self.maximum() - self.minimum()) * (self.height() - event.y())) / self.height() )
         else:
            self.setValue(self.minimum() + ((self.maximum() - self.minimum()) * event.x()) / self.width()) 
         event.accept

      self.clicked.emit()
      QSlider.mousePressEvent(self, event)
Esempio n. 24
0
    def __init__(self):
        QMainWindow.__init__(self)
        layout = QGridLayout(self)
        layout.setMargin(2)
        btnFiles = QPushButton(u'Файлы', self)
        btnVideo = QPushButton(u'Видео', self)
        btnPlay = QPushButton(u'Play/Pause', self)
        btnStop = QPushButton(u'Stop', self)
        btnMute = QPushButton(u'Mute', self)
        btnMute.setCheckable(True)
        btnMainMenu = QPushButton(u'Main', self)
        self.sldVolume = QSlider(Qt.Vertical, self)
        self.sldPosition = QSlider(Qt.Horizontal, self)
        self.layMain = QStackedLayout()
        
        btnFiles.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        btnVideo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        btnPlay.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        btnStop.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        btnMute.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        btnMainMenu.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.sldVolume.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.sldPosition.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        layout.addWidget(btnFiles, 0, 0)
        layout.addWidget(btnVideo, 0, 1)
        layout.addWidget(btnPlay, 0, 3)
        layout.addWidget(btnStop, 0, 4)
        layout.addWidget(btnMute, 0, 5)
        layout.addWidget(btnMainMenu, 2, 5)
        layout.addWidget(self.sldVolume, 1, 5)
        layout.addWidget(self.sldPosition, 2, 0, 1, 5)
        layout.addLayout(self.layMain, 1, 0, 1, 5)
        
        fileBrowser = CFileBrowser(self)
        self.videoWidget = QWidget(self)
        self.exitMenu = CExitMenu(self)
        self.mplayer = MPlayerControl(self, self.videoWidget)
        
        fileBrowser.chosen.connect(self.startPlay)
        btnFiles.clicked.connect(lambda: self.selectMode(0))
        btnVideo.clicked.connect(lambda: self.selectMode(1))
        btnMainMenu.clicked.connect(lambda: self.selectMode(2))
        self.sldPosition.valueChanged.connect(self.mplayer.seek)
        self.sldVolume.valueChanged.connect(self.mplayer.setvol)
        btnMute.clicked.connect(lambda: self.mplayer.mute(btnMute.isChecked()))
        btnPlay.clicked.connect(self.mplayer.play)
        btnStop.clicked.connect(self.mplayer.stop)
        self.sldVolume.setValue(QtGui.qApp.settings['volume'])
        self.mplayer.percent_position.connect(self.on_mplayer_position)
        
        self.layMain.addWidget(fileBrowser)
        self.layMain.addWidget(self.videoWidget)
        self.layMain.addWidget(self.exitMenu)
Esempio n. 25
0
def metronome():
    import os, sys, time
    from PyQt4.QtCore import SIGNAL
    from PyQt4.QtGui import QApplication, QPushButton, QSlider, QWidget
    from PyQt4.QtGui import QHBoxLayout
    import scsynth
    import synths
    
    app = QApplication(sys.argv)
    server = scsynth.server.start(verbose=True)
    #server = scsynth.server.connect()
    engine = Engine(server, app)
    server.sendMsg('/dumpOSC', 1)
    engine.tempoclock.set_tempo(120)

    SYNTHDEF_PATH = os.path.join(os.path.expanduser('~'),
                                 '.pksampler', 'synthdefs')
    SYNTHDEFS = ('JASStereoSamplePlayer.scsyndef',
                 'JASSine.scsyndef',
                 )
    for fname in SYNTHDEFS:
        engine.server.sendMsg('/d_load', os.path.join(SYNTHDEF_PATH, fname))
    
    CLICK = '/Users/patrick/.pksampler/clicks/click_1.wav'
    engine.loader.load(CLICK)
    time.sleep(.1)

    notes = [scsynth.Note(i, i+16, 69) for i in (0, )]
    pattern = scsynth.Pattern(notes)
    pattern.beats = 1
    stream = engine.register(synths.Sine(), pattern)
    stream.loop(True)
    engine.start()

    widget = QWidget()
    Layout = QHBoxLayout(widget)
    widget.resize(100, 250)
    widget.show()
    
    def set_tempo(value):
        engine.tempoclock.set_tempo(value)
    slider = QSlider(widget)
    slider.setRange(100, 180)
    slider.setValue(140)
    QObject.connect(slider, SIGNAL('valueChanged(int)'), set_tempo)
    Layout.addWidget(slider)

    button = QPushButton('quit', widget)
    QObject.connect(button, SIGNAL('clicked()'), app.quit)
    Layout.addWidget(button)
    
    app.exec_()
    engine.stop()
Esempio n. 26
0
    def __init__(self, sliderOrientation=None):
        super(QCustomSlider, self).__init__()
        self._slider = QSlider(sliderOrientation)

        self.setLayout(QVBoxLayout())

        self._labelTicksWidget = QWidget(self)
        self._labelTicksWidget.setLayout(QHBoxLayout())
        self._labelTicksWidget.layout().setContentsMargins(0, 0, 0, 0)

        self.layout().addWidget(self._slider)
        self.layout().addWidget(self._labelTicksWidget)
Esempio n. 27
0
class Window(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.main_layout = QGridLayout()

        self.steps_spin = QSpinBox()
        self.steps_spin.setRange(1, 12)
        self.steps_label = QLabel("steps:")
        self.steps_slider = QSlider(1)  #horizontal
        self.steps_slider.setRange(1, 12)

        self.smooth_spin = QSpinBox()
        self.smooth_spin.setRange(1, 100)
        self.smooth_label = QLabel("smoothness:")
        self.smooth_slider = QSlider(1)  #horizontal
        self.smooth_slider.setRange(0, 100)
        self.smooth_slider.setSingleStep(1)

        self.dampen_spin = QSpinBox()
        self.dampen_spin.setRange(1, 100)
        self.dampen_label = QLabel("dampening:")
        self.dampen_slider = QSlider(1)  #horizontal
        self.dampen_slider.setRange(0, 100)
        self.dampen_slider.setSingleStep(1)

        self.update_button = QPushButton("update")

        self.view = QGraphicsView()

        self.main_layout.addWidget(self.steps_spin, 0, 0)
        self.main_layout.addWidget(self.steps_label, 0, 1)
        self.main_layout.addWidget(self.steps_slider, 0, 2)

        self.main_layout.addWidget(self.smooth_spin, 1, 0)
        self.main_layout.addWidget(self.smooth_label, 1, 1)
        self.main_layout.addWidget(self.smooth_slider, 1, 2)

        self.main_layout.addWidget(self.dampen_spin, 2, 0)
        self.main_layout.addWidget(self.dampen_label, 2, 1)
        self.main_layout.addWidget(self.dampen_slider, 2, 2)

        self.main_layout.addWidget(self.update_button, 3, 0, 1, 3)

        self.main_layout.addWidget(
            self.view,
            4,
            0,
            1,  #rowSpan
            3)  #columnSpan

        self.setLayout(self.main_layout)
Esempio n. 28
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        layout = QFormLayout()
        self.setLayout(layout)

        self.inputLabel = QLabel("Video Input")
        self.inputLayout = QHBoxLayout()
        self.inputCombobox = QComboBox()
        self.inputSettingsToolButton = QToolButton()
        self.inputSettingsToolButton.setText("Settings")
        configIcon = QIcon.fromTheme("preferences-other")
        self.inputSettingsToolButton.setIcon(configIcon)
        self.inputSettingsToolButton.setSizePolicy(QSizePolicy.Maximum,
                                                   QSizePolicy.Maximum)
        self.inputSettingsToolButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
        self.inputSettingsStack = QStackedWidget()
        blankWidget = QWidget()
        self.inputSettingsStack.addWidget(blankWidget)
        self.inputSettingsStack.addWidget(self.inputSettingsToolButton)
        self.inputLayout.addWidget(self.inputCombobox)
        self.inputLayout.addWidget(self.inputSettingsStack)
        layout.addRow(self.inputLabel, self.inputLayout)

        self.videocolourLabel = QLabel(self.tr("Colour Format"))
        self.videocolourComboBox = QComboBox()
        self.videocolourComboBox.addItem("video/x-raw-rgb")
        self.videocolourComboBox.addItem("video/x-raw-yuv")
        self.videocolourComboBox.setSizePolicy(QSizePolicy.Minimum,
                                               QSizePolicy.Maximum)
        layout.addRow(self.videocolourLabel, self.videocolourComboBox)

        self.framerateLabel = QLabel("Framerate")
        self.framerateLayout = QHBoxLayout()
        self.framerateSlider = QSlider()
        self.framerateSlider.setOrientation(Qt.Horizontal)
        self.framerateSlider.setMinimum(1)
        self.framerateSlider.setMaximum(60)
        self.framerateSpinBox = QSpinBox()
        self.framerateSpinBox.setMinimum(1)
        self.framerateSpinBox.setMaximum(60)
        self.framerateLayout.addWidget(self.framerateSlider)
        self.framerateLayout.addWidget(self.framerateSpinBox)
        layout.addRow(self.framerateLabel, self.framerateLayout)

        self.videoscaleLabel = QLabel("Video Scale")
        self.videoscaleComboBox = QComboBox()
        for scale in resmap:
            self.videoscaleComboBox.addItem(scale)
        self.videoscaleComboBox.setSizePolicy(QSizePolicy.Minimum,
                                              QSizePolicy.Maximum)
        layout.addRow(self.videoscaleLabel, self.videoscaleComboBox)
Esempio n. 29
0
 def __init__(self, parent=None):
     '''
     Constructor
     '''
     QSlider.__init__(self, parent)
     self.setOrientation(QtCore.Qt.Horizontal)
     self.animationType = QEasingCurve.OutExpo
     self.animation = QPropertyAnimation(self, "value")
     self.animation.setDuration(250)
     self.animation.finished.connect(self.animationDone)
     self.resize(85, 50)
     self.clicked.connect(self.changeValue)
     self.setStyleSheet(self.styleKnob + self.styleBkgOFF)
Esempio n. 30
0
    def __setupWidgetsForClippingPlanes(self): 
        self.cpl_xmax_label = QLabel( 'Clipping Plane X' )
        self.cpl_xmax = QSlider(Qt.Horizontal)
        self.cpl_xmax.setRange(-30.000000, -30 + 120 * 0.252) # data set dependent
        # todo - set this with loadable dimensions config file with data

        self.cpl_ymax_label = QLabel( 'Clipping Plane Y' )
        self.cpl_ymax = QSlider(Qt.Horizontal)
        self.cpl_ymax.setRange(-15.000000, -15 + 120 * 0.252)
        
        self.cpl_zmax_label = QLabel( 'Clipping Plane Z' )
        self.cpl_zmax = QSlider(Qt.Horizontal)
        self.cpl_zmax.setRange(-30.000000, -30 + 120 * 0.252)
Esempio n. 31
0
 def __init__(self, parent=None):
     '''
     Constructor
     '''
     QSlider.__init__(self, parent)
     self.setOrientation(QtCore.Qt.Horizontal)
     self.animationType = QEasingCurve.OutExpo
     self.animation = QPropertyAnimation(self, "value")
     self.animation.setDuration(250)
     self.animation.finished.connect(self.animationDone)
     self.resize(85, 50)
     self.clicked.connect(self.changeValue)
     self.setStyleSheet(self.styleKnob + self.styleBkgOFF)
Esempio n. 32
0
    def __init__(self, *args):
        COMCUPluginBase.__init__(self, BrickletMotorizedLinearPoti, *args)

        self.mp = self.device

        self.cbe_position = CallbackEmulator(self.mp.get_position,
                                             self.cb_position,
                                             self.increase_error_count)

        self.current_position = None

        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)
        self.slider.setMinimumWidth(200)
        self.slider.setEnabled(False)

        plots = [('Potentiometer Position', Qt.red, lambda: self.current_position, str)]
        self.plot_widget = PlotWidget('Position', plots, extra_key_widgets=[self.slider],
                                      curve_motion_granularity=40, update_interval=0.025)

        self.motor_slider = QSlider(Qt.Horizontal)
        self.motor_slider.setRange(0, 100)
        self.motor_slider.valueChanged.connect(self.motor_slider_value_changed)
        self.motor_hold_position = QCheckBox("Hold Position")
        self.motor_drive_mode = QComboBox()
        self.motor_drive_mode.addItem('Fast')
        self.motor_drive_mode.addItem('Smooth')
        
        def get_motor_slider_value():
            return self.motor_slider.value()
        
        self.motor_hold_position.stateChanged.connect(lambda x: self.motor_slider_value_changed(get_motor_slider_value()))
        self.motor_drive_mode.currentIndexChanged.connect(lambda x: self.motor_slider_value_changed(get_motor_slider_value()))

        self.motor_position_label = MotorPositionLabel('Motor Target Position:')

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.motor_position_label)
        hlayout.addWidget(self.motor_slider)
        hlayout.addWidget(self.motor_drive_mode)
        hlayout.addWidget(self.motor_hold_position)

        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        layout = QVBoxLayout(self)
        layout.addWidget(self.plot_widget)
        layout.addWidget(line)
        layout.addLayout(hlayout)
class SensitivitySlider(QWidget):
	def __init__(self, obj = None, parent = None):
		QWidget.__init__(self, parent)

		if obj is None : return

		self.layout = QVBoxLayout()

		self.sensitivityLabel = QLabel()
		self.layout.addWidget(self.sensitivityLabel)
		self.sensitivitySlider = QSlider()
		self.sensitivitySlider.setRange(0, 200)
		self.sensitivitySlider.setSingleStep(1)
		self.sensitivitySlider.setOrientation(Qt.Horizontal)
		self.sensitivitySlider.valueChanged[int].connect(self.sensitivityDisplay)
		self.layout.addWidget(self.sensitivitySlider)

		self.setLayout(self.layout)
		if obj.config().hasKey("Sensitivity") :
			data_ = obj.config().readEntry("Sensitivity")
			value, state = data_.toInt()
			if not state : value = 100
		else : value = 100
		self.sensitivitySlider.setValue(value)

	def sensitivityDisplay(self, i = 100):
		if i<100 :
			s = 2 + int(float(100-i)/33)
			self.sensitivityLabel.setText('<b><u>Sensitivity of sliders</u>: 1/%s</b>' % s)
		else :
			s = 1 + int(float(i-100)/25)
			self.sensitivityLabel.setText('<b><u>Sensitivity of sliders</u>: %i</b>' % s)
Esempio n. 34
0
 def __init__(self):
     super(PyGui, self).__init__()
     self.setObjectName('PyGui')
     self.pub = rospy.Publisher("pyqt_topic", String, queue_size=10)
     rospy.init_node('pyqt_gui')
     self.current_value = 0
     my_layout = QHBoxLayout()
     my_btn = QPushButton()
     my_btn.setText("Publisher")
     my_btn.setFixedWidth(130)
     my_btn.clicked.connect(self.publish_topic)
     my_layout.addWidget(my_btn)
     my_layout.addSpacing(50)
     self.my_label = QLabel()
     self.my_label.setFixedWidth(140)
     self.my_label.setText("num: " + str(0))
     self.my_label.setEnabled(False)
     my_layout.addWidget(self.my_label)
     my_slider = QSlider()
     my_slider.setMinimum(0)
     my_slider.setMaximum(99)
     my_slider.setOrientation(Qt.Horizontal)
     my_slider.valueChanged.connect(self.changeValue)
     my_vlay = QVBoxLayout()
     my_vlay.addWidget(my_slider)
     layout = QVBoxLayout()
     layout.addLayout(my_layout)
     layout.addLayout(my_vlay)
     self.setLayout(layout)
Esempio n. 35
0
class IntelligentSlider(QWidget):
    ''' A slider that adds a 'name' attribute and calls a callback
    with 'name' as an argument to the registerd callback.

    This allows you to create large groups of sliders in a loop,
    but still keep track of the individual events

    It also prints a label below the slider.

    The range of the slider is hardcoded from zero - 1000,
    but it supports a conversion factor so you can scale the results'''

    def __init__(self, name, a, b, callback):
        QWidget.__init__(self)
        self.name = name
        self.callback = callback
        self.a = a
        self.b = b
        self.manually_triggered = False

        self.slider = QSlider()
        self.slider.setRange(0, 1000)
        self.slider.setValue(500)
        self.slider.valueChanged.connect(self.slider_changed)

        self.name_label = QLabel()
        self.name_label.setText(self.name)
        self.name_label.setAlignment(QtCore.Qt.AlignCenter)

        self.value_label = QLabel()
        self.value_label.setText('%2.2f' % (self.slider.value() * self.a
                                             + self.b))
        self.value_label.setAlignment(QtCore.Qt.AlignCenter)

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.name_label, 0, 0)
        self.layout.addWidget(self.slider, 1, 0, QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.value_label, 2, 0)

    # bind this to the valueChanged signal of the slider
    def slider_changed(self, val):
        val = self.val()
        self.value_label.setText(str(val)[:4])

        if not self.manually_triggered:
            self.callback(self.name, val)

    def set_conv_fac(self, a, b):
        self.a = a
        self.b = b

    def set_value(self, val):
        self.manually_triggered = True
        self.slider.setValue(int((val - self.b) / self.a))
        self.value_label.setText('%2.2f' % val)
        self.manually_triggered = False

    def val(self):
        return self.slider.value() * self.a + self.b
Esempio n. 36
0
    def __init__(self, parent, sigma):
        QDialog.__init__(self, parent, Qt.FramelessWindowHint)
        
        # init
        # ------------------------------------------------
        self.oldSigma = sigma
        self.sigma = sigma
        self.brushSize = 0
        self.setStyleSheet("background-color:window;")
        # widgets and layouts
        # ------------------------------------------------
        
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        
        labelsLayout =  QHBoxLayout()
        self.labelSigma = QLabel("Sigma: xx")
        self.labelBrushSize = QLabel("BrushSize: xx")
        labelsLayout.addWidget(self.labelSigma)
        labelsLayout.addWidget(self.labelBrushSize)
        self.layout.addLayout(labelsLayout)
        
        self.slider = QSlider(Qt.Horizontal)
        self.slider.setMinimum(1)
        self.slider.setMaximum(100)
        self.slider.sliderMoved.connect(self.on_sliderMoved)
        self.layout.addWidget(self.slider)
        
        self.buttonsLayout = QHBoxLayout()
        self.cancel = QToolButton()
        self.cancel.setText("cancel")
        self.cancel.clicked.connect(self.on_cancelClicked)
        self.buttonsLayout.addWidget(self.cancel)
        
        
        self.ok = QToolButton()
        self.ok.setText("OK")
        self.ok.clicked.connect(self.on_okClicked)
        self.buttonsLayout.addWidget(self.ok)

        self.layout.addLayout(self.buttonsLayout)
        
        self.layout.setContentsMargins(10, 0, 10, 0)
        labelsLayout.setContentsMargins(0, 0, 0, 0)
        self.buttonsLayout.setContentsMargins(0, 0, 0, 0)
        
        self.setlabelSigma()
        self.setLabelBrushSize()
        self.setSliderPosition()
Esempio n. 37
0
    def __init__(self, page):
        super(MusicView, self).__init__(page)

        layout = QGridLayout()
        self.setLayout(layout)

        self.newerFilesOnly = QCheckBox(toggled=self.changed)
        layout.addWidget(self.newerFilesOnly, 0, 0, 1, 3)

        self.magnifierSizeLabel = QLabel()
        self.magnifierSizeSlider = QSlider(Qt.Horizontal,
                                           valueChanged=self.changed)
        self.magnifierSizeSlider.setSingleStep(50)
        self.magnifierSizeSlider.setRange(
            *popplerview.MagnifierSettings.sizeRange)
        self.magnifierSizeSpinBox = QSpinBox()
        self.magnifierSizeSpinBox.setRange(
            *popplerview.MagnifierSettings.sizeRange)
        self.magnifierSizeSpinBox.valueChanged.connect(
            self.magnifierSizeSlider.setValue)
        self.magnifierSizeSlider.valueChanged.connect(
            self.magnifierSizeSpinBox.setValue)
        layout.addWidget(self.magnifierSizeLabel, 1, 0)
        layout.addWidget(self.magnifierSizeSlider, 1, 1)
        layout.addWidget(self.magnifierSizeSpinBox, 1, 2)

        self.magnifierScaleLabel = QLabel()
        self.magnifierScaleSlider = QSlider(Qt.Horizontal,
                                            valueChanged=self.changed)
        self.magnifierScaleSlider.setSingleStep(50)
        self.magnifierScaleSlider.setRange(
            *popplerview.MagnifierSettings.scaleRange)
        self.magnifierScaleSpinBox = QSpinBox()
        self.magnifierScaleSpinBox.setRange(
            *popplerview.MagnifierSettings.scaleRange)
        self.magnifierScaleSpinBox.valueChanged.connect(
            self.magnifierScaleSlider.setValue)
        self.magnifierScaleSlider.valueChanged.connect(
            self.magnifierScaleSpinBox.setValue)
        layout.addWidget(self.magnifierScaleLabel, 2, 0)
        layout.addWidget(self.magnifierScaleSlider, 2, 1)
        layout.addWidget(self.magnifierScaleSpinBox, 2, 2)

        self.enableKineticScrolling = QCheckBox(toggled=self.changed)
        layout.addWidget(self.enableKineticScrolling)
        self.showScrollbars = QCheckBox(toggled=self.changed)
        layout.addWidget(self.showScrollbars)
        app.translateUI(self)
Esempio n. 38
0
class IntelligentSlider(QWidget):
    ''' A slider that adds a 'name' attribute and calls a callback
    with 'name' as an argument to the registerd callback.

    This allows you to create large groups of sliders in a loop,
    but still keep track of the individual events

    It also prints a label below the slider.

    The range of the slider is hardcoded from zero - 1000,
    but it supports a conversion factor so you can scale the results'''

    def __init__(self, name, a, b, callback):
        QWidget.__init__(self)
        self.name = name
        self.callback = callback
        self.a = a
        self.b = b
        self.manually_triggered = False

        self.slider = QSlider()
        self.slider.setRange(0, 1000)
        self.slider.setValue(500)
        self.slider.valueChanged.connect(self.slider_changed)

        self.name_label = QLabel()
        self.name_label.setText(self.name)
        self.name_label.setAlignment(QtCore.Qt.AlignCenter)

        self.value_label = QLabel()
        self.value_label.setText('%2.2f' % (self.slider.value() * self.a + self.b))
        self.value_label.setAlignment(QtCore.Qt.AlignCenter)

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.name_label, 0, 0)
        self.layout.addWidget(self.slider, 1, 0, QtCore.Qt.AlignHCenter)
        self.layout.addWidget(self.value_label, 2, 0)

    # bind this to the valueChanged signal of the slider
    def slider_changed(self, val):
        val = self.val()
        self.value_label.setText(str(val)[:4])

        if not self.manually_triggered:
            self.callback(self.name, val)

    def set_conv_fac(self, a, b):
        self.a = a
        self.b = b

    def set_value(self, val):
        self.manually_triggered = True
        self.slider.setValue(int((val - self.b) / self.a))
        self.value_label.setText('%2.2f' % val)
        self.manually_triggered = False

    def val(self):
        return self.slider.value() * self.a + self.b
Esempio n. 39
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.lp = bricklet_linear_poti.LinearPoti(self.uid)
        self.ipcon.add_device(self.lp)
        self.version = ".".join(map(str, self.lp.get_version()[1]))

        self.qtcb_position.connect(self.cb_position)
        self.lp.register_callback(self.lp.CALLBACK_POSITION, self.qtcb_position.emit)

        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)

        self.position_label = PositionLabel("Position: ")

        self.current_value = 0
        plot_list = [["", Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget("Position", plot_list)

        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
Esempio n. 40
0
    def __init__(self, value=0, parent=None):
        super(okno_podzialu, self).__init__(parent)

        self.aa = str(value)
        self.setWindowTitle("Divide Ringwidth")
        self.resize(150, 80)

        self.s = QSlider(Qt.Horizontal)
        self.s.setMinimum(1)
        self.s.setMaximum(int(self.aa))
        self.wart1 = QLabel("1")
        self.wart2 = QLabel(self.aa)
        self.lab = QLabel("Length = " + self.aa + " [1/100mm]")
        self.ok = QPushButton("OK")
        self.anuluj = QPushButton("Anuluj")

        layout = QGridLayout()
        layout.addWidget(self.wart1, 0, 0)
        layout.addWidget(self.s, 0, 1)
        layout.addWidget(self.wart2, 0, 2)
        layout.addWidget(self.lab, 1, 0, 1, 3)
        layout1 = QHBoxLayout()
        layout1.addWidget(self.ok)
        layout1.addWidget(self.anuluj)
        layout.addLayout(layout1, 2, 0, 1, 3)
        self.setLayout(layout)

        self.connect(self.s, SIGNAL("valueChanged(int)"), self.uaktualnij)
        self.connect(self.anuluj, SIGNAL("clicked()"), self.anulowanie)
        self.connect(self.ok, SIGNAL("clicked()"), self.akceptuj)
Esempio n. 41
0
 def __init__(self, parent=None):
     super(XZoomSlider, self).__init__(parent)
     
     # define the interface
     in_icon  = projexui.resources.find('img/zoom_in.png')
     out_icon = projexui.resources.find('img/zoom_out.png')
     
     self._zoomInButton = QToolButton(self)
     self._zoomInButton.setAutoRaise(True)
     self._zoomInButton.setToolTip('Zoom In')
     self._zoomInButton.setIcon(QIcon(in_icon))
     
     self._zoomOutButton = QToolButton(self)
     self._zoomOutButton.setAutoRaise(True)
     self._zoomOutButton.setToolTip('Zoom Out')
     self._zoomOutButton.setIcon(QIcon(out_icon))
     
     self._zoomSlider = QSlider(Qt.Horizontal, self)
     self._zoomSlider.setRange(10, 100)
     self._zoomSlider.setValue(100)
     
     # define the layout
     layout = QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     layout.addWidget(self._zoomOutButton)
     layout.addWidget(self._zoomSlider)
     layout.addWidget(self._zoomInButton)
     
     self.setLayout(layout)
     
     # create connections
     self._zoomSlider.valueChanged.connect(self.emitZoomAmountChanged)
     self._zoomInButton.clicked.connect(self.zoomIn)
     self._zoomOutButton.clicked.connect(self.zoomOut)
Esempio n. 42
0
 def __init__(self, parent=None):
     """ Init Custom Switch Widget, set Animation and Glow effects """
     QSlider.__init__(self, parent)
     self.setOrientation(Qt.Horizontal)
     self.animationType = QEasingCurve.OutExpo
     self.animation = QPropertyAnimation(self, "value")
     self.animation.setDuration(1000)
     self.animation.finished.connect(self.animationDone)
     self.clicked.connect(self.changeValue)
     self.setStyleSheet(self.style_knob + self.style_off)
     self.glow = QGraphicsDropShadowEffect(self)
     self.glow.setOffset(0)
     self.glow.setBlurRadius(99)
     self.glow.setColor(QColor(99, 255, 255))
     self.setGraphicsEffect(self.glow)
     self.glow.setEnabled(False)
Esempio n. 43
0
 def __init__(self, parent=None):
     # Create our main`layout for picking duration and such
     super(MainForm, self).__init__(parent)
     self.setWindowTitle("SelfRestraint")
     # Create widgets such as buttons and slider
     self.editButton  = QPushButton("Edit Blocklist")
     self.startButton = QPushButton("Start")    
     self.timeSlider  = QSlider(Qt.Horizontal)
     self.timeLabel   = QLabel('Disabled')
     # Disable start button
     self.startButton.setEnabled(False)
     # Mess with the slider
     self.timeSlider.setTickPosition(QSlider.TicksBelow)
     self.timeSlider.setTickInterval(1)
     # Edit button widths
     self.startButton.setFixedWidth(90)
     self.editButton.setFixedWidth(120)
     self.setFixedSize(600,150)
     # Create another layout to hold bottom contents
     bottomRow = QHBoxLayout()
     layout = QVBoxLayout()
     # Add to the layout
     layout.addWidget(self.startButton,0,Qt.AlignHCenter)
     layout.addWidget(self.timeSlider)        
     bottomRow.addWidget(self.timeLabel)
     bottomRow.addWidget(self.editButton,0,Qt.AlignRight)
     layout.addLayout(bottomRow)
     # Set layout
     self.setLayout(layout)
     # Link functions to button and slider
     self.startButton.clicked.connect(backend.startBlock)
     self.timeSlider.valueChanged.connect(self.change)
     self.editButton.clicked.connect(self.openList)
Esempio n. 44
0
 def __init__(self, parent=None):
     """ Init Custom Switch Widget, set Animation and Glow effects """
     QSlider.__init__(self, parent)
     self.setOrientation(Qt.Horizontal)
     self.animationType = QEasingCurve.OutExpo
     self.animation = QPropertyAnimation(self, "value")
     self.animation.setDuration(1000)
     self.animation.finished.connect(self.animationDone)
     self.clicked.connect(self.changeValue)
     self.setStyleSheet(self.style_knob + self.style_off)
     self.glow = QGraphicsDropShadowEffect(self)
     self.glow.setOffset(0)
     self.glow.setBlurRadius(99)
     self.glow.setColor(QColor(99, 255, 255))
     self.setGraphicsEffect(self.glow)
     self.glow.setEnabled(False)
Esempio n. 45
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Linear Poti Bricklet', version)
        
        self.lp = BrickletLinearPoti(uid, ipcon)
        
        self.qtcb_position.connect(self.cb_position)
        self.lp.register_callback(self.lp.CALLBACK_POSITION,
                                  self.qtcb_position.emit) 
        
        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 100)
        
        self.position_label = PositionLabel('Position: ')
        
        self.current_value = None

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)
        
        layout_h = QHBoxLayout()
        layout_h.addStretch()
        layout_h.addWidget(self.position_label)
        layout_h.addWidget(self.slider)
        layout_h.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h)
        layout.addWidget(self.plot_widget)
Esempio n. 46
0
class LabelledSlider(QWidget):
    '''
    This class holds QSlider, budded to QLabel
    This is used only to simplify GUI creation 
    '''
    def __init__(self, labelText=QString(), orientation=Qt.Horizontal,
                 topLeftTuple=LEFT, parent=None):
        super(LabelledSlider, self).__init__(parent)
        
        self.labelText = labelText
        self.slider = QSlider(orientation)
        self.valueChanged = self.slider.valueChanged
        self.label = QLabel(self.labelText + ' ' + str(self.slider.value()))
        self.label.setBuddy(self.slider)
        self.slider.valueChanged.connect(self.sliderMove)
        layout = QBoxLayout(QBoxLayout.LeftToRight
                if topLeftTuple == LEFT else QBoxLayout.TopToBottom)
        layout.addWidget(self.label)
        layout.addWidget(self.slider)
        self.setLayout(layout)
        # Creating links to functions
        self.value = self.slider.value
        self.setValue = self.slider.setValue
        self.setMaximum = self.slider.setMaximum
        self.setMinimum = self.slider.setMinimum
        self.setText = self.label.setText
        self.text = self.label.text
    
    def sliderMove(self, value):
        self.label.setText(self.labelText + ' ' + str(value))
Esempio n. 47
0
 def _create(self, base_frame):
     self.sliders = []
     self.spinboxes = []
     for i in range(len(self.dim_labels)):
         self.sliders.append(QSlider(QtCore.Qt.Horizontal))
         self.sliders[i].setRange(0, self.n_slider_steps[i])
         self.sliders[i].valueChanged.connect(
             partial(self._on_slide, i))
         spinbox = QDoubleSpinBox()
         spinbox.setRange(*self.limits[i])
         spinbox.setDecimals(3)
         spinbox.setSingleStep(0.001)
         self.spinboxes.append(spinbox)
         self.spinboxes[i].valueChanged.connect(
             partial(self._on_pos_edited, i))
     slider_group = QGridLayout()
     slider_group.addWidget(QLabel("Position"),
                            0, 0, 1, 3, QtCore.Qt.AlignCenter)
     slider_group.addWidget(QLabel("Orientation (Euler angles)"),
                            0, 3, 1, 3, QtCore.Qt.AlignCenter)
     for i, slider in enumerate(self.sliders):
         slider_group.addWidget(QLabel(self.dim_labels[i]), 1, i)
         slider_group.addWidget(slider, 2, i)
         slider_group.addWidget(self.spinboxes[i], 3, i)
     slider_groupbox = QGroupBox("Transformation in frame '%s'"
                                 % base_frame)
     slider_groupbox.setLayout(slider_group)
     layout = QHBoxLayout()
     layout.addWidget(slider_groupbox)
     layout.addStretch(1)
     return layout
Esempio n. 48
0
    def __init__(self, parent=None):

        QWidget.__init__(self, parent)

        format = QAudioFormat()
        format.setChannels(1)
        format.setFrequency(22050)
        format.setSampleSize(16)
        format.setCodec("audio/pcm")
        format.setByteOrder(QAudioFormat.LittleEndian)
        format.setSampleType(QAudioFormat.SignedInt)
        self.output = QAudioOutput(format, self)

        self.frequency = 440
        self.volume = 0
        self.buffer = QBuffer()
        self.data = QByteArray()

        self.deviceLineEdit = QLineEdit()
        self.deviceLineEdit.setReadOnly(True)
        self.deviceLineEdit.setText(
            QAudioDeviceInfo.defaultOutputDevice().deviceName())

        self.pitchSlider = QSlider(Qt.Horizontal)
        self.pitchSlider.setMaximum(100)
        self.volumeSlider = QSlider(Qt.Horizontal)
        self.volumeSlider.setMaximum(32767)
        self.volumeSlider.setPageStep(1024)

        self.playButton = QPushButton(self.tr("&Play"))

        self.pitchSlider.valueChanged.connect(self.changeFrequency)
        self.volumeSlider.valueChanged.connect(self.changeVolume)
        self.playButton.clicked.connect(self.play)

        formLayout = QFormLayout()
        formLayout.addRow(self.tr("Device:"), self.deviceLineEdit)
        formLayout.addRow(self.tr("P&itch:"), self.pitchSlider)
        formLayout.addRow(self.tr("&Volume:"), self.volumeSlider)

        buttonLayout = QVBoxLayout()
        buttonLayout.addWidget(self.playButton)
        buttonLayout.addStretch()

        horizontalLayout = QHBoxLayout(self)
        horizontalLayout.addLayout(formLayout)
        horizontalLayout.addLayout(buttonLayout)
Esempio n. 49
0
    def __init__(self, parent = None):

        QWidget.__init__(self, parent)

        format = QAudioFormat()
        format.setChannels(1)
        format.setFrequency(22050)
        format.setSampleSize(16)
        format.setCodec("audio/pcm")
        format.setByteOrder(QAudioFormat.LittleEndian)
        format.setSampleType(QAudioFormat.SignedInt)
        self.output = QAudioOutput(format, self)

        self.frequency = 440
        self.volume = 0
        self.buffer = QBuffer()
        self.data = QByteArray()

        self.deviceLineEdit = QLineEdit()
        self.deviceLineEdit.setReadOnly(True)
        self.deviceLineEdit.setText(QAudioDeviceInfo.defaultOutputDevice().deviceName())

        self.pitchSlider = QSlider(Qt.Horizontal)
        self.pitchSlider.setMaximum(100)
        self.volumeSlider = QSlider(Qt.Horizontal)
        self.volumeSlider.setMaximum(32767)
        self.volumeSlider.setPageStep(1024)

        self.playButton = QPushButton(self.tr("&Play"))

        self.pitchSlider.valueChanged.connect(self.changeFrequency)
        self.volumeSlider.valueChanged.connect(self.changeVolume)
        self.playButton.clicked.connect(self.play)

        formLayout = QFormLayout()
        formLayout.addRow(self.tr("Device:"), self.deviceLineEdit)
        formLayout.addRow(self.tr("P&itch:"), self.pitchSlider)
        formLayout.addRow(self.tr("&Volume:"), self.volumeSlider)

        buttonLayout = QVBoxLayout()
        buttonLayout.addWidget(self.playButton)
        buttonLayout.addStretch()

        horizontalLayout = QHBoxLayout(self)
        horizontalLayout.addLayout(formLayout)
        horizontalLayout.addLayout(buttonLayout)
Esempio n. 50
0
 def setupUi(self):
     """layout the window"""
     self.setContentsMargins(0, 0, 0, 0)
     vlayout = QVBoxLayout(self)
     vlayout.setContentsMargins(0, 0, 0, 0)
     sliderLayout = QHBoxLayout()
     self.kcfg_showShadows = QCheckBox(m18n('Show tile shadows'), self)
     self.kcfg_showShadows.setObjectName('kcfg_showShadows')
     self.kcfg_rearrangeMelds = QCheckBox(
         m18n('Rearrange undisclosed tiles to melds'), self)
     self.kcfg_rearrangeMelds.setObjectName('kcfg_rearrangeMelds')
     self.kcfg_showOnlyPossibleActions = QCheckBox(
         m18n('Show only possible actions'))
     self.kcfg_showOnlyPossibleActions.setObjectName(
         'kcfg_showOnlyPossibleActions')
     self.kcfg_propose = QCheckBox(m18n('Propose what to do'))
     self.kcfg_propose.setObjectName('kcfg_propose')
     self.kcfg_animationSpeed = QSlider(self)
     self.kcfg_animationSpeed.setObjectName('kcfg_animationSpeed')
     self.kcfg_animationSpeed.setOrientation(Qt.Horizontal)
     self.kcfg_animationSpeed.setSingleStep(1)
     lblSpeed = QLabel(m18n('Animation speed:'))
     lblSpeed.setBuddy(self.kcfg_animationSpeed)
     sliderLayout.addWidget(lblSpeed)
     sliderLayout.addWidget(self.kcfg_animationSpeed)
     self.kcfg_useSounds = QCheckBox(m18n('Use sounds if available'), self)
     self.kcfg_useSounds.setObjectName('kcfg_useSounds')
     self.kcfg_uploadVoice = QCheckBox(m18n('Let others hear my voice'),
                                       self)
     self.kcfg_uploadVoice.setObjectName('kcfg_uploadVoice')
     pol = QSizePolicy()
     pol.setHorizontalPolicy(QSizePolicy.Expanding)
     pol.setVerticalPolicy(QSizePolicy.Expanding)
     spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum,
                              QSizePolicy.Expanding)
     vlayout.addWidget(self.kcfg_showShadows)
     vlayout.addWidget(self.kcfg_rearrangeMelds)
     vlayout.addWidget(self.kcfg_showOnlyPossibleActions)
     vlayout.addWidget(self.kcfg_propose)
     vlayout.addWidget(self.kcfg_useSounds)
     vlayout.addWidget(self.kcfg_uploadVoice)
     vlayout.addLayout(sliderLayout)
     vlayout.addItem(spacerItem)
     self.setSizePolicy(pol)
     self.retranslateUi()
Esempio n. 51
0
    def add_parameter(self, name, parameter_data, parameter_change):
        layout = self.frm_parameters.layout()
        qtitle = QLabel(parameter_data[3])
        qslider = QSlider(Qt.Horizontal)
        qmin = QLabel(str(parameter_data[0]))
        qmax = QLabel(str(parameter_data[1]))
        qvalue = QLabel(str(parameter_data[2]))
        qslider.setRange(parameter_data[0], parameter_data[1])
        qslider.setValue(parameter_data[2])
        qtitle.setAlignment(Qt.AlignHCenter)
        qvalue.setAlignment(Qt.AlignHCenter)
        pos = layout.rowCount()
        layout.addWidget(qtitle, pos, 0, 1, 3)
        layout.addWidget(qmin, pos + 1, 0, 1, 1)
        layout.addWidget(qslider, pos + 1, 1, 1, 1)
        layout.addWidget(qmax, pos + 1, 2, 1, 1)
        layout.addWidget(qvalue, pos + 2, 0, 1, 3)

        def value_changed(value):
            v = parameter_change(name, value)
            qvalue.setNum(v)

        qslider.valueChanged.connect(value_changed)
        qslider.setTracking(True)

        self.parameters[name] = qslider
Esempio n. 52
0
 def createMainFrame(self):
     self.mainFrame = QWidget()
     
     self.dpi = 72
     self.fig = Figure((5.0, 2.5), dpi=self.dpi, tight_layout=True)
     self.canvas = FigureCanvasQTAgg(self.fig)
     self.canvas.setParent(self.mainFrame)
     self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     
     self.mpl_toolbar = NavigationToolbar2QTAgg(self.canvas, self.mainFrame)
     
     # Other GUI controls
     # 
     self.channelTextbox = QLineEdit()
     self.channelTextbox.setMinimumWidth(100)
     self.typeTextbox = QLineEdit()
     self.typeTextbox.setMinimumWidth(100)
     self.propertyTextbox = QLineEdit()
     self.propertyTextbox.setMinimumWidth(100)
     #self.connect(self.textbox, SIGNAL('editingFinished ()'), self.on_draw)
     
     self.addPlotButton = QPushButton("Add Plot")
     self.connect(self.addPlotButton, SIGNAL('clicked()'), self.addPlot)
     
     self.mergePlotButton = QPushButton("Reset Data")
     self.connect(self.mergePlotButton, SIGNAL('clicked()'), self.clearPlots)
     
     self.gridCheckBox = QCheckBox("Show Grid")
     self.gridCheckBox.setChecked(False)
     self.connect(self.gridCheckBox, SIGNAL('stateChanged(int)'), self.on_draw)
     
     slider_label = QLabel('Bar width (%):')
     self.slider = QSlider(Qt.Horizontal)
     self.slider.setRange(1, 100)
     self.slider.setValue(20)
     self.slider.setTracking(True)
     self.slider.setTickPosition(QSlider.TicksBothSides)
     self.connect(self.slider, SIGNAL('valueChanged(int)'), self.on_draw)
     
     #
     # Layout with box sizers
     # 
     hbox = QHBoxLayout()
     
     for w in [self.channelTextbox, self.typeTextbox, self.propertyTextbox, 
               self.addPlotButton, self.mergePlotButton, self.gridCheckBox, 
               slider_label, self.slider]:
         hbox.addWidget(w)
         hbox.setAlignment(w, Qt.AlignVCenter)
     
     vbox = QVBoxLayout()
     vbox.addWidget(self.canvas)
     vbox.addWidget(self.mpl_toolbar)
     vbox.addLayout(hbox)
     
     self.mainFrame.setLayout(vbox)
     self.setCentralWidget(self.mainFrame)
Esempio n. 53
0
class MainWindow(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.d_plot = Plot(self)
        self.setCentralWidget(self.d_plot)

        self.toolBar = QToolBar(self)
        self.btnPrint = QToolButton(self.toolBar)
        self.btnPrint.setText("Print")
        self.btnPrint.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.toolBar.addWidget(self.btnPrint)
        #self.btnPrint.clicked.connect(self.d_plot.printPlot() )

        self.toolBar.addSeparator()

        self.toolBar.addWidget(QLabel("Color Map "))
        self.mapBox = QComboBox(self.toolBar)
        self.mapBox.addItem("RGB")
        self.mapBox.addItem("Indexed Colors")
        self.mapBox.addItem("Hue")
        self.mapBox.addItem("Alpha")
        self.mapBox.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.toolBar.addWidget(self.mapBox)
        self.mapBox.currentIndexChanged['int'].connect(self.d_plot.setColorMap)
        self.toolBar.addWidget(QLabel(" Opacity "))
        self.slider = QSlider(Qt.Horizontal)
        self.slider.setRange(0, 255)
        self.slider.setValue(255)
        self.slider.valueChanged['int'].connect(self.d_plot.setAlpha)
        self.toolBar.addWidget(self.slider)
        self.toolBar.addWidget(QLabel("   "))
        self.btnSpectrogram = QCheckBox("Spectrogram", self.toolBar)
        self.toolBar.addWidget(self.btnSpectrogram)
        self.btnSpectrogram.toggled['bool'].connect(
            self.d_plot.showSpectrogram)

        self.btnContour = QCheckBox("Contour", self.toolBar)
        self.toolBar.addWidget(self.btnContour)
        #self.btnContour.toggled['bool'](self.d_plot.showContour )

        self.addToolBar(self.toolBar)

        self.btnSpectrogram.setChecked(True)
        self.btnContour.setChecked(False)
class LabelControlItems(QWidget):
    def __init__(self):
        super(LabelControlItems, self).__init__()
        
        nlabels = 5
        
        self.combobox_labels = QComboBox()
        self.label_label = QLabel("Label: ")
        self.label_text = QLabel("Text: ")
        self.text_label = QLineEdit("Label1")
        self.button_label = QPushButton("On/Off")
        
        self.scale_labelsize = QSlider(Qt.Horizontal)
        self.label_labelsize = QLabel("Label Size")
        self.scale_labelsize.setMinimum(1)
        self.scale_labelsize.setValue(20)
        
        self.button_label.setCheckable(True)
        
        for i in range(nlabels):
            self.combobox_labels.addItem("Label"+str(i+1))
            
        layout = QGridLayout()
        
        layout.addWidget(self.label_label,0,0)
        layout.addWidget(self.combobox_labels,1,0)
        layout.addWidget(self.label_text,0,1)
        layout.addWidget(self.text_label,1,1)
        layout.addWidget(self.button_label,1,2)

        layout.addWidget(self.label_labelsize,0,3)
        layout.addWidget(self.scale_labelsize,1,3)        


            
        
            
        for col, stretch in enumerate((5,5,5,5)):
            layout.setColumnStretch(col, stretch)            
        
        layout.setMargin(5)
        layout.setHorizontalSpacing(5)       
        layout.setVerticalSpacing(0)                  
        self.setLayout(layout)
Esempio n. 55
0
    def __init__(self,
                 caption,
                 default_value,
                 minimum_value=1,
                 maximum_value=60,
                 single_step=1,
                 page_step=6,
                 caption_size=None,
                 unit='',
                 time=False,
                 tooltip=''):
        QWidget.__init__(self)

        self.value = default_value
        self.unit = unit
        self.time = time

        description = QLabel(caption)
        description.setWordWrap(True)
        description.setToolTip(tooltip)
        if caption_size:
            description.setMaximumWidth(caption_size)

        self.slider = QSlider(Qt.Horizontal)
        self.slider.setMaximum(maximum_value)
        self.slider.setMinimum(minimum_value)
        self.slider.setSingleStep(single_step)
        self.slider.setPageStep(page_step)
        self.slider.setToolTip(tooltip)
        #self.slider.setTickInterval(2)
        #self.slider.setTickPosition(QSlider.TicksBelow)
        self.slider.valueChanged.connect(self.__on_change)

        self.value_label = QLabel()

        hbox = QHBoxLayout()
        hbox.addWidget(description)
        hbox.addWidget(self.slider)
        hbox.addWidget(self.value_label)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(5, 0, 5, 0)
        self.slider.setValue(self.value)
        self.__on_change(self.value)
    def __init__(self, volumeProperty, reader, renWin):
        super(ColorEditor, self).__init__()
        self.volumeProperty = volumeProperty
        self.reader = reader
        self.renWin = renWin
        self.setWindowTitle("Color Editor")

        self.colorfunction = self.volumeProperty.GetRGBTransferFunction(0)
        self.npts = self.colorfunction.GetSize()

        self.vScale = [[QSlider(Qt.Horizontal) for i in range(6)]
                       for j in range(self.npts)]
        self.label_value = [[QLabel(" ") for i in range(6)]
                            for j in range(self.npts)]

        label_scaleName = [QLabel() for j in range(6)]
        for j, text in enumerate(
            ("Intensity", "Red", "Green", "Blue", "Midpoint", "Sharpness")):
            label_scaleName[j].setText(text)

        layout = QGridLayout()

        for j in range(6):
            layout.addWidget(label_scaleName[j], 0, 2 * j)

        rmax = self.reader.GetOutput().GetScalarRange(
        )[1] if self.reader.GetOutput().GetScalarRange(
        )[1] > self.colorfunction.GetRange(
        )[1] else self.colorfunction.GetRange()[1]
        rmin = self.reader.GetOutput().GetScalarRange(
        )[0] if self.reader.GetOutput().GetScalarRange(
        )[0] < self.colorfunction.GetRange(
        )[0] else self.colorfunction.GetRange()[0]
        opacityNode = np.empty((6, ))

        for i in range(self.npts):
            self.colorfunction.GetNodeValue(i, opacityNode)
            for j in range(6):
                layout.addWidget(self.label_value[i][j], 2 * i, 2 * j + 1)
                layout.addWidget(self.vScale[i][j], 2 * i + 1, 2 * j, 1, 2)
                if j == 0:
                    self.vScale[i][j].setMinimum(rmin)
                    self.vScale[i][j].setMaximum(rmax)
                    self.vScale[i][j].setValue(opacityNode[j])
                else:
                    self.vScale[i][j].setValue(100 * opacityNode[j])

                self.vScale[i][j].valueChanged.connect(self.updateColor)

        self.updateColor()

        layout.setSpacing(0)
        layout.setHorizontalSpacing(10)
        self.setLayout(layout)
        self.resize(600, 50 * self.npts)
Esempio n. 57
0
class QCustomSlider(QWidget):
    def __init__(self, sliderOrientation=None):
        super(QCustomSlider, self).__init__()
        self._slider = QSlider(sliderOrientation)

        self.setLayout(QVBoxLayout())

        self._labelTicksWidget = QWidget(self)
        self._labelTicksWidget.setLayout(QHBoxLayout())
        self._labelTicksWidget.layout().setContentsMargins(0, 0, 0, 0)

        self.layout().addWidget(self._slider)
        self.layout().addWidget(self._labelTicksWidget)

    def setTickLabels(self, listWithLabels):
        lengthOfList = len(listWithLabels)
        for index, label in enumerate(listWithLabels):
            label = QLabel(str(label))
            label.setContentsMargins(0, 0, 0, 0)
            if index > lengthOfList/3:
                label.setAlignment(QtCore.Qt.AlignCenter)
            if index > 2*lengthOfList/3:
                label.setAlignment(QtCore.Qt.AlignRight)
            self._labelTicksWidget.layout().addWidget(label)

    def setRange(self, mini, maxi):
        self._slider.setRange(mini, maxi)

    def setPageStep(self, value):
        self._slider.setPageStep(value)

    def setTickInterval(self, value):
        self._slider.setTickInterval(value)

    def setTickPosition(self, position):
        self._slider.setTickPosition(position)

    def setValue(self, value):
        self._slider.setValue(value)

    def onValueChangedCall(self, function):
        self._slider.valueChanged.connect(function)