Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to set a tkinter window to a constant size

import tkinter as tk

def startgame():

    pass

mw = tk.Tk()

#If you have a large number of widgets, like it looks like you will for your
#game you can specify the attributes for all widgets simply like this.
mw.option_add("*Button.Background", "black")
mw.option_add("*Button.Foreground", "red")

mw.title('The game')
#You can set the geometry attribute to change the root windows size
mw.geometry("500x500") #You want the size of the app to be 500x500
mw.resizable(0, 0) #Don't allow resizing in the x or y direction

back = tk.Frame(master=mw,bg='black')
back.pack_propagate(0) #Don't allow the widgets inside to determine the frame's width / height
back.pack(fill=tk.BOTH, expand=1) #Expand the frame to fill the root window

#Changed variables so you don't have these set to None from .pack()
go = tk.Button(master=back, text='Start Game', command=startgame)
go.pack()
close = tk.Button(master=back, text='Quit', command=mw.destroy)
close.pack()
info = tk.Label(master=back, text='Made by me!', bg='red', fg='black')
info.pack()

mw.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: python tkinter.ttk combobox down event on mouseclick 
Python :: download Twitter Images with BeautifulSoup 
Python :: pygame getting your charecter to jump 
Python :: fiusion python lists 
Python :: python extract multiple values from a single cell in a dataframe column using pandas 
Python :: tensorflow 1.x spp implementation 
Python :: fetch inbox mail python 
Python :: pandas select random entry after groupby 
Python :: seaborn colorbar labelsize 
Python :: separete even and odd numbers from a list by filter in python 
Python :: python list len 
Python :: Trying to use image in Flask website only shows broken img icon 
Python :: Flask error: werkzeug.routing.BuildError 
Python :: how to blend pixels in pygame 
Python :: EDA dataframe get missing and zero values 
Python :: python discord next page 
Python :: ring convert string lines to list items and convert the list to a string 
Python :: plotly scatter add annotation / text 
Python :: check string on substring godot 
Python :: mehrzeiliges kommentar python 
Python :: matplotlib doesnt show suptitle 
Python :: django create ap 
Python :: rĂșllandi veltandi standandi sitjandi 
Python :: ConversionofDatatypes-I 
Python :: Wireframes and Surface Plots 
Python :: ptyhton json respones 
Python :: how can space be bent 
Python :: kivy video recorder 
Python :: tuples in python 
Python :: python find first char index from a string stackoverflow 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =