how to make a window in python

Solutions on MaxInterview for how to make a window in python by the best coders in the world

showing results for - "how to make a window in python"
Lucia
12 Oct 2020
1#---------moving a Window in Center-----------#
2
3from tkinter import *
4
5window = Tk()
6
7window.title("Python GUI App")
8window.configure(width=500, height=300)
9window.configure(bg='lightgray')
10
11# move window center
12winWidth = window.winfo_reqwidth()
13winwHeight = window.winfo_reqheight()
14posRight = int(window.winfo_screenwidth() / 2 - winWidth / 2)
15posDown = int(window.winfo_screenheight() / 2 - winwHeight / 2)
16window.geometry("+{}+{}".format(posRight, posDown))
17
18window.mainloop()
Kenzo
02 Jul 2020
1import tkinter
2from tkinter import *
3
4#this makes the window
5window = Tk()
6#title
7window.title("My Window")
8#change the size to whatever you want too
9window.configure(width = 800, height = 800)
10#change the background color to whatever you want too
11window.configure(bg = 'black')
12#this runs the window
13window.mainloop()
14
15#simple way to a window in python
Avaline
17 Apr 2016
1import tkinter as tk
2 
3 
4def new_window1():
5    " new window"
6    try:
7        if win1.state() == "normal": win1.focus()
8    except NameError as e:
9        print(e)
10        win1 = tk.Toplevel()
11        win1.geometry("300x300+500+200")
12        win1["bg"] = "navy"
13        lb = tk.Label(win1, text="Hello")
14        lb.pack()
15 
16 
17win = tk.Tk()
18win.geometry("200x200+200+100")
19button = tk.Button(win, text="Open new Window")
20button['command'] = new_window1
21button.pack()
22win.mainloop()
23
Lilia
05 Nov 2016
1#If using tkinter
2import tkinter as tk
3from tkinter import*
4#Window creating
5root = tk.Tk()
6# Defining name
7name = "First window"
8# Setting window
9root.title(name)
10# IF want to use geometry So let me tell that no need of that at all
11# Tkinter sets the window according to data or things inside it
12# Adding button
13Button bt1 = Button(root, text = "Simple click");
14# Making function
15def doer():
16  # Print is for console
17  print("Did well");
18# Adding button with function
19Button bt2 = Button(root, text = "Function", command = doer)
20# If you will add () it after brackets it will run automatically
21# Adding buttons
22bt1.pack()
23bt2.pack()
24root.mainloop()
25# This can show error If using pycharm reformat file
26# Set it as you are best
Sofia
22 Nov 2018
1import pygame
2pygame.init()
3
4sh = int(500)
5sw = int(500)
6win = pygame.display.set_mode((sh, sw))
7
8run = True
9while run:
10    pygame.time.delay(100)
11	for event in pygame.event.get():
12        if event.type == pygame.QUIT:
13            run = False
14
queries leading to this page
how to make window in pythonmake a screen in pythonhow to create new window in python 3 10window function pythonhow to make window pythonhow to open a window in pythonhow to create a window in windows using pythonopen new window pythonhow to have a timer on screen unitycreating screen in pythonpython screenshithow to design a window in pythonpython creat a screenhow to create window using pythonpython best way to create a windowscreen with pythonhow to link a js file to pythonhow to open a tk windowpython information from open windowpython how to open file windowhow to access screen in pythonhow to hold screen in pythonhow to get screen information from computer pythonhow to make a window using pythonpython screen windowpython how to open in new windowhow to create the window in pythonpython window functionsc 23 take picture with camerascreen inside screen pythonopen window with pythonhow to do a window screen in pythonhow to make a new screen with pythonopen a new window pythonpython window functionhow to open python filehow to open window in pythonhow to create a screen in pythonhow to load a screen in pythonhow to create a window using pythonmake a print screen pythonshowing a screen in pythonwindowing in pythonhow do you make a window in python python windowedhow do you make a window in python fromhow to make a window in pyhamepython code screen how to make your python program open in a new windowhow to get screen pythontkinter open another window pyrthonpython make windowhow to make screen in pythontake print screen pythonread screen using pythoncreate screen in pythonscreen python usecreate a python windowhow to type on screen using pythonwhat is window in pythonpython window makecreate a window in pythonpython open new window tkinterhow to add window in window pythonhow to get window using pythonhow to open a window with pythonpython window librarypython windowwhat is the hardest way to make a window in pythonpython screenscreen in python opening a windowusing pythonhow to create screen in pythonhow to make a screen in pythonpython open a windowpython make windowswhich python windowpython how to show a windowcreate a window pythonhow to view screen through pythonbrython windowpython how change screen setuphow do i create a window in pythonpython create new windowpython windows windowhow to use a window with pythontkinter next window after loginhow to make a window with pythonmake a window with pythohoe to do a screen in pythonhow ot open window in oythonpython code to open new windowmake a window with pythonhow do i generate a window in pythonwhat to use for window in pythonhow to make a window app with pythonopen a window pythinhow to have a stopwatch on screen unity 2dhow do window in pyhow to read screen with pythonpython make a windowwindow function in pythonwindow program pythonhow to create windows pythonhow to make python open a windowhow to make new window in tkinterpython open the window of a softwarehow to make an window app in pythonsimple python screencreate window pythonpython window codehow to open new window in pythonhow to print screen in ptyhonhow to get the screen pythonwhat is this or window in pythonhow to create a window in pythonhow to capture the screen in pythonhow to open a new window using pythonhow to hold the screen in pythonmake a window using pythonwindowing pythonscreen pythonpython how to make windowhow to make pyton open a windowpython open windowpython open windowshow to create a new window in pythonopen a window pythonscreen python linuxpython how to make a screendoes window comes with pytonall windows in python how to make a windowpython how to use screenhow to print screen in pythonwhat is python screenpython how to make a windowopen window in pythonwindow pythondoes window comes with pythonhow to setup screen in pythonhow to hind a screen in tkinterpython create a screenhow to open a window on pythonhow to create a window with pythonopen new windows pythonwindow functions pythoncan i create window in pythonpython print on screenhow do you open create a window in pythonhow to print screen on pythonrun new window in pythonmaking a window in pythonwindow in pythonopen python program in windowpython make a screensehow to open a new window in flask webguiuse screen in python scriptcreate a screen pythonopen window pythonpython create windowhow to access the screen in pythoncreate a screen in pythonhow to make a python windowhow to make a window pythonhow to take screenchot using pythonscreen 28 29 pythonhow to program a window in pythonopen a window with pythonscreen start pythonsimple window in pythonmake page javascript run in backgroundhow to make a window in pythonhow to print open window in pythonscreen pytonhow to code screen on pythonopen python file in new window pythonhow to make a new window in pythonpython tkinter open new window with infoopen a window in pythonhow to get the screen in pythonhow to print screen on specific window pythonopen window of windows with pythonhow to make a window from scratch pythonhow to get the python screenhow to make a window in python