码迷,mamicode.com
首页 > 其他好文 > 详细

pyqt备份之1和2

时间:2015-07-16 16:10:46      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

源代码1:

# -*- coding: utf-8 -*-

import sys,time,os

import ctypes

from PyQt4 import QtCore, QtGui,Qt

from PyQt4.QtCore import Qt

from PyQt4.QtCore import pyqtSignature

from mp import Ui_Form

import win32gui

import win32api

import win32con

User32dll = ctypes.windll.User32

#print ctypes.windll.User32

 

class MyForm(QtGui.QMainWindow):

    def __init__(self,parent=None):

        QtGui.QWidget.__init__(self,parent)

        self.ui=Ui_Form()

        self.ui.setupUi(self)

        self.createContexMenu()

 

        self.ui.open1.setToolTip(u‘添加文件/文件夹,Ctrl+O‘)

        self.ui.open1.setShortcut(u‘Ctrl+O‘)

        self.ui.cha.setToolTip(u‘查找当前目录文件/文件夹,Ctrl+F‘)

        self.ui.cha.setShortcut(u‘Ctrl+F‘)

        self.ui.ting.setToolTip(u‘暂停当前歌曲播放‘)

        self.ui.hou.setToolTip(u‘向后一首‘)

        self.ui.qian.setToolTip(u‘向前一首‘)

 

        self.vox=QtGui.QSlider(QtCore.Qt.Horizontal,self)

        self.vox.setFocusPolicy(QtCore.Qt.NoFocus)

        self.vox.setGeometry(400, 40, 80, 30)

        self.vox.setToolTip(u‘声音‘)

 

        self.lcd=QtGui.QLCDNumber(self)

        self.lcd.setGeometry(530, 40, 80, 30)

        self.vbox=QtGui.QVBoxLayout()

        self.vbox.addWidget(self.lcd)

 

        self.timer=QtCore.QBasicTimer()

        self.a=0

 

        #事件与信号

        self.ra=QtGui.QButtonGroup(None)

        self.ra.addButton( self.ui.ra1,0)

        self.ra.addButton( self.ui.ra2,1)

        self.ra.addButton( self.ui.ra3,2)

        self.ra.addButton( self.ui.ra4,3)

        self.connect(self.ra,QtCore.SIGNAL("clicked()"), self.buttonBoxx)

 

        self.connect( self.ui.ra1, QtCore.SIGNAL("clicked()"),self.change)

        self.connect( self.ui.ra2, QtCore.SIGNAL("clicked()"),self.change)

        self.connect( self.ui.ra3, QtCore.SIGNAL("clicked()"),self.change)

        self.connect( self.ui.ra4, QtCore.SIGNAL("clicked()"),self.change)

 

        self.connect(self.vox, QtCore.SIGNAL(‘valueChanged(int)‘), self.timerEvent)

        self.connect(self.vox,QtCore.SIGNAL(‘valueChanged(int)‘),

                     self.vov)

        self.connect(self.vox,  QtCore.SIGNAL(‘valueChanged(int)‘), self.lcd,

                 QtCore.SLOT(‘display(int)‘))

        self.connect(self.vox, QtCore.SIGNAL(‘valueChanged(int)‘), self.onstart)

        self.connect(self.vox, QtCore.SIGNAL(‘valueChanged(int)‘), self.timerEvent)

        self.connect(self.ui.hou,QtCore.SIGNAL(‘triggered()‘),QtGui.qApp,QtCore.SLOT(‘‘))#歌曲后一首

        self.connect(self.ui.qian,QtCore.SIGNAL(‘triggered()‘),QtGui.qApp,QtCore.SLOT(‘‘))#歌曲前一首

        self.connect(self.ui.ting,QtCore.SIGNAL(‘triggered()‘),QtGui.qApp,QtCore.SLOT(‘‘))#歌曲前暂停

 

        self.connect(self.ui.open1, QtCore.SIGNAL(‘clicked()‘), self.addafile)

        self.ui.ra1.setToolTip(u‘单曲播放‘)

        self.ui.ra2.setToolTip(u‘单曲循环‘)

        self.ui.ra3.setToolTip(u‘列表播放‘)

        self.ui.ra4.setToolTip(u‘随机播放‘)

        self.vox.setToolTip(u‘调节音量‘)

        self.ui.text1.setToolTip(u‘音乐‘)

        self.ui.l1.setToolTip(u‘静音‘)

 

 

        #事件:

        self.connect(self.ui.text1,QtCore.SIGNAL(‘(customContextMenuRequested‘),self. createContexMenu)

        self.ui.text1.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

        #self.connect(self.ui.text1,QtCore.SIGNAL(‘clicked()‘),self.ctypes1)

 

    #播放方式

    def change(self):

        if self.ui.ra1.isChecked():

            print u‘单曲循环

        elif  self.ui.ra2.isChecked():

            print u‘单曲播放

        elif  self.ui.ra3.isChecked():

            print u‘列表播放

        elif self.ui.ra4.isChecked():

            print u‘随机播放

        else:

            print u‘未选择

    def buttonBoxx(self):

        try:

            if self.ra.checkedId():

                print u‘当前选中的是‘,self.ra.checkedId()

        except Exception:

            print ‘error:‘,u‘4个状态未选中

 

 

    def createContexMenu(self):

        """

        创建右击菜单

        """

        #self.text(Qt.CustomContextMenu)

        self.setContextMenuPolicy(Qt.CustomContextMenu)

        self.customContextMenuRequested.connect(self.showContextMenu)

 

        #创建QMENU

        self.contextMenu=QtGui.QMenu()

        self.actionA=self.contextMenu.addAction(u‘添加歌曲文件/歌曲文件夹(基本完成)‘)

        self.actionA.setShortcut(u‘Ctrl+O‘)

        self.actionB=self.contextMenu.addAction(u‘清除歌曲列表(基本完成)‘)

        self.actionB.setShortcut(u‘Ctrl+C‘)

        self.actionC=self.contextMenu.addAction(u‘歌曲播放模式‘)

        self.actionD=self.contextMenu.addAction(u‘歌曲排序‘)

        self.actionD.setShortcut(u‘Ctrl+#‘)

        self.actionE=self.contextMenu.addAction(u‘打开歌曲所在目录或者路径‘)

        self.actionE.setShortcut(u‘Ctrl+F‘)

        self.actionF=self.contextMenu.addAction(u‘歌曲重名名‘)

        self.actionF.setShortcut(u‘Ctrl+R‘)

        self.actionG=self.contextMenu.addAction(u‘删除音乐文件(包括硬盘中的文件)(基本完成)‘)

        self.actionG.setShortcut(u‘Ctrl+D‘)

        self.actionH=self.contextMenu.addAction(u‘查看歌曲信息(基本完成)‘)

        self.actionH.setShortcut(u‘Ctrl+H‘)

        self.actionX=self.contextMenu.addAction(u‘导出歌曲‘)

        self.actionX.setShortcut(u‘Ctrl+P‘)

        self.actionS=self.contextMenu.addAction(u‘设置‘)

        self.actionS.setShortcut(u‘Ctrl+M‘)

        self.actionU=self.contextMenu.addAction(u‘更新音乐文件‘)

        self.actionU.setShortcut(u‘Ctrl+U‘)

        aboutAction = QtGui.QAction(QtGui.QIcon(""), u"关于(&A)(基本完成)", self)

        self.contextMenu.addAction(aboutAction)

        self.connect(aboutAction,QtCore.SIGNAL(‘triggered()‘),self.about)

        """

        self.she=QtGui.QPushButton(u‘设置(M)‘,self)

        self.she.setGeometry(230,490, 75, 23)

        self.she.setToolTip(u‘设置,Ctrl+M‘)

        self.she.setShortcut(u‘Ctrl+M‘)

    """

        #对播放模式选择

        self.a1=QtGui.QAction(u‘单曲循环‘,self)

        self.a2=QtGui.QAction(u‘单曲播放‘,self)

        self.a3=QtGui.QAction(u‘列表播放‘,self)

        self.a4=QtGui.QAction(u‘随机播放‘,self)

        self.c1=QtGui.QMenu()#二级菜单创建

        self.actionC.setMenu(self.c1)

        self.c1.addAction(self.a1)

        self.c1.addAction(self.a2)

        self.c1.addAction(self.a3)

        self.c1.addAction(self.a4)

        #对排序方式

        self.b1=QtGui.QAction(u‘播放次数‘,self)

        self.b2=QtGui.QAction(u‘文件大小‘,self)

        self.b3=QtGui.QAction(u‘随机排序‘,self)

        self.c2=QtGui.QMenu()

        self.actionD.setMenu(self.c2)

        self.c2.addAction(self.b1)

        self.c2.addAction(self.b2)

        self.c2.addAction(self.b3)

        #self.action*方法进行设置功能

        self.actionA.triggered.connect(self.actionHta)

        self.actionB.triggered.connect(self.actionHtb)

        self.actionC.triggered.connect(self.actionHtc)

        self.actionD.triggered.connect(self.actionHtd)

        self.actionE.triggered.connect(self.actionHte)

        self.actionF.triggered.connect(self.actionHtf)

        self.actionG.triggered.connect(self.actionHtg)

        self.actionH.triggered.connect(self.actionHth)

        self.actionX.triggered.connect(self.actionHtx)

        self.actionS.triggered.connect(self.actionHts)

        self.actionU.triggered.connect(self.actionHtu)

        ctypes.windll.user32.SetCursorPos(400,300)

        win32gui.GetCursorPos()#鼠标坐标信息

        #win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 400,200)

        #time.sleep(0.05)

        #win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 400, 400)

        #self.connect(self.actionC,QtCore.SIGNAL(‘triggered()‘),self.actionHtc)

 

    def actionHts(self):#设置

        self.setup =QtGui.QTextBrowser(self)

        self.setup.setGeometry(100,70,600,400)

        self.setup.show()

        self.Optionsetting=QtGui.QLabel(u‘选       项       设      置‘,self)

        self.Optionsetting.setToolTip(u‘选项设置‘)

        self.Optionsetting.setGeometry(100,70,300,30)

        self.Optionsetting.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.Optionsetting.show()

        self.Generalsettings=QtGui.QPushButton(u‘   常规设置‘,self)

        self.Generalsettings.setToolTip(u‘常规设置‘)

        self.Generalsettings.setGeometry(100,95,150,30)

        self.Generalsettings.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.Generalsettings.setIcon(QtGui.QIcon(‘./Gear.png‘))

        self.Generalsettings.setIconSize(QtCore.QSize(35,21))

        self.Generalsettings.setMask(QtGui.QPixmap("‘./Gear.png").mask())

        self.Generalsettings.setStyleSheet("* {  margin-top:0pt; ">        self.Generalsettings.show()

        self.close1=QtGui.QPushButton(u‘x‘,self)#功能完成

        self.close1.setGeometry(670,70,30,20)

        self.close1.setStyleSheet("* {  margin-top:0pt; ">        self.close1.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.close1.show()

        self.habit=QtGui.QPushButton(u‘   操作习惯‘,self)

        self.habit.setToolTip(u‘操作习惯‘)

        self. habit.setGeometry(100,135,150,30)

        self.habit.setIcon(QtGui.QIcon(‘./Rocker.png‘))

        self.habit.setIconSize(QtCore.QSize(35,21))

        self.habit.setMask(QtGui.QPixmap("‘./Rocker.png").mask())

        self.habit.setIconSize(QtCore.QSize(35,21))

        self.habit.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.habit.setStyleSheet("* {  margin-top:0pt; ">        self.habit.show()

        self.Hotkey=QtGui.QPushButton(u‘   热键设置‘,self)

        self.Hotkey.setToolTip(u‘热键设置‘)

        self.Hotkey.setGeometry(100,175,150,30)

        self.Hotkey.setIcon(QtGui.QIcon(‘./Hotkey settings.png‘))

        self.Hotkey.setIconSize(QtCore.QSize(35,21))

        self.Hotkey.setMask(QtGui.QPixmap("‘./Hotkey settings.png").mask())

        self.Hotkey.setIconSize(QtCore.QSize(35,21))

        self.Hotkey.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.Hotkey.setStyleSheet("* {  margin-top:0pt; ">        self.Hotkey.show()

        self.connect(self.close1,QtCore.SIGNAL(‘clicked()‘),self.off)

        self.close1.setToolTip(u‘设置选项关闭‘)

        #对常规设置按钮

        self.connect(self.Generalsettings,QtCore.SIGNAL(‘clicked()‘),self.Genetimes)

    #self.Generalsettings=QtGui.QPushButton(u‘   常规设置‘,self)继续做这个

    def Genetimes(self):

        self.mian=QtGui.QTextBrowser(self)

        self.mian.setGeometry(300,50,500,400)

        self.mian.show()

        self.whenstar=QtGui.QLabel(u‘启 动 时‘,self)

        self.whenstar.setToolTip(u‘启动时‘)

        self.whenstar.setGeometry(300,60,200,25)

        self.whenstar.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.whenstar.show()

        self.xian1=QtGui.QLabel(u‘----------------------------‘,self)

        self.xian1.setGeometry(410,60,500,35)

        self.xian1.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.xian1.show()

        #复选框

        self.radion1=QtGui.QCheckBox(u‘自动播放歌曲‘,self)

        self.radion1.setGeometry(300,85,150,35)

        self.radion1.show()

        self.radion1.toggle()#checked状态发生改变时 发出toggled(bool) 信号

        #如果想对复选框之类的东西进行选中的,就必须使用obj.toggle()这个方法

        #toggle()切换反转的意思

        #button.setCheckable(True) #设置为开关按钮 toggle 就是按下按钮不会弹起

        self.connect(self.radion1,QtCore.SIGNAL(‘stateChanged(int)‘),

                     self.radion2)#stateChanged(int)复选框被选中或清除

    def off(self):

        time.sleep(1)

        print u‘关闭中

        sys.exit(0)

        time.sleep(1)

    def radion2(self,value):

        if self.radion1.isChecked():

            self.radion1(‘Checkbox‘)

        else:

            self.radion1()

    def actionHth(self):#查看歌曲信息

        self.information =QtGui.QTextBrowser(self)

        self.information.setGeometry(100,70,600,400)

        self.information.setStyleSheet("* {  margin-top:0pt; ">        self.information.show()

        self.heng1=QtGui.QLabel(u‘----------------------------------------‘,self)

        self.heng1.setGeometry(110,55,300,50)

        self.heng1.show()

        self.heng2=QtGui.QLabel(u‘-------------------------------------------‘,self)

        self.heng2.setGeometry(430,55,300,50)

        self.heng2.show()

        self.fileinformation=QtGui.QLabel(u‘歌曲信息‘,self)

        self.fileinformation.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.fileinformation.setGeometry(350,60,100,30)

        self.fileinformation.setStyleSheet("* {  margin-top:0pt; ">        self.fileinformation.show()

        self.for1=QtGui.QLabel(u‘文件信息:‘,self)

        self.for1.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.for1.setGeometry(110,85,300,40)

        self.for1.show()

        self.heng3=QtGui.QLabel(u‘---------------------------------------------------------------------------------‘,self)

        self.heng3.setGeometry(200,85,5000,50)

        self.heng3.show()

        self.filepath=QtGui.QLabel(u‘音乐文件路径:‘,self)

        self.filepath.setGeometry(110,115,300,70)

        self.filepath.show()

        self.filepath1=QtGui.QPushButton(u‘浏览‘,self)

        self.filepath1.setGeometry(200,135,50,30)

        self.filepath1.show()

        self.look=QtGui.QLabel(U‘a‘,self)

        self.filesize=QtGui.QLabel(u‘音乐文件大小:‘,self)

        self.filesize.setGeometry(110,160,100,50)

        self.filesize.show()

        self.filesize1=QtGui.QTextBrowser(self)

        self.filesize1.setGeometry(200,170,160,30)

        self.filesize1.show()

        self.bytex=QtGui.QLabel(u‘:bytes(或字节)‘,self)

        self.bytex.setGeometry(370,170,200,30)

        self.bytex.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.bytex.show()

        self.fileformat=QtGui.QLabel(u‘音乐文件格式:‘,self)

        self.fileformat.setGeometry(110,210,200,30)

        self.fileformat.show()

        self.fileformat1=QtGui.QTextBrowser(self)

        self.fileformat1.setGeometry(200,210,200,30)

        self.fileformat1.show()

        self.singer=QtGui.QLabel(u‘歌        手:‘,self)

        self.singer.setGeometry(110,250,200,30)

        self.singer.show()

        self.singer1=QtGui.QTextBrowser(self)

        self.singer1.setGeometry(200,250,200,30)

        self.singer1.show()

        self.album=QtGui.QLabel(u‘专     辑:‘,self)

        self.album.setGeometry(420,210,200,30)

        self.album.show()

        self.album1=QtGui.QTextBrowser(self)

        self.album1.setGeometry(490,210,200,30)

        self.album1.show()

        self.timelength=QtGui.QLabel(u‘时     长:‘,self)

        self.timelength.setGeometry(420,250,200,30)

        self.timelength.show()

        self.timelength1=QtGui.QTextBrowser(self)

        self.timelength1.setGeometry(490,250,200,30)

        self.timelength1.show()

        self.quality=QtGui.QLabel(u‘音        质:‘,self)

        self.quality.setGeometry(110,290,200,30)

        self.quality.show()

        self.quality1=QtGui.QTextBrowser(self)

        self.quality1.setGeometry(200,290,200,30)

        self.quality1.show()

 

    def showContextMenu(self,pos):

        self.contextMenu.move(self.pos()+pos)

        self.contextMenu.show()

 

 

    def actionHta(self):

        self.list=[]

        self.file1=QtGui.QFileDialog.getOpenFileNames(self,‘Open file‘,‘/‘,‘p3(*.mp3)‘)

        for files in range(len(self.file1)):

            self.list.append(self.ui.text1.append(self.file1[files]))

    """

    self.a1=QtGui.QAction(u‘单曲循环‘,self)

    self.a2=QtGui.QAction(u‘单曲播放‘,self)

    self.a3=QtGui.QAction(u‘列表播放‘,self)

    self.a4=QtGui.QAction(u‘随机播放‘,self)

    self.c1=QtGui.QMenu()#二级菜单创建

    self.actionC.setMenu(self.c1)

    self.c1.addAction(self.a1)

    self.c1.addAction(self.a2)

    self.c1.addAction(self.a3)

    self.c1.addAction(self.a4)

    """

 

    def actionHtc(self):#u‘歌曲播放模式

        if self.actionC(self.c1):

            print ‘a‘

    def triggerEvent(self,action):

        print(‘Event triggered: %s‘ % action.text())

    def actionHtb(self):

        self.ui.text1.clear()

    """

      self.b1=QtGui.QAction(u‘播放次数‘,self)

        self.b2=QtGui.QAction(u‘文件大小‘,self)

        self.b3=QtGui.QAction(u‘随机排序‘,self)

    """

    def actionHtd(self):#‘歌曲排序

        print u‘D‘

    def actionHte(self):#打开歌曲所在目录或者路径

        print u‘E‘

    def actionHtf(self,path):#歌曲重名名

        pass

    def actionHtg(self):#删除音乐文件

        path=u‘F:\\KuGou\\叮当 猜不透1.mp3‘

        if os.path.exists(path):

            re1=QtGui.QMessageBox.question(self,u‘删除当前选择歌曲‘,u‘是否彻底删除歌曲?%s?‘%(path),QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)

            if re1==QtGui.QMessageBox.Yes:

                print u‘删除

                time.sleep(1)

                os.remove(path)

            else:

                print u‘未删除

                time.sleep(1)

                pass

 

    def actionHtx(self):#导出歌曲

        pass

    def actionHtu(self):#更新

        print‘U‘

 

    """

    def mousePressEvent(self,event):

        if event.button()==Qt.LeftButton:

            self.dragPosition=event.globalPos()-self.frameGeometry().topLeft()

            event.accept()

        if event.button()==Qt.RightButton:

            self.ui.text1.pos()

            print‘aaaa‘

    def mouseMoveEvent(self,event):

        if event.buttons() & Qt.LeftButton:

            self.move(event.globalPos()-self.dragPosition)

            event.accept()

    """

    def addafile(self):

        self.list=[]

        self.file1=QtGui.QFileDialog.getOpenFileNames(self,‘Open file‘,‘/‘,‘p3(*.mp3)‘)

        for files in range(len(self.file1)):

            self.list.append(self.ui.text1.append(self.file1[files]))

 

    def vov(self,value):

        self.pos=self.vox.value()

        if self.pos==0:

            print‘声音静音0%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self1.jpg‘))

            self.ui.l1.setToolTip(u‘静声‘)

 

        elif 0<self.pos<=30:

            print‘声音中小25%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self2.jpg‘))

            self.ui.l1.setToolTip(u‘声音达到25%‘)

        elif 30<self.pos<=80:

            print‘声音较中50%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self3.jpg‘))

            self.ui.l1.setToolTip(u‘声音达到50%‘)

 

        elif 80<self.pos<=95:

            print‘声音较大75%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self4.jpg‘))

            self.ui.l1.setToolTip(u‘声音达到75%‘)

 

        else:

            print‘声音最大100%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self5.jpg‘))

            self.ui.l1.setToolTip(u‘声音最大‘)

 

    def showContextMenu(self,pos):

        self.contextMenu.move(self.pos()+pos)

        self.contextMenu.show()

    def timerEvent(self,event):

        if self.a>=100:

            #self.vox()

            self.timer.stop()

            return

        self.a+=1

        self.vox.setValue(self.a)

    def onstart(self):

        if self.timer.isActive():

            self.timer.stop()

        else:

            self.timer.start(100,self)

    def about(self):#关于

about = QtGui.QMessageBox(self)

about.setWindowTitle(u‘关于BUG Player‘)

about.setText(u"BUG音乐盒是一个简单MP3播放器\n\mhxy13867806343@live.cn,<a href=http://music.baidu.com/>http://music.baidu.com/songlist</a>")

about.show()

 

if __name__ == "__main__":

    app = QtGui.QApplication(sys.argv)

    myapp =MyForm()

    myapp.show()

    sys.exit(app.exec_())

 #self.contextMenu.addAction(self.a1)

        #self.contextMenu.addAction(self.a2)

        #self.contextMenu.addAction(self.a3)

        #self.contextMenu.addAction(self.a4)

    """

    @pyqtSignature(‘QPoint‘)

    def on_list(self):

        item=self.ui.text1.isRightToLeft()

        if item!=None:

            self.createContexMenu()

        """

------

源代码2:

# -*- coding: utf-8 -*-

import sys,time,os

import ctypes

from PyQt4 import QtCore, QtGui,Qt

from PyQt4.QtCore import Qt

from PyQt4.QtCore import pyqtSignature

from mp import Ui_Form

import win32gui,subprocess,string

import glob

import win32api

import win32con

User32dll = ctypes.windll.User32

#print ctypes.windll.User32

 

class MyForm(QtGui.QMainWindow):

    def __init__(self,parent=None):

        QtGui.QWidget.__init__(self,parent)

        self.ui=Ui_Form()

        self.ui.setupUi(self)

        self.createContexMenu()

 

        self.ui.open1.setToolTip(u‘添加文件/文件夹,Ctrl+O‘)

        self.ui.open1.setShortcut(u‘Ctrl+O‘)

        self.ui.cha.setToolTip(u‘查找当前目录文件/文件夹,Ctrl+F‘)

        self.ui.cha.setShortcut(u‘Ctrl+F‘)

        self.ui.ting.setToolTip(u‘暂停当前歌曲播放Ctrl+Alt+-‘)

        self.ui.hou.setToolTip(u‘向后一首Ctrl+Alt+[‘)

        self.ui.qian.setToolTip(u‘向前一首Ctrl+Alt+]‘)

        self.ui.ting.setShortcut(u‘Ctrl+Alt+-‘)

        self.ui.hou.setShortcut(u‘Ctrl+Alt+[‘)

        self.ui.qian.setShortcut(u‘Ctrl+Alt+]‘)

 

        self.vox=QtGui.QSlider(QtCore.Qt.Horizontal,self)

        self.vox.setFocusPolicy(QtCore.Qt.NoFocus)

        self.vox.setGeometry(400, 40, 80, 30)

        self.vox.setToolTip(u‘声音‘)

 

        self.lcd=QtGui.QLCDNumber(self)

        self.lcd.setGeometry(530, 40, 80, 30)

        self.vbox=QtGui.QVBoxLayout()

        self.vbox.addWidget(self.lcd)

        self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self1.jpg‘))

        self.ui.l1.resize(30,30)

 

        self.timer=QtCore.QBasicTimer()

        self.a=0

 

        #事件与信号

        self.ra=QtGui.QButtonGroup(None)

        self.ra.addButton( self.ui.ra1,0)

        self.ra.addButton( self.ui.ra2,1)

        self.ra.addButton( self.ui.ra3,2)

        self.ra.addButton( self.ui.ra4,3)

        self.connect(self.ra,QtCore.SIGNAL("clicked()"), self.buttonBoxx)

 

        self.connect( self.ui.ra1, QtCore.SIGNAL("clicked()"),self.change)

        self.connect( self.ui.ra2, QtCore.SIGNAL("clicked()"),self.change)

        self.connect( self.ui.ra3, QtCore.SIGNAL("clicked()"),self.change)

        self.connect( self.ui.ra4, QtCore.SIGNAL("clicked()"),self.change)

 

        self.connect(self.vox, QtCore.SIGNAL(‘valueChanged(int)‘), self.timerEvent)

        self.connect(self.vox,QtCore.SIGNAL(‘valueChanged(int)‘),

                     self.vov)

        self.connect(self.vox,  QtCore.SIGNAL(‘valueChanged(int)‘), self.lcd,

                 QtCore.SLOT(‘display(int)‘))

        self.connect(self.vox, QtCore.SIGNAL(‘valueChanged(int)‘), self.onstart)

        self.connect(self.vox, QtCore.SIGNAL(‘valueChanged(int)‘), self.timerEvent)

        self.connect(self.ui.hou,QtCore.SIGNAL(‘triggered()‘),QtGui.qApp,QtCore.SLOT(‘‘))#歌曲后一首

        self.connect(self.ui.qian,QtCore.SIGNAL(‘triggered()‘),QtGui.qApp,QtCore.SLOT(‘‘))#歌曲前一首

        self.connect(self.ui.ting,QtCore.SIGNAL(‘triggered()‘),QtGui.qApp,QtCore.SLOT(‘‘))#歌曲前暂停

 

        self.connect(self.ui.open1, QtCore.SIGNAL(‘clicked()‘), self.addafile)

        self.ui.ra1.setToolTip(u‘单曲播放‘)

        self.ui.ra2.setToolTip(u‘单曲循环‘)

        self.ui.ra3.setToolTip(u‘列表播放‘)

        self.ui.ra4.setToolTip(u‘随机播放‘)

        self.vox.setToolTip(u‘调节音量‘)

        self.ui.text1.setToolTip(u‘音乐‘)

        self.ui.l1.setToolTip(u‘静音‘)

        self.timeclose1=QtGui.QPushButton(u‘设置关机时间?‘,self)

        self.timeclose1.setGeometry(700,520,100,20)

        self.timeclose1.setToolTip(u‘关机时间‘)

        #self.ui.text1.toPlainText()对内容进行编辑

        #toPlainText

        #事件:

        self.connect(self.ui.text1,QtCore.SIGNAL(‘(customContextMenuRequested‘),self. createContexMenu)

        self.ui.text1.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

        self.connect(self.timeclose1,QtCore.SIGNAL(‘clicked()‘),self.timeclose2)

        #self.connect(self.timeclose1,QtCore.SIGNAL(‘returnPressed()‘),self.timeclose2)

        #self.connect(self.ui.text1,QtCore.SIGNAL(‘clicked()‘),self.ctypes1)

        #######self.connect(self.ui.text1,QtCore.SIGNAL(‘clicked()‘),self.t)

        #self.lineedit.selectAll()  选中状态

        #self.ui.text1.currentCharFormat()

        #self.connect(self.ui.text1,QtCore.SIGNAL(‘(customContextMenuRequested‘),self.t)#有问题

        #有问题self.connect(self.ui.text1,QtCore.SIGNAL(‘clicked()‘),self.open_x)

        #self.ui.text1.redo()

        #self.ui.text1.paste()

        #移出和删除事件

        #self.connect(self.ui.text1, QtCore.SIGNAL(‘itemDoubleClicked (QListWidgetItem *)‘), self.textpaichu)

        #self.connect(self.ui.text1, QtCore.SIGNAL(‘clicked()‘),self.textremove )

        self.connect(self.ui.text1, QtCore.SIGNAL(‘clicked()‘),self.select1 )

        #有问题self.connect(self.ui.text1,QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem*)"),self.paly)

        QtCore.QMetaObject.connectSlotsByName(self)

 

 

    def mouseDoubleClickEvent(self, event):

        self.emit(QtCore.SIGNAL(‘doubleClick‘))

    def timeclose2(self):

        self.gj1=QtGui.QLineEdit(self)

        self.gj1.setGeometry(100,60,40,30)

        text, ok = QtGui.QInputDialog.getText(self, u‘请输入‘,

                                              u‘关机时间?‘)

        if ok:

            self.gj1.setText(unicode(text))

        i=0

        while (self.gj1.text()>i):

            try:

                if float(self.gj1.text())>=0 and float(self.gj1.text())<=23:

                    self.j=float(self.gj1.text())*3600-int(i)

                    print ‘离下次关机秒为:‘,str(self.j),‘

                    time.sleep(1)

                    self.popo=QtGui.QSystemTrayIcon(self)

                    self.icon1=QtGui.QIcon(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\pic.jpg‘)

                    self.popo.setIcon(self.icon1)

                    if int(self.j)<=0:

                        self.popo.show()

                        self.popo.showMessage(u"提示",u"还有30秒钟关机",icon=3)

                        #o="c:\\windows\\system32\\shutdown -s -t 30"

                        #os.system(o)

                        print u‘爆炸了

                        break

                    i+=1

                else:

                   self.gj1.clear()

                   raise  IOError,‘当前输入的数据超出23或者小于0‘

                if (self.gj1.text())==int(i):

 

                    pass

            except ValueError:

               self.gj1.clear()

               print  QtGui.QMessageBox.information(self,‘warn:‘,self.tr(‘The input is invalid or error‘)),self.gj1.text()

               break

 

    #播放方式

    def change(self):

        if self.ui.ra1.isChecked():

            print u‘单曲循环

        elif  self.ui.ra2.isChecked():

            print u‘单曲播放

        elif  self.ui.ra3.isChecked():

            print u‘列表播放

        elif self.ui.ra4.isChecked():

            print u‘随机播放

        else:

            print u‘未选择

    def buttonBoxx(self):

        try:

            if self.ra.checkedId():

                print u‘当前选中的是‘,self.ra.checkedId()

        except Exception:

            print ‘error:‘,u‘4个状态未选中

 

 

    def createContexMenu(self):

        """

        创建右击菜单

        """

        #self.text(Qt.CustomContextMenu)

        self.setContextMenuPolicy(Qt.CustomContextMenu)

        self.customContextMenuRequested.connect(self.showContextMenu)

 

        #创建QMENU

        self.contextMenu=QtGui.QMenu()

        self.actionA=self.contextMenu.addAction(u‘添加歌曲文件/歌曲文件夹(基本完成)‘)

        self.actionA.setShortcut(u‘Ctrl+O‘)

        self.actionB=self.contextMenu.addAction(u‘清除歌曲列表(基本完成)‘)

        self.actionB.setShortcut(u‘Ctrl+C‘)

        self.actionC=self.contextMenu.addAction(u‘歌曲播放模式‘)

        self.actionD=self.contextMenu.addAction(u‘歌曲排序‘)

        self.actionD.setShortcut(u‘Ctrl+#‘)

        self.actionE=self.contextMenu.addAction(u‘打开歌曲所在目录或者路径‘)

        self.actionE.setShortcut(u‘Ctrl+F‘)

        self.actionF=self.contextMenu.addAction(u‘歌曲重名名‘)

        self.actionF.setShortcut(u‘Ctrl+R‘)

        self.actionG=self.contextMenu.addAction(u‘删除音乐文件(包括硬盘中的文件)(基本完成)‘)

        self.actionG.setShortcut(u‘Ctrl+D‘)

        self.actionH=self.contextMenu.addAction(u‘查看歌曲信息(基本完成)‘)

        self.actionH.setShortcut(u‘Ctrl+H‘)

        self.actionX=self.contextMenu.addAction(u‘导出歌曲‘)

        self.actionX.setShortcut(u‘Ctrl+P‘)

        self.actionS=self.contextMenu.addAction(u‘设置‘)

        self.actionS.setShortcut(u‘Ctrl+M‘)

        self.actionU=self.contextMenu.addAction(u‘更新音乐文件‘)

        self.actionU.setShortcut(u‘Ctrl+U‘)

        aboutAction = QtGui.QAction(QtGui.QIcon(""), u"关于(&A)(基本完成)", self)

        self.contextMenu.addAction(aboutAction)

        self.connect(aboutAction,QtCore.SIGNAL(‘triggered()‘),self.about)

        """

        self.she=QtGui.QPushButton(u‘设置(M)‘,self)

        self.she.setGeometry(230,490, 75, 23)

        self.she.setToolTip(u‘设置,Ctrl+M‘)

        self.she.setShortcut(u‘Ctrl+M‘)

    """

        #对播放模式选择

        self.a1=QtGui.QAction(u‘单曲循环‘,self)

        self.a2=QtGui.QAction(u‘单曲播放‘,self)

        self.a3=QtGui.QAction(u‘列表播放‘,self)

        self.a4=QtGui.QAction(u‘随机播放‘,self)

        self.c1=QtGui.QMenu()#二级菜单创建

        self.actionC.setMenu(self.c1)

        self.c1.addAction(self.a1)

        self.c1.addAction(self.a2)

        self.c1.addAction(self.a3)

        self.c1.addAction(self.a4)

        #对排序方式

        self.b1=QtGui.QAction(u‘播放次数‘,self)

        self.b2=QtGui.QAction(u‘文件大小‘,self)

        self.b3=QtGui.QAction(u‘随机排序‘,self)

        self.c2=QtGui.QMenu()

        self.actionD.setMenu(self.c2)

        self.c2.addAction(self.b1)

        self.c2.addAction(self.b2)

        self.c2.addAction(self.b3)

        #self.action*方法进行设置功能

        self.actionA.triggered.connect(self.actionHta)

        self.actionB.triggered.connect(self.actionHtb)

        self.actionC.triggered.connect(self.actionHtc)

        self.actionD.triggered.connect(self.actionHtd)

        self.actionE.triggered.connect(self.actionHte)

        self.actionF.triggered.connect(self.actionHtf)

        self.actionG.triggered.connect(self.actionHtg)

        self.actionH.triggered.connect(self.actionHth)

        self.actionX.triggered.connect(self.actionHtx)

        self.actionS.triggered.connect(self.actionHts)

        self.actionU.triggered.connect(self.actionHtu)

        ctypes.windll.user32.SetCursorPos(400,300)

        win32gui.GetCursorPos()#鼠标坐标信息

        #win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 400,200)

        #time.sleep(0.05)

        #win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 400, 400)

        #self.connect(self.actionC,QtCore.SIGNAL(‘triggered()‘),self.actionHtc)

 

    def actionHts(self):#设置

        self.setup =QtGui.QTextBrowser(self.ui.text1)#####

        self.setup.setGeometry(100,70,600,400)

        self.setup.show()

        self.Optionsetting=QtGui.QLabel(u‘选       项       设      置‘,self)

        self.Optionsetting.setToolTip(u‘选项设置‘)

        self.Optionsetting.setGeometry(100,70,300,30)

        self.Optionsetting.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.Optionsetting.show()

        self.Generalsettings=QtGui.QPushButton(u‘   常规设置‘,self)

        self.Generalsettings.setToolTip(u‘常规设置‘)

        self.Generalsettings.setGeometry(100,95,150,30)

        self.Generalsettings.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.Generalsettings.setIcon(QtGui.QIcon(‘./Gear.png‘))

        self.Generalsettings.setIconSize(QtCore.QSize(35,21))

        self.Generalsettings.setMask(QtGui.QPixmap("‘./Gear.png").mask())

        self.Generalsettings.setStyleSheet("* {  margin-top:0pt; ">        self.Generalsettings.show()

        self.close1=QtGui.QPushButton(u‘x‘,self)#功能完成

        self.close1.setGeometry(670,70,30,20)

        self.close1.setStyleSheet("* {  margin-top:0pt; ">        self.close1.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.close1.show()

        self.habit=QtGui.QPushButton(u‘   操作习惯功能暂不支持‘,self)

        self.habit.setToolTip(u‘操作习惯功能暂不支持‘)

        self. habit.setGeometry(100,135,150,30)

        self.habit.setIcon(QtGui.QIcon(‘./Rocker.png‘))

        self.habit.setIconSize(QtCore.QSize(35,21))

        self.habit.setMask(QtGui.QPixmap("‘./Rocker.png").mask())

        self.habit.setIconSize(QtCore.QSize(35,21))

        self.habit.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.habit.setStyleSheet("* {  margin-top:0pt; ">        self.habit.show()

        self.Hotkey=QtGui.QPushButton(u‘   热键设置‘,self)

        self.Hotkey.setToolTip(u‘热键设置‘)

        self.Hotkey.setGeometry(100,175,150,30)

        self.Hotkey.setIcon(QtGui.QIcon(‘./Hotkey settings.png‘))

        self.Hotkey.setIconSize(QtCore.QSize(35,21))

        self.Hotkey.setMask(QtGui.QPixmap("‘./Hotkey settings.png").mask())

        self.Hotkey.setIconSize(QtCore.QSize(35,21))

        self.Hotkey.setFont(QtGui.QFont(‘oldEnglish‘,15))

        self.Hotkey.setStyleSheet("* {  margin-top:0pt; ">        self.Hotkey.show()

        self.connect(self.close1,QtCore.SIGNAL(‘clicked()‘),self.off)

        self.close1.setToolTip(u‘设置选项关闭‘)

        #对常规设置按钮

        self.connect(self.Generalsettings,QtCore.SIGNAL(‘clicked()‘),self.Genetimes)

        self.connect(self.Hotkey,QtCore.SIGNAL(‘clicked()‘),self.Shortcutkeys)

        self.setup.exec_(QtGui.QCursor.pos())#有问题

    #self.Generalsettings=QtGui.QPushButton(u‘   常规设置‘,self)继续做这个

 

    def Shortcutkeys(self):

        self.button=QtGui.QTextBrowser(self)

        self.button.setGeometry(300,100,400,400)

        self.button.show()

        self.tab=QtGui.QTableWidget(10,2,self)

        self.tab.setGeometry(320,120,300,300)

        self.tab.setHorizontalHeaderLabels([u‘动作内容‘,u‘全局快捷键(热键 )‘])

        self.tab.show()

        self.dongzuo1=QtGui.QTableWidgetItem(u‘打开文件/文件夹‘)

        self.rj1=QtGui.QTableWidgetItem(u‘Ctrl+O‘)

        self.tab.setItem(0,0,self.dongzuo1)

        self.tab.setItem(0,1,self.rj1)

        self.dongzuo2=QtGui.QTableWidgetItem(u‘查找音乐文件‘)

        self.rj2=QtGui.QTableWidgetItem(u‘Ctrl+F‘)

        self.qian1=QtGui.QTableWidgetItem(u‘向前一首‘)

        self.rj3=QtGui.QTableWidgetItem(u‘Ctrl+Alt+]‘)

        self.hou1=QtGui.QTableWidgetItem(u‘向后一首‘)

        self.rj4=QtGui.QTableWidgetItem(u‘Ctrl+Alt+[‘)

        self.ting1=QtGui.QTableWidgetItem(u‘暂停当前歌曲‘)

        self.rj5=QtGui.QTableWidgetItem(u‘Ctrl+aLT+-‘)

        self.tab.setItem(0,2,self.dongzuo2)

        self.tab.setItem(1,1,self.rj2)

        self.tab.setItem(0,4,self.qian1)

        self.tab.setItem(1,3,self.rj3)

        self.tab.setItem(0,6,self.hou1)

        self.tab.setItem(1,5,self.rj4)

        self.tab.setItem(0,8,self.ting1)

        self.tab.setItem(1,7,self.rj5)

        self.tab.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)

        self.tab.setEditTriggers(QtGui.QAbstractItemView.SelectedClicked)

        self.tab.verticalHeader().setVisible(False)#隐藏行与列

        #self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self5.jpg‘))

        self.close3=QtGui.QPushButton(self)

        self.close3.setGeometry(570,395,30,25)

        self.close3.setIcon(QtGui.QIcon(‘./Rocker.png‘))

        self.close3.setIconSize(QtCore.QSize(20,170))

        self.close3.setMask(QtGui.QPixmap((‘./Rocker.png‘)).mask())

        self.close3.setToolTip(u‘热键设置关闭‘)

        self.close3.show()

        self.connect(self.close3,QtCore.SIGNAL(‘clicked()‘),self.close3_1)

 

    def close3_1(self):#有问题

        sys.exit(0)

    def Genetimes(self):

        self.mian=QtGui.QTextBrowser(self)

        self.mian.setGeometry(300,50,500,400)

        self.mian.show()

        self.whenstar=QtGui.QLabel(u‘启 动 时‘,self)

        self.whenstar.setToolTip(u‘启动时‘)

        self.whenstar.setGeometry(300,60,200,25)

        self.whenstar.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.whenstar.show()

        self.xian1=QtGui.QLabel(u‘----------------------------‘,self)

        self.xian1.setGeometry(410,60,500,35)

        self.xian1.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.xian1.show()

        #复选框

        self.radion1=QtGui.QCheckBox(u‘自动播放歌曲‘,self)

        self.radion1.setGeometry(300,85,150,35)

        self.radion1.show()

        self.radion1.toggle()#checked状态发生改变时 发出toggled(bool) 信号

        #如果想对复选框之类的东西进行选中的,就必须使用obj.toggle()这个方法

        #toggle()切换反转的意思

        #button.setCheckable(True) #设置为开关按钮 toggle 就是按下按钮不会弹起

        self.xian2=QtGui.QLabel(u‘-----------------------------------‘,self)

        self.xian2.setGeometry(300,100,1000,35)

        self.xian2.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.xian2.show()

        self.close2=QtGui.QLabel(u‘关闭或者缩小‘,self)

        self.close2.setGeometry(300,130,170,35)

        self.close2.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.close2.show()

        self.radion_1=QtGui.QRadioButton(u‘最小化到系统托盘,不退出程序‘,self)

        self.radion_2=QtGui.QRadioButton(u‘退出程序‘,self)

        #self.radion_1.setChecked(True)

        self.radion_1.setGeometry(330,150,180,35)

        self.radion_2.setGeometry(330,170,150,35)

        #self.radion_1.toggle()

        self.radion_1.show()

        self.radion_2.show()

        self.radion1.setFocusPolicy(QtCore.Qt.NoFocus)

        self.radion_1.setFocusPolicy(QtCore.Qt.NoFocus)

        self.radion_2.setFocusPolicy(QtCore.Qt.NoFocus)

        self.xian3=QtGui.QLabel(u‘-----------------------------------‘,self)

        self.xian3.setGeometry(300,180,1000,35)

        self.xian3.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.xian3.show()

        self.delete=QtGui.QLabel(u‘是否保留文件?‘,self)

        self.delete.setGeometry(300,200,175,35)

        self.delete.setFont(QtGui.QFont(‘oldEnglish‘,20))

        self.delete.show()

        self.Retention=QtGui.QRadioButton(u‘保留本地歌曲文件?‘,self)

        self.Retention.setGeometry(320,220,175,35)

        self.Retention.show()

 

        self.connect(self.radion1,QtCore.SIGNAL(‘stateChanged(int)‘),

                     self.radion2)#stateChanged(int)复选框被选中或清除

        self.connect(self.radion_1,QtCore.SIGNAL(‘clicked()‘),

                     self.radion_x)#stateChanged(int)复选框被选中或清

        self.connect(self.radion_2,QtCore.SIGNAL(‘clicked()‘),

                     self.radion_x1)#stateChanged(int)复选框被选中或清

        self.connect(self.Retention,QtCore.SIGNAL(‘clicked()‘),

                     self.Retention1)

 

 

    def Retention1(self):

        if self.Retention.isChecked():

            path=u‘F:\\KuGou\\叮当 猜不透1.mp3‘

            reply=QtGui.QMessageBox.question(self,u‘是否保留本地文件?‘,

                                             u‘确定要删除本地文件吗?‘,QtGui.QMessageBox.Yes,

                                             QtGui.QMessageBox.No)

            if reply==QtGui.QMessageBox.Yes:

                print u‘删除本地硬盘文件

                os.remove(path)

            else:

                print u‘不删除本地硬盘文件

 

    def off(self):#有问题

        time.sleep(1)

        print u‘关闭中

        sys.exit(0)

        time.sleep(1)

    def radion2(self,value):

        if self.radion1.isChecked():

            print  u‘已选中

        else:

            print  u‘未选中

    def radion_x(self):

        if self.radion_1.isChecked():

            print ‘self.radion_1‘,u‘选中

        else:

             print ‘self.radion_1‘,u‘未选中

    def radion_x1(self):

        if self.radion_2.isChecked():

            print ‘self.radion_2‘,u‘选中

        else:

             print ‘self.radion_2‘,u‘未选中

    def actionHth(self):#查看歌曲信息

        self.information =QtGui.QTextBrowser(self)

        self.information.setGeometry(100,70,600,400)

        self.information.setStyleSheet("* {  margin-top:0pt; ">        self.information.show()

        self.heng1=QtGui.QLabel(u‘----------------------------------------‘,self)

        self.heng1.setGeometry(110,55,300,50)

        self.heng1.show()

        self.heng2=QtGui.QLabel(u‘-------------------------------------------‘,self)

        self.heng2.setGeometry(430,55,300,50)

        self.heng2.show()

        self.fileinformation=QtGui.QLabel(u‘歌曲信息‘,self)

        self.fileinformation.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.fileinformation.setGeometry(350,60,100,30)

        self.fileinformation.setStyleSheet("* {  margin-top:0pt; ">        self.fileinformation.show()

        self.for1=QtGui.QLabel(u‘文件信息:‘,self)

        self.for1.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.for1.setGeometry(110,85,300,40)

        self.for1.show()

        self.heng3=QtGui.QLabel(u‘---------------------------------------------------------------------------------‘,self)

        self.heng3.setGeometry(200,85,5000,50)

        self.heng3.show()

        self.filepath=QtGui.QLabel(u‘音乐文件路径:‘,self)

        self.filepath.setGeometry(110,115,300,70)

        self.filepath.show()

        self.filepath1=QtGui.QPushButton(u‘浏览‘,self)

        self.filepath1.setGeometry(200,135,50,30)

        self.filepath1.show()

        self.look=QtGui.QLabel(U‘a‘,self)

        self.filesize=QtGui.QLabel(u‘音乐文件大小:‘,self)

        self.filesize.setGeometry(110,160,100,50)

        self.filesize.show()

        self.filesize1=QtGui.QTextBrowser(self)

        self.filesize1.setGeometry(200,170,160,30)

        self.filesize1.show()

        self.bytex=QtGui.QLabel(u‘:bytes(或字节)‘,self)

        self.bytex.setGeometry(370,170,200,30)

        self.bytex.setFont(QtGui.QFont(‘OldEnglish‘, 15))

        self.bytex.show()

        self.fileformat=QtGui.QLabel(u‘音乐文件格式:‘,self)

        self.fileformat.setGeometry(110,210,200,30)

        self.fileformat.show()

        self.fileformat1=QtGui.QTextBrowser(self)

        self.fileformat1.setGeometry(200,210,200,30)

        self.fileformat1.show()

        self.singer=QtGui.QLabel(u‘歌        手:‘,self)

        self.singer.setGeometry(110,250,200,30)

        self.singer.show()

        self.singer1=QtGui.QTextBrowser(self)

        self.singer1.setGeometry(200,250,200,30)

        self.singer1.show()

        self.album=QtGui.QLabel(u‘专     辑:‘,self)

        self.album.setGeometry(420,210,200,30)

        self.album.show()

        self.album1=QtGui.QTextBrowser(self)

        self.album1.setGeometry(490,210,200,30)

        self.album1.show()

        self.timelength=QtGui.QLabel(u‘时     长:‘,self)

        self.timelength.setGeometry(420,250,200,30)

        self.timelength.show()

        self.timelength1=QtGui.QTextBrowser(self)

        self.timelength1.setGeometry(490,250,200,30)

        self.timelength1.show()

        self.quality=QtGui.QLabel(u‘音        质:‘,self)

        self.quality.setGeometry(110,290,200,30)

        self.quality.show()

        self.quality1=QtGui.QTextBrowser(self)

        self.quality1.setGeometry(200,290,200,30)

        self.quality1.show()

 

    def showContextMenu(self,pos):

        self.contextMenu.move(self.pos()+pos)

        self.contextMenu.show()

 

 

    def actionHta(self):

 

        self.list=[]

        self.file1=QtGui.QFileDialog.getOpenFileNames(self,‘Open file‘,‘/‘,‘mp3(*.mp3)‘)

        #for files in range(len(self.file1)):

        #for it in glob.glob(self.file1):

        for it in self.file1:

            #self.list.append(self.ui.text1.append(self.file1[files]))

            self.ui.text1.addItem(it)

 

    """

    self.a1=QtGui.QAction(u‘单曲循环‘,self)

    self.a2=QtGui.QAction(u‘单曲播放‘,self)

    self.a3=QtGui.QAction(u‘列表播放‘,self)

    self.a4=QtGui.QAction(u‘随机播放‘,self)

    self.c1=QtGui.QMenu()#二级菜单创建

    self.actionC.setMenu(self.c1)

    self.c1.addAction(self.a1)

    self.c1.addAction(self.a2)

    self.c1.addAction(self.a3)

    self.c1.addAction(self.a4)

    """

 

    def actionHtc(self):#u‘歌曲播放模式

        if self.actionC(self.c1):

            print ‘a‘

    def triggerEvent(self,action):

        print(‘Event triggered: %s‘ % action.text())

    def actionHtb(self):

        self.ui.text1.clear()

    """

      self.b1=QtGui.QAction(u‘播放次数‘,self)

        self.b2=QtGui.QAction(u‘文件大小‘,self)

        self.b3=QtGui.QAction(u‘随机排序‘,self)

    """

    def actionHtd(self):#‘歌曲排序

        print u‘D‘

    def actionHte(self):#打开歌曲所在目录或者路径

        print u‘E‘

    def actionHtf(self,path):#歌曲重名名

        pass

    def actionHtg(self):#删除音乐文件

        path=u‘F:\\KuGou\\叮当 猜不透1.mp3‘

        if os.path.exists(path):

            re1=QtGui.QMessageBox.question(self,u‘删除当前选择歌曲‘,u‘是否彻底删除歌曲?%s?‘%(path),QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)

            if re1==QtGui.QMessageBox.Yes:

                print u‘删除

                time.sleep(1)

                os.remove(path)

            else:

                print u‘未删除

                time.sleep(1)

                pass

 

    def actionHtx(self):#导出歌曲

        pass

    def actionHtu(self):#更新

        print‘U‘

 

    """

    def mousePressEvent(self,event):

        if event.button()==Qt.LeftButton:

            self.dragPosition=event.globalPos()-self.frameGeometry().topLeft()

            event.accept()

        if event.button()==Qt.RightButton:

            self.ui.text1.pos()

            print‘aaaa‘

    def mouseMoveEvent(self,event):

        if event.buttons() & Qt.LeftButton:

            self.move(event.globalPos()-self.dragPosition)

            event.accept()

    """

    def addafile(self):

        self.list=[]

        self.file1=QtGui.QFileDialog.getOpenFileNames(self,‘Open file‘,‘/‘,‘mp3(*.mp3)‘)

        #for files in range(len(self.file1)):

        #for it in glob.glob(self.file1):

        for it in self.file1:

            #self.list.append(self.ui.text1.append(self.file1[files]))

            self.ui.text1.addItem(it)

 

    def vov(self,value):

        self.pos=self.vox.value()

        if self.pos==0:

            print‘声音静音0%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self1.jpg‘))

            self.ui.l1.setToolTip(u‘静声‘)

 

        elif 0<self.pos<=30:

            print‘声音中小25%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self2.jpg‘))

            self.ui.l1.setToolTip(u‘声音达到25%‘)

        elif 30<self.pos<=80:

            print‘声音较中50%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self3.jpg‘))

            self.ui.l1.setToolTip(u‘声音达到50%‘)

 

        elif 80<self.pos<=95:

            print‘声音较大75%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self4.jpg‘))

            self.ui.l1.setToolTip(u‘声音达到75%‘)

 

        else:

            print‘声音最大100%‘

            self.ui.l1.setPixmap(QtGui.QPixmap(‘E:\\pyqt\\2013year9month2\\flie1\\BUGmusicbox\\self5.jpg‘))

            self.ui.l1.setToolTip(u‘声音最大‘)

 

    def showContextMenu(self,pos):

        self.contextMenu.move(self.pos()+pos)

        self.contextMenu.show()

    def timerEvent(self,event):

        if self.a>=100:

            #self.vox()

            self.timer.stop()

            return

        self.a+=1

        self.vox.setValue(self.a)

    def onstart(self):

        if self.timer.isActive():

            self.timer.stop()

        else:

            self.timer.start(100,self)

    def paly(self):

        self.signallist=self.sender()

        self.itek=self.signallist.currentRow()

        self.itemtext=self.ui.text1[self.itek]

        self.url=string.split(self.itemtext)[1]

        subprocess.Popen([‘smplay‘,self.url])

    def about(self):#关于

about = QtGui.QMessageBox(self)

about.setWindowTitle(u‘关于BUG Player‘)

about.setText(u"BUG音乐盒是一个简单MP3播放器\n\mhxy13867806343@live.cn,<a href=http://music.baidu.com/>http://music.baidu.com/songlist</a>")

about.show()

    #排出

    def textpaichu(self):

        self.ui.text1.takeItem(self.ui.text1.currentRow())

        # self.lst.setSortingEnabled(True)进行从下面开始到上面的进行排序

    #删除

    def textremove(self):

        self.ui.text1.takeItem(self.ui.text1.currentRow())

    def select1(self):

        self.ui.text1.selectedItems()

    #空白处不进行右击操作

    @pyqtSignature(‘QPoint‘)

    def on_listview_customcontextme(self,point):

        self.uite=self.ui.text1.itemAt(point)

        if self.uite!=None:

            self.createContexMenu()

 

 

if __name__ == "__main__":

    app = QtGui.QApplication(sys.argv)

    myapp =MyForm()

    myapp.show()

    sys.exit(app.exec_())

 #self.contextMenu.addAction(self.a1)

        #self.contextMenu.addAction(self.a2)

        #self.contextMenu.addAction(self.a3)

        #self.contextMenu.addAction(self.a4)

    """

    @pyqtSignature(‘QPoint‘)

    def on_list(self):

        item=self.ui.text1.isRightToLeft()

        if item!=None:

            self.createContexMenu()

             @pyqtSignature("QTreeWidgetItem(int)")

    def on_textBrowser(self,item,index):

        self.open_bookmark()

    #打开后编辑

    def open_x(self):

        self.ui.text1.openPersistentEditor(QtGui.QListWidgetItem.Type)

        pass

    @pyqtSignature("QListWidgetItem*")

    def on1(self,item_new):

        self.open_pdf_file()

 

        """

pyqt备份之1和2

标签:

原文地址:http://www.cnblogs.com/mhxy13867806343/p/4058415.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!