Hallo,
vor einiger Zeit habe ich eine kleine Applikation geschrieben, die MatPlotLib Graphen in einem wxPython GUI verwendet. Das hat bis gestern wunderbar funktioniert, aber nun wird der Graph plötzlich nur z.T. angezeigt, egal wie groß das GUI Hauptfenster ist. Der Code ist der gleiche geblieben. Unter Windows tritt das Problem übrigens nicht auf - da funktioniert alles wie bisher.
Ich habe keine Idee, wo ich nach dem Fehler suchen soll ... - unten der Link zu einem Screenshot.
Für Tipps bin ich dankbar.
Grüße, Sebastian
http://picasaweb.google.com/sebrhode/Wx ... directlink
Matplotlib Graph wird in wxPython Appliktion abgeschnitten
-
- User
- Beiträge: 19
- Registriert: Mittwoch 16. Dezember 2009, 11:05
Das hatte ich eigentlich auch vor, aber das wird recht lang. Ich hoffe, dieser Teil reicht ...
Code: Alles auswählen
#!/usr/bin/env python
# Author: Sebastian Rhode
# Created: 2009-11-03
# Version: 1.6 - 2010-03-19
#
# Feel free to improve it! There still some bugs inside ...
import wx
import os, sys
import numpy as np
import wx.grid
# Matplotlib Figure object
from matplotlib.figure import Figure
# import the WxAgg FigureCanvas object, that binds Figure to
# WxAgg backend --> a wxPanel
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
# import the NavigationToolbar WxAgg widget
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
# ------------------------------------------------------------------------------------
# global variables and additional functions
# range of graph
xmin_limit = 200
xmax_limit = 1500
# size of figure & resolution (dpi)
sizex = 12
sizey = 9
res = 100
# array with used laser wavelengths
wl = np.array([405, 445, 473, 488, 491, 515, 532, 561, 594, 640]) # wavelengths of Lasers
# corresponding colors in HEX-RGB code
colors = ['#8700ff','#5600ff','#00baff','#00f6ff','#00fffc','#00ffa0','#00ff64','#c1ff00','#ff8900','#ff001f']
# line width for displaying the laser lines
linew = 2
# ------------------------------------------------------------------------------------
# calculation for Raman lines
raman = np.zeros( (wl.shape[0], 4))
raman[:,0] = wl
for i in range (0,wl.shape[0],1):
raman1 = 1.0 /(1.0/wl[i]-1595/1E7)
raman2 = 1.0 /(1.0/wl[i]-3652/1E7)
raman3 = 1.0 /(1.0/wl[i]-3756/1E7)
raman[i,1] = raman1
raman[i,2] = raman2
raman[i,3] = raman3
# normalizes dye spectra to 1
def normspec(datain):
out = datain
out[:,1] = datain[:,1]/datain[:,1].max(0)
return out
# converts filters spectra to 0-1 range
#def normspec_filter(datain):
# out = datain
# if datain[:,1].max(0)>10:
# out[:,1] = datain[:,1]/100
# print "max. value: ", datain[:,1].max(0)
# print 'Filter normalized !!!'
# return out
def normspec_filter(datain): # converts filters spectra to 0-1 range
out = datain
maxvalue = datain[:,1].max(0)
#print 'maxvalue: ', maxvalue
if (maxvalue > 1):
decdigits = np.floor(np.log(maxvalue)/np.log(10)) + 1
out[:,1] = datain[:,1]/10**(decdigits)
print 'maxvalue: ', maxvalue
print 'Filter Normalized by division: ', 10**(decdigits)
return out
def AdjustDisplay(self):
self.page_graph.axes.axis([self.xmin, self.xmax, self.ymin, self.ymax])
self.page_graph.axes.legend(loc=4)
leg = self.page_graph.axes.legend(loc='lower right')
# matplotlib.text.Text instances
try:
for t in leg.get_texts():
t.set_fontsize('small') # the legend text fontsize
except:
test=1
self.page_graph.figure.canvas.draw()
class Page_Abs(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class Page_Flu(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class Page_Ex(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class Page_Di(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class Page_Em(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class Page_Ls(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class Page_Misc(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class MplPanel(wx.Panel):
def __init__(self, *args, **kwds):
wx.Panel.__init__(self, *args, **kwds)
self.__set_properties()
self.__do_layout()
xmin = 320
xmax = 700
ymin = 0
ymax = 1.05
self.figure = Figure(figsize=(sizex, sizey), dpi=res)
self.axes = self.figure.add_subplot(111)
self.axes.set_xticks(np.arange(xmin_limit, xmax_limit, 20))
self.axes.set_yticks(np.arange(ymin, ymax, 0.1));
self.axes.axis([xmin,xmax,ymin,ymax])
self.axes.grid(True)
self.axes.set_xlabel('Wavelength [nm]',fontsize=14)
self.axes.set_ylabel('Transmission [%] or Intensity [a.u.]',fontsize=14)
self.figure.subplots_adjust(left=0.07, bottom=0.09, right=0.97, top=0.94,wspace=0.20, hspace=0.20)
# we bind the figure to the FigureCanvas, so that it will be drawn using the specific backend
self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
# create an BoxSizer, to define the layout of our window
self.sizer = wx.BoxSizer(wx.VERTICAL)
# add the figure canvas
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
# instantiate the Navigation Toolbar
self.toolbar = NavigationToolbar2Wx(self.canvas)
# needed to support Windows systems
self.toolbar.Realize()
# add it to the sizer
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
# explicitly show the toolbar
self.toolbar.Show()
# sets the window to have the given layout sizer
self.SetSizer(self.sizer)
# adapt sub-widget sizes to fit the window size following sizer specification
self.Fit()
def __set_properties(self):
# begin wxGlade: MplPanel.__set_properties
pass
# end wxGlade
def __do_layout(self):
# begin wxGlade: MplPanel.__do_layout
pass
# end wxGlade
class MplFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds['style'] = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.MAXIMIZE|wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.FULL_REPAINT_ON_RESIZE|wx.CLIP_CHILDREN
wx.Frame.__init__(self, *args, **kwds)
# Here we create a panel and a notebook on the panel
p = wx.Panel(self)
self.nb = wx.Notebook(p)
# create the page windows as children of the notebook
self.page_graph = MplPanel(self.nb)
self.page_abs = Page_Abs(self.nb)
self.page_flu = Page_Flu(self.nb)
self.page_ex = Page_Ex(self.nb)
self.page_di = Page_Di(self.nb)
self.page_em = Page_Em(self.nb)
self.page_ls = Page_Ls(self.nb)
self.page_misc = Page_Misc (self.nb)
# add the pages to the notebook with the label to show on the tab
self.nb.AddPage(self.page_graph, 'Graph')
self.nb.AddPage(self.page_abs, 'Abs')
self.nb.AddPage(self.page_flu, 'Flu')
self.nb.AddPage(self.page_ex, 'Ex')
self.nb.AddPage(self.page_di, 'Di')
self.nb.AddPage(self.page_em, 'Em')
self.nb.AddPage(self.page_ls, 'Ls')
self.nb.AddPage(self.page_misc, 'Misc')
self.createMenuBar()
self.MplFrame_statusbar = self.CreateStatusBar(1, 0)
self.__set_properties()
self.__do_layout()
# default x/y scaling values
self.xmin = 320
self.xmax = 700
self.ymin = 0
self.ymax = 1.05
def menuData(self):
return (('File',
('Save Graph As...', '', self.OnSaveAs, wx.ITEM_NORMAL, True),
('', '', '', '', ''), # separator
('Set Working Directory', '', self.OnSetDir, wx.ITEM_NORMAL, True),
('', '', '', '', ''), # separator
('Quit', '', self.OnQuit, wx.ITEM_NORMAL, True)),
('Dyes',
('Load Dye Absorption', '', self.OnLoadAbs, wx.ITEM_NORMAL, True),
('Load Dye Emission', '', self.OnLoadFlu, wx.ITEM_NORMAL, True),
('', '', '', '', ''),
('Delete last Absorption', '', self.OnDelAbs, wx.ITEM_NORMAL, False),
('Delete last Emission', '', self.OnDelFlu, wx.ITEM_NORMAL, False)),
('Filter',
('Load Excitation Filter', '', self.OnLoadEx, wx.ITEM_NORMAL, True),
('Load Dichroic Mirror', '', self.OnLoadDi, wx.ITEM_NORMAL, True),
('Load Emission Filter', '', self.OnLoadEm, wx.ITEM_NORMAL, True),
('', '', '', '', ''),
('Delete last Excitation Filter', '', self.OnDelEx, wx.ITEM_NORMAL, False),
('Delete last Dichroic Mirror', '', self.OnDelDi, wx.ITEM_NORMAL, False),
('Delete Last Emission Filter', '', self.OnDelEm, wx.ITEM_NORMAL, False)),
('Light Source',
('Load Light Source', '', self.OnLoadLs, wx.ITEM_NORMAL, True),
('', '', '', '', ''),
('Delete last Light Source', '', self.OnDelLs, wx.ITEM_NORMAL, False)),
('Misc. Spectra',
('Load misc. Spec', '', self.OnLoadMisc, wx.ITEM_NORMAL, True),
('', '', '', '', ''),
('Delete misc. Spec', '', self.OnDelMisc, wx.ITEM_NORMAL, False)),
('Fura Excitation',
('Fura 340nm', '', self.OnShowFura340, wx.ITEM_CHECK, True),
('Fura 380nm', '', self.OnShowFura380, wx.ITEM_CHECK, True)),
('Laser Lines',
('405nm', '', self.OnShow405, wx.ITEM_CHECK, True),
('445nm', '', self.OnShow445, wx.ITEM_CHECK, True),
('473nm', '', self.OnShow473, wx.ITEM_CHECK, True),
('488nm', '', self.OnShow488, wx.ITEM_CHECK, True),
('491nm', '', self.OnShow491, wx.ITEM_CHECK, True),
('515nm', '', self.OnShow515, wx.ITEM_CHECK, True),
('532nm', '', self.OnShow532, wx.ITEM_CHECK, True),
('561nm', '', self.OnShow561, wx.ITEM_CHECK, True),
('594nm', '', self.OnShow594, wx.ITEM_CHECK, True),
('640nm', '', self.OnShow640, wx.ITEM_CHECK, True),
('', '', '', '', ''),
('Custom Laser', '', self.OnShowCustomLaser, wx.ITEM_CHECK, True)),
('H2O Raman Lines',
('H2O Raman 405nm', '', self.OnShowRaman405, wx.ITEM_CHECK, True),
('H2O Raman 445nm', '', self.OnShowRaman445, wx.ITEM_CHECK, True),
('H2O Raman 473nm', '', self.OnShowRaman473, wx.ITEM_CHECK, True),
('H2O Raman 488nm', '', self.OnShowRaman488, wx.ITEM_CHECK, True),
('H2O Raman 491nm', '', self.OnShowRaman491, wx.ITEM_CHECK, True),
('H2O Raman 515nm', '', self.OnShowRaman515, wx.ITEM_CHECK, True),
('H2O Raman 532nm', '', self.OnShowRaman532, wx.ITEM_CHECK, True),
('H2O Raman 561nm', '', self.OnShowRaman561, wx.ITEM_CHECK, True),
('H2O Raman 594nm', '', self.OnShowRaman594, wx.ITEM_CHECK, True),
('H2O Raman 640nm', '', self.OnShowRaman640, wx.ITEM_CHECK, True),
('', '', '', '', ''),
('Custom Raman Laser', '', self.OnShowCustomRaman, wx.ITEM_CHECK, True)),
('Scaling Options',
('Set X-Min Value', '', self.OnSetXMin, wx.ITEM_NORMAL, True),
('Set X-Max Value', '', self.OnSetXMax, wx.ITEM_NORMAL, True)))
def createMenuBar(self):
menuBar = wx.MenuBar()
for eachMenuData in self.menuData():
menuLabel = eachMenuData[0]
menuItems = eachMenuData[1:]
menuBar.Append(self.createMenu(menuItems), menuLabel)
self.SetMenuBar(menuBar)
def createMenu(self, menuData):
menu = wx.Menu()
for eachLabel, eachStatus, eachHandler, eachKind, eachEnable in menuData:
if not eachLabel:
menu.AppendSeparator()
continue
menuItem = menu.Append(-1, eachLabel, eachStatus, eachKind)
menuItem.Enable(eachEnable)
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
return menu
def __set_properties(self):
self.SetTitle('Spectra 1.6 - by Sebastian Rhode')
self.SetSize((sizex*res, sizey*res))
self.MplFrame_statusbar.SetStatusWidths([-1])
# statusbar fields
MplFrame_statusbar_fields = ['MplFrame_statusbar']
for i in range(len(MplFrame_statusbar_fields)):
self.MplFrame_statusbar.SetStatusText(MplFrame_statusbar_fields[i], i)
def __do_layout(self):
mplsizer1 = wx.BoxSizer(wx.VERTICAL)
mplsizer1.Add(self.nb, 1, wx.ALL|wx.EXPAND, 0)
self.SetSizer(mplsizer1)
self.Layout()
...
Hallo.
Da war übrigens noch ein Hinweis auf Pastebins ...
Die Code-Tags unterstützen übrigens auch Highlighting für Python, das macht es noch einmal deutlich einfacher zu lesen.
Sebastian
Du solltest versuchen deinen Code auf ein minimales, lauffähiges Beispiel kürzen. Das erhöht die Chancen auf eine Antwort deutlich. Ich kann mich nicht überwinden durch so viele Zeilen zu suchen.sebastian06 hat geschrieben:Das hatte ich eigentlich auch vor, aber das wird recht lang.
Da war übrigens noch ein Hinweis auf Pastebins ...

Die Code-Tags unterstützen übrigens auch Highlighting für Python, das macht es noch einmal deutlich einfacher zu lesen.
Sebastian
Das Leben ist wie ein Tennisball.
-
- User
- Beiträge: 19
- Registriert: Mittwoch 16. Dezember 2009, 11:05
OK, das mit dem Code hat wohl nicht so funktioniert. Ich habe das Programm jetzt stark gekürzt (Noch viel kürzer ist schwer ...). Und wie gesagt, unter Windows läuft es normal, unter Ubuntu 10.04 aber eben nicht--> siehe Screen Shot. Vor einigen Wochen (keine Änderung an Code) lief es noch auf beiden Plattformen.
Grüße,
Sebi
Grüße,
Sebi
Code: Alles auswählen
import wx
import os, sys
import numpy as np
import wx.grid
# Matplotlib Figure object
from matplotlib.figure import Figure
# import the WxAgg FigureCanvas object, that binds Figure to
# WxAgg backend --> a wxPanel
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
# import the NavigationToolbar WxAgg widget
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
# ------------------------------------------------------------------------------------
# global variables and additional functions
# range of graph
xmin_limit = 200
xmax_limit = 1500
# size of figure & resolution (dpi)
sizex = 12
sizey = 9
res = 100
# ------------------------------------------------------------------------------------
# normalizes dye spectra to 1
def normspec(datain):
out = datain
out[:,1] = datain[:,1]/datain[:,1].max(0)
return out
def normspec_filter(datain): # converts filters spectra to 0-1 range
out = datain
maxvalue = datain[:,1].max(0)
#print 'maxvalue: ', maxvalue
if (maxvalue > 1):
decdigits = np.floor(np.log(maxvalue)/np.log(10)) + 1
out[:,1] = datain[:,1]/10**(decdigits)
print 'maxvalue: ', maxvalue
print 'Filter Normalized by division: ', 10**(decdigits)
return out
def AdjustDisplay(self):
self.page_graph.axes.axis([self.xmin, self.xmax, self.ymin, self.ymax])
self.page_graph.axes.legend(loc=4)
leg = self.page_graph.axes.legend(loc='lower right')
# matplotlib.text.Text instances
try:
for t in leg.get_texts():
t.set_fontsize('small') # the legend text fontsize
except:
test=1
self.page_graph.figure.canvas.draw()
class Page_Abs(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class Page_Flu(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
class MplPanel(wx.Panel):
def __init__(self, *args, **kwds):
wx.Panel.__init__(self, *args, **kwds)
self.__set_properties()
self.__do_layout()
xmin = 320
xmax = 700
ymin = 0
ymax = 1.05
self.figure = Figure(figsize=(sizex, sizey), dpi=res)
self.axes = self.figure.add_subplot(111)
self.axes.set_xticks(np.arange(xmin_limit, xmax_limit, 20))
self.axes.set_yticks(np.arange(ymin, ymax, 0.1));
self.axes.axis([xmin,xmax,ymin,ymax])
self.axes.grid(True)
self.axes.set_xlabel('Wavelength [nm]',fontsize=14)
self.axes.set_ylabel('Transmission [%] or Intensity [a.u.]',fontsize=14)
self.figure.subplots_adjust(left=0.07, bottom=0.09, right=0.97, top=0.94,wspace=0.20, hspace=0.20)
# we bind the figure to the FigureCanvas, so that it will be drawn using the specific backend
self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
# create an BoxSizer, to define the layout of our window
self.sizer = wx.BoxSizer(wx.VERTICAL)
# add the figure canvas
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
# instantiate the Navigation Toolbar
self.toolbar = NavigationToolbar2Wx(self.canvas)
# needed to support Windows systems
self.toolbar.Realize()
# add it to the sizer
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
# explicitly show the toolbar
self.toolbar.Show()
# sets the window to have the given layout sizer
self.SetSizer(self.sizer)
# adapt sub-widget sizes to fit the window size following sizer specification
self.Fit()
def __set_properties(self):
# begin wxGlade: MplPanel.__set_properties
pass
# end wxGlade
def __do_layout(self):
# begin wxGlade: MplPanel.__do_layout
pass
# end wxGlade
class MplFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds['style'] = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.MAXIMIZE|wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.FULL_REPAINT_ON_RESIZE|wx.CLIP_CHILDREN
wx.Frame.__init__(self, *args, **kwds)
# Here we create a panel and a notebook on the panel
p = wx.Panel(self)
self.nb = wx.Notebook(p)
# create the page windows as children of the notebook
self.page_graph = MplPanel(self.nb)
self.page_abs = Page_Abs(self.nb)
self.page_flu = Page_Flu(self.nb)
# add the pages to the notebook with the label to show on the tab
self.nb.AddPage(self.page_graph, 'Graph')
self.nb.AddPage(self.page_abs, 'Abs')
self.nb.AddPage(self.page_flu, 'Flu')
self.createMenuBar()
self.MplFrame_statusbar = self.CreateStatusBar(1, 0)
self.__set_properties()
self.__do_layout()
# default x/y scaling values
self.xmin = 320
self.xmax = 700
self.ymin = 0
self.ymax = 1.05
def menuData(self):
return (('File',
('Save Graph As...', '', self.OnSaveAs, wx.ITEM_NORMAL, True),
('', '', '', '', ''), # separator
('Set Working Directory', '', self.OnSetDir, wx.ITEM_NORMAL, True),
('', '', '', '', ''), # separator
('Quit', '', self.OnQuit, wx.ITEM_NORMAL, True)),
('Dyes',
('Load Dye Absorption', '', self.OnLoadAbs, wx.ITEM_NORMAL, True),
('Load Dye Emission', '', self.OnLoadFlu, wx.ITEM_NORMAL, True),
('', '', '', '', ''),
('Delete last Absorption', '', self.OnDelAbs, wx.ITEM_NORMAL, False),
('Delete last Emission', '', self.OnDelFlu, wx.ITEM_NORMAL, False)))
def createMenuBar(self):
menuBar = wx.MenuBar()
for eachMenuData in self.menuData():
menuLabel = eachMenuData[0]
menuItems = eachMenuData[1:]
menuBar.Append(self.createMenu(menuItems), menuLabel)
self.SetMenuBar(menuBar)
def createMenu(self, menuData):
menu = wx.Menu()
for eachLabel, eachStatus, eachHandler, eachKind, eachEnable in menuData:
if not eachLabel:
menu.AppendSeparator()
continue
menuItem = menu.Append(-1, eachLabel, eachStatus, eachKind)
menuItem.Enable(eachEnable)
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
return menu
def __set_properties(self):
self.SetTitle('Spectra 1.6 - by Sebastian Rhode')
self.SetSize((sizex*res, sizey*res))
self.MplFrame_statusbar.SetStatusWidths([-1])
# statusbar fields
MplFrame_statusbar_fields = ['MplFrame_statusbar']
for i in range(len(MplFrame_statusbar_fields)):
self.MplFrame_statusbar.SetStatusText(MplFrame_statusbar_fields[i], i)
def __do_layout(self):
mplsizer1 = wx.BoxSizer(wx.VERTICAL)
mplsizer1.Add(self.nb, 1, wx.ALL|wx.EXPAND, 0)
self.SetSizer(mplsizer1)
self.Layout()
def ToggleItem(self, event, IDjump):
item1 = self.GetMenuBar().FindItemById(event.GetId()) # get the corresponding item
item2 = self.GetMenuBar().FindItemById(event.GetId() + IDjump) # get the cooresponding item to switch Enalbled status
enabled1 = item1.IsEnabled()
enabled2 = item2.IsEnabled()
item1.Enable(not enabled1) # toggle status
item2.Enable(not enabled2) # toggle status
def ShowSpectralData(self, event, path, dat, kind, fc):
path = os.path.basename(path)
colLabels = ['Wavelength', 'Trans / Int']
sizex = 300
sizey = 580
if (kind == 'abs'):
grid = wx.grid.Grid(self.page_abs, size = (sizex, sizey))
elif (kind == 'flu'):
grid = wx.grid.Grid(self.page_flu, size = (sizex, sizey))
grid.CreateGrid(dat.shape[0],dat.shape[1])
grid.SelectAll()
grid.ClearSelection()
for row in range(dat.shape[0]):
for col in range(dat.shape[1]):
grid.SetCellValue(row, col, str(dat[row,col]))
grid.SetCellTextColour(row, col, fc)
for col in range(dat.shape[1]):
grid.SetColLabelValue(col, colLabels[col])
def OnSaveAs(self, event):
dlg = wx.FileDialog(self, 'Choose a Filename', os.getcwd(), '', '*.png*',
wx.SAVE | wx.OVERWRITE_PROMPT)
if dlg.ShowModal() == wx.ID_OK:
savename = dlg.GetPath()
self.page_graph.figure.savefig(savename)
dlg.Destroy()
def OnSetDir(self, event):
dlg = wx.DirDialog(self, 'Choose a working directory:',
style = wx.wx.DD_DIR_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
workingdir = dlg.GetPath()
os.chdir(workingdir)
self.SetStatusText('Selected default directory: %s' % workingdir)
dlg.Destroy()
def OnQuit(self, event):
self.Close(True)
def OnLoadAbs(self, event):
dlg = wx.FileDialog(self, 'Choose Dye Absorption Spectra', os.getcwd(), '', '*.abs*', wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
pathabs = dlg.GetPath()
mypathabs = os.path.basename(pathabs)
self.SetStatusText('Selected Absorption Spectra: %s' % mypathabs)
abs = np.loadtxt(pathabs)
abs = normspec(abs)
self.gabs, = self.page_graph.axes.plot(abs[:,0],abs[:,1],'k-', lw=2,label = mypathabs)
AdjustDisplay(self)
self.ToggleItem(event, 2)
fc = 'black'
kind = 'abs'
self.ShowSpectralData(event, pathabs, abs, kind, fc)
dlg.Destroy()
def OnLoadFlu(self, event):
dlg = wx.FileDialog(self, 'Choose Dye Emission Spectra', os.getcwd(), '', '*.flu*', wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
pathflu = dlg.GetPath()
mypathflu = os.path.basename(pathflu)
self.SetStatusText('Selected Fluorescence Spectra: %s' % mypathflu)
flu = np.loadtxt(pathflu)
flu = normspec(flu)
self.gflu, = self.page_graph.axes.plot(flu[:,0],flu[:,1],'k--', lw=2,label = mypathflu)
AdjustDisplay(self)
self.ToggleItem(event, 2)
fc = 'black'
kind = 'flu'
self.ShowSpectralData(event, pathflu, flu, kind, fc)
dlg.Destroy()
def OnDelAbs(self, event):
try:
self.gabs.remove()
self.page_graph.axes.legend_= None
AdjustDisplay(self)
self.ToggleItem(event, -2)
fc = 'black'
kind = 'flu'
self.ShowSpectralData(event, '', np.zeros([1,1]), kind, fc) # delete grid table
except:
dial = wx.MessageDialog(None, 'No Absorption Spectra found', 'Error', wx.OK | wx.ICON_ERROR)
dial.ShowModal()
def OnDelFlu(self, event):
try:
self.gflu.remove()
self.page_graph.axes.legend_= None
AdjustDisplay(self)
self.ToggleItem(event, -2)
fc = 'black'
kind = 'abs'
self.ShowSpectralData(event, '', np.zeros([1,1]), kind, fc)
except:
dial = wx.MessageDialog(None, 'No Fluorescence Spectra found', 'Error', wx.OK | wx.ICON_ERROR)
dial.ShowModal()
# end of class MplFrame
if __name__ == '__main__':
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
MplFrame = MplFrame(parent=None, id = -1)
app.SetTopWindow(MplFrame)
MplFrame.Show()
app.MainLoop()
- Rebecca
- User
- Beiträge: 1662
- Registriert: Freitag 3. Februar 2006, 12:28
- Wohnort: DN, Heimat: HB
- Kontaktdaten:
Dein Problem tritt bei auch auf. Wenn ich mir die anderen Tabs so anschaue, sieht es aus, als waere da der zugehoerige Bereich auch nicht groesser, also wuerde ich da mal nachschauen: Ueberpruefe deine Sizer und Panels, ob sie auch den kompletten Raum einnehmen und die Parent-Beziehungen stimmen (fuer das Notebook als auch fuer dessen Inhalte).
Ich sehe uebrigens noch ziemlich vieles, was aus dem Programm rausfliegen kann, damit unsereins besser durchsteigt: Das Menue, die Statuszeile; lasse im Graphen nur eine einfache Gerade zeichnen und schmeiss allen anderen Berechnungskram raus, etc. Das hilft nicht nur uns, sondern ist auch fuer einen selbst nuetzlich um den Fehler einzugrenzen.
Wenn etwas ploetzlich nicht mehr geht, ist es im allgemeinen auch mal sinnvoll zu ueberlegen, ob du mit Ubuntu ein Update gemacht hast. Hat sich dabei die Python-Version, matplotlib-Version oder wx-Version geaendert? Wenn ja, geben vlt. Changelogs Auskunft darueber, ob sich etwas geaendert hat und du deinen Code entsprechend anpassen musst. Kann aber auch sein, dass dein Code vorher schon nicht ganz in Ordnung war und es erst jetzt auffaellt...
Ich sehe uebrigens noch ziemlich vieles, was aus dem Programm rausfliegen kann, damit unsereins besser durchsteigt: Das Menue, die Statuszeile; lasse im Graphen nur eine einfache Gerade zeichnen und schmeiss allen anderen Berechnungskram raus, etc. Das hilft nicht nur uns, sondern ist auch fuer einen selbst nuetzlich um den Fehler einzugrenzen.
Wenn etwas ploetzlich nicht mehr geht, ist es im allgemeinen auch mal sinnvoll zu ueberlegen, ob du mit Ubuntu ein Update gemacht hast. Hat sich dabei die Python-Version, matplotlib-Version oder wx-Version geaendert? Wenn ja, geben vlt. Changelogs Auskunft darueber, ob sich etwas geaendert hat und du deinen Code entsprechend anpassen musst. Kann aber auch sein, dass dein Code vorher schon nicht ganz in Ordnung war und es erst jetzt auffaellt...
Offizielles Python-Tutorial (Deutsche Version)
Urheberrecht, Datenschutz, Informationsfreiheit: Piratenpartei
Urheberrecht, Datenschutz, Informationsfreiheit: Piratenpartei