SHARE
TWEET

Untitled

a guest May 26th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from tkinter.ttk import *
  3.  
  4. def plus_one():
  5.     """adds 1 to the counter"""
  6.     global click_counter, counter_label
  7.    
  8.     click_counter += 1
  9.     counter_label["text"] = str(click_counter)
  10.    
  11. def minus_one():
  12.     """takes 1 away from the counter"""
  13.     global click_counter, counter_label
  14.    
  15.     click_counter -= 1
  16.     counter_label["text"] = str(click_counter)
  17.    
  18. def main():
  19.     """main function"""
  20.    
  21.     global click_counter, counter_label
  22.    
  23.     click_counter = 0
  24.     window = Tk()
  25.    
  26.     counter_label = Label(window, text=str(click_counter))
  27.     counter_label.grid(row=0, column=0)
  28.    
  29.     plus_one_button = Button(window, text="+1", command=plus_one)
  30.     plus_one_button.grid(row=2, column=0)
  31.    
  32.     minus_one_button = Button(window, text="-1", command=minus_one)
  33.     minus_one_button.grid(row=2, column=1)
  34.    
  35.     window.mainloop()
  36.    
  37. main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top