Ejemplo 1: tutorial de tkinter
# check this code first.
from tkinter import *
app = Tk()
# The title of the project
app.title("The title of the project")
# The size of the window
app.geometry("400x400")
# Defining a funtion
def c():
# Label
m = Label(app, text="Text")
m.pack()
# Button
l = Button(app, text="The text of the Butoon", command=c)
# Packing the Button
l.pack()
app.mainloop()
# Quick Note :
# When you put a command you should not use parentheses
# l = Button(app, text="The text of the Butoon", command=c)
# l = Button(app, text="The text of the Butoon", command=c())
Ejemplo 2: interfaz gráfica de usuario básica de tkinter
import tkinter as tk
root = tk.Tk()
root.title("my title")
root.geometry('200x150')
root.configure(background='black')
# enter widgets here
root.mainloop()
Ejemplo 3: tutorial de tkinter
# Python 3.x
import tkinter
top = tkinter.Tk()
# Code to add widgets will go here...
top.mainloop()
# I recommend creating each tkinter window as a child class to a frame.
# This keeps all methods related to the window encapsulated, and makes
# your code alot more understandable and readable :)
Ejemplo 4: tutorial de tkinter
text_box.insert(tk.END, "Put me at the end!")
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)