#脚本工具代码重构
import openpyxl
from tkinter import filedialog
from tkinter import messagebox
import threading
import re
import tkinter as tk
'''松耦合'''
# 弹窗
class MyDialog(tk.Toplevel):
def __init__(self):
super().__init__()
self.title('文件导入窗口')
# 弹窗界面
self.setup_UI()
self.wm_attributes('-topmost',1)
def setup_UI(self):
# 第一行(两列)
tk.Button(self, text="退出文件导入窗口", width=30, command=self.ExitWin).pack(side=tk.BOTTOM)
tk.Button(self, text="Import Controller umts radio Files", width=30, command=self.ParBut).pack(side=tk.BOTTOM)
tk.Button(self, text="Import Parameters Rule File", width=30, command=self.RulBut).pack(side=tk.BOTTOM)
tk.Button(self, text="Import Cells List File", width=30, command=self.CelBut).pack(side=tk.BOTTOM)
def ParBut(self):
global ParFile
ParFile = filedialog.askopenfilenames()
#self.destroy() # 销毁窗口
def RulBut(self):
global RulFile
RulFile = filedialog.askopenfilenames()
#self.destroy() # 销毁窗口
def CelBut(self):
global CelFile
CelFile = filedialog.askopenfilenames()
#self.destroy()
def ExitWin(self):
self.destroy()
# 主窗
class MyApp(tk.Tk):
def __init__(self):
super().__init__()
#self.pack() # 若继承 tk.Frame ,此句必须有!
self.title('Script Creater V2.0')
self.geometry('1200x800')
self.setupUI()
def setupUI(self):
tk.Button(self, text="打开文件导入窗口", command=self.ask_filename).pack(side=tk.LEFT)
def ask_filename(self):
inputDialog = MyDialog()
self.wait_window(inputDialog) # 这一句很重要!!!
print (CelFile)
print (RulFile)
print (ParFile)
if __name__ == '__main__':
app = MyApp()
app.mainloop()
tkinker(2)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。