Commit 53031a68 authored by Matheus Müller's avatar Matheus Müller
Browse files

Aperfeiçoamento da interface do usuário

Ainda falta implementar algumas funções como pause, escolher arquivo para salvar, alterar escalas do gráfico, regiões de interesse
parent 1e488563
......@@ -7,7 +7,11 @@ import Tkinter as tk
import tkMessageBox
import matplotlib.pyplot as plt
from pylab import *
from ROI import *
import time
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import tkFileDialog
##############################################################################
##############################################################################
......@@ -28,18 +32,14 @@ Data=list()
for a in range(8192):
Data.insert(a, 0)
xx = arange(0, 8192)
temp, = plot(xx, xx*0, 'y.', lw=0.9)
plt.grid(True)
plt.xlabel('Channel')
plt.ylabel('Counts')
ax = subplot(111)
ax.xaxis.set_major_locator(MultipleLocator(1024))
ax.xaxis.set_minor_locator(MultipleLocator(128))
#############################################################################
##############################################################################
# Main window
ax.xaxis.grid(True,'minor')
ax.xaxis.grid(True,'major',linewidth=2)
root = tk.Tk()
root.minsize(400,350)
root.title('Modulo Multicanal')
#root.geometry('670x470+200+200')
##############################################################################
##############################################################################
......@@ -83,11 +83,12 @@ def graphic():
for n in arange(0, int(Interface['spinboxes'][0].get())):
Data[n] = int(child.readline().strip("\r\n"))
temp.set_ydata(Data)
f.canvas.draw()
#plt.fill_between(range(8192),Data,0,color='0.8')
plt.xlim(bmin, bmax)
plt.ylim(0, max(Data[bmin:bmax])*1.1)
show()
#show()
def realtimeplot():
global t
dump()
......@@ -97,15 +98,6 @@ def realtimeplot():
except ValueError:
pass
#############################################################################
##############################################################################
# Main window
root = tk.Tk()
root.minsize(400,350)
root.title('Modulo Multicanal')
#root.geometry('670x470+200+200')
##############################################################################
##############################################################################
# Control functions
......@@ -125,7 +117,8 @@ def reset():
child.send('r')
def pause():
return 0
global child
child.send('p')
def restart():
global child
......@@ -148,13 +141,16 @@ def plotting():
bmax = int(Interface['entries'][1].get())
Interface['labelframes'][0].configure(text = 'Region of interest - %i to %i' %(bmin, bmax))
else:
tkMessageBox.showinfo("Error", "Invalid values")
tkMessageBox.showinfo("Error", "Invalid values: Must be from 0 to 8192")
def refreshrate():
global t
if Interface['entries'][2].get().isdigit() and int(Interface['entries'][2].get()) > 499:
t = int(Interface['entries'][2].get())
Interface['labelframes'][1].configure(text = 'Refresh Rate - %ims' %t)
if Interface['entries'][2].get().isdigit():
if int(Interface['entries'][2].get()) > 799:
t = int(Interface['entries'][2].get())
Interface['labelframes'][1].configure(text = 'Refresh Rate - %ims' %t)
else:
tkMessageBox.showinfo("Error", "This refresh rate is likely to reach maximum recursion depht!")
else:
tkMessageBox.showinfo("Error", "Invalid value")
......@@ -183,7 +179,7 @@ Interface['labels'].insert(1,tk.Label(Interface['labelframes'][3], text='Total T
Interface['labels'].insert(2,tk.Label(Interface['labelframes'][3], text='Live Time: %s' %Livetime['LiveTime']))
for i in range(3):
Interface['labelframes'][i].pack()
Interface['labelframes'][i].pack(side='left')
Interface['frames'].insert((i+2), tk.Frame(Interface['labelframes'][0]))
Interface['frames'][(i+2)].pack(side='left')
Interface['labels'][i].pack()
......@@ -215,7 +211,30 @@ Interface['buttons'].insert(7, tk.Button(Interface['labelframes'][0], text = 'C
Interface['buttons'].insert(8, tk.Button(Interface['labelframes'][1], text = 'Change', command = lambda i=i: refreshrate(), bd=2, width=13, height=1))
for i in range(9):
Interface['buttons'][i].pack()
Interface['buttons'][i].pack(side = 'left')
##############################################################################
##############################################################################
# Plotting
f = plt.figure()
a = f.add_subplot(111)
dataPlot = FigureCanvasTkAgg(f, master=root)
dataPlot.get_tk_widget().pack(side='top', fill='both', expand=1)
xx = arange(0, 8192)
temp, = a.plot(xx, xx*0, 'y.', lw=0.9)
xlabel('Channel')
ylabel('Counts')
a.xaxis.set_major_locator(MultipleLocator(1024))
a.xaxis.set_minor_locator(MultipleLocator(128))
a.grid(True)
a.xaxis.grid(True,'minor')
a.xaxis.grid(True,'major',linewidth=2)
##############################################################################
##############################################################################
menubar = tk.Menu(root, bg='grey', relief='flat', bd=0)
filemenu = tk.Menu(menubar, tearoff=0)
......
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