python create window code example
Example 1: create window with python
from tkinter import *
app = Tk()
app.title("Test")
label = Label(app, text="Testing testing one, two, three")
label.pack()
app.mainloop()
Example 2: how to open a window in python
import tkinter as tk
def new_window1():
" new window"
try:
if win1.state() == "normal": win1.focus()
except NameError as e:
print(e)
win1 = tk.Toplevel()
win1.geometry("300x300+500+200")
win1["bg"] = "navy"
lb = tk.Label(win1, text="Hello")
lb.pack()
win = tk.Tk()
win.geometry("200x200+200+100")
button = tk.Button(win, text="Open new Window")
button['command'] = new_window1
button.pack()
win.mainloop()
Example 3: how to create a tkinter window
from tkinter import *
new_window = Tk()
new_window.title("My Python Project")
new_window.geometry("200x150")
new_window.configure(bg = "red")
new_window.mainloop()
Example 4: how to create tkinter window
import tkinter
master = tkinter.Tk()
master.mainloop()