I am trying to write a Program, in which u are able to open a seperate testing/debug window. Like, a second window including some buttons to affect the main window. I already tried a few things and i am able to open two seperate windows but whatever i am trying to draw is drawn in the main window.
import tkinter as tk
from tkinter import *
def debugWindow():
dbWin = tk.Tk()
dbWin.title("Debug")
btn = tk.Button(text="Test")
btn.pack()
dbWin.mainloop()
window = tk.Tk()
window.title("Mainwindow")
btn2 = tk.Button(text="Start debug Window", command=debugWindow)
btn2.pack()
window.mainloop()
So that's what i tried, but as i said the second button renders in the first window. Also i am pretty new to Python so if this is not the way u normally do it, please correct me. I am still learning :) And also sorry for my english, i am not a native speaker.
Toplevel()for that second window - callingTk()a second time does give you a second window, but it lives in an entirely separate GUI environment that cannot interact with the original environment. To put widgets in a specific window (or other container), pass it as the first parameter to the widget.btn = tk.Button(text="Test")tobtn = tk.Button(dbWin, text="Test")to telltkinterthatbtn's master should be the second window (otherwise it assumes that the first window is the master).