Danke, daran hab ich nicht gedacht, da ich das Paket nicht mit "from tkinter import*" eingebunden hab.
Ich hab jetzt dieses Programm gemacht:
Code: Alles auswählen
#!/usr/bin/env python
import tkinter
root = tkinter.Tk()
root2 = tkinter.Tk()
widget1 = tkinter.Label (root, text="This is a text1", width=50, height = 30)
widget1.pack (side=tkinter.LEFT)
widget2 = tkinter.Label (root, text="This is a text2", width=50, height = 30)
widget2.pack (side=tkinter.RIGHT)
widget3 = tkinter.Label (root, text="This is a text_top", width=50, height = 30)
widget3.pack (side=tkinter.TOP)
widget4 = tkinter.Label (root, text="This is a text_bottom", width=50, height = 30)
widget4.pack (side=tkinter.BOTTOM)
widget5 = tkinter.Label (root2, text="fenster2", width=20, height = 10)
widget5.pack ()
root.mainloop()
Darin gibt es root und root2. Der Label widget5 wird root2 zugeordnet - soweit klar. Zum Schluss schreibe ich root.mainloop(). Dennoch wird auch das Fenster erstellt, dass mit root2 initialisiert wurde. Das verstehe ich nicht, ich wäre jetzt davon ausgegangen, dass nur das Fenster mit den Elementen, die root zugeordnet wurden, gestartet würde und nicht das Label bei root2.
Ich hätte gedacht, dass das nur ginge, wenn das steht:
root.mainloop()
root1.mainloop()