Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import os
- import tkinter as tk
- from tkinter import StringVar, OptionMenu, Button, messagebox, Frame
- from mani_functions import _1_check, _2_check, _3_check
- from pathlib import Path
- # create and title the window
- root = tk.Tk()
- root.title("Addendum")
- # Add a grid
- mainframe = Frame(root)
- mainframe.grid(column=0,row=0, sticky="" )
- mainframe.columnconfigure(0, weight = 1)
- mainframe.rowconfigure(0, weight = 1)
- mainframe.pack(pady = 0, padx = 75)
- # list of options for dropdown menu
- optionList = ['Check 1', 'Check 2', 'Check 3']
- # dictionary of functions
- funct_Dict = {
- 'Check 1': _1_check,
- 'Check 2': _2_check,
- 'Check 3': _3_check
- }
- # path to save file
- file = Path('C:/Desktop/Addendum.xlsx')
- def func(value):
- try:
- print(value)
- funct_Dict[value]()
- except:
- root.quit()
- root.destroy()
- def on_closing():
- if messagebox.askokcancel("Quit", "Do you want to quit?"):
- root.quit()
- root.destroy()
- # create tkinter variables and OptionMenu
- root.dropVar=StringVar(root)
- root.dropVar.set("Select a file")
- root.dropMenu = OptionMenu(root, root.dropVar, *optionList, command=func)
- root.quitButton = Button(root, text='Quit', command=root.quit)
- root.dropMenu.pack()
- root.protocol("WM_DELETE_WINDOW", on_closing)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment