Advertisement
NikolayBezay

Untitled

May 21st, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. # Online Python compiler (interpreter) to run Python online.
  2. # Write Python 3 code in this online editor and run it.
  3. import tkinter
  4. import random
  5.  
  6. list_b=[[],[],[],[],[]]
  7. for i in range (5):
  8. for j in range (5):
  9. list_b[i].append(Label(tk, bg = 'lightblue', width = 4))
  10. list_b[i][j].grid(row = i, column = j, padx = 2, pady = 2)
  11.  
  12. def output():
  13. for i in range (5):
  14. for j in range (5):
  15. list_b[i][j].config(text = str(a[i][j]))
  16.  
  17. Label(tk, text = 'Координати верхнього лівого кута:').grid(row = 5,column = 0, columnspan = 5)
  18. enx1 = Entry(tk, width = 3)
  19. enx1.grid(row = 6, column = 1)
  20. eny1=Entry(tk, width = 3)
  21. eny1.grid(row = 6, column = 3)
  22.  
  23. envart = Entry(tk, width = 6)
  24. envart.grid(row = 10, column = 2)
  25.  
  26. but = Button(text = 'Обчислити', command = but_click, width =14).grid(row = 9, column = 0, columnspan = 5)
  27.  
  28. def but_click():
  29. x1 = int(enx1.get())
  30. y1 = int(eny1.get())
  31. x2 = int(enx2.get())
  32. y2 = int(eny2.get())
  33. vart = 0
  34. for i in range(x1, x2+1):
  35. for j in range(y1, y2+1):
  36. vart = vart+a[i][j]
  37. envart.delete(0, END)
  38. envart.insert(0, str(vart))
  39.  
  40. tk.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement