| 1 | import tkinter as tk
|
|---|
| 2 | from tkinter import ttk
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | class AppMenu(tk.Menu):
|
|---|
| 6 |
|
|---|
| 7 | # FIXME: Parent should not be used, but event bus, mediator or announcer work better to decouple views
|
|---|
| 8 | def __init__(self, parent):
|
|---|
| 9 | super().__init__(parent)
|
|---|
| 10 |
|
|---|
| 11 | filemenu = tk.Menu(self, tearoff=0)
|
|---|
| 12 | filemenu.add_command(label="Import questions from exam", command=parent.import_exam)
|
|---|
| 13 | filemenu.add_command(label="Import exam from file", command=parent.import_exam_from_file)
|
|---|
| 14 | filemenu.add_separator()
|
|---|
| 15 | filemenu.add_command(label="Exit", command=parent.quit)
|
|---|
| 16 | self.add_cascade(label="File", menu=filemenu)
|
|---|
| 17 |
|
|---|
| 18 | catalog_menu = tk.Menu(self, tearoff=0)
|
|---|
| 19 | catalog_menu.add_command(label="Create Catalog", command=parent.create_catalog)
|
|---|
| 20 | catalog_menu.add_command(label="Open Catalog", command=parent.open_catalog)
|
|---|
| 21 | catalog_menu.add_command(label="Close Catalog", command=parent.close_catalog)
|
|---|
| 22 | self.add_cascade(label="Catalogs", menu=catalog_menu)
|
|---|
| 23 |
|
|---|
| 24 | domain_menu = tk.Menu(self, tearoff=0)
|
|---|
| 25 | domain_menu.add_command(label="Add domain", command=parent.add_domain)
|
|---|
| 26 | self.add_cascade(label="Domains", menu=domain_menu)
|
|---|
| 27 |
|
|---|
| 28 | exam_menu = tk.Menu(self, tearoff=0)
|
|---|
| 29 | exam_menu.add_command(label="Create new exam", command=parent.create_exam_dialog)
|
|---|
| 30 | exam_menu.add_command(label="Layout existing exam", command=parent.layout_exam)
|
|---|
| 31 | self.add_cascade(label="Exams", menu=exam_menu)
|
|---|
| 32 |
|
|---|
| 33 | help_menu = tk.Menu(self, tearoff=0)
|
|---|
| 34 | help_menu.add_command(label="Help / FAQ", command=parent.show_help)
|
|---|
| 35 | self.add_cascade(label="Help", menu=help_menu)
|
|---|
| 36 | parent.config(menu=self)
|
|---|
| 37 |
|
|---|