Answers for "TKinter menu"

6

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
Posted by: Guest on November-07-2020
5

how to make menu in tkinter

from tkinter import *

def do_some():
    print('Do some!')

root = Tk()

main_menu = Menu(root)
root.config(menu=main_menu)


# Type 1 Menu
main_menu.add_command(label='File', command=do_some)
# Type 1 Menu


# Type 2 Menu
file_menu = Menu(main_menu)
main_menu.add_cascade(label='File', menu=file_menu)

file_menu.add_command(label='Save', command=do_some)
file_menu.add_command(label='Save As', command=do_some)
# Type 2 Menu


# Type 3 Menu
file_menu = Menu(main_menu)
main_menu.add_cascade(label='File', menu=file_menu)

save_menu = Menu(file_menu)
save_as_menu = Menu(file_menu)

file_menu.add_cascade(label='Save', menu=save_menu)
file_menu.add_cascade(label='Save As', menu=save_as_menu)

save_menu.add_command(label='New', command=do_some)
save_menu.add_command(label='Old', command=do_some)
save_as_menu.add_command(label='New', command=do_some)
save_as_menu.add_command(label='Old', command=do_some)
# Type 3 Menu

root.mainloop()
Posted by: Guest on July-01-2020
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
0

menù a tendina tkinter

pythonCopyimport tkinter as tk

OptionList = [
"Aries",
"Taurus",
"Gemini",
"Cancer"
] 

app = tk.Tk()

app.geometry('100x200')

variable = tk.StringVar(app)
variable.set(OptionList[0])

opt = tk.OptionMenu(app, variable, *OptionList)
opt.config(width=90, font=('Helvetica', 12))
opt.pack()

app.mainloop()
Posted by: Guest on May-17-2020

Python Answers by Framework

Browse Popular Code Answers by Language