0

I am still a little new on python and tkinter and I have a question. I have a GUI that has two dropdowns the ultimate goal is to have each drop download load a second file. The question that I have is whether there is an ability that if I used one drop down I can set it to ignore the other dropdown. I coded everything into one function but wonder if that needs to be in two. The two issues that I am having are when I choose Belen or Corales variables in clicked1 nothing happens or if I choose the variable in clicked both variables happen.


from tkinter import *
from unittest import result
import sqlalchemy as sa
from PIL import ImageTk
#!/usr/bin/env python3
from tkinter.tix import Tk, Tree
from turtle import st
import sqlalchemy as sa
import pandas as pd
import subprocess





root=Tk()
root.title("Compliance Helper")
root.eval("tk::PlaceWindow . center")
bg_color = '#3d6446'

North_Central = ["North Central Steel SLO","Espanola", "Santa Fe"]
Metro = ["Metro Steel SLO", "ABQ", "Belen", "Corales"]

clicked1 = StringVar()
clicked1.set("Metro Steel SLO")
drop1 = OptionMenu(root, clicked1, *Metro)
drop1.config(background="#28393a", fg='white')
drop1.pack(padx=3, pady=2, side="left")

clicked = StringVar()
clicked.set("North Central Steel SLO")
drop = OptionMenu(root, clicked, *North_Central)
drop.config(background="#28393a", fg="white")
drop.pack(padx=3, pady=2, side="left")


def load_db():
    #result = subprocess.call(["python", "TKTest.py"])
    #result1 = subprocess.call(["python", "TKTest1.py"])
   if clicked.get() == 'Espanola':
       subprocess.call(["python", "TKTest.py"])
   elif clicked.get() == 'Santa Fe':
       subprocess.call(["python", "TKTest1.py"])
   else:
       pass
   if clicked1.get() == 'ABQ':
        print("Metro Records")
   elif clicked1.get == 'Belen':
        print ("Belen Records")
   elif clicked1.get == 'Corales':
        print ("Corales Records")
   else:
       pass
       

        
    
    
     

def load_frame1():
    #load frame 1 for selection
    frame1.pack_propagate(False)
    logo_img = ImageTk.PhotoImage(file="photo/image.jpg")

    logo_widget = Label(frame1, image=logo_img, bg=bg_color)
    logo_widget.image = logo_img
    logo_widget.pack()
    label1 = Label(frame1, text="Please select data that you are needing?", bg=bg_color, fg="white", font=("TkMenu")).pack()
  
    Button(frame1, text="Generate Report", font=("TkheadingFont", 20), bg="#28393a", fg="white", command=lambda:load_frame2()).pack(pady=20)
    
    

    
    
def load_frame2():
    load_db()
    

#drop down setup

frame1 = Frame(root, width=500, height=600, bg=bg_color)
frame2 = Frame(root,bg=bg_color)

for frame in (frame1, frame2):
    frame.pack(padx=0, pady=0)
    
load_frame1()

root.mainloop()

0 Answers0