tkinter gui界面使用调戏妹子
# _*_ coding: utf-8 _*_
__author__ = 'pythonwu'
__date__ = "2018/7/18 14:43"
from tkinter import *
from PIL import Image,ImageTk
import tkinter.messagebox
import os
from multiprocessing import Process
class Window(Frame):
def __init__(self,master = None):
Frame.__init__(self,master)
self.master = master
self.numbers = []
self.init_window()
def init_window(self):
self.master.title(" xx IS FOREVER !")
self.pack(fill=BOTH,expand = 1)
menu = Menu(self.master)
self.master.config(menu=menu)
file = Menu(menu)
file.add_command(label = '相册',command = self.showImg)
file.add_command(label = '心里话',command = self.showTxt)
menu.add_cascade(label='珍惜',menu=file)
def showImg(self):
load = Image.open('pic.png')
render = ImageTk.PhotoImage(load)
img = Label(self,image=render)
img.image = render
img.place(x=0,y=0)
def showTxt(self):
if len(self.numbers) == 9 :
text = Label(self,text='彩蛋,I LOVE YOU')
text.pack()
else:
text = Label(self,text='哎iu被发现了')
text.pack()
# self.numbers += 1
# print(self.numbers)
self.numbers.append('1') #添加类属性进行计数
def run_proc(name):
for i in range(10):
root = Tk()
root.geometry('400x300')
def protect():
tkinter.messagebox.showinfo('请大声说:汪汪汪','接收声音中....')
root.protocol("WM_DELETE_WINDOW", protect) #重写x按钮使之无效化
app = Window(root)
root.mainloop()
if __name__ == '__main__':
print('Parent process %s.' % os.getpid())
p = Process(target=run_proc, args=('test',))
print('Child process will start.')
p.start()
p.join()
print('Child process end.')
最后使用Pyinstaller 打包选择 --noconsole 去除cmd黑框
效果展示