From f3b5f514fff84ab8bcf3b2927ce926206294ec4f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 17 Dec 2023 19:45:46 +0300 Subject: [PATCH] Feat(wx): Create main menu bar, add command "Quit" [skip ci] --- .gitattributes | 1 + m_librarian/wx/Application.py | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index b7dbfd2..cf217cc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ .git* export-ignore /README.rus.txt encoding=utf-8 +*.py encoding=utf-8 *.rst encoding=utf-8 *.txt text diff --git a/m_librarian/wx/Application.py b/m_librarian/wx/Application.py index d20868c..35575c3 100644 --- a/m_librarian/wx/Application.py +++ b/m_librarian/wx/Application.py @@ -1,10 +1,28 @@ +# coding: utf-8 + import wx +class MainWindow(wx.Frame): + + def InitMenu(self): + MenuBar = wx.MenuBar() + self.SetMenuBar(MenuBar) + + file_menu = wx.Menu() + exit = file_menu.Append(wx.ID_EXIT, u"&Выход", u"Выйти из программы") + self.Bind(wx.EVT_MENU, self.OnQuit, exit) + MenuBar.Append(file_menu, u"&Файл") + + def OnQuit(self, event): + self.Close(True) + + class Application(wx.App): def OnInit(self): - frame = wx.Frame(None, -1, u"m_Librarian") + frame = MainWindow(None, -1, u"m_Librarian") + frame.InitMenu() frame.Show(True) self.SetTopWindow(frame) return True -- 2.39.5