from tkinter import *
import random
root = Tk()
root.geometry("500x500")
main_menu = Menu()
a = set()
b = set()
с = set()
#Functions
def generate_set(elem):
if elem == "A":
a = set(random.randint(-10,10) for i in range(int(value1)))
elif elem == "B":
b = set(random.randint(-10,10) for i in range(int(value2)))
elif elem == "C":
c = set(random.randint(-10,10) for i in range(int(value3)))
def Window_open_2():
Window2 = Tk()
def Window_open_3():
Window3 = Tk()
############################
root.config(menu = main_menu)
e1 = Label(text = "Бурбело Сергій Сергійович ІВ-91 Номер у списку 04")
e1.pack()
lab1 =Label(text = "Введіть кількість елементів:").place(x = 8 , y = 200)
Entry1 = Entry(root, width = 25)
Entry1.place(x = 10, y = 220)
value1 = Entry1.get()
bt1 = Button(text = "Згенерувати множину А ")
bt1.bind('<Button-1>', generate_set("A"))
bt1.pack(side = LEFT, padx = 10)
lab2 =Label(text = "Введіть кількість елементів:").place(x = 330 , y = 200)
Entry2 = Entry(root,width = 25)
Entry2.place(x = 330, y = 220)
value2 = Entry2.get()
bt2 = Button(text ="Згенерувати множину B ")
bt2.bind('<Button-1>', generate_set("B"))
bt2.pack(side = RIGHT, padx = 25)
lab3 =Label(text = "Введіть кількість елементів:").place(x = 170 , y = 280)
Entry3 = Entry(root, width = 25)
Entry3.place(x = 170, y = 300)
value3 = Entry3.get()
bt3 = Button(text = "Згенерувати множину C ")
bt3.bind('<Button-1>', generate_set("C"))
bt3.place(x = 170, y = 320)
main_menu.add_cascade(label = 'Window 2', command = Window_open_2)
main_menu.add_cascade(label = "Window 3", comman = Window_open_3)
root.mainloop()
Проблема:
def generate_set(elem):
if elem == "A":
a = set(random.randint(-10,10) for i in range(int(value1)))
elif elem == "B":
b = set(random.randint(-10,10) for i in range(int(value2)))
elif elem == "C":
c = set(random.randint(-10,10) for i in range(int(value3)))
Ошибка:
File "tk.py", line 16, in generate_set a = set(random.randint(-10,10) for i in range(int(value1))) ValueError: invalid literal for int() with base 10: ''