Quantcast
Channel: How to put 2 Frames in 1 Application with wxpython? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How to put 2 Frames in 1 Application with wxpython?

$
0
0

Hello i have created 2 frames, and when I run this program it will show each frame as their own application (at least on windows). Is there a way to use both frames but put them in one application?

import wxclass MainFrame(wx.Frame):     def __init__(self):         wx.Frame.__init__(self, None, wx.NewId(), "Main")         self.sizer = wx.BoxSizer(wx.VERTICAL)        self.button = wx.Button(self, wx.NewId(), "Open a child")        self.sizer.Add(self.button, proportion=0, border=2, flag=wx.ALL)        self.SetSizer(self.sizer)        self.button.Bind(wx.EVT_BUTTON, self.on_button)        self.Layout()    def on_button(self, evt):        frame = ChildFrame(self)        frame.Show(True)        frame.MakeModal(True)class ChildFrame(wx.Frame):     def __init__(self, parent):         wx.Frame.__init__(self, parent, wx.NewId(), "Child")        self.Bind(wx.EVT_CLOSE, self.on_close)    def on_close(self, evt):        self.MakeModal(False)        evt.Skip()class MyApp(wx.App):    def OnInit(self):        frame = MainFrame()        frame.Show(True)        self.SetTopWindow(frame)        return Trueapp = MyApp(0)app.MainLoop()    

Here is an image of what I do not want:https://i.stack.imgur.com/7gayc.png

that is what I do not want,I would like both frames to be in ONE application.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images