-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython - TK - Dropdown Menu Info.txt
More file actions
37 lines (28 loc) · 1.03 KB
/
Python - TK - Dropdown Menu Info.txt
File metadata and controls
37 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import tkinter as tk
from tkinter import ttk
import pandas as pd
customer_files_directory = 'C:/Users/botoole/Documents/BX STUFF/CODING DOCS/'
def on_select(event=None):
# Retrieve the selected item from the dropdown list
selection = dropdown.get()
# Read the corresponding Excel file
df = pd.read_excel(customer_files_directory + f'{selection}.xlsx')
# Display the contents of the file in the text box
text.config(state='normal')
text.delete('1.0', tk.END)
text.insert('1.0', df.to_string())
text.config(state='disabled')
root = tk.Tk()
root.title('NetXPerts Customer Information Directory')
# Create the dropdown list
dropdown = ttk.Combobox(root, values=['Applied Test Systems', 'file2', 'file3'])
dropdown.current(0)
dropdown.bind('<<ComboboxSelected>>', on_select)
dropdown.pack()
# Create the button
button = tk.Button(root, text='Submit', command=on_select)
button.pack()
# Create the text box
text = tk.Text(root, state='disabled')
text.pack()
root.mainloop()