I am trying to run a window.pyw file from Visual Studio Code. Running it directly from Windows Explorer with Python works but when I try it from Visual Studio Code I get the error in the application console and it won't open.
The application error starts appearing when I have sticky="e"
or anchor="e"
.
Error that I get:
Traceback (most recent call last):
File ".\ventana.pyw", line 13, in <module>
cuadroTexto=Label(miFrame, text="Nombre:", sticky="e") # Texto
File "C:\Program Files\Python310\lib\tkinter\__init__.py", line 3177, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Program Files\Python310\lib\tkinter\__init__.py", line 2601, in __init__
self.tk.call(
_tkinter.TclError: unknown option "-sticky"
File code:
# Para Importar todas las clases de Tkinter
from tkinter import *
# Crear la variable ventana
root = Tk()
root.title("Nombre") # Titulo de la ventana
root.config(bg="black")
# Crear espacio de trabajo
miFrame=Frame(root, width=500, height=400)
miFrame.pack() # Poner en la ventana
# Nombre
Label1=Label(miFrame, text="Nombre:") # Texto
Label1.grid(row="0", column="0", sticky="e") # Posicion
Entry1=Entry(miFrame) # Entrada de texto
Entry1.grid(row="0", column="1") # Posicion
# Apellidos
Label2=Label(miFrame, text="Apellidos:") # Texto
Label2.grid(row="1", column="0", sticky="e") # Posicion
Entry2=Entry(miFrame) # Entrada de texto
Entry2.grid(row="1", column="1") # Posicion
#
Label3=Label(miFrame, text="De donde eres:") # Texto
Label3.grid(row="2", column="0", sticky="e") # Posicion
Entry3=Entry(miFrame) # Entrada de texto
Entry3.grid(row="2", column="1") # Posicion
# Abrir ventana
root.mainloop()
Ok I realized while writing this, for some reason the terminal got stuck and I had to restart the program.
Specifically in this piece.
Before, without realizing it, I left:
By declaring them with the same name I left the application stuck there and by not closing the previous execution it did not let me launch the new one.