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
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
1import tkinter as tk
2root = tk.Tk()
3root.title("my title")
4root.geometry('200x150')
5root.configure(background='black')
6
7# enter widgets here
8
9root.mainloop()
1import tkinter as tk
2#Importing the main module
3window = tk.Tk()
4window.mainloop()
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