Здравствуйте, я получаю некоторые номера, и ящики, соответствующие этим номерам, загораются, когда я их получаю.Дело в том, что я пытаюсь увеличить размер полей, но при компиляции это выдает ошибку: _tkinter.TclError: ожидаемое целое число, но полученное «1.5».
вот мой код:
# read the TCP sequence received
def sequencia():
for i in range(0,999):
s = so.recv(port) + b'\n' #since the sequence received is : 1\n 2\n 5\n etc
print (s)
if (len(s)!=0):
i = int(s)
labels[i-1].configure(width=12, height=1.5, background="green",foreground="red")
root.update()
winsound.PlaySound(sounds[i-1], winsound.SND_FILENAME)
#time.sleep(1)
labels[i-1].configure(width=10, height=1, background="gray",foreground="white")
root.update()
#window
root = Tk()
root.title("Sequencia")
#root.attributes('-fullscreen', True) #for fullscreen
#root.bind('<Escape>',lambda e: root.destroy()) #to get out of the full screen
root.state('zoomed') #just zoomed not fullscreen
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
fm = Frame(root, width=w, height=h, bg="black")
#draw center lines
#wi = Canvas(fm, width=20, height=20, bg ="green", selectborderwidth=0)
#wi.create_line(0, 200, 150, 150, width=10, fill="blue")
label_sim = Label(fm, width=10, height=1, bg="gray", text = "SIM", font = ('TkDefaultFont',28), fg="white")
label_nao = Label(fm, width=10, height=1, bg="gray", text = "NÃO", font = ('TkDefaultFont',28), fg="white")
label_fome = Label(fm, width=10, height=1, bg="gray", text = "FOME", font = ('TkDefaultFont',28), fg="white")
label_sede = Label(fm, width=10, height=1, bg="gray", text = "SEDE", font = ('TkDefaultFont',28), fg="white")
label_urinar = Label(fm, width=10, height=1, bg="gray", text = "URINAR", font = ('TkDefaultFont',28), fg="white")
label_ar = Label(fm, width=10, height=1, bg="gray", text = "AR", font = ('TkDefaultFont',28), fg="white")
label_posicao = Label(fm, width=10, height=1, bg="gray", text = "POSIÇÃO", font = ('TkDefaultFont',28), fg="white")
labels = [label_sim,label_nao,label_fome,label_sede,label_urinar,label_ar,label_posicao]
#ordem de sequencia (1 2 3 4 5 6 7): (SIM, NAO, FOME, SEDE, URINAR, AR, POSICAO)
#posicionamento das palavras:
fm.pack()
label_ar.place(relx=0.5, rely=0.15, anchor=CENTER)
label_posicao.place(relx=0.70, rely=0.3, anchor=CENTER)
label_urinar.place(relx=0.3, rely=0.3, anchor=CENTER)
label_nao.place(relx=0.72, rely=0.55, anchor=CENTER)
label_sim.place(relx=0.28, rely=0.55, anchor=CENTER)
label_sede.place(relx=0.60, rely=0.77, anchor=CENTER)
label_fome.place(relx=0.4, rely=0.77, anchor=CENTER)
root.update()
sequencia()
программа при компиляции выдает мне эту ошибку и трассировку:
Traceback (most recent call last):
File "C:\Users\meca\Desktop\Python_Exercises\seq_tcp_offline_sem_feedback.py", line 92, in <module>
sequencia()
File "C:\Users\meca\Desktop\Python_Exercises\seq_tcp_offline_sem_feedback.py", line 46, in sequencia
labels[i-1].configure(width=12, height=1.5, background="green",foreground="red")
File "C:\Users\meca\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1485, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\meca\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1476, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: expected integer but got "1.5"
У вас есть идеи, как решить эту проблему?Большое спасибо