wx
でプロットするためのフロントエンドとして、Python で最初のアプリケーションを作成していmatplotlib
ます。データをnumpy
配列angles
とcol_cnts
. ただし、 plt.plot を発行すると、次のエラーが表示されます
usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py:621: DeprecationWarning: Use the new widget gtk.Tooltip
Segmentation fault (core dumped)
私のコードが追加されます。どこからデバッグを開始すればよいかわかりません。私はそれを plt.plot 行まで追跡しましたが、それ以上の情報がない場合、私は迷子になります。私は走っpython 2.6
ていますrhel 6.4
#!/usr/bin/env python
import wx
from wx.lib.masked import NumCtrl
import matplotlib.pyplot as plt
import numpy as np
import pylab
from datetime import datetime
import time
class NeoProbe(wx.Frame):
def __init__(self, parent, title):
super(NeoProbe, self).__init__(parent, title=title,
size=(750, 400))
self.probe_list = ['Old','New']
#default probe is old
self.default_probe = self.probe_list[0]
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self)
font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
font.SetPointSize(9)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
st1 = wx.StaticText(panel, label='Date')
st1.SetFont(font)
hbox1.Add(st1, flag=wx.RIGHT, border=8)
self.dp = wx.DatePickerCtrl(panel,wx.ID_ANY,wx.DefaultDateTime,wx.DefaultPosition)
self.dp.SetFont(font)
hbox1.Add(self.dp,flag=wx.RIGHT,border=10)
hbox1.Add((80,1))
st2 = wx.StaticText(panel, label='Probe')
st2.SetFont(font)
hbox1.Add(st2, flag=wx.RIGHT, border=8)
cb1 = wx.ComboBox(panel,wx.ID_ANY,choices = self.probe_list,
value=self.default_probe,
style=wx.TE_PROCESS_ENTER,size=(100, 30))
cb1.SetFont(font)
hbox1.Add(cb1,proportion=0,flag=wx.ALIGN_RIGHT|wx.LEFT, border =10)
vbox.Add(hbox1, flag=wx.LEFT|wx.RIGHT|wx.TOP, border=10)
vbox.Add((-1, 10))
## Now add grid sizer
fgs = wx.FlexGridSizer(10,6,9,25)
bfont = wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.BOLD)
angle = wx.StaticText(panel,label="Angle")
angle.SetFont(bfont)
count_c = wx.StaticText(panel,label="Counts (C)")
count_c.SetFont(bfont)
count_u = wx.StaticText(panel,label="Counts (U)")
count_u.SetFont(bfont)
angle2 = wx.StaticText(panel,label="Angle")
angle2.SetFont(bfont)
count_c2 = wx.StaticText(panel,label="Counts (C)")
count_c2.SetFont(bfont)
count_u2 = wx.StaticText(panel,label="Counts (U)")
count_u2.SetFont(bfont)
#Set input boxes for results
self.numctrl_ccm90 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm90 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp90 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp90 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm75 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm75 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp75 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp75 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm60 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm60 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp60 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp60 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm45 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm45 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp45 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp45 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm30 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm30 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp30 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp30 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm15 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm15 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp15 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp15 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_cc0 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_uc0 = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_fwhm = NumCtrl(panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
fgs.AddMany([(angle),(count_c), (count_u),(angle2),(count_c2), (count_u2),
(wx.StaticText(panel, -1, '-90')),
(self.numctrl_ccm90,0,wx.EXPAND,5),
(self.numctrl_ucm90,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '90')),
(self.numctrl_ccp90,0,wx.EXPAND,5),
(self.numctrl_ucp90,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '-75')),
(self.numctrl_ccm75,0,wx.EXPAND,5),
(self.numctrl_ucm75,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '75')),
(self.numctrl_ccp75,0,wx.EXPAND,5),
(self.numctrl_ucp75,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '-60')),
(self.numctrl_ccm60,0,wx.EXPAND,5),
(self.numctrl_ucm60,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '60')),
(self.numctrl_ccp60,0,wx.EXPAND,5),
(self.numctrl_ucp60,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '-45')),
(self.numctrl_ccm45,0,wx.EXPAND,5),
(self.numctrl_ucm45,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '45')),
(self.numctrl_ccp45,0,wx.EXPAND,5),
(self.numctrl_ucp45,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '-30')),
(self.numctrl_ccm30,0,wx.EXPAND,5),
(self.numctrl_ucm30,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '30')),
(self.numctrl_ccp30,0,wx.EXPAND,5),
(self.numctrl_ucp30,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '-15')),
(self.numctrl_ccm15,0,wx.EXPAND,5),
(self.numctrl_ucm15,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '15')),
(self.numctrl_ccp15,0,wx.EXPAND,5),
(self.numctrl_ucp15,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '0')),
(self.numctrl_cc0,0,wx.EXPAND,5),
(self.numctrl_uc0,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, '')),
(wx.StaticText(panel, -1, '')),
(wx.StaticText(panel, -1, '')),
(wx.StaticText(panel, -1, '')),
(wx.StaticText(panel, -1, '')),
(wx.StaticText(panel, -1, '')),
(wx.StaticText(panel, -1, 'FWHM')),
(self.numctrl_fwhm,0,wx.EXPAND,5),
(wx.StaticText(panel, -1, 'deg'))])
vbox.Add(fgs, proportion=1,flag = wx.LEFT | wx.RIGHT |wx.ALIGN_CENTER,border=5)
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
graph_btn = wx.Button(panel, label='Plot', size=(70, 30))
hbox2.Add(graph_btn)
db_btn = wx.Button(panel, label='Update db', size=(100, 30))
hbox2.Add(db_btn, flag=wx.LEFT|wx.BOTTOM, border=5)
exit_btn = wx.Button(panel, label='Exit', size=(70, 30))
hbox2.Add(exit_btn, flag=wx.LEFT|wx.BOTTOM, border=5)
vbox.Add(hbox2, flag=wx.ALIGN_RIGHT|wx.RIGHT, border=10)
#Setup button bindings
self.Bind(wx.EVT_BUTTON, self.OnExit,exit_btn)
self.Bind(wx.EVT_BUTTON, self.OnPlot, graph_btn)
self.Bind(wx.EVT_BUTTON, self.OnUpdate, db_btn)
#Probe checkbox choice
self.Bind(wx.EVT_COMBOBOX, self.OnSelect, cb1)
panel.SetSizer(vbox)
def OnExit(self,event):
dlg = wx.MessageDialog(self,
"Do you really want to close this application?",
"Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
result = dlg.ShowModal()
dlg.Destroy()
if result == wx.ID_OK:
self.Close()
def OnPlot(self,event):
#datestring = str(self.dp.GetValue())
#dateobject = datetime(*(time.strptime(datestring, "%a %d %b %Y %H:%M:%S %Z")[0:6]))
#date = dateobject.strftime("%d_%B_%Y")
#print date
#Angle numpy arrange
angles = np.arange(-90,91,15)
col_cnts = np.array([self.numctrl_ccm90.GetValue(),self.numctrl_ccm75.GetValue(),
self.numctrl_ccm60.GetValue(),self.numctrl_ccm45.GetValue(),
self.numctrl_ccm30.GetValue(),self.numctrl_ccm15.GetValue(),
self.numctrl_cc0.GetValue(),
self.numctrl_ccp15.GetValue(),self.numctrl_ccp30.GetValue(),
self.numctrl_ccp45.GetValue(),self.numctrl_ccp60.GetValue(),
self.numctrl_ccp75.GetValue(),self.numctrl_ccp90.GetValue()])
#read in collimated counts
uncol_cnts = np.array([self.numctrl_ucm90.GetValue(),self.numctrl_ucm75.GetValue(),
self.numctrl_ucm60.GetValue(),self.numctrl_ucm45.GetValue(),
self.numctrl_ucm30.GetValue(),self.numctrl_ucm15.GetValue(),
self.numctrl_uc0.GetValue(),
self.numctrl_ucp15.GetValue(),self.numctrl_ucp30.GetValue(),
self.numctrl_ucp45.GetValue(),self.numctrl_ucp60.GetValue(),
self.numctrl_ucp75.GetValue(),self.numctrl_ucp90.GetValue()])
#Plot col counts vs angle, blue squares
plt.plot(angles,col_cnts,'bs')
print col_cnts
print uncol_cnts
def OnUpdate(self,event):
print "Updating non-existant database\n"
def OnSelect(self,event):
self.default_probe = self.probe_list[event.GetSelection()]
if __name__ == '__main__':
app = wx.App()
NeoProbe(None, title='Neoprobe QC Application')
app.MainLoop()
編集
これで、パネルを上部パネルと下部パネルに分割できました。ただし、スペース管理は非常に貧弱です。最後の NumCtrl と上部パネルのボタンの間の大きなギャップ。また、フィギュアを下部パネルの中央に配置し、パネルのサイズに合わせてサイズを変更する方法もわかりません
import wx
from wx.lib.masked import NumCtrl
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use('WXAgg')
import matplotlib.backends.backend_wxagg as mwx
import numpy as np
import pylab
from datetime import datetime
import time
class NeoProbe(wx.Frame):
def __init__(self, parent, title):
super(NeoProbe, self).__init__(parent, title=title,
size=(750, 900))
panel = wx.Panel(self)
vsizer = wx.BoxSizer(wx.VERTICAL)
top_panel = wx.Panel(panel)
vsizer.Add(top_panel, 1, wx.EXPAND)
top_panel_sizer = wx.BoxSizer(wx.VERTICAL)
top_panel.SetSizer(top_panel_sizer)
bottom_panel = wx.Panel(panel)
vsizer.Add(bottom_panel, 1, wx.EXPAND)
bottom_panel_sizer = wx.BoxSizer(wx.VERTICAL)
bottom_panel.SetSizer(bottom_panel_sizer)
self.midPanel = wx.Panel(bottom_panel)
bottom_panel_sizer.Add(self.midPanel, 1, wx.EXPAND | wx.ALL, 20)
top_panel_sizer = wx.BoxSizer(wx.VERTICAL)
top_panel.SetSizer(top_panel_sizer)
panel.SetSizer(vsizer)
self.probe_list = ['Old','New']
#default probe is old
self.default_probe = self.probe_list[0]
font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
font.SetPointSize(9)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
st1 = wx.StaticText(top_panel, label='Date')
st1.SetFont(font)
hbox1.Add(st1, flag=wx.RIGHT, border=8)
self.dp = wx.DatePickerCtrl(top_panel,wx.ID_ANY,wx.DefaultDateTime,wx.DefaultPosition)
self.dp.SetFont(font)
hbox1.Add(self.dp,flag=wx.RIGHT,border=10)
hbox1.Add((80,1))
st2 = wx.StaticText(top_panel, label='Probe')
st2.SetFont(font)
hbox1.Add(st2, flag=wx.RIGHT, border=8)
cb1 = wx.ComboBox(top_panel,wx.ID_ANY,choices = self.probe_list,
value=self.default_probe,
style=wx.TE_PROCESS_ENTER,size=(100, 30))
cb1.SetFont(font)
hbox1.Add(cb1,proportion=0,flag=wx.ALIGN_RIGHT|wx.LEFT, border =10)
vbox.Add(hbox1, flag=wx.LEFT|wx.RIGHT|wx.TOP, border=10)
## Now add grid sizer
fgs = wx.FlexGridSizer(10,6,9,25)
bfont = wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.BOLD)
angle = wx.StaticText(top_panel,label="Angle")
angle.SetFont(bfont)
count_c = wx.StaticText(top_panel,label="Counts (C)")
count_c.SetFont(bfont)
count_u = wx.StaticText(top_panel,label="Counts (U)")
count_u.SetFont(bfont)
angle2 = wx.StaticText(top_panel,label="Angle")
angle2.SetFont(bfont)
count_c2 = wx.StaticText(top_panel,label="Counts (C)")
count_c2.SetFont(bfont)
count_u2 = wx.StaticText(top_panel,label="Counts (U)")
count_u2.SetFont(bfont)
#Set input boxes for results
self.numctrl_ccm90 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm90 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp90 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp90 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm75 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm75 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp75 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp75 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm60 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm60 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp60 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp60 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm45 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm45 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp45 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp45 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm30 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm30 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp30 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp30 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccm15 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucm15 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ccp15 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_ucp15 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_cc0 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_uc0 = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
self.numctrl_fwhm = NumCtrl(top_panel,-1,style=wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB)
fgs.AddMany([(angle),(count_c), (count_u),(angle2),(count_c2), (count_u2),
(wx.StaticText(top_panel, -1, '-90')),
(self.numctrl_ccm90,0,wx.EXPAND,5),
(self.numctrl_ucm90,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '90')),
(self.numctrl_ccp90,0,wx.EXPAND,5),
(self.numctrl_ucp90,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '-75')),
(self.numctrl_ccm75,0,wx.EXPAND,5),
(self.numctrl_ucm75,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '75')),
(self.numctrl_ccp75,0,wx.EXPAND,5),
(self.numctrl_ucp75,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '-60')),
(self.numctrl_ccm60,0,wx.EXPAND,5),
(self.numctrl_ucm60,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '60')),
(self.numctrl_ccp60,0,wx.EXPAND,5),
(self.numctrl_ucp60,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '-45')),
(self.numctrl_ccm45,0,wx.EXPAND,5),
(self.numctrl_ucm45,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '45')),
(self.numctrl_ccp45,0,wx.EXPAND,5),
(self.numctrl_ucp45,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '-30')),
(self.numctrl_ccm30,0,wx.EXPAND,5),
(self.numctrl_ucm30,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '30')),
(self.numctrl_ccp30,0,wx.EXPAND,5),
(self.numctrl_ucp30,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '-15')),
(self.numctrl_ccm15,0,wx.EXPAND,5),
(self.numctrl_ucm15,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '15')),
(self.numctrl_ccp15,0,wx.EXPAND,5),
(self.numctrl_ucp15,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, '0')),
(self.numctrl_cc0,0,wx.EXPAND,5),
(self.numctrl_uc0,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, 'FWHM')),
(self.numctrl_fwhm,0,wx.EXPAND,5),
(wx.StaticText(top_panel, -1, 'deg'))])
vbox.Add(fgs, proportion=1,flag = wx.LEFT | wx.RIGHT |wx.ALIGN_CENTER,border=5)
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
graph_btn = wx.Button(top_panel, label='Plot', size=(70, 30))
hbox2.Add(graph_btn)
db_btn = wx.Button(top_panel, label='Update db', size=(100, 30))
hbox2.Add(db_btn, flag=wx.LEFT|wx.BOTTOM, border=5)
exit_btn = wx.Button(top_panel, label='Exit', size=(70, 30))
hbox2.Add(exit_btn, flag=wx.LEFT|wx.BOTTOM, border=5)
vbox.Add(hbox2, flag=wx.ALIGN_RIGHT|wx.RIGHT, border=10)
#Setup button bindings
self.Bind(wx.EVT_BUTTON, self.OnExit,exit_btn)
self.Bind(wx.EVT_BUTTON, self.OnPlot, graph_btn)
self.Bind(wx.EVT_BUTTON, self.OnUpdate, db_btn)
#Probe checkbox choice
self.Bind(wx.EVT_COMBOBOX, self.OnSelect, cb1)
top_panel.SetSizer(vbox)
self.Centre()
self.Show()
def OnExit(self,event):
dlg = wx.MessageDialog(self,
"Do you really want to close this application?",
"Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
result = dlg.ShowModal()
dlg.Destroy()
if result == wx.ID_OK:
self.Close()
def OnPlot(self,event):
#datestring = str(self.dp.GetValue())
#dateobject = datetime(*(time.strptime(datestring, "%a %d %b %Y %H:%M:%S %Z")[0:6]))
#date = dateobject.strftime("%d_%B_%Y")
#print date
#Angle numpy arrange
angles = np.arange(-90,91,15)
col_cnts = np.array([self.numctrl_ccm90.GetValue(),self.numctrl_ccm75.GetValue(),
self.numctrl_ccm60.GetValue(),self.numctrl_ccm45.GetValue(),
self.numctrl_ccm30.GetValue(),self.numctrl_ccm15.GetValue(),
self.numctrl_cc0.GetValue(),
self.numctrl_ccp15.GetValue(),self.numctrl_ccp30.GetValue(),
self.numctrl_ccp45.GetValue(),self.numctrl_ccp60.GetValue(),
self.numctrl_ccp75.GetValue(),self.numctrl_ccp90.GetValue()])
#read in collimated counts
uncol_cnts = np.array([self.numctrl_ucm90.GetValue(),self.numctrl_ucm75.GetValue(),
self.numctrl_ucm60.GetValue(),self.numctrl_ucm45.GetValue(),
self.numctrl_ucm30.GetValue(),self.numctrl_ucm15.GetValue(),
self.numctrl_uc0.GetValue(),
self.numctrl_ucp15.GetValue(),self.numctrl_ucp30.GetValue(),
self.numctrl_ucp45.GetValue(),self.numctrl_ucp60.GetValue(),
self.numctrl_ucp75.GetValue(),self.numctrl_ucp90.GetValue()])
#Plot col counts vs angle, blue squares
fig = mpl.figure.Figure()
canvas = mwx.FigureCanvasWxAgg(self.midPanel, -1, fig)
ax = fig.add_subplot(1, 1, 1)
ax.plot(angles,col_cnts,'bs')
canvas.draw()
print col_cnts
print uncol_cnts
def OnUpdate(self,event):
print "Updating non-existant database\n"
def OnSelect(self,event):
self.default_probe = self.probe_list[event.GetSelection()]
if __name__ == '__main__':
app = wx.App()
NeoProbe(None, title='Neoprobe QC Application')
app.MainLoop()