Пример #1
0
 def setPalette(self, palette):
     QFrame.setPalette(self, palette)
     palette = QPalette(palette)
     palette.setColor(QPalette.Window, palette.color(QPalette.Base))
     palette.setColor(QPalette.Background, palette.color(QPalette.Base))
     palette.setColor(QPalette.Foreground, palette.color(QPalette.Base))
     palette.setColor(QPalette.AlternateBase, palette.color(QPalette.Base))
     palette.setColor(QPalette.Button, palette.color(QPalette.Base))
     self.checkbox.setPalette(palette)
     return
Пример #2
0
class MainWindow(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.frmTuner = TunerFrame( self )
        #self.frmTuner.setFrameStyle( QFrame.Panel | QFrame.Raised )

        self.frmAmp = AmpFrame( self )
        self.frmAmp.setFrameStyle( QFrame.Panel | QFrame.Raised )

        self.layout = QVBoxLayout( self )
        #self.layout.setMargin( 0 )
        self.layout.setSpacing( 0 )
        self.layout.addWidget( self.frmTuner )
        self.layout.addWidget( self.frmAmp )

        self.frmTuner.fieldChanged['double'].connect(self.frmAmp.setMaster)

        self.frmTuner.setFreq( 90.0 )

        self.setPalette( QPalette( QColor( 192, 192, 192 ) ) )
        self.updateGradient()

    def resizeEvent(self, QResizeEvent  ):
        # Qt 4.7.1: QGradient.StretchToDeviceMode is buggy on X11
        self.updateGradient()

    def updateGradient(self):
        self.pal = QPalette()

        self.buttonColor = self.pal.color( QPalette.Button )
        self.midLightColor = self.pal.color( QPalette.Midlight )

        #self.gradient = QLinearGradient( rect().topLeft(), rect().topRight() ) FIXME
        self.gradient = QLinearGradient(  )
        self.gradient.setColorAt( 0.0, self.midLightColor )
        self.gradient.setColorAt( 0.7, self.buttonColor )
        self.gradient.setColorAt( 1.0, self.buttonColor )

        self.pal.setBrush( QPalette.Window, self.gradient )
        self.setPalette( self.pal )
Пример #3
0
	def __drawAxes(self, painter):
		"""
		Pozor, tato metoda vracia nove velkosti X a Y pretoze pri kresleni osi
		sa rata aj s velkostou textu ktora je variabilna
		"""

		palette = QPalette()
		penColor = QColor(palette.color(QPalette.WindowText))
		ciara = QPen(penColor)
		pozadieBaseColor = QColor(palette.color(QPalette.Base))
		pozadieMixColor = QColor(90, 150, 250);
		red   = (pozadieBaseColor.red() * 4 + pozadieMixColor.red()) / 5
		green = (pozadieBaseColor.green() * 4 + pozadieMixColor.green()) / 5
		blue  = (pozadieBaseColor.blue() * 4 + pozadieMixColor.blue()) / 5
		pozadieColor = QColor(red, green, blue);
		pozadie = QBrush(pozadieColor)

		painter.setPen(ciara)
		painter.setBrush(pozadie)

		xVelkost = self.width() - (2 * self.__padding)
		yVelkost = self.height() - (2 * self.__padding)
		xOs = self.__calcAxesData(xVelkost, self.__xMedzery, self.__minDay, self.__maxDay)
		yOs = self.__calcAxesData(yVelkost, self.__yMedzery, self.__minPoints, self.__maxPoints)

		xText = self.__convertXData(xOs)
		yText = self.__convertYData(yOs)

		(xxText, xyText) = self.__calcMaxTextSize(self.font(), xText)
		(yxText, yyText) = self.__calcMaxTextSize(self.font(), yText)

		xVelkost = xVelkost - yxText
		yVelkost = yVelkost - xyText

		painter.translate(yxText + 5, 5)
		rect = QRect(0, 0, xVelkost, yVelkost)
		painter.drawRect(rect)

		penColor.setAlpha(60)
		painter.setPen(QPen(penColor))

		for hodnota in yOs:
			y = self.__getYCoord(yVelkost, hodnota)
			painter.drawLine(0, y, xVelkost, y)
		for hodnota in xOs:
			x = self.__getXCoord(xVelkost, hodnota)
			painter.drawLine(x, 0, x, yVelkost)

		painter.setPen(palette.color(QPalette.WindowText))

		for i in range(len(yText)):
			hodnota = yOs[i]
			text = yText[i]
			y = self.__getYCoord(yVelkost, hodnota)
			textRect = QRect(-yxText-3, y - yyText / 2, yxText, yyText)
			painter.drawText(textRect, Qt.AlignRight, text)
		for i in range(len(xText)):
			hodnota = xOs[i]
			text = xText[i]
			x = self.__getXCoord(xVelkost, hodnota)
			textRect = QRect(x - xxText / 2, yVelkost + xyText / 2, xxText, xyText)
			painter.drawText(textRect, Qt.AlignHCenter, text)
		return (xVelkost, yVelkost)
Пример #4
0
    def createUI(self):
        """Make the window interface."""
        self.videoFrame = VLCWidget()
        self.videoFrame.mouseMoved.connect(self.showBar)

        self.currentTime = QtGui.QLabel('--:--')

        self.positionSlider = Slider(Qt.Horizontal)
        self.positionSlider.setToolTip('Position')
        self.positionSlider.setMaximum(1000)
        self.positionSlider.sliderMoved.connect(self.setPosition)

        self.totalTime = QtGui.QLabel('--:--')

        timeLayout = QtGui.QHBoxLayout()
        timeLayout.addWidget(self.currentTime)
        timeLayout.addWidget(self.positionSlider)
        timeLayout.addWidget(self.totalTime)

        tool = QtGui.QToolBar()
        self.playButton = tool.addAction(
            QIcon(ICONS + 'play.png'), 'Play', self.playPause)
        tool.addAction(
            QIcon(ICONS + 'backward.png'), u'Précédent', self.previousEpisode)
        tool.addAction(QIcon(ICONS + 'stop.png'), 'Stop', self.stop)
        tool.addAction(
            QIcon(ICONS + 'forward.png'), 'Suivant', self.nextEpisode)
        tool.addSeparator()

        self.playListBtn = tool.addAction(
            QIcon(ICONS + 'playlist.png'), 'Playlist', self.showPlayList)
        self.playListBtn.setCheckable(True)
        self.autoPlay = tool.addAction(
            QIcon(ICONS + 'reload.png'), 'Activer la lecture automatique')
        self.autoPlay.setCheckable(True)

        self.btnRandom = tool.addAction(
            QIcon(ICONS + 'random.png'),
            u'Jouer aléatoirement un autre épisode')
        self.btnRandom.setCheckable(True)

        toolRight = QtGui.QToolBar()
        self.volumeBtn = toolRight.addAction(
            QIcon(ICONS + 'volume-mute.png'), 'Volume', self.toggleVolume)

        menu = QtGui.QMenu()
        menu.addAction('Ralentir', self.speedDown)
        menu.addAction('Vitesse normale', self.normalSpeed)
        menu.addAction(u'Accélérer', self.speedUp)

        self.toolButton = QtGui.QToolButton()
        self.toolButton.setIcon(QIcon(ICONS + 'speed.png'))
        self.toolButton.setToolTip('Vitesse')
        self.toolButton.setMenu(menu)
        self.toolButton.setPopupMode(QtGui.QToolButton.InstantPopup)
        tool.addWidget(self.toolButton)

        tool.addSeparator()

        self.screenBtn = tool.addAction(
            QIcon(ICONS + 'fullscreen.png'), u'Plein écran', self.fullScreen)
        tool.addAction(
            QIcon(ICONS + 'options.png'), 'Options', self.showOptionsWindow)

        volume = self.mediaPlayer.audio_get_volume()
        self.volumeSlider = QtGui.QSlider(Qt.Horizontal)
        self.volumeSlider.setMaximum(100)
        self.volumeSlider.setValue(volume)
        self.volumeSlider.setToolTip('Volume')
        self.volumeSlider.valueChanged.connect(self.setVolume)
        self.setBtnVolume(volume)

        hButtonBox = QtGui.QHBoxLayout()
        hButtonBox.addWidget(tool)
        hButtonBox.addStretch(1)
        hButtonBox.addWidget(toolRight)
        hButtonBox.addWidget(self.volumeSlider)

        vBoxLayout = QtGui.QVBoxLayout()
        vBoxLayout.addLayout(timeLayout)
        vBoxLayout.addLayout(hButtonBox)

        self.playList = QtGui.QListWidget()
        self.playList.currentRowChanged.connect(self.changeEpisode)
        self.playList.hide()

        palette = QPalette()
        palette.setColor(QPalette.Window, palette.color(QPalette.Window))
        self.currentEpisodeWidget = Episode()
        self.currentEpisodeWidget.setObjectName('currentEpisode')
        self.currentEpisodeWidget.setPalette(palette)
        self.currentEpisodeWidget.setAutoFillBackground(True)
        self.currentEpisodeWidget.hide()

        self.bar = QtGui.QWidget()
        self.bar.setObjectName('tool')
        self.bar.hide()
        self.drawBar()
        self.bar.setLayout(vBoxLayout)

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.videoFrame)
        mainLayout.setContentsMargins(0, 0, 0, 0)

        widget = QtGui.QWidget()
        widget.setLayout(mainLayout)
        self.setCentralWidget(widget)
        self.bar.setParent(widget)
        self.playList.setParent(widget)
        self.currentEpisodeWidget.setParent(widget)

        if sys.platform == "linux2":    # For Linux
            self.mediaPlayer.set_xwindow(self.videoFrame.winId())
        elif sys.platform == "win32":   # For Windows
            self.mediaPlayer.set_hwnd(self.videoFrame.winId())
        elif sys.platform == "darwin":  # For Mac OS
            self.mediaPlayer.set_agl(self.videoFrame.windId())
Пример #5
0
    def createUI(self):
        """Make the window interface."""
        self.videoFrame = VLCWidget()
        self.videoFrame.mouseMoved.connect(self.showBar)

        self.currentTime = QtGui.QLabel('--:--')

        self.positionSlider = Slider(Qt.Horizontal)
        self.positionSlider.setToolTip('Position')
        self.positionSlider.setMaximum(1000)
        self.positionSlider.sliderMoved.connect(self.setPosition)

        self.totalTime = QtGui.QLabel('--:--')

        timeLayout = QtGui.QHBoxLayout()
        timeLayout.addWidget(self.currentTime)
        timeLayout.addWidget(self.positionSlider)
        timeLayout.addWidget(self.totalTime)

        tool = QtGui.QToolBar()
        self.playButton = tool.addAction(QIcon(ICONS + 'play.png'), 'Play',
                                         self.playPause)
        tool.addAction(QIcon(ICONS + 'backward.png'), u'Précédent',
                       self.previousEpisode)
        tool.addAction(QIcon(ICONS + 'stop.png'), 'Stop', self.stop)
        tool.addAction(QIcon(ICONS + 'forward.png'), 'Suivant',
                       self.nextEpisode)
        tool.addSeparator()

        self.playListBtn = tool.addAction(QIcon(ICONS + 'playlist.png'),
                                          'Playlist', self.showPlayList)
        self.playListBtn.setCheckable(True)
        self.autoPlay = tool.addAction(QIcon(ICONS + 'reload.png'),
                                       'Activer la lecture automatique')
        self.autoPlay.setCheckable(True)

        self.btnRandom = tool.addAction(
            QIcon(ICONS + 'random.png'),
            u'Jouer aléatoirement un autre épisode')
        self.btnRandom.setCheckable(True)

        toolRight = QtGui.QToolBar()
        self.volumeBtn = toolRight.addAction(QIcon(ICONS + 'volume-mute.png'),
                                             'Volume', self.toggleVolume)

        menu = QtGui.QMenu()
        menu.addAction('Ralentir', self.speedDown)
        menu.addAction('Vitesse normale', self.normalSpeed)
        menu.addAction(u'Accélérer', self.speedUp)

        self.toolButton = QtGui.QToolButton()
        self.toolButton.setIcon(QIcon(ICONS + 'speed.png'))
        self.toolButton.setToolTip('Vitesse')
        self.toolButton.setMenu(menu)
        self.toolButton.setPopupMode(QtGui.QToolButton.InstantPopup)
        tool.addWidget(self.toolButton)

        tool.addSeparator()

        self.screenBtn = tool.addAction(QIcon(ICONS + 'fullscreen.png'),
                                        u'Plein écran', self.fullScreen)
        tool.addAction(QIcon(ICONS + 'options.png'), 'Options',
                       self.showOptionsWindow)

        volume = self.mediaPlayer.audio_get_volume()
        self.volumeSlider = QtGui.QSlider(Qt.Horizontal)
        self.volumeSlider.setMaximum(100)
        self.volumeSlider.setValue(volume)
        self.volumeSlider.setToolTip('Volume')
        self.volumeSlider.valueChanged.connect(self.setVolume)
        self.setBtnVolume(volume)

        hButtonBox = QtGui.QHBoxLayout()
        hButtonBox.addWidget(tool)
        hButtonBox.addStretch(1)
        hButtonBox.addWidget(toolRight)
        hButtonBox.addWidget(self.volumeSlider)

        vBoxLayout = QtGui.QVBoxLayout()
        vBoxLayout.addLayout(timeLayout)
        vBoxLayout.addLayout(hButtonBox)

        self.playList = QtGui.QListWidget()
        self.playList.currentRowChanged.connect(self.changeEpisode)
        self.playList.hide()

        palette = QPalette()
        palette.setColor(QPalette.Window, palette.color(QPalette.Window))
        self.currentEpisodeWidget = Episode()
        self.currentEpisodeWidget.setObjectName('currentEpisode')
        self.currentEpisodeWidget.setPalette(palette)
        self.currentEpisodeWidget.setAutoFillBackground(True)
        self.currentEpisodeWidget.hide()

        self.bar = QtGui.QWidget()
        self.bar.setObjectName('tool')
        self.bar.hide()
        self.drawBar()
        self.bar.setLayout(vBoxLayout)

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.videoFrame)
        mainLayout.setContentsMargins(0, 0, 0, 0)

        widget = QtGui.QWidget()
        widget.setLayout(mainLayout)
        self.setCentralWidget(widget)
        self.bar.setParent(widget)
        self.playList.setParent(widget)
        self.currentEpisodeWidget.setParent(widget)

        if sys.platform == "linux2":  # For Linux
            self.mediaPlayer.set_xwindow(self.videoFrame.winId())
        elif sys.platform == "win32":  # For Windows
            self.mediaPlayer.set_hwnd(self.videoFrame.winId())
        elif sys.platform == "darwin":  # For Mac OS
            self.mediaPlayer.set_agl(self.videoFrame.windId())