Python 3.6 - Create my own class in Tkinter

1

I have an application developed in Tkinter and I would like to create a class to get whenever I need a fixed size window with a text box and a button. But I do not know how to do it.

Greetings.

    
asked by Alfredo Lopez Rodes 16.10.2018 в 08:46
source

1 answer

0
from tkinter import Tk, Entry, Button, Label

class Ventana():
    def __init__(self, x, y, ancho, alto, titulo, texto):
        self.ventana = Tk()
        self.ventana.geometry(str(ancho)+ "x" + str(alto) + "+" + str(x) + "+" + str(y))
        self.ventana.title(str(titulo))

        Label(self.ventana, text="Escriba algo:").place(x=5, y=0)
        self.txt_texto = Entry(self.ventana).place(x=5, y=25, width=185)
        self.btn_boton = Button(self.ventana, text="Miau").place(x=5, y=50, width=185)



if __name__ == "__main__":
    v1 = Ventana(450, 300, 200, 90, "#", "Buenos días")
    v2 = Ventana(750, 300, 200, 90, "&", "Buenas noches")
    
answered by 29.11.2018 / 16:57
source