上一章,我们用介绍了多线程,大家可以看一下: Python GUI:Tkinter——06 本章我们将要介绍 文件浏览弹窗,以及如何将我们的 .py 文件,打包成 exe,以便所有人使用它!!!
搭建 GUI
我们在 tab2 页面添加如下代码,首先打开 tab2.py 文件,并修改:
import tkinter as tk
from tkinter import ttk
import shutil
from tkinter import messagebox as mBox
class Tab2():
"""开发页面2"""
def __init__(self,tab):
self._createWidget(tab)
def _createWidget(self,tab):
self.muniao = ttk.LabelFrame(tab,text='我是frame')
self.muniao.grid(column=0,row=0)
"""之后,所有的空间的 Master 就是 frame muniao了"""
self.dFlag = tk.IntVar()
self.eFlag = tk.IntVar()
self.fFlag = tk.IntVar()
self.dCheck = tk.Checkbutton(self.muniao,variable=self.dFlag,text='A',state='disabled')
self.eCheck = tk.Checkbutton(self.muniao,variable=self.eFlag,text='B')
self.eCheck.select()
self.fCheck = tk.Checkbutton(self.<