我想从我的主面板打开一个新的面板,这样我就可以放置文本框来输入数据,并有一个后退按钮返回主面板。这是我的代码。
#!/usr/bin/env python
import wx
class secPanel(wx.Panel):
def __init__(self):
wx.Panel.__init__(self)
self.Show(true)
class Frame(wx.Frame):
"""subclassing wx.Frame for app templates with file->quit coded"""
def __init__(self, title, pos, size):
wx.Frame.__init__(self, None, -1, title, pos, size)
menuBar = wx.MenuBar()
menu1 = wx.Menu()
menuItem = menu1.Append(-1, "&Exit")
menuBar.Append(menu1, "&File")
mainPanel = wx.Panel(self, wx.ID_ANY)
strainEntry = wx.Button(mainPanel, label="Enter Strain", pos=(900,100),
size=(100,100))
uploadPic = wx.Button(mainPanel, label="Upload Pics", pos=(900,150),
size=(100,100))
editStrain = wx.Button(mainPanel, label="Edit Strain", pos=(900,200),
size=(100,100))
self.Bind(wx.EVT_BUTTON, self.strButtonClick, strainEntry)
#self.SetToolTip(wx.ToolTip("Click to Enter Strain"))
def strButtonClick(self,event):
newPanel = secPanel(self)
with my app.py
import wx
from FrmTem import *
import FrmTem
class App(wx.App):
def OnInit(self):
self.frame = Frame("Growtistics", (40,40),(1080,680))
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main():
app = App()
app.MainLoop()
if __name__ == '__main__':
main()
答案 0 :(得分:0)
这可能会让你在那里部分或全部:
http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
您可能还想查看wxPython包含的各种Notebook小部件或者可能是向导。
顺便说一句,有一个官方的wxPython邮件列表非常适合学习wxPython并提出问题:http://groups.google.com/group/wxpython-users/topics?pli=1