Advertisement
Dezus

Buttons_project

Nov 30th, 2020 (edited)
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import *
  3.  
  4. window = Tk()
  5. window.title('Button Project')
  6. #window = tk.Canvas(window,  height=500,  width=500,  bg="black") can use this to create a canvas, if you do, make sure to do window.pack() to complete it
  7. window.geometry('300x200')
  8.  
  9. Label(window,  text='Select the ammo you would like to scan') .grid(row=0,  column=0,  sticky=W)
  10.  
  11. #import imrunning this will run the whole imrunning.py on startup. The exec command will run when its called.
  12. #exec(open('imrunning.py').read())
  13.  
  14. #value1= exec(open('imrunning.py').read())#This will call imrunning.py and run it. Can also call induvidual functions using the import function
  15. chkbutton_1 = Checkbutton(window,  text="9mm below .50cents", onvalue=1,  offvalue=2) .grid(row=1,  column=0,  sticky=W)
  16.  
  17. #value2=exec(open('imalsorunning.py') .read())
  18. chkbutton_2 = Checkbutton(window,  text=".223 below .50cents", onvalue=1,  offvalue=2) .grid(row=2,  column=0,  sticky=W)
  19.  
  20. output = Text(window,  width=35,  height=4,  wrap=WORD, bg="white")
  21. output.grid(row=5,  column=0, columnspan=2,  sticky=W)
  22.  
  23. def enter_check(): #these define what the command function is in the Button functions.
  24.     output.insert(END, 'Pressed\n')
  25.  
  26. enterButton = Button(window,  text="Enter",  width=4,  command=enter_check) .grid(row=3,  column=0,  sticky=W)
  27.  
  28. def close_window():
  29.     window.destroy()
  30.     exit()
  31.    
  32. exitButton = Button(window,  text="Exit",  width=4,  command=close_window) .grid(row=3,  column=0,  sticky=E)
  33.  
  34.    
  35.  
  36. window.mainloop()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement