jagata

for tedzo :D

May 10th, 2021 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. import tkinter as tk
  2. from random import randint
  3.  
  4. def main_func():
  5.     global for_change
  6.     for_change.grid(row=6, column=0)
  7.     try:
  8.         sum = 0
  9.         for i in range(int(t1.get())):
  10.             sum+=randint(int(t2.get()),int(t3.get()))
  11.  
  12.         for_change.config(text='sum of nubers: %s ' % sum)
  13.  
  14.     except ValueError:
  15.         for_change.config(text='incorrect input values')
  16.  
  17.     except:
  18.         for_change.config(text='something went wrong')
  19.  
  20.  
  21. root = tk.Tk()
  22. root.geometry("500x200")
  23. root.configure(bg="orange red")
  24. f = tk.Label(root, text="tornike edilashvili", font=('Arial', 18))
  25. f.grid(row=0,column=0)
  26.  
  27.  
  28.  
  29. t1 = tk.Entry(root)
  30. t2 = tk.Entry(root)
  31. t3 = tk.Entry(root)
  32.  
  33.  
  34. t1.grid(row=1, column=0)
  35. t2.grid(row=2, column=0)
  36. t3.grid(row=3, column=0)
  37.  
  38.  
  39. tk.Button(root,
  40.           text='Count', command=main_func).grid(row=4,
  41.                                                        column=0,
  42.                                                        sticky=tk.W,
  43.                                                        pady=4)
  44. for_change = tk.Label(root, text="", font=('Arial', 16))
  45. for_change.grid_forget()
  46. tk.mainloop()
  47.  
Add Comment
Please, Sign In to add comment