这是我的代码
#!/usr/bin/python
#
import sys
if not hasattr(sys, 'frozen'):
import wxversion
wxversion.ensureMinimal('2.8')
import wxmplot
import numpy
import wx
import os
import subprocess
import re
import wx.lib.plot as plot
import urllib2
from BeautifulSoup import BeautifulSoup
from wx.lib.pubsub import Publisher
""""""
#----------------------------------------------------------------------
def __init__(self, parent, size = (5000,5000)):
"""Constructor"""
wx.Panel.__init__(self, parent=parent, size = (5000,5000))
self.frame = parent
Publisher().subscribe(self.showFrame, ("show.mainframe"))
menu=wx.MenuBar()
file0 = wx.Menu()
help0 = wx.Menu()
Load=file0.Append(wx.NewId(),"Load Protein","Load from PDB File")
parent.Bind(wx.EVT_MENU,self.load,Load)
file0.Append(wx.NewId(),"Save")
Close = file0.Append(wx.NewId(),"Quit")
parent.Bind(wx.EVT_MENU,self.close,Close)
help0.Append(wx.NewId(),"Help")
help0.Append(wx.NewId(),"About")
menu.Append(file0,"File")
menu.Append(help0,"Help")
parent.SetMenuBar(menu)
self.pubsubText = wx.StaticText(self,-1," ", (5,150))
def close(self,event):
self.Close(True)
def showFrame(self, msg):
"""
Shows the frame and shows the message sent in the
text control
"""
self.pubsubText.SetLabel("This is the Contact Map for the chain "+msg.data[0]+" in the PDB file "+msg.data[1])
self.data = number_list
x = numpy.arange(100)/20.0 + numpy.random.random(size=100)
y = numpy.random.random(size=len(x))
def onlasso(data=None, selected=None, mask=None):
print ':: lasso ', selected
pframe = wxmplot.PlotFrame()
pframe.scatterplot(x, y, title='Scatter Plot', size=15,xlabel='$ x\, \mathrm{(\AA)}$',ylabel='$ y\, \mathrm{(\AA^{-1})}$')
pframe.panel.lasso_callback = onlasso
pframe.write_message('WXMPlot PlotFrame example: Try Help->Quick Reference')
pframe.Show()
frame=self.GetParent()
frame.Show()
########################################################################
class MainFrame(wx.Frame):
#----------------------------------------------------------------------
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "PSP Solver")
panel = MainPanel(self)
#----------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App(False)
frame = MainFrame()
frame.Show()
app.MainLoop()
首先是一帧,带有一个菜单栏,然后从下拉菜单中选择加载蛋白质,这会使当前帧消失,并弹出一个新的帧,然后加载所需的数据,然后按确定。在此之后应该发生的是应该出现一个图表,但它没有。我是 python 新手,所以不确定我哪里出错了。对于图表,我使用的是我认为与 matplotlib 相关的 wxmplot。我认为我的问题是与框架或类似的东西混淆了。任何帮助将不胜感激干杯