主面板样式及代码:
# -*- coding: utf-8 -*- """ Created on Tue Jul 19 16:57:27 2016 @author: hugo """ import wx # 实例化一个APP app = wx.App() # 创建一个Frame main = wx.Frame(None, title = "Demo", size = (450,350)) # 打开布局画板 mainpanel = wx.Panel(main) # 创建一个垂直布局箱子 Vbox = wx.BoxSizer(wx.VERTICAL) SearchButton = wx.Button(mainpanel, label=u"结构搜索") SubmitJobButton = wx.Button(mainpanel, label=u"作业提交") AnalyzeButton = wx.Button(mainpanel, label=u"结果分析") Vbox.Add(SearchButton, proportion=1, flag=wx.EXPAND) Vbox.Add(SubmitJobButton, proportion=1, flag=wx.EXPAND, border=5) Vbox.Add(AnalyzeButton, proportion=1, flag=wx.EXPAND, border=5) mainpanel.SetSizer(Vbox) #显示 main.Show() #主循环 app.MainLoop()
搜索面板样式及代码:
# -*- coding: utf-8 -*- """ Created on Tue Jul 19 12:59:59 2016 @author: hugo """ #导入库 import wx #实例化一个app app=wx.App() #创建一个Frame win = wx.Frame(None,title = u"结构搜索", size=(450,350)) #打开布局画板 Bkg = wx.Panel(win) #创建一个水平布局箱子 Hbox = wx.BoxSizer(wx.HORIZONTAL) # 搜索模式 #modelist = [u‘分子量‘, u‘分子式‘] #SearchMode = wx.ComboBox(Bkg, -1, u‘分子量‘, (15, 15), wx.DefaultSize, modelist, wx.CB_DROPDOWN) SearchMode = wx.Button(Bkg, label = u"分子量") # 搜索框 SearchBox = wx.TextCtrl(Bkg) # 搜索按钮 searchpng = wx.Image(‘search.png‘, wx.BITMAP_TYPE_PNG).ConvertToBitmap() SearchButton = wx.BitmapButton(Bkg, -1, searchpng, size = (30,30)) #SearchButton = wx.Button(Bkg, label = u"搜索") Hbox.Add(SearchMode, proportion = 0, flag = wx.LEFT) Hbox.Add(SearchBox, proportion = 1, flag = wx.EXPAND | wx.LEFT, border = 5) Hbox.Add(SearchButton, proportion = 0, flag = wx.LEFT, border = 5) ContentsTxtCtl = wx.TextCtrl(Bkg, style = wx.TE_MULTILINE | wx.HSCROLL) # 创建一个垂直布局箱子 Vbox = wx.BoxSizer(wx.VERTICAL) Vbox.Add(Hbox, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5) Vbox.Add(ContentsTxtCtl, proportion = 1, flag = wx.EXPAND | wx.RIGHT | wx.BOTTOM, border = 5) Bkg.SetSizer(Vbox) #显示 win.Show() #主循环 app.MainLoop()
问题:如何通过点击主面板上的“结构搜索”进入“搜索面板”
时间: 2024-10-10 08:29:41