def setupUi(self): toolbar = QtGui.QToolBar() toolbar.addAction(self.playAction) toolbar.addAction(self.pauseAction) toolbar.addAction(self.stopAction) toolbar.addSeparator() toolbar.addAction(self.previousAction) toolbar.addAction(self.nextAction) toolbar.addSeparator() toolbar.addAction(self.sequentialAction) toolbar.addAction(self.shuffleAction) toolbar.addAction(self.repeatAction) self.seekSlider = Phonon.SeekSlider(self) self.seekSlider.setMediaObject(self.mediaObject) self.volumeSlider = Phonon.VolumeSlider(self) self.volumeSlider.setAudioOutput(self.audioOutput) self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkGreen) self.timeLcd = QtGui.QLCDNumber() self.timeLcd.setPalette(palette) headers = (u"Title", u"Artist", u"Album", u"Year") self.musicTable = QtGui.QTableWidget(0, 4) self.musicTable.setHorizontalHeaderLabels(headers) self.musicTable.setSelectionMode( QtGui.QAbstractItemView.SingleSelection) self.musicTable.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.musicTable.cellDoubleClicked.connect(self.tableClicked) seekerLayout = QtGui.QHBoxLayout() seekerLayout.addWidget(self.seekSlider) seekerLayout.addWidget(self.timeLcd) playbackLayout = QtGui.QHBoxLayout() playbackLayout.addWidget(toolbar) playbackLayout.addStretch() playbackLayout.addWidget(self.volumeSlider) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(self.musicTable) mainLayout.addLayout(seekerLayout) mainLayout.addLayout(playbackLayout) main_widget = QtGui.QWidget() main_widget.setLayout(mainLayout) self.setCentralWidget(main_widget) self.setWindowTitle("中文".decode('utf-8')) print "中文1", type("中文1") print "中文1".decode('utf-8'), type("中文1".decode('utf-8'))
def setupMusicGui(self): """ Define all music GUI components :return: Void """ # Define GUI components for 3 basics actions actionBar = QtGui.QToolBar() actionBar.addAction(self.playAction) actionBar.addAction(self.pauseAction) actionBar.addAction(self.stopAction) # Defining seek slider self.seekSlider = Phonon.SeekSlider(self) self.seekSlider.setMediaObject(self.mediaObject) # Defining palette and lcd time palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkGray) self.timeLcd = QtGui.QLCDNumber() self.timeLcd.setPalette(palette) # Defining volume icon and slider volumeLabel = QtGui.QLabel() volumeLabel.setPixmap(QtGui.QPixmap('images/volume.png')) self.volumeSlider = Phonon.VolumeSlider(self) self.volumeSlider.setAudioOutput(self.audioOutput) self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) # Defining seekerLayout which include seek slider and lcd time seekerLayout = QtGui.QHBoxLayout() seekerLayout.addWidget(self.seekSlider) seekerLayout.addWidget(self.timeLcd) # Defining playbackLayout which inlcude seekerLayout and volumeSlider # with icon playbackLayout = QtGui.QHBoxLayout() playbackLayout.addWidget(actionBar) playbackLayout.addStretch() playbackLayout.addWidget(volumeLabel) playbackLayout.addWidget(self.volumeSlider) # Defining mainLayout which include seekerLayout and playbackLayout mainLayout = QtGui.QVBoxLayout() mainLayout.addLayout(seekerLayout) mainLayout.addLayout(playbackLayout) # Defining Player box which include mainLayout box = gui.widgetBox(self.controlArea, 'Player') box.layout().addLayout(mainLayout)
def setupUi(self): bar = QtGui.QToolBar() bar.addAction(self.playAction) bar.addAction(self.pauseAction) bar.addAction(self.stopAction) self.seekSlider = Phonon.SeekSlider(self) self.seekSlider.setMediaObject(self.mediaObject) self.volumeSlider = Phonon.VolumeSlider(self) self.volumeSlider.setAudioOutput(self.audioOutput) self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) volumeLabel = QtGui.QLabel() volumeLabel.setPixmap(QtGui.QPixmap('images/volume.png')) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkGray) self.timeLcd = QtGui.QLCDNumber() self.timeLcd.setPalette(palette) headers = ("Title", "Artist", "Album", "Year") self.musicTable = QtGui.QTableWidget(0, 4) self.musicTable.setHorizontalHeaderLabels(headers) self.musicTable.setSelectionMode( QtGui.QAbstractItemView.SingleSelection) self.musicTable.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.musicTable.cellPressed.connect(self.tableClicked) seekerLayout = QtGui.QHBoxLayout() seekerLayout.addWidget(self.seekSlider) seekerLayout.addWidget(self.timeLcd) playbackLayout = QtGui.QHBoxLayout() playbackLayout.addWidget(bar) playbackLayout.addStretch() playbackLayout.addWidget(volumeLabel) playbackLayout.addWidget(self.volumeSlider) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(self.musicTable) mainLayout.addLayout(seekerLayout) mainLayout.addLayout(playbackLayout) widget = QtGui.QWidget() widget.setLayout(mainLayout) self.setCentralWidget(widget) self.setWindowTitle("Phonon Music Player")
def setupUi2(self): bar = QtGui.QToolBar(self.tab_2) bar.setGeometry(QtCore.QRect(700, 535, 140, 23)) bar.addAction(self.playAction) bar.addAction(self.pauseAction) bar.addAction(self.stopAction) bar.addAction(self.muteAction) self.seekSlider = Phonon.SeekSlider(self.tab_2) self.seekSlider.setGeometry(QtCore.QRect(200, 470, 551, 19)) self.seekSlider.setObjectName(_fromUtf8("seekSlider")) self.seekSlider.setMediaObject(self.mediaObject) self.volumeSlider = Phonon.VolumeSlider(self.tab_2) self.volumeSlider.setGeometry(QtCore.QRect(730, 510, 109, 22)) self.volumeSlider.setObjectName(_fromUtf8("volumeSlider")) self.volumeSlider.setAudioOutput(self.audioOutput) self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum,QtGui.QSizePolicy.Maximum) volumeLabel = QtGui.QLabel() volumeLabel.setPixmap(QtGui.QPixmap('volume.png')) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkGray) self.timeLcd = QtGui.QLCDNumber(self.tab_2) self.timeLcd.setPalette(palette) self.timeLcd.setGeometry(QtCore.QRect(760, 470, 81, 23)) self.timeLcd.setObjectName(_fromUtf8("lcdNumber")) seekerLayout = QtGui.QHBoxLayout() seekerLayout.addWidget(self.seekSlider) seekerLayout.addWidget(self.timeLcd) playbackLayout = QtGui.QHBoxLayout() playbackLayout.addWidget(bar) playbackLayout.addStretch() playbackLayout.addWidget(volumeLabel) playbackLayout.addWidget(self.volumeSlider) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(self.videoWidget) mainLayout.addLayout(seekerLayout) mainLayout.addLayout(playbackLayout)
def setupUi(self): bar = QToolBar() bar.addAction(self.playAction) bar.addAction(self.pauseAction) bar.addAction(self.stopAction) self.seekSlider = Phonon.SeekSlider(self) self.seekSlider.setMediaObject(media) self.volumeSlider = Phonon.VolumeSlider(self) self.volumeSlider.setAudioOutput(audio) self.volumeSlider.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) volumeLabel = QLabel() volumeLabel.setPixmap(QPixmap('images/volume.png')) palette = QPalette() palette.setBrush(QPalette.Light, Qt.darkGray) self.timeLcd = QLCDNumber() self.timeLcd.setPalette(palette) headers = ("Title", "Artist", "Album", "Year") seekerLayout = QHBoxLayout() seekerLayout.addWidget(self.seekSlider) seekerLayout.addWidget(self.timeLcd) playbackLayout = QHBoxLayout() playbackLayout.addWidget(bar) playbackLayout.addStretch() playbackLayout.addWidget(volumeLabel) playbackLayout.addWidget(self.volumeSlider) mainLayout = QVBoxLayout() mainLayout.addWidget(video) mainLayout.addLayout(seekerLayout) mainLayout.addLayout(playbackLayout) self.setLayout(mainLayout)
def __init__(self,window): #参数window为播放器父框对象 reload(sys) sys.setdefaultencoding('utf8') self.window = window self.mediaObject = Phonon.MediaObject(self.window) #实例化一个媒体对象 self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self.window) #实例化音频输出 Phonon.createPath(self.mediaObject, self.audioOutput) #将上面的媒体对象作为音频来源并对接到音频输出 self.mediaObject.stateChanged.connect(self.stateChange) #播放状态改变触发事件 self.mediaObject.finished.connect(self.Finished) #播放状态改变触发事件 #----------加载进度条---------- self.seek = Phonon.SeekSlider(self.mediaObject,window.proWgt) self.seek.setIconVisible(False) # -----------加载音量条---------- self.vlu = Phonon.VolumeSlider (self.audioOutput,window.vluWgt) self.vlu.setMuteVisible(False) self.vlu.setMaximumVolume(1.5) self.vlu.setStyleSheet(""" QSlider::sub-page:horizontal{ background:QLinearGradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 #9EEAFD, stop:0.25 #5FF199, stop:0.5 #5FF199, stop:1 #9EEAFD); } QSlider::add-page:horizontal{background: QLinearGradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 orange, stop:0.25 orange, stop:0.5 orange, stop:1 orange);} """) #----------加载播放列表-------- self.playlist()
def __init__(self, url=None, parent=None): self.url = '' QWidget.__init__(self, parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.player = Phonon.VideoPlayer(Phonon.VideoCategory, self) self.player.setMinimumSize(640, 360) self.player.mediaObject().setTickInterval(100) self.player.mediaObject().tick.connect(self.tock) self.play_pause = QPushButton(self) self.play_pause.setIcon(QIcon(':/play.png')) self.play_pause.released.connect(self.playClicked) self.stop = QPushButton(self) self.stop.setIcon(QIcon(':/stop.png')) self.stop.clicked.connect(self.stopClicked) self.player.mediaObject().stateChanged.connect(self.stateChanged) self.slider = Phonon.SeekSlider(self.player.mediaObject(), self) self.status = QLabel(self) self.status.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.volume = Phonon.VolumeSlider(self.player.audioOutput(), self) topLayout = QVBoxLayout(self) topLayout.addWidget(self.player, 2) layout = QHBoxLayout(self) layout.addWidget(self.play_pause) layout.addWidget(self.stop) layout.addWidget(self.slider, 2) layout.addWidget(self.status) layout.addWidget(self.volume) topLayout.addLayout(layout) self.setLayout(topLayout)
def volumeSlider(self): volumeSlider = Phonon.VolumeSlider(self) volumeSlider.setAudioOutput(self.audioOutput) volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) return volumeSlider
def setupUi(self):#set up music gui self.resize(1123, 759) self.centralwidget = QtGui.QWidget(self) self.fileMenu = self.mainMenu.addMenu('&File') self.fileMenu.addAction(self.FileAction) self.HLayout = QtGui.QHBoxLayout(self) self.tabs = QtGui.QTabWidget()#for tabs in ui self.tabs.setTabBar(FingerTabWidget(width=350,height=50)) self.tabs.setTabPosition(QtGui.QTabWidget.West) styles = """ QTabBar {color: #c2c5c9; font-size: 15px; padding:0px } QTabBar::tab:selected {background: #3c4043; border-left: 4px solid #646a6f; } QTabBar::tab {background: #373b3f; color: white; } """ tabstyle = """ QTableWidget{ padding: 10px 10px 10px 30px; background: #f9f9f9; color: #a5aeb2; selection-color: white; font-size: 15px; margin:0px; } QTableWidget::item{ padding: 15px 0px; color: #a5aeb2; border-top: 1px solid #eeeded; } QTableWidget::item:selected{ color: #646a6f; background: white; border-top: 1px solid #eeeded; } """ tabstyle2 = """ QTableWidget{ padding: 10px 10px 10px 30px; background: #f9f9f9; color: #a5aeb2; selection-color: white; font-size: 15px; margin:0px; } QTableWidget::item{ padding: 15px 0px; color: #a5aeb2; border-top: 1px solid #eeeded; } QTableWidget::item:selected{ color: #646a6f; background: white; border-top: 1px solid #eeeded; } """ self.tabs.setStyleSheet(styles)#style music table self.TLayout = QtGui.QHBoxLayout(self) bar = QtGui.QToolBar()#create music ui buttons bar.addAction(self.playAction) bar.addAction(self.previousAction) bar.addAction(self.stopAction) bar.addAction(self.nextAction) headers = ( "Title", "Artist", "Album", "Year", "Time")#main table header labels self.musicTable = QtGui.QTableWidget(0, 5)#create main music table in ui self.musicTable.setHorizontalHeaderLabels(headers) self.musicTable.setShowGrid(False) self.musicTable.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.musicTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.musicTable.setAutoFillBackground(True) self.musicTable.setAlternatingRowColors(False) self.musicTable.horizontalHeader().setDefaultSectionSize(200) self.musicTable.horizontalHeader().setVisible(False) self.musicTable.verticalHeader().setVisible(False) self.musicTable.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.musicTable.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.musicTable.cellDoubleClicked.connect(self.tableClicked) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.musicTable.sizePolicy().hasHeightForWidth()) self.musicTable.setSizePolicy(sizePolicy) self.musicTable.setStyleSheet(tabstyle) self.musicTable.setContextMenuPolicy(Qt.CustomContextMenu) self.musicTable.customContextMenuRequested.connect(self.popup) self.tabs.addTab(self.musicTable, 'Tracks')#add to tracks tab in ui header = self.musicTable.horizontalHeader()#format music table columns header.setResizeMode(0, QtGui.QHeaderView.Stretch) header.setResizeMode(1, QtGui.QHeaderView.Stretch) header.setResizeMode(2, QtGui.QHeaderView.Stretch) header.setResizeMode(3, QtGui.QHeaderView.Stretch) header.setResizeMode(4, QtGui.QHeaderView.ResizeToContents) self.TLayout.addWidget(self.tabs) self.seekSlider = Phonon.SeekSlider(self)#initialize play slider self.seekSlider.setMediaObject(self.mediaObject) self.seekSlider.setStyleSheet(self.stylesheet()) self.volumeSlider = Phonon.VolumeSlider(self)#volume slider self.volumeSlider.setAudioOutput(self.audioOutput) self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) volumeLabel = QtGui.QLabel() self.pic = QtGui.QLabel(self)#initialize music cover icon in lower ui self.pix = QtGui.QPixmap('img/Musicplayer-256.png') self.pixmap = self.pix self.pixmap2 = self.pixmap.scaled(70,70) self.pic.setPixmap(self.pixmap2) self.pic.setStyleSheet("background: grey") self.pic.mousePressEvent = self.artcover self.nplay = QtGui.QWidget()#initialize now pplaying tab self.nplay.setStyleSheet("background: white;") self.tabs.addTab(self.nplay, 'Now Playing') self.cover_layout = QtGui.QGridLayout() self.cover_layout.setColumnStretch(0, 1) self.cover_layout.setColumnStretch(3, 1) self.cover_layout.setRowStretch(0, 1) self.cover_layout.setRowStretch(3, 1) self.bigpic = QtGui.QLabel(self) self.cover_layout.addWidget(self.bigpic, 1, 1, 2, 2) self.nplay.setLayout(self.cover_layout) self.rectab = QtGui.QWidget() self.rectab.setStyleSheet("background: white;") self.tabs.addTab(self.rectab, 'Recommended') self.mLayout = QtGui.QVBoxLayout(self) head = ( "Title", "Artist", "Album", "Time") self.recTable = QtGui.QTableWidget(0, 4) self.recTable.setHorizontalHeaderLabels(head) self.recTable.setShowGrid(False) self.recTable.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.recTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.recTable.setAutoFillBackground(True) self.recTable.setAlternatingRowColors(False) self.recTable.horizontalHeader().setDefaultSectionSize(200) self.recTable.horizontalHeader().setVisible(False) self.recTable.verticalHeader().setVisible(False) self.recTable.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.recTable.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.recTable.cellDoubleClicked.connect(self.rtableClicked) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.recTable.sizePolicy().hasHeightForWidth()) self.recTable.setSizePolicy(sizePolicy) self.recTable.setStyleSheet(tabstyle2) #self.tabs.addTab(self.recTable, 'Tracks') headr = self.recTable.horizontalHeader() headr.setResizeMode(0, QtGui.QHeaderView.Stretch) headr.setResizeMode(1, QtGui.QHeaderView.Stretch) headr.setResizeMode(2, QtGui.QHeaderView.Stretch) headr.setResizeMode(3, QtGui.QHeaderView.ResizeToContents) self.inLayout = QtGui.QHBoxLayout(self) self.inLayout.addStretch() self.button = QtGui.QPushButton("Recommend", self) self.button.clicked.connect(self.on_clicked) self.inLayout.addWidget(self.button) self.mLayout.addLayout(self.inLayout) self.mLayout.addWidget(self.recTable) self.rectab.setLayout(self.mLayout) self.album1 = QtGui.QWidget()#album tab in ui self.album1.setStyleSheet("background: white;") self.tabs.addTab(self.album1, 'Albums') self.albumLayout = QtGui.QVBoxLayout(self) self.albumGrid = QtGui.QHBoxLayout(self) self.albumList = QtGui.QHBoxLayout(self) self.Xlay = QtGui.QVBoxLayout(self) self.albumLayout.addLayout(self.albumList) self.album1.setLayout(self.albumLayout) head = ( "Title", "Artist", "Album", "Time") self.albumTable = QtGui.QTableWidget(0, 4)#initialize album table self.albumTable.setHorizontalHeaderLabels(head) self.albumTable.setShowGrid(False) self.albumTable.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.albumTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.albumTable.setAutoFillBackground(True) self.albumTable.setAlternatingRowColors(False) self.albumTable.horizontalHeader().setDefaultSectionSize(200) self.albumTable.horizontalHeader().setVisible(False) self.albumTable.verticalHeader().setVisible(False) self.albumTable.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.albumTable.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.albumTable.cellDoubleClicked.connect(self.atableClicked) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.albumTable.sizePolicy().hasHeightForWidth()) self.albumTable.setSizePolicy(sizePolicy) self.albumTable.setStyleSheet(tabstyle2) #self.tabs.addTab(self.albumTable, 'Tracks') headr = self.albumTable.horizontalHeader() headr.setResizeMode(0, QtGui.QHeaderView.Stretch) headr.setResizeMode(1, QtGui.QHeaderView.Stretch) headr.setResizeMode(2, QtGui.QHeaderView.Stretch) headr.setResizeMode(3, QtGui.QHeaderView.ResizeToContents) self.albumGrid.addWidget(self.albumTable) self.scrollArea = QtGui.QScrollArea(self) self.scrollArea.setWidgetResizable(True) self.scrollArea.setFixedHeight(245) self.scrollArea.setStyleSheet("background: grey") self.scrollAreaWidgetContents = QtGui.QWidget(self.scrollArea) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.Xlay.addWidget(self.scrollArea) self.verticalLayoutScroll = QtGui.QGridLayout(self.scrollAreaWidgetContents) self.albumLayout.addWidget(self.scrollArea) self.albumLayout.addLayout(self.albumGrid)#end of album tab in ui bottom = QtGui.QWidget(self)#bottom widget in ui bottom.setStyleSheet("background: #e83c00; margin:0px; padding:0px;") self.title = QtGui.QLabel(" ",self) self.artist = QtGui.QLabel(" ",self) self.title.setStyleSheet("color: #fff; font-size:20px; font-family:Arial;\ border:0px; padding:0px; margin:0px") self.artist.setStyleSheet("color: #fff; font-size:13px; font-family:Arial;\ border:0px; padding:0px; margin:0px") self.title.setFixedWidth(252) self.artist.setFixedWidth(252) square = QtGui.QWidget(self) square.setStyleSheet("background: #373b3f") self.BLayout = QtGui.QHBoxLayout(self) self.KLayout = QtGui.QHBoxLayout(self) square.setLayout(self.KLayout) self.TabLayout = QtGui.QHBoxLayout(self) self.labLayout = QtGui.QVBoxLayout(self) self.labLayout.addWidget(self.title) self.labLayout.addWidget(self.artist) self.KLayout.addLayout(self.TabLayout) self.TabLayout.addWidget(self.pic) self.TabLayout.addLayout(self.labLayout) self.TabLayout.addWidget(self.seekSlider) self.TabLayout.addWidget(bar) self.TabLayout.addWidget(volumeLabel) self.TabLayout.addWidget(self.volumeSlider) self.BLayout.addWidget(square) mainLayout = QtGui.QVBoxLayout() mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.addLayout(self.TLayout) mainLayout.addLayout(self.BLayout) mainLayout.insertSpacing(1,-30) widget = QtGui.QWidget()#add all widgets to main widget widget.setStyleSheet("background: #373b3f") widget.setLayout(mainLayout) widget.setMaximumHeight(1050) widget.resizeEvent = self.onResize self.setCentralWidget(widget)
def __init__(self): QtGui.QWidget.__init__(self) self.media = Phonon.MediaObject(self) #self.media.stateChanged.connect(self.handleStateChanged) self.video = Video(self) self.video.setMinimumSize(800, 600) self.video.doubleClicked.connect(self.toggle_fullscreen) self.video.keyPressed.connect(self.handle_key) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) self.btn_open = QtGui.QPushButton(QtGui.QIcon('icons/video.png'), '') self.btn_open.clicked.connect(self.handle_btn_open) self.btn_play = QtGui.QPushButton(QtGui.QIcon('icons/play.png'), '') self.btn_play.clicked.connect(self.handle_btn_play) self.btn_pause = QtGui.QPushButton(QtGui.QIcon('icons/pause.png'), '') self.btn_pause.clicked.connect(self.handle_btn_pause) self.btn_stop = QtGui.QPushButton(QtGui.QIcon('icons/stop.png'), '') self.btn_stop.clicked.connect(self.handle_btn_stop) self.btn_fullscreen = QtGui.QPushButton( QtGui.QIcon('icons/expand.png'), '') self.btn_fullscreen.clicked.connect(self.handle_btn_fullscreen) cur_time = str(timedelta(seconds=self.media.currentTime() / 1000)) total_time = str(timedelta(seconds=self.media.totalTime() / 1000)) self.lab_cur_time = QtGui.QLabel(cur_time) self.lab_total_time = QtGui.QLabel(total_time) #self.list = QtGui.QListWidget(self) #self.list.addItems(Phonon.BackendCapabilities.availableMimeTypes()) self.slider = Phonon.SeekSlider(self) self.slider.setMediaObject(self.media) self.audio_output = Phonon.AudioOutput(Phonon.MusicCategory) Phonon.createPath(self.media, self.audio_output) self.volumeSlider = Phonon.VolumeSlider() #self.volumeSlider.setAudioOuput(self.audio_output) self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) control_layout = QtGui.QHBoxLayout() control_layout.addWidget(self.btn_open) control_layout.addWidget(self.btn_play) control_layout.addWidget(self.btn_pause) control_layout.addWidget(self.btn_stop) control_layout.addWidget(self.lab_cur_time) control_layout.addWidget(self.slider) control_layout.addWidget(self.lab_total_time) control_layout.addWidget(self.btn_fullscreen) control_layout.addWidget(self.volumeSlider) video_layout = QtGui.QVBoxLayout() video_layout.addWidget(self.video) mainlayout = QtGui.QVBoxLayout(self) mainlayout.addLayout(video_layout) mainlayout.addLayout(control_layout) self.setLayout(mainlayout)
def __init__(self, main, parent=None): QFrame.__init__(self, parent) self.main = main #使用主体窗口的媒体和音频对象 self._mediaObject = main.mediaObject self._audioOutput = main.audioOutput #获得正在播放的音乐 self._playingMusic = main.playingMusic #播放模式 self.playingOrder = 0 self.count = 0 #底部模块的背景 self.setStyleSheet( ''' BottomToolFrame{ border-image: url(res/box.png); background-repeat: no-repeat; } ''') rect = parent.rect() #各个按钮的位置和形状 #上一曲 self.setGeometry(0, rect.height() - 60, rect.width(), 60) self.lastButton = QPushButton() self.lastButton.setMinimumSize(40, 40) self.lastButton.setObjectName("btnSpecial") self.lastButton.setStyleSheet( ''' QPushButton#btnSpecial { border-image: url(res/last.png); background-repeat: no-repeat; } QPushButton#btnSpecial:pressed { border-image: url(res/last_press.png); background-repeat: no-repeat; } ''') #播放 self.playButton = QPushButton() # self.playButton.setText(u"播放") self.playButton.setMinimumSize(40, 40) self.playButton.setObjectName("btnSpecial") self.playButton.setStyleSheet( ''' QPushButton#btnSpecial { border-image: url(res/play.png); background-repeat: no-repeat; } QPushButton#btnSpecial:pressed { border-image: url(res/play_press.png); background-repeat: no-repeat; } ''') #下一曲 self.nextButton = QPushButton() self.nextButton.setMinimumSize(40, 40) self.nextButton.setObjectName("btnSpecial") self.nextButton.setStyleSheet( ''' QPushButton#btnSpecial { border-image: url(res/next.png); background-repeat: no-repeat; } QPushButton#btnSpecial:pressed { border-image: url(res/next_press.png); background-repeat: no-repeat; } ''') #播放顺序 self.orderButton = QPushButton() #初始的播放模式为顺序播放 self.orderButton.setText(u"顺序播放") #用来确定是什么播放模式 self.orderButton.clicked.connect(self.updateCount) self.seekSlider = Phonon.SeekSlider() self.seekSlider.setMediaObject(self._mediaObject) #时间进度条 self.curTimeInt = -1 self.timeString = QString('00:00/00:00') #初始值 self.timeLabel = QLabel(self.timeString) self.timeLabel.setAlignment(Qt.AlignCenter) self.timeLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) #声音模块 self.volumeSlider = Phonon.VolumeSlider() self.volumeSlider.setAudioOutput(self._audioOutput) #将各个模块横向排列 hLayout = QHBoxLayout(self) hLayout.addWidget(self.lastButton) hLayout.addWidget(self.playButton) hLayout.addWidget(self.nextButton) hLayout.addWidget(self.orderButton) hLayout.addWidget(self.seekSlider) hLayout.addWidget(self.timeLabel) hLayout.addWidget(self.volumeSlider) hLayout.addStretch() hLayout.setStretchFactor(self.lastButton, 1) hLayout.setStretchFactor(self.playButton, 1) hLayout.setStretchFactor(self.nextButton, 1) hLayout.setStretchFactor(self.orderButton, 1) hLayout.setStretchFactor(self.seekSlider, 10) hLayout.setStretchFactor(self.timeLabel, 1) hLayout.setStretchFactor(self.volumeSlider, 5) #将各个按钮连接到相应的函数,这些函数都在music_player_widget里面 self.lastButton.clicked.connect(self.lastMusic) self.playButton.clicked.connect(self.playControl) self.nextButton.clicked.connect(self.nextMusic) self.orderButton.clicked.connect(self.changeOrder)
def __init__(self, repro): super(InterfazGrafica, self).__init__() self.setWindowTitle(self.tr("Reproductor De Musica")) self.setMinimumSize(550, 250) self.repro = repro vbox = QVBoxLayout(self) hboxA = QHBoxLayout(self) hboxB = QHBoxLayout(self) #initiate table self.table = QTableWidget() self.tableItem = QTableWidgetItem() self.table.setRowCount(10) self.table.setColumnCount(3) self.table.setHorizontalHeaderLabels( QString("Titulo;Artista;Genero;").split(";")) self.table.show() vbox.addWidget(self.table) # Create textbox self.textbox = QLabel(self) self.textbox.move(20, 20) self.textbox.resize(280, 40) self.textbox.setStyleSheet('color: orangered') #teal #crimson vbox.addWidget(self.textbox) self.phonon = self.repro.phonon self.slide = Phonon.SeekSlider(self.phonon, self) hboxA.addWidget(self.slide) hboxA.addWidget(self.repro.timeLcd) self.volumeSlider = Phonon.VolumeSlider(self) self.volumeSlider.setAudioOutput(self.repro.audioOutput) self.volumeSlider.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) volumeLabel = QLabel() volumeLabel.setPixmap(QPixmap('images/volume.png')) vbox.addLayout(hboxA) #Botones self.rep = QPushButton(self.style().standardIcon(QStyle.SP_MediaPlay), '') self.pausar = QPushButton( self.style().standardIcon(QStyle.SP_MediaPause), '') self.parar = QPushButton( self.style().standardIcon(QStyle.SP_MediaStop), '') self.prev = QPushButton( self.style().standardIcon(QStyle.SP_MediaSkipBackward), '') self.next = QPushButton( self.style().standardIcon(QStyle.SP_MediaSkipForward), '') hboxB.addWidget(self.rep) hboxB.addWidget(self.pausar) hboxB.addWidget(self.parar) hboxB.addWidget(self.prev) hboxB.addWidget(self.next) hboxB.addWidget(self.volumeSlider) vbox.addLayout(hboxB) self.connect(self.rep, SIGNAL("clicked()"), self.play) self.connect(self.pausar, SIGNAL("clicked()"), self.pause) self.connect(self.parar, SIGNAL("clicked()"), self.stop) self.connect(self.prev, SIGNAL("clicked()"), self.atras) self.connect(self.next, SIGNAL("clicked()"), self.siguiente) self.phonon.finished.connect(self.siguiente)
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(820, 635) MainWindow.setMinimumSize(820, 635) MainWindow.setMaximumSize(820, 635) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.lineEdit = QtGui.QTextEdit(self.centralwidget) self.lineEdit.setGeometry(QtCore.QRect(10, 475, 800, 105)) self.lineEdit.setObjectName(_fromUtf8("lineEdit")) self.lineEdit.setReadOnly(True) redir = RedirectText(self.lineEdit) sys.stdout = redir self.lineEdit.append( u'Microsoft Imagine Cup 2017 - ARshaker에 오신 것을 환영합니다.') self.lineEdit.append(u'음악 파일이나 기 생성된 악보 파일(*.jhw)을 열어주세요!') self.lineEdit.append(u'JHW=김주현(JH)+황혜원(HW) 제작') self.listWidget = QtGui.QListWidget(self.centralwidget) self.listWidget.setGeometry(QtCore.QRect(650, 5, 160, 465)) self.listWidget.setObjectName(_fromUtf8("listWidget")) self.seekSlider = Phonon.SeekSlider(self.centralwidget) self.seekSlider.setGeometry(QtCore.QRect(220, 6, 241, 22)) self.seekSlider.setObjectName(_fromUtf8("seekSlider")) paletteb = QtGui.QPalette() paletteb.setBrush(QtGui.QPalette.Light, QtCore.Qt.black) paletteg = QtGui.QPalette() paletteg.setBrush(QtGui.QPalette.Light, QtCore.Qt.green) palettegl = QtGui.QPalette() palettegl.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkYellow) paletter = QtGui.QPalette() paletter.setBrush(QtGui.QPalette.Light, QtCore.Qt.red) palettem = QtGui.QPalette() palettem.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkMagenta) palettebl = QtGui.QPalette() palettebl.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkBlue) palettebb = QtGui.QPalette() palettebb.setBrush(QtGui.QPalette.Light, QtCore.Qt.blue) palettebc = QtGui.QPalette() palettebc.setBrush(QtGui.QPalette.Light, QtCore.Qt.cyan) self.lcdNumber = QtGui.QLCDNumber(self.centralwidget) self.lcdNumber.setPalette(paletteb) self.lcdNumber.setGeometry(QtCore.QRect(580, 5, 64, 23)) self.lcdNumber.setObjectName(_fromUtf8("lcdNumber")) self.lcdNumber.display("00:00") self.lcdr = QtGui.QLCDNumber(self.centralwidget) self.lcdr.setPalette(palettegl) self.lcdr.setGeometry(QtCore.QRect(15, 420, 80, 23)) self.lcdr.setObjectName(_fromUtf8("lcdr")) self.lcdr.display("00:00") self.rlab = QtGui.QLabel(self.centralwidget) self.rlab.setText(u'남은 시간') self.rlab.setGeometry(QtCore.QRect(23, 445, 100, 22)) self.lcda = QtGui.QLCDNumber(self.centralwidget) self.lcda.setPalette(paletteb) self.lcda.setGeometry(QtCore.QRect(110, 420, 80, 23)) self.lcda.setObjectName(_fromUtf8("lcdAccu")) self.lcda.display("00000") self.alab = QtGui.QLabel(self.centralwidget) self.alab.setText(u'현재 비트') self.alab.setGeometry(QtCore.QRect(118, 445, 100, 22)) self.lcdo = QtGui.QLCDNumber(self.centralwidget) self.lcdo.setPalette(palettebb) self.lcdo.setGeometry(QtCore.QRect(205, 420, 80, 23)) self.lcdo.setObjectName(_fromUtf8("lcdCorrect")) self.lcdo.display("00000") self.olab = QtGui.QLabel(self.centralwidget) self.olab.setText(u'맞은 비트') self.olab.setGeometry(QtCore.QRect(213, 445, 100, 22)) self.lcdx = QtGui.QLCDNumber(self.centralwidget) self.lcdx.setPalette(palettem) self.lcdx.setGeometry(QtCore.QRect(300, 420, 80, 23)) self.lcdx.setObjectName(_fromUtf8("lcdWrong")) self.lcdx.display("00000") self.xlab = QtGui.QLabel(self.centralwidget) self.xlab.setText(u'틀린 비트') self.xlab.setGeometry(QtCore.QRect(308, 445, 100, 22)) self.lcdl = QtGui.QLCDNumber(self.centralwidget) self.lcdl.setPalette(paletteg) self.lcdl.setGeometry(QtCore.QRect(395, 420, 80, 23)) self.lcdl.setObjectName(_fromUtf8("lcdLeft")) self.lcdl.display("00000") self.llab = QtGui.QLabel(self.centralwidget) self.llab.setText(u'남은 비트') self.llab.setGeometry(QtCore.QRect(403, 445, 100, 22)) self.lcdpg = QtGui.QLCDNumber(self.centralwidget) self.lcdpg.setPalette(palettebc) self.lcdpg.setGeometry(QtCore.QRect(490, 420, 70, 23)) self.lcdpg.setObjectName(_fromUtf8("lcdProgress")) self.lcdpg.display("00000") self.pglab = QtGui.QLabel(self.centralwidget) self.pglab.setText(u'진행률(%)') self.pglab.setGeometry(QtCore.QRect(491, 445, 100, 22)) self.lcdg = QtGui.QLCDNumber(self.centralwidget) self.lcdg.setPalette(paletter) self.lcdg.setGeometry(QtCore.QRect(572, 420, 70, 23)) self.lcdg.setObjectName(_fromUtf8("lcdPercent")) self.lcdg.display("00000") self.glab = QtGui.QLabel(self.centralwidget) self.glab.setText(u'정확도(%)') self.glab.setGeometry(QtCore.QRect(573, 445, 100, 22)) self.lrlab = QtGui.QLabel(self.centralwidget) self.lrlab.setText(u'좌,우(L,R)크기') self.lrlab.setGeometry(QtCore.QRect(13, 380, 100, 22)) self.lrsl = QtGui.QSlider(QtCore.Qt.Horizontal, self.centralwidget) self.lrsl.setGeometry(QtCore.QRect(117, 380, 120, 22)) self.lrsl.setMinimum(30) self.lrsl.setMaximum(200) self.lrsl.setValue(30) self.lrsl.setObjectName(_fromUtf8("lrsl")) self.lrsl.valueChanged.connect(self.lrslchange) self.ulab = QtGui.QLabel(self.centralwidget) self.ulab.setText(u'위(U) 경계') self.ulab.setGeometry(QtCore.QRect(244, 380, 100, 22)) self.usl = QtGui.QSlider(QtCore.Qt.Horizontal, self.centralwidget) self.usl.setGeometry(QtCore.QRect(317, 380, 120, 22)) self.usl.setMinimum(100) self.usl.setMaximum(400) self.usl.setValue(100) self.usl.setObjectName(_fromUtf8("usl")) self.usl.valueChanged.connect(self.uslchange) self.dlab = QtGui.QLabel(self.centralwidget) self.dlab.setText(u'색상 경계값') self.dlab.setGeometry(QtCore.QRect(441, 380, 100, 22)) self.dsl = QtGui.QSlider(QtCore.Qt.Horizontal, self.centralwidget) self.dsl.setGeometry(QtCore.QRect(524, 380, 120, 22)) self.dsl.setMinimum(1) self.dsl.setMaximum(255) self.dsl.setValue(10) self.dsl.setObjectName(_fromUtf8("dsl")) self.dsl.valueChanged.connect(self.dslchange) #음악 재생 부분 self.volumeSlider = Phonon.VolumeSlider(self.centralwidget) #self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) self.volumeSlider.setGeometry(QtCore.QRect(460, 3, 113, 26)) self.volumeSlider.setObjectName(_fromUtf8("volumeSlider")) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 820, 26)) self.menubar.setObjectName(_fromUtf8("menubar")) self.menu = QtGui.QMenu(self.menubar) self.menu.setObjectName(_fromUtf8("menu")) self.menu_2 = QtGui.QMenu(self.menubar) self.menu_2.setObjectName(_fromUtf8("menu_2")) self.menu_3 = QtGui.QMenu(self.menubar) self.menu_3.setObjectName(_fromUtf8("menu_3")) self.menu_4 = QtGui.QMenu(self.menubar) self.menu_4.setObjectName(_fromUtf8("menu_4")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.action = QtGui.QAction(MainWindow) self.action.setObjectName(_fromUtf8("action")) self.action.setShortcut("Ctrl+O") self.action.setStatusTip( u'음악 파일을 엽니다. 악보가 이전에 생성되지 않은 음악일 경우, 악보 생성에 시간이 소요됩니다.') self.action.triggered.connect(lambda: self.openMusic(True)) self.action_2 = QtGui.QAction(MainWindow) self.action_2.setObjectName(_fromUtf8("action_2")) self.action_2.setShortcut("Ctrl+S") self.action_2.setStatusTip( u'악보 파일을 엽니다. 파일 확장자가 *.jhw로 끝나며 .jhw 앞에 붙은 숫자가 클 수록 난이도가 쉽습니다.') self.action_2.triggered.connect(self.openScore) self.action_y = QtGui.QAction(MainWindow) self.action_y.setObjectName(_fromUtf8("action_y")) self.action_y.setShortcut("Ctrl+Y") self.action_y.setStatusTip( u'YouTube 주소를 입력합니다. YouTube에서 음악을 받아 악보파일을 자동으로 생성합니다.') self.action_y.triggered.connect(lambda: self.openMusic(False)) self.action_3 = QtGui.QAction(MainWindow, checkable=True) self.action_3.setObjectName(_fromUtf8("action_3")) self.action_4 = QtGui.QAction(MainWindow, checkable=True) self.action_4.setObjectName(_fromUtf8("action_4")) self.action_4.setChecked(True) self.action_5 = QtGui.QAction(MainWindow) self.action_5.setObjectName(_fromUtf8("action_5")) self.action_6 = QtGui.QAction(MainWindow) self.action_6.setObjectName(_fromUtf8("action_6")) self.action_6.setShortcut("Ctrl+H") self.action_6.setStatusTip(u'간략한 정보와 사용방법을 수록 하고 있습니다.') self.action_6.triggered.connect(self.help) ag = QtGui.QActionGroup(MainWindow, exclusive=True) self.action_7 = ag.addAction(QtGui.QAction(MainWindow, checkable=True)) self.action_7.setChecked(True) self.action_8 = ag.addAction(QtGui.QAction(MainWindow, checkable=True)) self.action_9 = ag.addAction(QtGui.QAction(MainWindow, checkable=True)) #self.action_7 = QtGui.QAction(MainWindow) self.action_7.setObjectName(_fromUtf8("action_7")) self.action_7.setStatusTip('Easy: *.20.jhw') self.action_7.triggered.connect(self.easy) #self.action_8 = QtGui.QAction(MainWindow) self.action_8.setObjectName(_fromUtf8("action_8")) self.action_8.setStatusTip('Medium: *.15.jhw') self.action_8.triggered.connect(self.medi) #self.action_9 = QtGui.QAction(MainWindow) self.action_9.setObjectName(_fromUtf8("action_9")) self.action_9.setStatusTip('Hard: *.10.jhw') self.action_9.triggered.connect(self.hard) ag2 = QtGui.QActionGroup(MainWindow, exclusive=True) self.action_10 = ag2.addAction( QtGui.QAction(MainWindow, checkable=True)) self.action_10.setChecked(True) self.action_11 = ag2.addAction( QtGui.QAction(MainWindow, checkable=True)) self.action_10.setObjectName(_fromUtf8("action_10")) self.action_10.setStatusTip(u'인식 방법을 잔상 인식 모드로 설정합니다.') self.action_10.triggered.connect(self.shadow) self.action_11.setObjectName(_fromUtf8("action_11")) self.action_11.setStatusTip(u'인식 방법을 배경 제거 인식 모드로 설정합니다.') self.action_11.triggered.connect(self.bgrm) self.menu.addAction(self.action) self.menu.addAction(self.action_2) self.menu.addAction(self.action_y) self.menu.addAction(self.action_6) self.menu_2.addAction(self.action_3) self.menu_2.addAction(self.action_4) self.menu_3.addAction(self.action_7) self.menu_3.addAction(self.action_8) self.menu_3.addAction(self.action_9) self.menu_4.addAction(self.action_10) self.menu_4.addAction(self.action_11) self.menubar.addAction(self.menu.menuAction()) self.menubar.addAction(self.menu_2.menuAction()) self.menubar.addAction(self.menu_3.menuAction()) self.menubar.addAction(self.menu_4.menuAction()) self.camera = QtGui.QWidget(self.centralwidget) self.camera.setGeometry(QtCore.QRect(0, 20, 655, 365)) self.camera.setMinimumSize(QtCore.QSize(655, 365)) self.camera.setMaximumSize(QtCore.QSize(655, 365)) self.camera.setObjectName(_fromUtf8("camera")) self.startButton = QtGui.QPushButton(self.centralwidget) self.startButton.setGeometry(QtCore.QRect(10, 5, 91, 23)) self.startButton.setObjectName(_fromUtf8("startButton")) self.pauseButton = QtGui.QPushButton(self.centralwidget) self.pauseButton.setGeometry(QtCore.QRect(101, 5, 111, 23)) self.pauseButton.setObjectName(_fromUtf8("pauseButton")) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) #UI 부분 완성 이제 영상 부분 self.capture = None self.fps = 29.97 self.timer = None self.startButton.clicked.connect(self.start) self.startButton.connect( QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_F1), self.centralwidget), QtCore.SIGNAL('activated()'), self.start) self.monitor = QtGui.QVBoxLayout(self.camera) self.startCapture() # QProcess object for external app self.process = QtCore.QProcess() # QProcess emits `readyRead` when there is data to be read self.process.readyRead.connect(self.dataReady) # Just to prevent accidentally running multiple times # Disable the button when process starts, and enable it when it finishes self.process.started.connect(lambda: self.menu.setEnabled(False)) self.process.started.connect( lambda: self.startButton.setEnabled(False)) self.process.finished.connect(lambda: self.menu.setEnabled(True)) self.process.finished.connect( lambda: self.startButton.setEnabled(True)) self.process.finished.connect(self.scoremade)
def __init__(self, parent=None): super(window, self).__init__(parent) _VERSION_=0.1 #-----------window setting-------------- self.setWindowTitle('QPlayer') self.setWindowIcon(QIcon('icon.png')) self.setGeometry(50, 50, 700,680) self.setFixedSize(700,680) #----------Full screen-------------------- self.short=QShortcut(self) self.short.setKey(QKeySequence('Esc')) self.short.setContext(Qt.ApplicationShortcut) self.short.activated.connect(self.escape) #-----------Pause key event------------- self.short=QShortcut(self) self.short.setKey(QKeySequence('Space')) self.short.setContext(Qt.ApplicationShortcut) self.short.activated.connect(self.space) #----------------------------------------- self.setStyleSheet('background-color:#1A2836;') #--------ToolBar setting------------------------- toolbar=self.addToolBar('') open=QAction(QIcon('open.png'),'open file',self) About=QAction('About',self) quit=QAction('Quit',self) toolbar.addAction(open) toolbar.addAction(About) toolbar.addAction(quit) open.triggered.connect(self.open_file) quit.triggered.connect(self.exiting) toolbar.setMovable(False) toolbar.setFocusPolicy(True) #---------Phonon source-------------------- self.media = Phonon.MediaObject(self) self.media.stateChanged.connect(self.statech) self.video= Phonon.VideoWidget(self) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) self.video.setGeometry(20,50,660,400) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) #---------Slider-------------------------- self.slider=Phonon.SeekSlider(self) self.slider.setMediaObject(self.media) self.slider.setGeometry(20,460,660,20) #--------Frame------------------------ self.frame=QFrame(self) self.frame.setGeometry(20,498,660,20) self.frame.setStyleSheet("background-color:#1A2938;") #--------Label ----------------- self.label=QLabel(self) self.label.move(20,495) self.label.setText("<font color='White'>Volume :</font>") #----------Volume---------------------------------------- self.volumeslider=Phonon.VolumeSlider(self) self.volumeslider.setAudioOutput(self.audio) self.volumeslider.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum) self.volumeslider.setGeometry(195,500,150,20) #-----------Button play--------------------- self.button_play=QPushButton('Play',self) self.button_play.move(20,530) self.button_play.clicked.connect(self.playing) self.button_play.setStyleSheet('background-color:#070D14;') #---------------------------------------------------------- #-------Button pause------------------- self.button_paus=QPushButton('Pause',self) self.button_paus.move(130,530) self.button_paus.clicked.connect(self.pausing) self.button_paus.setStyleSheet('background-color:#D73434;') #----------Button FullScreen watch---------------------- self.button_full=QPushButton('Fullscreen',self) self.button_full.move(240,530) self.button_full.clicked.connect(self.fullscreen) self.show()
def __init__(self, main, parent=None): QFrame.__init__(self, parent) self.main = main self._mediaObject = main.mediaObject self._audioOutput = main.audioOutput self._playingMusic = main.playingMusic self.playingOrder = 0 self.setStyleSheet(''' BottomToolFrame{ border-width: 1px 0 0 0; border-style: solid; border-color: gray; } ''') rect = parent.rect() self.setGeometry(0, rect.height() - 60, rect.width(), 60) self.lastButton = QPushButton() self.lastButton.setMinimumSize(40, 40) self.lastButton.setObjectName("btnSpecial") self.lastButton.setStyleSheet(''' QPushButton#btnSpecial { border-image: url(res/last.png); background-repeat: no-repeat; } QPushButton#btnSpecial:pressed { border-image: url(res/last_press.png); background-repeat: no-repeat; } ''') self.playButton = QPushButton() self.playButton.setText(u"") self.playButton.setMinimumSize(40, 40) self.playButton.setObjectName("btnSpecial") self.playButton.setStyleSheet(''' QPushButton#btnSpecial { border-image: url(res/play.png); background-repeat: no-repeat; } QPushButton#btnSpecial:pressed { border-image: url(res/play_press.png); background-repeat: no-repeat; } ''') self.nextButton = QPushButton() self.nextButton.setMinimumSize(40, 40) self.nextButton.setObjectName("btnSpecial") self.nextButton.setStyleSheet(''' QPushButton#btnSpecial { border-image: url(res/next.png); background-repeat: no-repeat; } QPushButton#btnSpecial:pressed { border-image: url(res/next_press.png); background-repeat: no-repeat; } ''') self.orderButton = QPushButton() self.orderButton.setText(u"Reproducción secuencial") self.seekSlider = Phonon.SeekSlider() self.seekSlider.setMediaObject(self._mediaObject) self.curTimeInt = -1 self.timeString = QString('00:00/00:00') self.timeLabel = QLabel(self.timeString) self.timeLabel.setAlignment(Qt.AlignCenter) self.timeLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.volumeSlider = Phonon.VolumeSlider() self.volumeSlider.setAudioOutput(self._audioOutput) hLayout = QHBoxLayout(self) hLayout.addWidget(self.lastButton) hLayout.addWidget(self.playButton) hLayout.addWidget(self.nextButton) hLayout.addWidget(self.orderButton) hLayout.addWidget(self.seekSlider) hLayout.addWidget(self.timeLabel) hLayout.addWidget(self.volumeSlider) hLayout.addStretch() hLayout.setStretchFactor(self.lastButton, 1) hLayout.setStretchFactor(self.playButton, 1) hLayout.setStretchFactor(self.nextButton, 1) hLayout.setStretchFactor(self.orderButton, 1) hLayout.setStretchFactor(self.seekSlider, 10) hLayout.setStretchFactor(self.timeLabel, 1) hLayout.setStretchFactor(self.volumeSlider, 5) self.lastButton.clicked.connect(self.lastMusic) self.playButton.clicked.connect(self.playControl) self.nextButton.clicked.connect(self.nextMusic) self.orderButton.clicked.connect(self.changeOrder)
def __init__(self, parent=None): super(ControlBar, self).__init__(parent) self.btn_open = QtGui.QPushButton() self.btn_open.setStyleSheet(""" QPushButton{ background-image:url(icons/open_file_normal.svg); width:16px; height:16px; padding-top:0px; border:0px;} QPushButton:hover{ background-image:url(icons/open_file_hover_press.svg);} """) self.btn_play = QtGui.QPushButton() self.btn_play.setStyleSheet(""" QPushButton{ background-image:url(icons/play_normal_24px.png); width:24px; height:24px; padding-top:0px; border:0px;} QPushButton:hover{ background-image:url(icons/play_hover_press_24px.png);} """) self.btn_pause = QtGui.QPushButton() self.btn_pause.setStyleSheet(""" QPushButton{ background-image:url(icons/pause_normal_24px.png); width:24px; height:24px; padding-top:0px; border:0px;} QPushButton:hover{ background-image:url(icons/pause_hover_press_24px.png);} """) self.btn_stop = QtGui.QPushButton() self.btn_stop.setStyleSheet(""" QPushButton{ background-image:url(icons/stop_normal_20px.png); width:20px; height:20px; padding-top:0px; border:0px;} QPushButton:hover{ background-image:url(icons/stop_hover_press_20px.png);} """) self.btn_fullscreen = QtGui.QPushButton() self.btn_fullscreen.setStyleSheet(""" QPushButton{ background-image:url(icons/fullscreen_normal.svg); width:16px; height:16px; padding-top:0px; border:0px;} QPushButton:hover{ background-image:url(icons/cancel_fullscreen_normal.svg);} """) self.btn_playlist = QtGui.QPushButton() self.btn_playlist.setStyleSheet(""" QPushButton{ background-image:url(icons/playlist_open_normal.svg); width:16px; height:16px; padding-top:0px; border:0px;} QPushButton:hover{ background-image:url(icons/playlist_open_hover_press.svg);} """) self.lab_time = QtGui.QLabel() #self.lab_time.setText('00:00:00/00:00:00') self.lab_time.setText('') self.lab_time.setStyleSheet("color:white") # set logo transparent self.lab_time.setFont( QtGui.QFont("Roman times", 11, QtGui.QFont.Normal)) self.seekslider = Phonon.SeekSlider() self.volumeslider = Phonon.VolumeSlider() self.setWindowOpacity(0.5) # Set Controlbar transparent self.setTitleBarWidget(QtGui.QWidget(self)) # Hide title bar self.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.FramelessWindowHint | QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowStaysOnTopHint) self.setAllowedAreas(QtCore.Qt.TopDockWidgetArea | QtCore.Qt.BottomDockWidgetArea) self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) self.setFocusPolicy(QtCore.Qt.NoFocus) self.btn_open.setFocusPolicy(QtCore.Qt.NoFocus) self.btn_play.setFocusPolicy(QtCore.Qt.NoFocus) self.btn_pause.setFocusPolicy(QtCore.Qt.NoFocus) self.btn_stop.setFocusPolicy(QtCore.Qt.NoFocus) self.btn_fullscreen.setFocusPolicy(QtCore.Qt.NoFocus) self.btn_playlist.setFocusPolicy(QtCore.Qt.NoFocus) self.seekslider.setFocusPolicy(QtCore.Qt.NoFocus) self.volumeslider.setFocusPolicy(QtCore.Qt.NoFocus) # ControlBar Layout management w_controlbar = QtGui.QWidget() hbox = QtGui.QHBoxLayout() w_controlbar.setLayout(hbox) #hbox.addWidget(self.combo_open) hbox.addWidget(self.btn_open) hbox.addWidget(self.btn_play) hbox.addWidget(self.btn_pause) hbox.addWidget(self.btn_stop) hbox.addWidget(self.lab_time) hbox.addWidget(self.seekslider, 1) hbox.addWidget(self.volumeslider) hbox.addWidget(self.btn_fullscreen) hbox.addWidget(self.btn_playlist) self.setWidget(w_controlbar) self.setFixedHeight(45) self.translateLanguage() self.skin_name = QtCore.QString("skin/3-Blue-controlbar.png") self.pixmap = QtGui.QPixmap() self.pixmap.load(self.skin_name)
def __init__(self, parent=None): super(Window, self).__init__(parent) promptWidth = 275 self.fileList = [] self.outputFile = "" self.inputFile = "" self.outputDir = "" # Setting font used for terminal monoFont = QFont() monoFont.setFamily("Monospace") monoFont.setPointSize(10) # Preparing for media playback self.mediaObject = Phonon.MediaObject(self) self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self) self.path = Phonon.createPath(self.mediaObject, self.audioOutput) self.mediaObject.stateChanged.connect(self.handlePlayStateChanged) # Start constructing UI self.inputLabel = QLabel("Input file(s):", self) self.inputLabel.move(22, 20) self.inputFileList = QListWidget(self) self.inputFileList.resize(398, 200) self.inputFileList.move(20, 41) self.inputFileButton = QPushButton("Add", self) # Connect "Add" button to the selectFile function self.inputFileButton.clicked.connect(self.selectFile) self.inputFileButton.move(335, 245) self.listDeleteButton = QPushButton("Remove", self) self.listDeleteButton.move(250, 245) self.listDeleteButton.clicked.connect(self.listDelete) self.listClearButton = QPushButton("Clear", self) self.listClearButton.move(20, 245) self.listClearButton.clicked.connect(self.listClear) self.outputLabel = QLabel("Output directory:", self) self.outputLabel.move(22, 290) self.outputDirPrompt = QLineEdit(self) self.outputDirPrompt.setReadOnly(True) self.outputDirPrompt.setFixedWidth(promptWidth) self.outputDirPrompt.move(20, 310) self.outputDirButton = QPushButton("Select directory", self) self.outputDirButton.clicked.connect(self.selectDir) self.outputDirButton.move(promptWidth + 21, 310) self.modeLabel = QLabel("Select mode:", self) self.modeLabel.move(22, 360) self.encodeRadio = QRadioButton("Encode", self) self.encodeRadio.toggle() self.encodeRadio.move(20, 382) self.decodeRadio = QRadioButton("Decode", self) self.decodeRadio.move(110, 382) self.quitButton = QPushButton("Quit", self) self.quitButton.clicked.connect(self.close) self.quitButton.move(249, 375) self.startButton = QPushButton("Execute", self) self.startButton.move(334, 375) # Make the "execute" button create a thread which runs the execute function self.startButton.clicked.connect( lambda: threading.Thread(target=self.execute).start()) self.terminalLabel = QLabel("Terminal output:", self) self.terminalLabel.move(442, 20) # Redirect stdout and stderr to string which can be used in QTextEdit window sys.stdout = EmittingStream(textWritten=self.normalOutputWritten) sys.stderr = EmittingStream(textWritten=self.normalOutputWritten) self.terminalWindow = QTextEdit(self) self.terminalWindow.setReadOnly(True) self.terminalWindow.setFont(monoFont) self.terminalWindow.resize(398, 300) self.terminalWindow.move(440, 41) self.playerLabel = QLabel("Playback:", self) self.playerLabel.move(442, 348) self.playStopButton = QPushButton("Play", self) self.playStopButton.clicked.connect(self.handlePlayState) self.playStopButton.move(540, 375) self.volume = Phonon.VolumeSlider(self.audioOutput, self) self.volume.move(645, 378) self.setFixedSize(860, 425) self.setWindowTitle("LHAudioQt")
def setupUi(self, BaiduMusicBox): BaiduMusicBox.setObjectName(_fromUtf8("BaiduMusicBox")) BaiduMusicBox.resize(849, 607) self.centralwidget = QtGui.QWidget(BaiduMusicBox) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.layoutWidget = QtGui.QWidget(self.centralwidget) self.layoutWidget.setGeometry(QtCore.QRect(20, 20, 801, 541)) self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget) self.verticalLayout.setMargin(0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.keywordEdit = QtGui.QLineEdit(self.layoutWidget) self.keywordEdit.setObjectName(_fromUtf8("keywordEdit")) self.horizontalLayout.addWidget(self.keywordEdit) self.searchButton = QtGui.QPushButton(self.layoutWidget) self.searchButton.setObjectName(_fromUtf8("searchButton")) self.downloadButton = QtGui.QPushButton(self.layoutWidget) self.downloadButton.setObjectName(_fromUtf8("downloadButton")) self.horizontalLayout.addWidget(self.searchButton) self.horizontalLayout.addWidget(self.downloadButton) self.verticalLayout.addLayout(self.horizontalLayout) self.tabWidget = QtGui.QTabWidget(self.layoutWidget) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) # TabPosition: # QTabWidget.North: 0 # QTabWidget.South: 1 # QTabWidget.West: 2 # QTabWidget.East: 3 self.tabWidget.setTabPosition(QtGui.QTabWidget.West) self.musicTab = QtGui.QWidget() self.musicTab.setObjectName(_fromUtf8("musicTab")) self.musicScrollArea = QtGui.QScrollArea(self.musicTab) self.musicScrollArea.setGeometry(QtCore.QRect(0, 0, 781, 431)) self.musicScrollArea.setMinimumSize(QtCore.QSize(780, 420)) self.musicScrollArea.setWidgetResizable(True) self.musicTreeWidget = QtGui.QTreeWidget() self.musicTreeWidget.setObjectName(_fromUtf8("musicTreeWidget")) self.musicScrollArea.setWidget(self.musicTreeWidget) self.tabWidget.addTab(self.musicTab, _fromUtf8("音乐")) self.prevButton = QtGui.QPushButton("P&rev", self.tabWidget) self.prevButton.setGeometry(QtCore.QRect(30, 440, 60, 30)) self.prevButton.setObjectName(_fromUtf8("Prev")) self.playButton = QtGui.QPushButton("&Play", self.tabWidget) self.playButton.setGeometry(QtCore.QRect(100, 440, 60, 30)) self.playButton.setObjectName(_fromUtf8("Play")) self.pauseButton = QtGui.QPushButton("Pa&use", self.tabWidget) self.pauseButton.setGeometry(QtCore.QRect(170, 440, 60, 30)) self.pauseButton.setObjectName(_fromUtf8("Pause")) self.pauseButton.setEnabled(False) self.stopButton = QtGui.QPushButton("S&top", self.tabWidget) self.stopButton.setGeometry(QtCore.QRect(240, 440, 60, 30)) self.stopButton.setObjectName(_fromUtf8("Stop")) self.stopButton.setEnabled(False) self.nextButton = QtGui.QPushButton("&Next", self.tabWidget) self.nextButton.setGeometry(QtCore.QRect(310, 440, 60, 30)) self.nextButton.setObjectName(_fromUtf8("Next")) self.seekSlider = Phonon.SeekSlider(self.tabWidget) self.seekSlider.setGeometry(QtCore.QRect(410, 445, 360, 20)) self.musicLabel = QtGui.QLabel(self.tabWidget) self.musicLabel.setGeometry(QtCore.QRect(535, 470, 280, 25)) self.volumeSlider = Phonon.VolumeSlider(self.tabWidget) self.volumeSlider.setGeometry(QtCore.QRect(50, 480, 240, 20)) self.volumeSlider.setOrientation(1) # 0: vertical 1: horizontal self.closeButton = QtGui.QPushButton(self.tabWidget) self.closeButton.setObjectName(_fromUtf8("closeButton")) self.closeButton.setGeometry(QtCore.QRect(680, 475, 80, 30)) self.infoTab = QtGui.QWidget() self.infoTab.setObjectName(_fromUtf8("infoTab")) self.infoTreeWidget = QtGui.QTreeWidget(self.infoTab) self.infoTreeWidget.setGeometry(QtCore.QRect(0, 0, 781, 431)) self.infoTreeWidget.setObjectName(_fromUtf8("infoTreeWidget")) self.tabWidget.addTab(self.infoTab, _fromUtf8("搜索")) self.downloadTab = QtGui.QWidget() self.downloadTab.setObjectName(_fromUtf8("downloadTab")) self.downloadTreeWidget = QtGui.QTreeWidget(self.downloadTab) self.downloadTreeWidget.setGeometry(QtCore.QRect(0, 0, 781, 431)) self.downloadTreeWidget.setObjectName(_fromUtf8("downloadTreeWidget")) self.tabWidget.addTab(self.downloadTab, _fromUtf8("下载")) self.lyricTab = QtGui.QWidget() self.lyricTab.setObjectName(_fromUtf8("lyricTab")) self.lyricBrowser = QtGui.QTextBrowser(self.lyricTab) self.lyricBrowser.setGeometry(QtCore.QRect(20, 0, 760, 431)) self.lyricBrowser.setAlignment(QtCore.Qt.AlignCenter) self.coverPixmap = QtGui.QPixmap() # scaled之后需要赋值回coverPixmap self.coverPixmap.load(os.getcwd() + os.sep + 'Download' + os.sep + 'Covers' + os.sep + 'Default.jpg') self.coverPixmap = self.coverPixmap.scaledToHeight(230) self.scene = QtGui.QGraphicsScene(self.lyricTab) self.scene.setObjectName(_fromUtf8("scene")) self.scene.addPixmap(self.coverPixmap) self.coverView = QtGui.QGraphicsView(self.lyricTab) self.coverView.setScene(self.scene) self.coverView.setGeometry(QtCore.QRect(400, 100, 300, 240)) self.tabWidget.addTab(self.lyricTab, _fromUtf8("歌词")) self.verticalLayout.addWidget(self.tabWidget) BaiduMusicBox.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(BaiduMusicBox) self.menubar.setGeometry(QtCore.QRect(0, 0, 849, 23)) self.menubar.setObjectName(_fromUtf8("menubar")) self.fileMenu = QtGui.QMenu(_fromUtf8("文件(&F)"), self.menubar) self.fileMenu.setObjectName(_fromUtf8("fileMenu")) self.settingsMenu = QtGui.QMenu(_fromUtf8("设置(&S)"), self.menubar) self.settingsMenu.setObjectName(_fromUtf8("settingsMenu")) BaiduMusicBox.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(BaiduMusicBox) self.statusbar.setObjectName(_fromUtf8("statusbar")) BaiduMusicBox.setStatusBar(self.statusbar) self.importAction = QtGui.QAction(BaiduMusicBox) self.importAction.setObjectName(_fromUtf8("importAction")) self.exitAction = QtGui.QAction(BaiduMusicBox) self.exitAction.setObjectName(_fromUtf8("exitAction")) self.fileMenu.addAction(self.importAction) self.fileMenu.addSeparator() self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAction) self.menubar.addAction(self.fileMenu.menuAction()) self.dirSettingsAction = QtGui.QAction(BaiduMusicBox) self.dirSettingsAction.setObjectName(_fromUtf8("dirSettingsAction")) # 播放模式 # 一般模式(顺序循环) self.defaultModeAction = QtGui.QAction(BaiduMusicBox) self.defaultModeAction.setObjectName(_fromUtf8("defaultModeAction")) self.defaultModeAction.setCheckable(True) # 随机模式 self.randomModeAction = QtGui.QAction(BaiduMusicBox) self.randomModeAction.setObjectName(_fromUtf8("randomModeAction")) self.randomModeAction.setCheckable(True) # 单曲模式 self.singleModeAction = QtGui.QAction(BaiduMusicBox) self.singleModeAction.setObjectName(_fromUtf8("singleModeAction")) self.singleModeAction.setCheckable(True) self.modeMenu = QtGui.QMenu(self.settingsMenu) self.modeMenu.setObjectName(_fromUtf8("modeMenu")) self.modeMenu.addSeparator() self.modeMenu.addAction(self.defaultModeAction) self.modeMenu.addSeparator() self.modeMenu.addAction(self.randomModeAction) self.modeMenu.addAction(self.singleModeAction) self.settingsMenu.addAction(self.dirSettingsAction) self.settingsMenu.addSeparator() self.settingsMenu.addAction(self.modeMenu.menuAction()) self.menubar.addAction(self.settingsMenu.menuAction()) self.viewMenu = QtGui.QMenu(_fromUtf8("视图(&V)"), self.menubar) self.viewMenu.setObjectName(_fromUtf8("viewMenu")) self.menubar.addAction(self.viewMenu.menuAction()) self.musicViewAction = QtGui.QAction(BaiduMusicBox) self.musicViewAction.setObjectName(_fromUtf8("musicViewAction")) self.musicViewAction.setCheckable(True) self.musicViewAction.setChecked(True) self.musicViewAction.setText( QtGui.QApplication.translate("BaiduMusicBox", "音乐视图", None, QtGui.QApplication.UnicodeUTF8)) self.infoViewAction = QtGui.QAction(BaiduMusicBox) self.infoViewAction.setObjectName(_fromUtf8("infoViewAction")) self.infoViewAction.setCheckable(True) self.infoViewAction.setText( QtGui.QApplication.translate("BaiduMusicBox", "搜索视图", None, QtGui.QApplication.UnicodeUTF8)) self.downViewAction = QtGui.QAction(BaiduMusicBox) self.downViewAction.setObjectName(_fromUtf8("downViewAction")) self.downViewAction.setCheckable(True) self.downViewAction.setText( QtGui.QApplication.translate("BaiduMusicBox", "下载视图", None, QtGui.QApplication.UnicodeUTF8)) self.lyricViewAction = QtGui.QAction(BaiduMusicBox) self.lyricViewAction.setObjectName(_fromUtf8("lyricViewAction")) self.lyricViewAction.setCheckable(True) self.lyricViewAction.setText( QtGui.QApplication.translate("BaiduMusicBox", "歌词视图", None, QtGui.QApplication.UnicodeUTF8)) self.viewMenu.addAction(self.musicViewAction) self.viewMenu.addAction(self.infoViewAction) self.viewMenu.addAction(self.downViewAction) self.viewMenu.addAction(self.lyricViewAction) self.aboutAction = QtGui.QAction(BaiduMusicBox) self.aboutAction.setObjectName(_fromUtf8("aboutAction")) self.aboutAction.setText( QtGui.QApplication.translate("BaiduMusicBox", "关于", None, QtGui.QApplication.UnicodeUTF8)) self.aboutQtAction = QtGui.QAction(BaiduMusicBox) self.aboutQtAction.setObjectName(_fromUtf8("aboutQtAction")) self.aboutQtAction.setText( QtGui.QApplication.translate("BaiduMusicBox", "关于Qt", None, QtGui.QApplication.UnicodeUTF8)) self.aboutMenu = QtGui.QMenu(_fromUtf8("关于(&A)"), self.menubar) self.aboutMenu.setObjectName(_fromUtf8("aboutMenu")) # self.aboutMenu.setTitle(QtGui.QApplication.translate("BaiduMusicBox", "关于", None, QtGui.QApplication.UnicodeUTF8)) self.menubar.addAction(self.aboutMenu.menuAction()) self.aboutMenu.addAction(self.aboutAction) self.aboutMenu.addAction(self.aboutQtAction) self.retranslateUi(BaiduMusicBox) self.tabWidget.setCurrentIndex(0) QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), BaiduMusicBox.close) QtCore.QObject.connect(self.exitAction, QtCore.SIGNAL(_fromUtf8("triggered()")), BaiduMusicBox.close) QtCore.QMetaObject.connectSlotsByName(BaiduMusicBox)
def setup_ui(self): self.setObjectName(_fromUtf8("Display")) self.setEnabled(True) self.resize(462, 699) self.setAccessibleName(_fromUtf8("")) self.centralwidget = QtGui.QWidget(self) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) '''----------------------start of hack section--------------''' font = QtGui.QFont() font.setFamily(_fromUtf8("Microsoft YaHei UI")) font.setPointSize(12) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.textEdit_1 = QtGui.QTextEdit(self.centralwidget) self.textEdit_1.setMaximumSize(QtCore.QSize(16777215, 31)) self.textEdit_1.setFont(font) self.textEdit_1.setObjectName(_fromUtf8("textEdit")) self.textEdit_1.setHtml(_translate("Display", 'Search..', None)) self.splitter = QtGui.QSplitter(self.centralwidget) self.splitter.setMinimumSize(QtCore.QSize(81, 31)) self.splitter.setMaximumSize(QtCore.QSize(16777215, 81)) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setObjectName(_fromUtf8("splitter")) self.label = QtGui.QLabel(self.splitter) self.label.setMaximumSize(QtCore.QSize(241, 31)) self.label.setFont(font) self.label.setObjectName(_fromUtf8("label")) self.label.setText( _translate("Display", "hello " + self.username + ". Money:", None)) self.textEdit = QtGui.QTextEdit(self.splitter) self.textEdit.setEnabled(False) self.textEdit.setMaximumSize(QtCore.QSize(81, 31)) self.textEdit.setFont(font) self.textEdit.setObjectName(_fromUtf8("textEdit")) self.textEdit.setHtml(_translate("Display", self.money, None)) self.checkBox = QtGui.QCheckBox(self.splitter) self.checkBox.setFont(font) self.checkBox.setObjectName(_fromUtf8("checkBox")) self.checkBox.setText(_translate("Display", "hack money", None)) QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.textEdit.setEnabled) self.verticalLayout.addWidget(self.textEdit_1) self.verticalLayout.addWidget(self.splitter) """---------------------------- end of hack--------------------------""" bar = QtGui.QToolBar() bar.addAction(self.playAction) bar.addAction(self.pauseAction) bar.addAction(self.stopAction) self.seekSlider = Phonon.SeekSlider(self) self.seekSlider.setMediaObject(self.mediaObject) self.volumeSlider = Phonon.VolumeSlider(self) self.volumeSlider.setAudioOutput(self.audioOutput) self.volumeSlider.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) volumeLabel = QtGui.QLabel() volumeLabel.setPixmap(QtGui.QPixmap('images/volume.png')) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Light, QtCore.Qt.darkGray) self.time_lcd = QtGui.QLCDNumber() self.time_lcd.setPalette(palette) """---------------------------- tables --------------------------""" headers = ["Title", "Artist", "Album", "Cover"] items = [] self.musicTable = QtGui.QTableWidget(0, 4) self.musicTable.setStyleSheet("background: lightgreen") self.musicTable.setHorizontalHeaderLabels(headers) self.musicTable.setSelectionMode( QtGui.QAbstractItemView.SingleSelection) self.musicTable.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.musicTable.cellPressed.connect(self.tableClicked) self.musicTable.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) """---------------------------- end of tables--------------------------""" """---------------------------- Discover tables --------------------------""" self.musicTable_1 = QtGui.QTableWidget(0, 4) headers[3] = 'Price' self.musicTable_1.setHorizontalHeaderLabels(headers) self.musicTable_1.setStyleSheet("background: springgreen") self.musicTable_1.setSelectionMode( QtGui.QAbstractItemView.SingleSelection) self.musicTable_1.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.musicTable_1.cellPressed.connect(self.tableClickedDisover) """---------------------------- end of tables--------------------------""" """---------------------------- Discover tabs --------------------------""" self.TheMain = QtGui.QTabWidget(self.centralwidget) self.TheMain.setMinimumSize(QtCore.QSize(350, 500)) self.TheMain.setMaximumSize(QtCore.QSize(1000, 10000)) self.TheMain.setFont(font) self.TheMain.setObjectName(_fromUtf8("TheMain")) self.Discover_Tab = QtGui.QWidget() self.Discover_Tab.setFont(font) self.Discover_Tab.setAutoFillBackground(False) self.Discover_Tab.setObjectName(_fromUtf8("Discover_Tab")) self.verticalLayout_0 = QtGui.QVBoxLayout(self.Discover_Tab) self.verticalLayout_0.setObjectName(_fromUtf8("verticalLayout_0")) self.verticalLayout_0.addWidget(self.musicTable_1) self.TheMain.addTab(self.Discover_Tab, _fromUtf8("Discover")) self.songList_Tab = QtGui.QWidget() self.songList_Tab.setObjectName(_fromUtf8("songList_Tab")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.songList_Tab) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.verticalLayout_2.addWidget(self.musicTable) self.splitter.raise_() self.TheMain.addTab(self.songList_Tab, _fromUtf8("Song List")) self.CurrentPlaying_Tab = QtGui.QWidget() self.verticalLayout_3 = QtGui.QVBoxLayout(self.CurrentPlaying_Tab) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.CurrentPlaying_Tab.setObjectName(_fromUtf8("CurrentPlaying_Tab")) self.Current_song_pic = QtGui.QLabel(self.CurrentPlaying_Tab) self.Current_song_pic.setText('') self.Current_song_pic.setGeometry(QtCore.QRect(10, 70, 411, 411)) self.Current_song_pic.setStyleSheet( _fromUtf8( r"border-image: url(Squares.jpg) 0 0 0 0 stretch stretch;" " background-position: center;")) self.verticalLayout_3.addWidget(self.Current_song_pic) self.Current_song_label = QtGui.QLabel(self.CurrentPlaying_Tab) self.Current_song_label.setText('sample') self.Current_song_label.setGeometry(QtCore.QRect(10, 70, 31, 81)) self.Current_song_label.setMaximumSize(QtCore.QSize(1000, 31)) self.verticalLayout_3.addWidget(self.Current_song_label) self.TheMain.addTab(self.CurrentPlaying_Tab, _fromUtf8("Current Playing")) """---------------------------- end tabs --------------------------""" seekerLayout = QtGui.QHBoxLayout() seekerLayout.addWidget(self.seekSlider) seekerLayout.addWidget(self.time_lcd) playbackLayout = QtGui.QHBoxLayout() playbackLayout.addWidget(bar) playbackLayout.addStretch() playbackLayout.addWidget(volumeLabel) playbackLayout.addWidget(self.volumeSlider) mainLayout = QtGui.QVBoxLayout() mainLayout.addLayout(self.verticalLayout) mainLayout.addWidget(self.TheMain) mainLayout.addLayout(seekerLayout) mainLayout.addLayout(playbackLayout) widget = QtGui.QWidget() widget.setLayout(mainLayout) self.setCentralWidget(widget) self.setGeometry(50, 100, 450, 700) self.setWindowTitle("Roytify Client") self.setWindowIcon(QtGui.QIcon("useful\Logo.ico"))