tkinker(1)

import tkinter as tk
import openpyxl
from tkinter import filedialog
from tkinter import messagebox
import threading
import re
'''松耦合'''
# 弹窗
class MyDialog(tk.Toplevel):
  def __init__(self, Myname):
    super().__init__()
    self.Myname = Myname
    self.setup_but()
    # 弹窗界面
  def setup_but(self):
    tk.Button(self, text=self.Myname, command=self.but).pack()

  def but(self):
    global chartname
    chartname = filedialog.askopenfilenames()
    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.setupBut('Controller umts radio Chart')
    self.setupBut('Cells List Chart')
    self.setupBut('Parameters Rule')

  def setupBut(self, FileName):
    self.FileName = FileName
    tk.Button(self, text=self.FileName, command=self.ask_ParFile).pack(side=tk.RIGHT)

  # 弹窗
  def ask_ParFile(self):
    butname = 'Click the button to open ' + self.FileName
    inputDialog = MyDialog(butname)
    self.wait_window(inputDialog) # 这一句很重要!!!
    print (chartname)
if __name__ == '__main__':
  app = MyApp()
  app.mainloop()
  print (chartname)
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容