Fortgeschrittenes Python: GUI (Grafische Benutzeroberfläche)

Ziel

Schritt 1: Tkinter verwenden


import tkinter as tk

# Fenster erstellen
window = tk.Tk()
window.title("Mein Programm")

# Label hinzufügen
label = tk.Label(window, text="Hallo Welt")
label.pack()

# Programm starten
window.mainloop()

Erklärung:

Aufgabe

Button Beispiel


import tkinter as tk

def show_text():
    label.config(text="Button wurde geklickt!")

window = tk.Tk()
window.title("Button Beispiel")

label = tk.Label(window, text="Hallo Welt")
label.pack()

button = tk.Button(window, text="Klick mich!", command=show_text)
button.pack()

window.mainloop()