3 import wx, wx.adv # noqa: E401 multiple imports on one line
4 from ..__version__ import __version__
5 from .session_config import get_session_config
8 class AWindow(wx.Frame):
11 A universal parent class for all top-level application windows
13 Standard menu and ability to save/restore window size.
16 # Subclasses should override these
17 session_config_section_name = None
20 def __init__(self, parent=None):
21 if self.session_config_section_name:
22 session_config = get_session_config()
23 width = session_config.getint(
24 self.session_config_section_name, 'width', 600)
25 height = session_config.getint(
26 self.session_config_section_name, 'height', 400)
32 parent=parent, id=-1, title=self.window_title,
33 size=wx.Size(width=width, height=height),
40 if self.session_config_section_name:
41 self.Bind(wx.EVT_SIZE, self.OnSize)
44 MenuBar = wx.MenuBar()
45 self.SetMenuBar(MenuBar)
51 file_menu.Append(wx.ID_CLOSE, u"&Закрыть", u"Закрыть окно")
52 self.Bind(wx.EVT_MENU, self.OnCloseCommand, close_win)
54 quit = file_menu.Append(wx.ID_EXIT, u"&Выход", u"Выйти из программы")
55 self.Bind(wx.EVT_MENU, self.OnQuit, quit)
56 MenuBar.Append(file_menu, u"&Файл")
58 about_menu = wx.Menu()
59 about = about_menu.Append(wx.ID_ABOUT,
60 u"&О m_Librarian", u"О m_Librarian")
61 self.Bind(wx.EVT_MENU, self.OnAbout, about)
62 MenuBar.Append(about_menu, u"&О программе")
64 def OnCloseCommand(self, event):
67 def OnQuit(self, event):
68 wx.GetApp().ExitMainLoop()
70 def OnAbout(self, event):
71 aboutInfo = wx.adv.AboutDialogInfo()
72 aboutInfo.SetName(u'm_Librarian')
73 aboutInfo.SetVersion(__version__)
74 aboutInfo.SetDescription(
75 u'Библиотекарь для библиотек LibRusEc/Flibusta')
76 aboutInfo.AddDeveloper(u'Олег Бройтман')
78 u'https://phdru.name/Software/Python/m_librarian/')
79 aboutInfo.SetCopyright(u'(C) 2023, 2024 Олег Бройтман')
80 aboutInfo.SetLicense(u'GPL')
81 wx.adv.AboutBox(aboutInfo)
83 def OnSize(self, event):
84 """Save window size in the session config"""
85 if self.session_config_section_name:
86 size = event.GetSize()
87 session_config = get_session_config()
89 self.session_config_section_name, 'width', str(size.width))
91 self.session_config_section_name, 'height', str(size.height))
93 event.Skip() # Call other handlers