2013-01-24 102 views
0

这里是我的代码wxmplot matplotlib wxPython的交互式散点图

#!/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() 

起初有一个框架,有菜单栏,然后​​从下拉菜单负荷蛋白选择,这使得当前帧消失,然后弹出一个新的窗口,然后加载你想要的数据,然后按OK。在此之后,应该发生的是应该出现一个图形,但它不会。我是新来的python所以不知道我错了。 对于我使用wxmplot的图,我认为它与matplotlib有关。我认为我的问题是混淆帧或类似的东西。 任何帮助,将不胜感激 干杯

+0

您显示的代码太长。请尽量减少到最低限度,即如果您认为这是一个“与框架混合”,请尝试仅显示一些框架并放弃所有其他框架。 –

回答

0

通常,当发生这种情况时有GUI工具包整合matplotlib,这个问题是关系到matplotlib backend设置。由于您正在编写wx应用程序,因此建议您尝试使用“WXAgg”或“WX”后端。