I am doing OOP code and I have some problem, I have searched the internet and supposedly I am doing it right. But it gives me an error and does not execute me.
I have this:
from tkinter import *
from tkinter import ttk
import pymysql
from tkinter import messagebox as MessageBox
from tkinter import scrolledtext as st
class Aplicacion:
def __init__(self):
self.ventana1 = Tk()
self.ventana1.title("Login")
self.ventana1.geometry("400x400")
self.imagenLogo = PhotoImage(file="logo2.png")
self.divLogo = Label(self.ventana1, image=self.imagenLogo)
self.divLogo.place(x=93, y=0)
self.x_ventana = self.ventana1.winfo_screenwidth() // 2 - 300 // 2
self.y_ventana = self.ventana1.winfo_screenheight() // 2 - 300 // 2
self.posicion = str(300) + "x" + str(300) + "+" + str(self.x_ventana) + "+" + str(self.y_ventana)
self.ventana1.geometry(self.posicion)
self.ventana1.resizable(0,0)
self.formulario()
self.ventana1.mainloop()
def formulario(self):
### Formulario de Entrada ###
self.label1 = ttk.Label(text="Usuario:").place(x=50, y=110)
Ventana = Aplicacion()
What I want is to insert a tkinter Label
into the viewport from a function.
But it gives me this error in sublime text:
File "/Users/tomas/Downloads/DonMovil/objetos.py", line 29
self.label1 = ttk.Label(text="Usuario:").place(x=50, y=110)
TabError: inconsistent use of tabs and spaces in indentation
[Finished in 47ms with exit code 1]
[cmd: ['python3', '-u', '/Users/tomas/Downloads/DonMovil/objetos.py']]
[dir: /Users/tomas/Downloads/DonMovil]
[path: /Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin]