Answers for "python create window"

2

create window python

#---------moving a Window in Center-----------#

from tkinter import *

window = Tk()

window.title("Python GUI App")
window.configure(width=500, height=300)
window.configure(bg='lightgray')

# move window center
winWidth = window.winfo_reqwidth()
winwHeight = window.winfo_reqheight()
posRight = int(window.winfo_screenwidth() / 2 - winWidth / 2)
posDown = int(window.winfo_screenheight() / 2 - winwHeight / 2)
window.geometry("+{}+{}".format(posRight, posDown))

window.mainloop()
Posted by: Guest on October-26-2021
2

how to make a window in python

import tkinter
from tkinter import *

#this makes the window
window = Tk()
#title
window.title("My Window")
#change the size to whatever you want too
window.configure(width = 800, height = 800)
#change the background color to whatever you want too
window.configure(bg = 'black')
#this runs the window
window.mainloop()

#simple way to a window in python
Posted by: Guest on August-05-2021
1

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()
Posted by: Guest on September-14-2020
6

how to create a tkinter window

#Creating Tkinter Window In Python:

from tkinter import *

new_window = Tk() #Create a window ; spaces should be denoted with underscores ; every window should have a different name
new_window.title("My Python Project") #Name of screen ; name should be the one which you already declared (new_window)
new_window.geometry("200x150") #Resizes the default window size
new_window.configure(bg = "red") #Gives color to the background

new_window.mainloop() #Shows the window on the screen
Posted by: Guest on November-07-2020
1

how to create tkinter window

import tkinter
master = tkinter.Tk()
master.mainloop()
Posted by: Guest on May-01-2020

Python Answers by Framework

Browse Popular Code Answers by Language