Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. from tkinter import * #imports
  2. from tkinter import Tk
  3. from tkinter.filedialog import askopenfilename
  4.  
  5. win = Tk() #create instance
  6.  
  7. win.title("Spatialization of DSSAT model")
  8.  
  9. w = 160 # width for the Tk root
  10. h = 100 # height for the Tk root
  11.  
  12. # get screen width and height
  13. ws = win.winfo_screenwidth() # width of the screen
  14. hs = win.winfo_screenheight() # height of the screen
  15.  
  16. # calculate x and y coordinates for the Tk root window
  17. x = (ws/2) - (w/2)
  18. y = (hs/2) - (h/2)
  19.  
  20. # set the dimensions of the screen
  21. # and where it is placed
  22. win.geometry('%dx%d+%d+%d' % (w, h, x, y))
  23.  
  24. def var_states():
  25. print("soil: %d, nweather:%d" % (var1.get(), var2.get()))
  26.  
  27. Label(win, text="Select:").grid(row=0, sticky=W)
  28. var1 = IntVar()
  29. Checkbutton(win, text = "soil", variable=var1).grid(row=1, sticky=W)
  30. var2 = IntVar()
  31. Checkbutton(win, text = "weather", variable=var2).grid(row=2, sticky=W)
  32.  
  33. MyButton1 = Button(win, text="Submit", width=10)
  34. MyButton1.grid(row=10, column=10)
  35.  
  36. Tk().withdraw()
  37. filename1 = askopenfilename()
  38. print(filename1)
  39.  
  40. Tk().withdraw()
  41. filename2 = askopenfilename()
  42. print(filename2)
  43.  
  44. win.mainloop() #start the GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement