博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MyQThread
阅读量:6686 次
发布时间:2019-06-25

本文共 3214 字,大约阅读时间需要 10 分钟。

# coding=utf-8from PyQt4.QtCore import *import Tkinter as tkimport osimport timeclass MyQThread(QThread):    def __init__(self, parent=None):        super(MyQThread, self).__init__(parent)        self.working = True        self.num = 0    def __del__(self):        self.working = False        self.wait()    def run(self):        while self.working == True:            file_str = 'File index {0}'.format(self.num)            self.num += 1            self.sleep(10)            # print 'jianpan'            self.emit(SIGNAL('output(QString)'), file_str)class MyQThread_30(QThread):    def __init__(self, parent=None):        super(MyQThread_30, self).__init__(parent)        self.working = True        self.num = 0    def __del__(self):        self.working = False        self.wait()    def run(self):        while self.working == True:            file_str = 'File index {0}'.format(self.num)            self.num += 1            self.sleep(20)            self.emit(SIGNAL('output(QString)'), file_str)class MyQThreadDelay(QThread):    def __init__(self, parent=None):        super(MyQThreadDelay, self).__init__(parent)        self.working = True        self.num = 0    def run(self):        os.popen('warning.mp3')        print 'finish'class MyQThread_Warning(QThread):    def __init__(self, parent=None):        super(MyQThread_Warning, self).__init__(parent)        self.working = True        self.num = 0    def run(self):        # filename = r'music_delay.mp3'        # mp3 = mp3play.load(filename)        # mp3.play()        # time.sleep(mp3.seconds())        # print mp3.isplaying()        print '1'    def open(self):        self.root = WarningTK()        self.root.mainloop()    def getDlg(self):        return self.root.destroy    def close(self):        try:            self.root.quit()            self.root.destroy()        except Exception, e:            print eclass WarningTK(tk.Tk):    def __init__(self, master=None):        tk.Tk.__init__(self, master)        self.title('test')        self.withdraw()        screenwidth = self.winfo_screenwidth()        screenheight = self.winfo_screenheight() - 100        self.resizable(False, False)        # 添加组件        self.title("Warning!!")        frame = tk.Frame(self, relief=tk.RIDGE, borderwidth=3)        frame.pack(fill=tk.BOTH, expand=1)  # pack() 放置组件若没有则组件不会显示        # 窗口显示的文字、并设置字体、字号        label = tk.Label(frame, text="You have been working 30 minutes! Please have a break!!", \                         font="Monotype\ Corsiva -20 bold")        label.pack(fill=tk.BOTH, expand=1)        # 按钮的设置        self.button1 = tk.Button(frame, text="OK", font="Cooper -25 bold", fg="red", command=self.destroy)        self.button1.pack(side=tk.BOTTOM)        self.update_idletasks()        self.deiconify()  # now the window size was calculated        self.withdraw()  # hide the window again 防止窗口出现被拖动的感觉 具体原理未知?        self.geometry(            '%sx%s+%s+%s' % (self.winfo_width() + 10, self.winfo_height() + 10,                             (screenwidth - self.winfo_width()) / 2,                             (screenheight - self.winfo_height()) / 2))        self.deiconify()        self.mainloop()

转载于:https://www.cnblogs.com/jian-pan/p/6934847.html

你可能感兴趣的文章
安装和配置VNC服务器的法则
查看>>
ELK统一日志系统的应用
查看>>
select top @varible
查看>>
Incoming call missed/rejected Reminder on Windows Mobile
查看>>
iOS:网络编程的第三方框架:AFNetworking、SDWebImage
查看>>
集合已修改 ;可能无法执行枚举操作 Dictionary
查看>>
Ruby正则表达式实践非贪婪量词
查看>>
robot framework环境搭建
查看>>
Android百度地图相关内容汇总
查看>>
ITTC数据挖掘系统(六)批量任务,数据查看器和自由文档
查看>>
[Android Memory] 手动回收ImageVIew的图片资源
查看>>
GNU make manual 翻译( 一百四十一)
查看>>
LindAgile.SchedulingTask~设计一个不错的任务调度组件
查看>>
PostgreSQL的notify 与listen (一)
查看>>
高可用高性能分布式文件系统FastDFS进阶keepalived+nginx对多tracker进行高可用热备...
查看>>
【原】关于nil的几点认识,居然都现在才发现~~
查看>>
重新注册iis的.NET Framework版本
查看>>
Neutron 理解(5):Neutron 是如何向 Nova 虚机分配固定IP地址的 (How Neutron Allocates Fixed IPs to Nova Instance)...
查看>>
JS组件系列——BootstrapTable 行内编辑解决方案:x-editable
查看>>
关于Git的工作区域和对应的文件状态.
查看>>