Skip to content

Instantly share code, notes, and snippets.

@CnrLwlss
Created April 7, 2013 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CnrLwlss/5330159 to your computer and use it in GitHub Desktop.
Save CnrLwlss/5330159 to your computer and use it in GitHub Desktop.
Electronic clicker for manual counting of three cell types (G1, G2/M and S). While looking down the eyepiece of a microscope at cells on a glass slide, the user can press "g" to increment the number of cells in G1, "h" to increment the number of cells in G2/M and "j" to increment the number of cells in S. Press space bar to move from one slide t…
import winsound, time, Tkinter
slides=[]
cells=[0,0,0]
labels=["G1","S","G2/M"]
print "Slide: %02d"%(len(slides)+1)
def key(event):
if event.char=="g":
cells[0]+=1
winsound.Beep(220,100)
print cells
if event.char=="h":
cells[1]+=1
winsound.Beep(440,100)
print cells
if event.char=="j":
cells[2]+=1
winsound.Beep(880,100)
print cells
if event.char==" ":
slides.append(cells[:])
cells[:]=[0,0,0]
print "Slide: %02d"%(len(slides)+1)
winsound.Beep(330,100)
winsound.Beep(660,100)
winsound.Beep(1320,100)
print cells
if event.char=="q":
root.destroy()
root = Tkinter.Tk()
frame = Tkinter.Frame(root, width=0, height=0)
frame.bind("<Key>", key)
frame.pack()
frame.focus_set()
root.mainloop()
slides.append(cells[:])
timestamp=time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
f=open("CellReport_"+timestamp+".txt","w")
labels.insert(0,"Slide")
f.write("\t".join(labels)+"\n")
for s in xrange(0,len(slides)):
slide=slides[s]
slide.insert(0,s+1)
f.write("\t".join(["%04d "%sl for sl in slide])+"\n")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment