-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.py
57 lines (43 loc) · 2.17 KB
/
menu.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Menu module for project.
Created on 26.01.2020
@author: Ruslan Dolovanyuk
"""
import wx
class Menu:
"""Create menu for project."""
def __init__(self, parent):
"""Initialization menu."""
self.drawer = parent
self.phrases = self.drawer.phrases
self.command = self.drawer.command
self.__create_menu()
self.__create_accel()
self.__create_bindings()
def __create_menu(self):
"""Create menu program."""
menu_file = wx.Menu()
self.drawer.exit = menu_file.Append(-1, self.phrases.menu.file.items.exit.name, self.phrases.menu.file.items.exit.help)
menu_options = wx.Menu()
self.drawer.options = menu_options.Append(-1, self.phrases.menu.options.items.settings.name, self.phrases.menu.options.items.settings.help)
menu_help = wx.Menu()
self.drawer.donate = menu_help.Append(-1, self.phrases.menu.help.items.donate.name, self.phrases.menu.help.items.donate.help)
self.drawer.about = menu_help.Append(-1, self.phrases.menu.help.items.about.name, self.phrases.menu.help.items.about.help)
menuBar = wx.MenuBar()
menuBar.Append(menu_file, self.phrases.menu.file.title)
menuBar.Append(menu_options, self.phrases.menu.options.title)
menuBar.Append(menu_help, self.phrases.menu.help.title)
self.drawer.SetMenuBar(menuBar)
def __create_accel(self):
"""Create accelerated table for menu."""
acceltbl = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('Q'), self.drawer.exit.GetId()),
(wx.ACCEL_CTRL, ord('O'), self.drawer.options.GetId()),
])
self.drawer.SetAcceleratorTable(acceltbl)
def __create_bindings(self):
"""Create bindings for menu."""
self.drawer.Bind(wx.EVT_MENU, getattr(self.command, 'close'), self.drawer.exit)
self.drawer.Bind(wx.EVT_MENU, getattr(self.command, 'options'), self.drawer.options)
self.drawer.Bind(wx.EVT_MENU, getattr(self.command, 'donate'), self.drawer.donate)
self.drawer.Bind(wx.EVT_MENU, getattr(self.command, 'about'), self.drawer.about)