From d6a51114b89bbece8d1dbe34f5c741d958e0cf06 Mon Sep 17 00:00:00 2001 From: danamir Date: Fri, 9 Mar 2018 04:45:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=20?= =?UTF-8?q?=D0=B2=D0=BE=D1=80=D0=B4=20=D0=B4=D0=BB=D1=8F=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B2.=20=D0=93=D0=B0=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=BE=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D0=B2=D0=BD=D0=B0=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/lab1.py | 52 ++++++++++++++++++++++++++++++++++++++++++ gui/second_page.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++ gui/third_page.py | 52 ++++++++++++++++++++++++++++++++++++++++++ main.py | 16 ++++++++++++- 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 gui/lab1.py create mode 100644 gui/second_page.py create mode 100644 gui/third_page.py diff --git a/gui/lab1.py b/gui/lab1.py new file mode 100644 index 0000000..e76640c --- /dev/null +++ b/gui/lab1.py @@ -0,0 +1,52 @@ +import wx + + +# Some classes to use for the notebook pages. Obviously you would +# want to use something more meaningful for your application, these +# are just for illustration. + +class PageOne(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + t = wx.StaticText(self, -1, "This is a PageOne object", (20,20)) + +class PageTwo(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + t = wx.StaticText(self, -1, "This is a PageTwo object", (40,40)) + +class PageThree(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + t = wx.StaticText(self, -1, "This is a PageThree object", (60,60)) + + +class MainFrame(wx.Frame): + def __init__(self): + wx.Frame.__init__(self, None, title="Simple Notebook Example") + + # Here we create a panel and a notebook on the panel + p = wx.Panel(self) + nb = wx.Notebook(p) + + # create the page windows as children of the notebook + page1 = PageOne(nb) + page2 = PageTwo(nb) + page3 = PageThree(nb) + + # add the pages to the notebook with the label to show on the tab + nb.AddPage(page1, "Page 1") + nb.AddPage(page2, "Page 2") + nb.AddPage(page3, "Page 3") + + # finally, put the notebook in a sizer for the panel to manage + # the layout + sizer = wx.BoxSizer() + sizer.Add(nb, 1, wx.EXPAND) + p.SetSizer(sizer) + + +if __name__ == "__main__": + app = wx.App() + MainFrame().Show() + app.MainLoop() \ No newline at end of file diff --git a/gui/second_page.py b/gui/second_page.py new file mode 100644 index 0000000..23a157a --- /dev/null +++ b/gui/second_page.py @@ -0,0 +1,56 @@ +import wx + + +class SecondPage(wx.Frame): + + def __init__(self, parent): + wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"SecondPage", pos=wx.DefaultPosition, + size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) + + self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) + + fgSizer3 = wx.FlexGridSizer(0, 1, 0, 0) + fgSizer3.SetFlexibleDirection(wx.BOTH) + fgSizer3.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) + + self.m_staticText5 = wx.StaticText(self, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0) + self.m_staticText5.Wrap(-1) + fgSizer3.Add(self.m_staticText5, 0, wx.ALL, 5) + + self.m_radioBtn9 = wx.RadioButton(self, wx.ID_ANY, u"RadioBtn", wx.DefaultPosition, wx.DefaultSize, 0) + fgSizer3.Add(self.m_radioBtn9, 0, wx.ALL, 5) + + self.m_radioBtn10 = wx.RadioButton(self, wx.ID_ANY, u"RadioBtn", wx.DefaultPosition, wx.DefaultSize, 0) + fgSizer3.Add(self.m_radioBtn10, 0, wx.ALL, 5) + + self.m_radioBtn11 = wx.RadioButton(self, wx.ID_ANY, u"RadioBtn", wx.DefaultPosition, wx.DefaultSize, 0) + fgSizer3.Add(self.m_radioBtn11, 0, wx.ALL, 5) + + self.m_radioBtn12 = wx.RadioButton(self, wx.ID_ANY, u"RadioBtn", wx.DefaultPosition, wx.DefaultSize, 0) + fgSizer3.Add(self.m_radioBtn12, 0, wx.ALL, 5) + + self.SetSizer(fgSizer3) + self.Layout() + + self.Centre(wx.BOTH) + + # Connect Events + self.m_radioBtn9.Bind(wx.EVT_LEFT_DCLICK, self.lab1) + self.m_radioBtn10.Bind(wx.EVT_LEFT_DCLICK, self.lab1) + + def __del__(self): + pass + + # Virtual event handlers, overide them in your derived class + def lab1(self, event): + from gui import third_page + nex_page = third_page.MainFrame() + nex_page.Show() + + +app = wx.App(False) +frame = SecondPage(None) +frame.Show() +app.MainLoop() + + diff --git a/gui/third_page.py b/gui/third_page.py new file mode 100644 index 0000000..e76640c --- /dev/null +++ b/gui/third_page.py @@ -0,0 +1,52 @@ +import wx + + +# Some classes to use for the notebook pages. Obviously you would +# want to use something more meaningful for your application, these +# are just for illustration. + +class PageOne(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + t = wx.StaticText(self, -1, "This is a PageOne object", (20,20)) + +class PageTwo(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + t = wx.StaticText(self, -1, "This is a PageTwo object", (40,40)) + +class PageThree(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + t = wx.StaticText(self, -1, "This is a PageThree object", (60,60)) + + +class MainFrame(wx.Frame): + def __init__(self): + wx.Frame.__init__(self, None, title="Simple Notebook Example") + + # Here we create a panel and a notebook on the panel + p = wx.Panel(self) + nb = wx.Notebook(p) + + # create the page windows as children of the notebook + page1 = PageOne(nb) + page2 = PageTwo(nb) + page3 = PageThree(nb) + + # add the pages to the notebook with the label to show on the tab + nb.AddPage(page1, "Page 1") + nb.AddPage(page2, "Page 2") + nb.AddPage(page3, "Page 3") + + # finally, put the notebook in a sizer for the panel to manage + # the layout + sizer = wx.BoxSizer() + sizer.Add(nb, 1, wx.EXPAND) + p.SetSizer(sizer) + + +if __name__ == "__main__": + app = wx.App() + MainFrame().Show() + app.MainLoop() \ No newline at end of file diff --git a/main.py b/main.py index bdef88d..667c9a1 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ class MainPage(wx.Frame): self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) - sizer_all = wx.FlexGridSizer(2, 2, 0, 0) + sizer_all = wx.FlexGridSizer(3, 2, 0, 0) sizer_all.SetFlexibleDirection(wx.BOTH) sizer_all.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) @@ -29,11 +29,25 @@ class MainPage(wx.Frame): self.pswd_txt = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, style=wx.TE_PASSWORD) sizer_all.Add(self.pswd_txt, 0, wx.ALL, 5) + + self.lgn_button = wx.Button(self, wx.ID_ANY, u"Войти") + sizer_all.Add(self.lgn_button,0, wx.ALL, 5) + self.SetSizer(sizer_all) self.Layout() self.Centre(wx.BOTH) + # Connect Events + self.lgn_button.Bind(wx.EVT_BUTTON, self.login) + + + def login(self, event): + from gui import second_page + nxt_page = second_page.SecondPage(None) + nxt_page.Show() + nxt_page.Destroy() +