Button drücken in python

Gast #3713721
Lesenswert?

Hallo Leute,
ich aheb eine kleines python Code geschrieben, der einen Button 
darstellt. Durch drücken des buttons soll "Hello World" ausgegeben 
werden. Soweit funktioniert es. Nun wollte ich, dass es beim Start 
einmal automatisch auf das Button gedrückt werden. Kriege ich es aber 
irgendwie nicht hin. Hat jemand eine idee?

from tkinter import *

root = Tk()     #Create a Window
root.title("Unser GUI Programm")
root.geometry("400x500")    #Size of window


def ausgabe():  #Function for edition of strings on the console
    print("Hello World!")

knopf1 = Button(root, text="Menu", command=ausgabe)    #Creation of 
Button
knopf1.pack()

mainloop()

Vielen Dank im Vorraus!

Gruß
Mirko
#3713796
Lesenswert?

1
from tkinter import *
2

3
root = Tk()     #Create a Window
4
root.title("Unser GUI Programm")
5
root.geometry("400x500")    #Size of window
6

7

8
def ausgabe():  #Function for edition of strings on the console
9
    print("Hello World!")
10

11
knopf1 = Button(root, text="Menu", command=ausgabe)    #Creation of 
12
Button
13
knopf1.pack()
14

15
ausgabe()  # <- ?
16
mainloop()

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren