Answers for "Window in python"

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
2

Window in python

#If using tkinter
import tkinter as tk
from tkinter import*
#Window creating
root = tk.Tk()
# Defining name
name = "First window"
# Setting window
root.title(name)
# IF want to use geometry So let me tell that no need of that at all
# Tkinter sets the window according to data or things inside it
# Adding button
Button bt1 = Button(root, text = "Simple click");
# Making function
def doer():
  # Print is for console
  print("Did well");
# Adding button with function
Button bt2 = Button(root, text = "Function", command = doer)
# If you will add () it after brackets it will run automatically
# Adding buttons
bt1.pack()
bt2.pack()
root.mainloop()
# This can show error If using pycharm reformat file
# Set it as you are best
Posted by: Guest on April-22-2021
5

basic tkinter gui

import tkinter as tk
root = tk.Tk()
root.title("my title")
root.geometry('200x150')
root.configure(background='black')

#	enter widgets here

root.mainloop()
Posted by: Guest on July-10-2020
4

python gui

import tkinter as tk
#Importing the main module
window = tk.Tk()
window.mainloop()
Posted by: Guest on October-04-2020
-1

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
Posted by: Guest on May-08-2020

Python Answers by Framework

Browse Popular Code Answers by Language