-
Notifications
You must be signed in to change notification settings - Fork 0
/
tkinter8.py
41 lines (29 loc) · 1.29 KB
/
tkinter8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import tkinter as tk
from tkinter import messagebox
def about_app():
messagebox.showinfo("App", "The application\nthat does nothing")
def are_you_sure(event=None):
if messagebox.askyesno("", "Are you sure you want to quit the App?"):
window.destroy()
def open_file():
messagebox.showinfo("Open doc", "We'll open a file here...")
window = tk.Tk()
window.title("First Icon")
#window.tk.call('wm', 'iconphoto', window._w, tk.PhotoImage(file='moon.png'))
main_menu = tk.Menu(window)
window.config(menu=main_menu)
sub_menu_file = tk.Menu(main_menu, tearoff=0)
main_menu.add_cascade(label="File", menu=sub_menu_file, underline=0)
sub_menu_file.add_command(label="Open...", underline=0, command=open_file)
sub_sub_menu_file = tk.Menu(sub_menu_file, tearoff=0)
sub_menu_file.add_cascade(label="Open recent file...", underline=5, menu=sub_sub_menu_file)
for i in range(8):
number = str(i + 1)
sub_sub_menu_file.add_command(label=number + ". file.txt", underline=0)
sub_menu_file.add_separator()
sub_menu_file.add_command(label="Quit", accelerator="Ctrl-Q",
underline=0, command=AreYouSure)
sub_menu_help = tk.Menu(main_menu)
main_menu.add_command(label="About...", command=about_app, underline=1)
window.bind_all("<Control-q>", are_you_sure)
window.mainloop()