wx.aui problem
I want to design a GUI which has four panels. One of them will display a Mobile simulator. But that panel just displayed the screen print, it is not what I wanted. The Mobile simulator should inside the GUI, not pop-up by itself.
Could somebody help me? Thanks a lot.
Mobile.py
---------------------------------------------------------------------------------------------
#!/usr/bin/python
# Mobile.py
import wx
class Border(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(320, 640))
###Set up the frame layout###
borderPanel = wx.Panel(self, -1) # Make a new panel inside the frame \
borderPanel.SetBackgroundColour('#ededed') #(using as border)
panel = wx.Panel(borderPanel, -1) # Make a new panel inside the frame
panel.SetBackgroundColour('BLACK') # Set 'panels' bgcolor
topPan = wx.Panel(panel, -1) # Make a subpanel for the top of 'panel'
topPan.SetBackgroundColour('WHITE') # Set 'topPans' bgcolor
smallPan = wx.Panel(panel , -1) # Make a subpanel for the top of 'panel'
smallPan.SetBackgroundColour('#4f5049') # Set 'smallPans' bgcolor
bbox = wx.BoxSizer(wx.VERTICAL) # Make a new sizer for 'borderPanel'
vbox = wx.BoxSizer(wx.VERTICAL) # Make a new sizer for 'panel'
bbox.Add(panel, 1, wx.EXPAND | wx.ALL, 20)# Add panel to border panel
vbox.Add(topPan, 5, wx.EXPAND | wx.ALL, 10) # Add both subpanels to the new sizer \
vbox.Add(smallPan, 4, wx.EXPAND | wx.ALL, 10) # in order
borderPanel.SetSizer(bbox) # set 'panel' inside 'borderPanel'
panel.SetSizer(vbox) # set the sizer containing 'topPan' and 'smallPan' \
# inside 'panel
### Add the buttons to smallPan###
bOk=wx.Button(smallPan,label="OK",pos=(40,20),size=(50,30))
bMenu=wx.Button(smallPan,label="Menu",pos=(100,20),size=(50,30))
bCancel=wx.Button(smallPan,label="CANCEL",pos=(160,20),size=(50,30))
button1=wx.Button(smallPan,label="1",pos=(40,60),size=(50,30))
button2=wx.Button(smallPan,label="2",pos=(100,60),size=(50,30))
button3=wx.Button(smallPan,label="3",pos=(160,60),size=(50,30))
button4=wx.Button(smallPan,label="4",pos=(40,100),size=(50,30))
button5=wx.Button(smallPan,label="5",pos=(100,100),size=(50,30))
button6=wx.Button(smallPan,label="6",pos=(160,100),size=(50,30))
button7=wx.Button(smallPan,label="7",pos=(40,140),size=(50,30))
button8=wx.Button(smallPan,label="8",pos=(100,140),size=(50,30))
button9=wx.Button(smallPan,label="9",pos=(160,140),size=(50,30))
button_star=wx.Button(smallPan,label="*",pos=(40,180),size=(50,30))
button0=wx.Button(smallPan,label="0",pos=(100,180),size=(50,30))
button_h=wx.Button(smallPan,label="#",pos=(160,180),size=(50,30))
self.Centre()
self.Show(True)
##app = wx.App()
##Border(None, -1, 'Mobile Simulator')
##app.MainLoop()
---------------------------------------------------------------------------------------------------
Test-aui.py
---------------------------------------------------------------------------------------------------
#!/usr/bin/python
# Test-aui.py
import wx
import wx.aui
import Mobile
class MyFrame(wx.Frame):
def __init__(self, parent, id=-1, title='wx.aui Test',pos=wx.DefaultPosition, size=(800, 600), style=wx.DEFAULT_FRAME_STYLE):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self._mgr = wx.aui.AuiManager(self)
# create several text controls
text1 = wx.TextCtrl(self, -1, 'Pane 1 - sample text',
wx.DefaultPosition, wx.Size(320,640),
wx.NO_BORDER | wx.TE_MULTILINE)
text2 = wx.TextCtrl(self, -1, 'Pane 2 - sample text',
wx.DefaultPosition, wx.Size(320,640),
wx.NO_BORDER | wx.TE_MULTILINE)
## text3 = wx.TextCtrl(self, -1, 'Main content window',
## wx.DefaultPosition, wx.Size(200,150),
## wx.NO_BORDER | wx.TE_MULTILINE)
#canvas Mobile
mobile = self.mobile = Mobile.Border(parent,wx.ID_ANY,'')
text4 = wx.TextCtrl(self, -1, 'Pane 3 - content window',
wx.DefaultPosition, wx.Size(320,640),
wx.NO_BORDER | wx.TE_MULTILINE)
# add the panes to the manager
##self._mgr.AddPane(text3, wx.CENTER)
self._mgr.AddPane(mobile, wx.CENTER)
self._mgr.AddPane(text1, wx.LEFT, 'Pane Number One')
self._mgr.AddPane(text2, wx.RIGHT, 'Pane Number Two')
# self._mgr.AddPane(text4, wx.TOP)
self._mgr.AddPane(text4, wx.BOTTOM)
self._mgr.GetPane(mobile).Name("mobile")
# tell the manager to 'commit' all the changes just made
self._mgr.Update()
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
# deinitialize the frame manager
self._mgr.UnInit()
# delete the frame
self.Destroy()
app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()
|