Answers for "how to create a window in tkinter"

6

how to make a tkinter window

from tkinter import *

mywindow = Tk() #Change the name for every window you make
mywindow.title("New Project") #This will be the window title
mywindow.geometry("780x640") #This will be the window size (str)
mywindow.minsize(540, 420) #This will be set a limit for the window's minimum size (int)
mywindow.configure(bg="blue") #This will be the background color

mywindow.mainloop() #You must add this at the end to show the window
Posted by: Guest on September-25-2020
3

make a window tkinter

#!/usr/bin/python

import Tkinter
top = Tkinter.Tk()
# Code to add widgets will go here...
top.mainloop()
Posted by: Guest on May-23-2020
1

tkinter window

from tkinter import *

root = Tk()
root.geometry("500x500")
root.title("My App")
root.config(bg="#ff0000")

def printhi(*args):
	print("Hi!")
    
btn = Button(root, text="Click to print hi", command=printhi)
btn.place(x=200, y=200)

root.mainloop()
Posted by: Guest on August-05-2021
2

self.app = Tk()

# Use Tkinter for python 2, tkinter for python 3
import tkinter as tk

class MainApplication(tk.Frame):
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent

        <create the rest of your GUI here>

if __name__ == "__main__":
    root = tk.Tk()
    MainApplication(root).pack(side="top", fill="both", expand=True)
    root.mainloop()
Posted by: Guest on May-13-2020
1

how to create tkinter window

import tkinter
master = tkinter.Tk()
master.mainloop()
Posted by: Guest on May-01-2020

Code answers related to "how to create a window in tkinter"

Python Answers by Framework

Browse Popular Code Answers by Language