Commit b42987bd authored by Julio Tambara's avatar Julio Tambara
Browse files

Adicionado,hide_graphic(),Controle do focus,save/saveas.

hide_grafic():esconde um dos gráficos, foram adaptadas algumas funções
para manter compatibilidade.
Mudou-se o Focus para ficar apenas nos 2 gráficos.
Shift + arrow key foi adicionado para mudar os 2 gráficos
simultaneamente
Save/Saveas: funciona para os 2 gráficos agora (_A,_B)
parent 2717d2df
...@@ -26,9 +26,10 @@ a = f.add_subplot(111) ...@@ -26,9 +26,10 @@ a = f.add_subplot(111)
a2 = f2.add_subplot(111) a2 = f2.add_subplot(111)
t = f.suptitle('# 1') t = f.suptitle('# 1')
t2 = f2.suptitle('# 2') t2 = f2.suptitle('# 2')
Control = dict(t=600, bmin=0, bmax=8192, bmaxold=512, j=0, filename='temp', count=0, paused=True, ROIctrl=list(),CALIctrl=list(), start=False)
Control = dict(t=600, bmin=0, bmax=8192, bmaxold=512, j=0, filename='temp', count=0, paused=True, ROIctrl=list(),CALIctrl=list(), start=False, Logaritmo=False,graphic1=True,graphic2=True)
PlotLimControl = dict(limupdtx=True,limupdty=True,limupdt=True, limctrl=False, x0=0, y0=0, x1=512, y1=0, pressx=0., pressy=0., limtrans=False, dx=0., dy=0., limupdt_b=True, limupdt_bx=True, limupdt_by=True, limctrl_b=False, x0_b=0, y0_b=0, x1_b=512, y1_b=0, pressx_b=0., pressy_b=0., limtrans_b=False, dx_b=0., dy_b=0.) PlotLimControl = dict(limupdtx=True,limupdty=True,limupdt=True, limctrl=False, x0=0, y0=0, x1=512, y1=0, pressx=0., pressy=0., limtrans=False, dx=0., dy=0., limupdt_b=True, limupdt_bx=True, limupdt_by=True, limctrl_b=False, x0_b=0, y0_b=0, x1_b=512, y1_b=0, pressx_b=0., pressy_b=0., limtrans_b=False, dx_b=0., dy_b=0.)
FocusControl = dict( graphic1= True, graphic2=False) FocusControl = dict( full_screen= False, aux_click='gg')
Data=dict(a=list(),b=list()) Data=dict(a=list(),b=list())
ROIs=list() ROIs=list()
for j in range(8192): for j in range(8192):
...@@ -185,6 +186,7 @@ def roiroi(): ...@@ -185,6 +186,7 @@ def roiroi():
ROIs.insert(Control['j'], InterestRegion(Labelsf[Control['j']], Control['j'])) ROIs.insert(Control['j'], InterestRegion(Labelsf[Control['j']], Control['j']))
Control['ROIctrl'].insert(Control['j'], 0) Control['ROIctrl'].insert(Control['j'], 0)
Control['ROIctrl'][int(Control['j'])] = 1 Control['ROIctrl'][int(Control['j'])] = 1
ROIs[Control['j']].ROIme()
Control['j'] = Control['j'] + 1 Control['j'] = Control['j'] + 1
roibut = tk.Button(roiwin, text = 'Add', command = lambda i=i: addROI(), bd=2, width=7, height=1) roibut = tk.Button(roiwin, text = 'Add', command = lambda i=i: addROI(), bd=2, width=7, height=1)
...@@ -192,6 +194,18 @@ def roiroi(): ...@@ -192,6 +194,18 @@ def roiroi():
addROI() addROI()
roiwin.mainloop() roiwin.mainloop()
def chage_focus(): #change the focus g1->g2->g1&g2->
if (g1_show and g2_show):
if Controlfocus['g1_sel']:
if Controlfocus['g2_sel']:
return
#proximo = g1
#else:
#proximo =g2
if Controlfocus['g2_sel']:
return
#proximo =g1eg2
############################################################################## ##############################################################################
############################################################################## ##############################################################################
...@@ -299,11 +313,17 @@ def graphic2(Data, Data2): #Plot ...@@ -299,11 +313,17 @@ def graphic2(Data, Data2): #Plot
temp2.set_xdata(range(int(Interface['spinboxes'][0].get()))) temp2.set_xdata(range(int(Interface['spinboxes'][0].get())))
temp2.set_ydata(Data2) temp2.set_ydata(Data2)
if PlotLimControl['limupdtx'] or PlotLimControl['limupdty']: if PlotLimControl['limupdtx'] or PlotLimControl['limupdty']:
a.relim() if Control['Logaritmo']:
a.autoscale_view(scaley=PlotLimControl['limupdty'],scalex=PlotLimControl['limupdtx']) a.set_yscale('log')
else:
a.relim()
a.autoscale_view(scaley=PlotLimControl['limupdty'],scalex=PlotLimControl['limupdtx'])
if PlotLimControl['limupdt_bx'] or PlotLimControl['limupdt_by'] : if PlotLimControl['limupdt_bx'] or PlotLimControl['limupdt_by'] :
a2.relim() if Control['Logaritmo']:
a2.autoscale_view(scaley=PlotLimControl['limupdt_by'],scalex=PlotLimControl['limupdt_bx']) a2.set_yscale('log')
else:
a2.relim()
a2.autoscale_view(scaley=PlotLimControl['limupdt_by'],scalex=PlotLimControl['limupdt_bx'])
if PlotLimControl['limupdtx'] == True: if PlotLimControl['limupdtx'] == True:
grid(a, int(Interface['spinboxes'][0].get())) grid(a, int(Interface['spinboxes'][0].get()))
if PlotLimControl['limupdt_bx'] == True: if PlotLimControl['limupdt_bx'] == True:
...@@ -341,7 +361,43 @@ def realtimeplot(): # Funcao recursiva para plot em tempo real ...@@ -341,7 +361,43 @@ def realtimeplot(): # Funcao recursiva para plot em tempo real
############################################################################## ##############################################################################
############################################################################## ##############################################################################
# Control functions # Control functions
def hide_graphic(): #a= hide 1#, b=hide 2#, x= unhide
if FocusControl['full_screen']==True:
Interface['frames'][11].place_forget()
Interface['frames'][10].place_forget()
Interface['frames'][10].place(anchor='nw',relheight=0.99, relwidth=0.5)
Interface['frames'][11].place(anchor='nw',relheight=0.99, relwidth=0.5, relx = 0.5)
rig_but_menu.entryconfig('Unhide graphic',label ='Hide graphic')
FocusControl['full_screen']=False
elif FocusControl['aux_click']=='g1':
Interface['frames'][10].place_forget()
Interface['frames'][11].place_configure(anchor='n',relwidth=0.99,relheight=0.99)
rig_but_menu.entryconfig('Hide graphic',label ='Unhide graphic')
FocusControl['full_screen']=True
elif FocusControl['aux_click']=='g2':
Interface['frames'][11].place_forget()
Interface['frames'][10].place_forget()
Interface['frames'][10].place_configure(anchor='n',relwidth=0.99,relx=0.5,relheight=0.99)
rig_but_menu.entryconfig('Hide graphic',label ='Unhide graphic')
FocusControl['full_screen']=True
#dataPlot2.get_tk_widget().pack_forget()
#dataPlot.get_tk_widget().pack(side='top', fill='x', expand=1)
# dataPlot = FigureCanvasTkAgg(f, master=Interface['frames'][10])
#dataPlot.get_tk_widget().pack(side='top', fill='both', expand=1)
#dataPlot2 = FigureCanvasTkAgg(f2, master=Interface['frames'][11])
#dataPlot2.get_tk_widget().pack(side='top', fill='both', expand=1)
def reset(i, ii): # Zera o vetor de aquisicao def reset(i, ii): # Zera o vetor de aquisicao
if i: if i:
...@@ -375,27 +431,47 @@ def pause(): # Para/Continua a aquisicao de dados ...@@ -375,27 +431,47 @@ def pause(): # Para/Continua a aquisicao de dados
Interface['labels'][6]['text'] = 'Acquiring' Interface['labels'][6]['text'] = 'Acquiring'
realtimeplot() realtimeplot()
def save(): # Salva os dados no arquivo selecionado def save(grafico): # Salva os dados no arquivo selecionado (grafico= g1(salva g1) g2(salva g2) g12(salva os dois)
global child, Data global Data
Control['count'] = Control['count'] + 1 Control['count'] = Control['count'] + 1
fname = open(Control['filename']+'.'+str(Control['count']), mode = 'w') Interface['labels'][8].configure(text='%s.%d' %(Control['filename'], Control['count']))
for n in range(int(Interface['spinboxes'][0].get())): if grafico == 'g1' or grafico =='g12':
fname.write(str(n+1)+' '+str(Data[n])+'\n') fname = open(Control['filename']+'.'+str(Control['count'])+'_A', mode = 'w')
fname.close() for n in range(int(Interface['spinboxes'][0].get())):
Interface['labels'][5]['text'] = '%s.%d' %(Control['filename'], Control['count']) fname.write(str(n+1)+' '+str(Data['a'][n])+'\n')
fname.close()
Interface['labels'][5]['text'] = '%s.%d' %(Control['filename'], Control['count'])
if grafico == 'g2' or grafico =='g12':
fname = open(Control['filename']+'.'+str(Control['count'])+'_B', mode = 'w')
for n in range(int(Interface['spinboxes'][0].get())):
fname.write(str(n+1)+' '+str(Data['b'][n])+'\n')
fname.close()
#Interface['labels'][5]['text'] = '%s.%d' %(Control['filename'], Control['count'])
def saveas(): # Salva os dados no arquivo selecionado
def saveas(grafico): # Salva os dados no arquivo selecionado
global child, Data global child, Data
temp = tkFileDialog.asksaveasfilename(title='Save as') temp = tkFileDialog.asksaveasfilename(title='Save as')
if temp != str():
if temp != str():
Control['filename'] = temp Control['filename'] = temp
Control['count']=0 Control['count']=0
fname = open(Control['filename']+'.'+str(Control['count']), mode = 'w') if grafico == 'g1' or grafico =='g12':
fname = open(Control['filename']+'.'+str(Control['count'])+'_A', mode = 'w')
for n in range(int(Interface['spinboxes'][0].get())): for n in range(int(Interface['spinboxes'][0].get())):
fname.write(str(n+1)+' '+str(Data[n])+'\n') fname.write(str(n+1)+' '+str(Data['a'][n])+'\n')
fname.close() fname.close()
Interface['labels'][5]['text'] = '%s.%d' %(Control['filename'], Control['count']) Interface['labels'][5]['text'] = '%s.%d' %(Control['filename'], Control['count'])
Control['count'] = Control['count'] + 1 if grafico == 'g2' or grafico =='g12':
fname = open(Control['filename']+'.'+str(Control['count'])+'_B', mode = 'w')
for n in range(int(Interface['spinboxes'][0].get())):
fname.write(str(n+1)+' '+str(Data['b'][n])+'\n')
fname.close()
#Interface['labels'][5]['text'] = '%s.%d' %(Control['filename'], Control['count'])
Control['count'] = Control['count'] + 1
Interface['labels'][8].configure(text='%s.%d' %(Control['filename'], Control['count']))
def load(): # Manda os dados carregados para leitura def load(): # Manda os dados carregados para leitura
global child global child
...@@ -485,20 +561,21 @@ def lldt(): #Definir o lower level detection trueshot ...@@ -485,20 +561,21 @@ def lldt(): #Definir o lower level detection trueshot
lldtwin.mainloop() lldtwin.mainloop()
############################################################################## ##############################################################################
############################################################################## ##############################################################################
# Interface elements # Interface elements
for i in range(4): for i in range(4):
if i == 2: if i == 2:
Interface['frames'].insert(i, tk.Frame(root)) Interface['frames'].insert(i, tk.Frame(root,takefocus=0))
Interface['frames'][i].pack(side='top',fill='both', expand=1) Interface['frames'][i].pack(side='top',fill='both', expand=1)
else: else:
Interface['frames'].insert(i, tk.Frame(root)) Interface['frames'].insert(i, tk.Frame(root))
Interface['frames'][i].pack(side='top',fill='x', expand=0) Interface['frames'][i].pack(side='top',fill='x', expand=0)
Interface['labelframes'].insert(0,tk.LabelFrame(Interface['frames'][0], relief='raised', text='Bins', bd=2, pady=2, bg='grey')) Interface['labelframes'].insert(0,tk.LabelFrame(Interface['frames'][0], relief='raised',takefocus=0, text='Bins', bd=2, pady=2, bg='grey'))
Interface['labelframes'].insert(1,tk.LabelFrame(Interface['frames'][0], relief='raised', text='Time', bd=1, height=5, pady=2, bg='grey')) Interface['labelframes'].insert(1,tk.LabelFrame(Interface['frames'][0], relief='raised',takefocus=0, text='Time', bd=1, height=5, pady=2, bg='grey'))
for i in range(2): for i in range(2):
Interface['labelframes'][i].pack(side='right') Interface['labelframes'][i].pack(side='right')
...@@ -507,14 +584,19 @@ for i in range(3): ...@@ -507,14 +584,19 @@ for i in range(3):
Interface['frames'].insert((i+4), tk.Frame(Interface['labelframes'][0])) Interface['frames'].insert((i+4), tk.Frame(Interface['labelframes'][0]))
Interface['frames'][(i+4)].pack(side='left') Interface['frames'][(i+4)].pack(side='left')
Interface['spinboxes'].insert(0, tk.Spinbox(Interface['labelframes'][0], command = lambda i=i: set_fator(Interface['spinboxes'][0].get()), values=[64,128,256,512,1024,2048,4096,8192], state = 'readonly', bg='grey')) Interface['spinboxes'].insert(0, tk.Spinbox(Interface['labelframes'][0], command = lambda i=i: set_fator(Interface['spinboxes'][0].get()), values=[64,128,256,512,1024,2048,4096,8192],takefocus=0, state = 'readonly', bg='grey'))
Interface['spinboxes'][0].pack() Interface['spinboxes'][0].pack()
############################################################################## ##############################################################################
# Menu # Menu
menubar = tk.Menu(root, relief='raised', bd=2) menubar = tk.Menu(root, relief='raised', bd=2)
filemenu = tk.Menu(menubar, tearoff=0) filemenu = tk.Menu(menubar, tearoff=0)
filemenu.add_command(label="Open", command = lambda i=i:load()) filemenu.add_command(label="Open", command = lambda i=i:load())
filemenu.add_command(label ="Save", command = lambda i=i: save('g12'))
filemenu.add_command(label ="Save As", command = lambda i=i: saveas('g12'))
filemenu.add_command(label="Exit", command = sys.exit) filemenu.add_command(label="Exit", command = sys.exit)
settings = tk.Menu(menubar, tearoff=0) settings = tk.Menu(menubar, tearoff=0)
...@@ -523,17 +605,25 @@ settings.add_command(label="Plot Refresh Rate", command = lambda i=i:refreshrate ...@@ -523,17 +605,25 @@ settings.add_command(label="Plot Refresh Rate", command = lambda i=i:refreshrate
settings.add_command(label="Regions of Interest", command = lambda i=i: roiroi()) settings.add_command(label="Regions of Interest", command = lambda i=i: roiroi())
settings.add_command(label="Straight Calibration", command = lambda i=i:str_cali()) settings.add_command(label="Straight Calibration", command = lambda i=i:str_cali())
rig_but_menu= tk.Menu(root, tearoff=0)
rig_but_menu.add_command(label="Open", command = lambda i=i:load())
rig_but_menu.add_command(label="Change_plot", command = lambda i=i:load())
rig_but_menu.add_command(label="Hide graphic", command = lambda i=i:hide_graphic())
rig_but_menu.add_command(label="Select graphic", command = lambda i=i:dataPlot2.get_tk_widget().focus_set())
menubar.add_cascade(label="File", menu=filemenu) menubar.add_cascade(label="File", menu=filemenu)
menubar.add_cascade(label="Settings", menu=settings) menubar.add_cascade(label="Settings", menu=settings)
root.config(menu=menubar) root.config(menu=menubar)
############################################################################## ##############################################################################
Interface['buttons'].insert(0, tk.Button(Interface['frames'][0], text = 'Start', command = lambda i=i: realtimeplot(), bd=2, height=2, bg='grey')) Interface['buttons'].insert(0, tk.Button(Interface['frames'][0], takefocus=0, text = 'Start', command = lambda i=i: realtimeplot(), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(1, tk.Button(Interface['frames'][0], text = 'Start', command = lambda i=i: pause(), bd=2, height=2, bg='grey')) Interface['buttons'].insert(1, tk.Button(Interface['frames'][0],takefocus=0, text = 'Start', command = lambda i=i: pause(), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(2, tk.Button(Interface['frames'][0], text = 'Clear 1', command = lambda i=i: reset(True,False), bd=2, height=2, bg='grey')) Interface['buttons'].insert(2, tk.Button(Interface['frames'][0],takefocus=0, text = 'Clear 1', command = lambda i=i: reset(True,False), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(3, tk.Button(Interface['frames'][0], text = 'Clear 2', command = lambda i=i: reset(False, True), bd=2, height=2, bg='grey')) Interface['buttons'].insert(3, tk.Button(Interface['frames'][0],takefocus=0, text = 'Clear 2', command = lambda i=i: reset(False, True), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(4, tk.Button(Interface['frames'][0], text = 'Save', command = lambda i=i: save(), bd=2, height=2, bg='grey')) Interface['buttons'].insert(4, tk.Button(Interface['frames'][0],takefocus=0, text = 'Save', command = lambda i=i: save('g12'), bd=2, height=2, bg='grey'))
Interface['buttons'].insert(5, tk.Button(Interface['frames'][0], text = 'Save As', command = lambda i=i: saveas(), bd=2, height=2, bg='grey')) Interface['buttons'].insert(5, tk.Button(Interface['frames'][0],takefocus=0, text = 'Save As', command = lambda i=i: saveas('g12'), bd=2, height=2, bg='grey'))
for i in range(5): for i in range(5):
Interface['buttons'][i+1].pack(side = 'left', fill='both', expand=1) Interface['buttons'][i+1].pack(side = 'left', fill='both', expand=1)
...@@ -542,6 +632,7 @@ for i in range(3): ...@@ -542,6 +632,7 @@ for i in range(3):
Interface['frames'].insert(i+7, tk.Frame(Interface['frames'][3])) Interface['frames'].insert(i+7, tk.Frame(Interface['frames'][3]))
Interface['frames'][i+7].pack(side = 'left', fill='x', expand=1) Interface['frames'][i+7].pack(side = 'left', fill='x', expand=1)
Interface['frames'].insert(10, tk.Frame(Interface['frames'][2])) Interface['frames'].insert(10, tk.Frame(Interface['frames'][2]))
Interface['frames'][10].place(anchor='nw',relheight=0.99, relwidth=0.5) Interface['frames'][10].place(anchor='nw',relheight=0.99, relwidth=0.5)
Interface['frames'].insert(11, tk.Frame(Interface['frames'][2])) Interface['frames'].insert(11, tk.Frame(Interface['frames'][2]))
...@@ -560,7 +651,7 @@ Interface['labels'].insert(4,tk.Label(Interface['frames'][13], text='Total Time: ...@@ -560,7 +651,7 @@ Interface['labels'].insert(4,tk.Label(Interface['frames'][13], text='Total Time:
Interface['labels'].insert(5,tk.Label(Interface['frames'][13], text='Live Time: %s' %Livetime['LiveTime'], width=18, height=1, bg='grey')) Interface['labels'].insert(5,tk.Label(Interface['frames'][13], text='Live Time: %s' %Livetime['LiveTime'], width=18, height=1, bg='grey'))
Interface['labels'].insert(6,tk.Label(Interface['frames'][7], text='Waiting to Start', anchor='w')) Interface['labels'].insert(6,tk.Label(Interface['frames'][7], text='Waiting to Start', anchor='w'))
Interface['labels'].insert(7,tk.Label(Interface['frames'][8], text='Plot Refresh Rate %dms' %Control['t'], anchor='center')) Interface['labels'].insert(7,tk.Label(Interface['frames'][8], text='Plot Refresh Rate %dms' %Control['t'] + '(0,0)', anchor='center'))
Interface['labels'].insert(8,tk.Label(Interface['frames'][9], text='%s.%d' %(Control['filename'], Control['count']), anchor='e')) Interface['labels'].insert(8,tk.Label(Interface['frames'][9], text='%s.%d' %(Control['filename'], Control['count']), anchor='e'))
for i in range(6): for i in range(6):
...@@ -579,7 +670,9 @@ def key_2(event): ...@@ -579,7 +670,9 @@ def key_2(event):
def key_3(event): def key_3(event):
roiroi() roiroi()
def key_4(event): def key_4(event):
if event.inaxes != a.axes: return if event.inaxes != a.axes:
dataPlot.get_tk_widget().focus_set()
return
PlotLimControl['pressx'] = float(event.xdata) PlotLimControl['pressx'] = float(event.xdata)
PlotLimControl['pressy'] = float(event.ydata) PlotLimControl['pressy'] = float(event.ydata)
if event.button == 3:#dir if event.button == 3:#dir
...@@ -603,8 +696,10 @@ def key_4(event): ...@@ -603,8 +696,10 @@ def key_4(event):
PlotLimControl['limupdtx'] = False PlotLimControl['limupdtx'] = False
PlotLimControl['limtrans'] = True PlotLimControl['limtrans'] = True
def key_4_b(event): def key_4_b(event):
if event.inaxes != a2.axes: return if event.inaxes != a2.axes:
dataPlot2.get_tk_widget().focus_set()
return
PlotLimControl['pressx_b'] = float(event.xdata) PlotLimControl['pressx_b'] = float(event.xdata)
PlotLimControl['pressy_b'] = float(event.ydata) PlotLimControl['pressy_b'] = float(event.ydata)
if event.button == 3: #Dir if event.button == 3: #Dir
...@@ -630,6 +725,7 @@ def key_4_b(event): ...@@ -630,6 +725,7 @@ def key_4_b(event):
def key_5(event): def key_5(event):
if event.inaxes != a.axes: return if event.inaxes != a.axes: return
Interface['labels'][7].configure(text='Plot Refresh Rate %dms' %Control['t'] + ' (%.2f' %float(event.xdata)+ ',%.2f)'%float(event.ydata))
if PlotLimControl['limctrl'] == True: if PlotLimControl['limctrl'] == True:
PlotLimControl['dx'] = float(event.xdata) - PlotLimControl['pressx'] PlotLimControl['dx'] = float(event.xdata) - PlotLimControl['pressx']
PlotLimControl['dy'] = float(event.ydata) - PlotLimControl['pressy'] PlotLimControl['dy'] = float(event.ydata) - PlotLimControl['pressy']
...@@ -639,6 +735,7 @@ def key_5(event): ...@@ -639,6 +735,7 @@ def key_5(event):
def key_5_b(event): def key_5_b(event):
if event.inaxes != a2.axes: return if event.inaxes != a2.axes: return
Interface['labels'][7].configure(text='Plot Refresh Rate %dms' %Control['t'] + ' (%.2f' %float(event.xdata)+ ',%.2f)'%float(event.ydata))
if PlotLimControl['limctrl_b'] == True: if PlotLimControl['limctrl_b'] == True:
PlotLimControl['dx_b'] = float(event.xdata) - PlotLimControl['pressx_b'] PlotLimControl['dx_b'] = float(event.xdata) - PlotLimControl['pressx_b']
PlotLimControl['dy_b'] = float(event.ydata) - PlotLimControl['pressy_b'] PlotLimControl['dy_b'] = float(event.ydata) - PlotLimControl['pressy_b']
...@@ -647,6 +744,10 @@ def key_5_b(event): ...@@ -647,6 +744,10 @@ def key_5_b(event):
f2.canvas.draw() f2.canvas.draw()
def key_6(event): def key_6(event):
if event.inaxes != a.axes:
if event.button == 3:
FocusControl['aux_click']='g1'
rig_but_menu.tk_popup(event.x, root.winfo_height() - int(event.y)-20)
if event.button is not 2: if event.button is not 2:
(PlotLimControl['x0'] , PlotLimControl['x1']) = a.get_xlim() (PlotLimControl['x0'] , PlotLimControl['x1']) = a.get_xlim()
(PlotLimControl['y0'] , PlotLimControl['y1']) = a.get_ylim() (PlotLimControl['y0'] , PlotLimControl['y1']) = a.get_ylim()
...@@ -682,6 +783,10 @@ def key_6(event): ...@@ -682,6 +783,10 @@ def key_6(event):
grid(a, 8) grid(a, 8)
def key_6_b(event): def key_6_b(event):
if event.inaxes != a2.axes:
if event.button == 3:
FocusControl['aux_click']='g2'
rig_but_menu.tk_popup(event.x + dataPlot.get_tk_widget().winfo_width(), root.winfo_height() - int(event.y) -20)
if event.button is not 2: if event.button is not 2:
(PlotLimControl['x0_b'] , PlotLimControl['x1_b']) = a2.get_xlim() (PlotLimControl['x0_b'] , PlotLimControl['x1_b']) = a2.get_xlim()
(PlotLimControl['y0_b'] , PlotLimControl['y1_b']) = a2.get_ylim() (PlotLimControl['y0_b'] , PlotLimControl['y1_b']) = a2.get_ylim()
...@@ -715,45 +820,51 @@ def key_6_b(event): ...@@ -715,45 +820,51 @@ def key_6_b(event):
else: else:
grid(a2, 8) grid(a2, 8)
def shifts_zoom (valor): def shifts_zoom (valor,force):
if FocusControl['graphic1']: if (root.focus_get() == dataPlot.get_tk_widget()) or (force == 1):
PlotLimControl['limupdtx']=False PlotLimControl['limupdtx']=False
xmin, xmax = a.get_xlim() xmin, xmax = a.get_xlim()
a.set_xlim(xmin+valor,xmax+valor) a.set_xlim(xmin+valor,xmax+valor)
f.canvas.draw() f.canvas.draw()
if FocusControl['graphic2']: if (root.focus_get() == dataPlot2.get_tk_widget()) or (force == 1):
PlotLimControl['limupdtx']=False PlotLimControl['limupdt_bx']=False
xmin, xmax = a.get_xlim() xmin, xmax = a2.get_xlim()
a2.set_xlim(xmin+valor,xmax+valor) a2.set_xlim(xmin+valor,xmax+valor)
f2.canvas.draw() f2.canvas.draw()
def mult_zoom(valor): def mult_zoom(valor,force):
if FocusControl['graphic1']: if (root.focus_get() == dataPlot.get_tk_widget()) or (force == 1):
PlotLimControl['limupdty']=False PlotLimControl['limupdty']=False
ymin, ymax = a.get_ylim() ymin, ymax = a.get_ylim()
a.set_ylim(ymin,ymax*valor) a.set_ylim(ymin,ymax*valor)
f.canvas.draw() f.canvas.draw()
if FocusControl['graphic2']: if (root.focus_get() == dataPlot2.get_tk_widget()) or (force == 1):
PlotLimControl['limupdt_by']=False PlotLimControl['limupdt_by']=False
ymin, ymax = a.get_ylim() ymin, ymax = a.get_ylim()
a2.set_ylim(ymin,ymax*valor) a2.set_ylim(ymin,ymax*valor)
f2.canvas.draw() f2.canvas.draw()
root.bind_all("<Alt-KeyPress-1>", key_1) root.bind_all("<Alt-KeyPress-1>", lambda i=i:key_1)
root.bind_all("<Alt-KeyPress-2>", key_1) root.bind_all("<Alt-KeyPress-2>", lambda i=i:key_1)
root.bind_all("<Alt-KeyPress-3>", key_2) root.bind_all("<Alt-KeyPress-3>", lambda i=i:key_2)
root.bind_all("<Alt-KeyPress-6>", key_3) root.bind_all("<Alt-KeyPress-6>", lambda i=i:key_3)
root.bind_all("<Alt-KeyPress-4>", save) root.bind_all("<Alt-KeyPress-4>", lambda i=i:save('g12'))
root.bind_all("<Alt-KeyPress-5>", saveas) root.bind_all("<Alt-KeyPress-5>", lambda i=i:saveas('g12'))
root.bind_all("<Up>", lambda i=i:mult_zoom(1.25,0))
root.bind_all("<Shift-Up>",lambda i=i:mult_zoom(1.25,1))
root.bind_all("<Down>",lambda i=i:mult_zoom(0.8,0))
root.bind_all("<Shift-Down>",lambda i=i: mult_zoom(0.8,1))
root.bind_all("<Left>",lambda i=i: shifts_zoom(-1,0))
root.bind_all("<Shift-Left>",lambda i=i: shifts_zoom(-1,1))
root.bind_all("<Right>",lambda i=i: shifts_zoom(1,0))
root.bind_all("<Shift-Right>",lambda i=i: shifts_zoom(1,1))
root.bind_all("<Up>", lambda i=i:mult_zoom(1.25))
root.bind_all("<Down>",lambda i=i:mult_zoom(0.8))
root.bind_all("<Left>",lambda i=i: shifts_zoom(-1))
root.bind_all("<Right>",lambda i=i: shifts_zoom(1))
#root.bind_all("<Tab>" change_focus)
############################################################################## ##############################################################################
...@@ -767,6 +878,8 @@ dataPlot2.get_tk_widget().pack(side='top', fill='both', expand=1) ...@@ -767,6 +878,8 @@ dataPlot2.get_tk_widget().pack(side='top', fill='both', expand=1)
xx = arange(0, 8192) xx = arange(0, 8192)
temp, = a.plot(xx, xx*0, 'red', lw=0.9) temp, = a.plot(xx, xx*0, 'red', lw=0.9)
a.set_xlabel('Channel')
a.set_ylabel('Counts')
temp2, = a2.plot(xx, xx*0, 'red', lw=0.9) temp2, = a2.plot(xx, xx*0, 'red', lw=0.9)
xlabel('Channel') xlabel('Channel')
ylabel('Counts') ylabel('Counts')
...@@ -777,6 +890,7 @@ f.canvas.mpl_connect('button_release_event', key_6) ...@@ -777,6 +890,7 @@ f.canvas.mpl_connect('button_release_event', key_6)
f2.canvas.mpl_connect('button_press_event', key_4_b) f2.canvas.mpl_connect('button_press_event', key_4_b)
f2.canvas.mpl_connect('motion_notify_event', key_5_b) f2.canvas.mpl_connect('motion_notify_event', key_5_b)
f2.canvas.mpl_connect('button_release_event', key_6_b) f2.canvas.mpl_connect('button_release_event', key_6_b)
#canvas.mpl_connect('button_press_event', tab)
############################################################################## ##############################################################################
############################################################################## ##############################################################################
# Paralel mainloop and initiations # Paralel mainloop and initiations
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment