python make window code example
Example 1: create window with python
# basic setup
from tkinter import *
app = Tk() # the application itself
app.title("Test") # title of window
label = Label(app, text="Testing testing one, two, three") # creates label
label.pack() # adds the label to the window
app.mainloop() # this must go at the end of your window code
Example 2: 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
Example 3: how to make a screen in python
import pygame
pygame.init()
sh = int(500)
sw = int(500)
win = pygame.display.set_mode((sh, sw))
run = True
while run:
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
Example 4: make a window tkinter
#!/usr/bin/python
import Tkinter
top = Tkinter.Tk()
# Code to add widgets will go here...
top.mainloop()