From e1bb8a31e5380b8bfd5aa688b179606054202ae6 Mon Sep 17 00:00:00 2001 From: "Silas S. Brown" <ssb22@cam.ac.uk> Date: Thu, 17 Dec 2009 18:00:17 +0000 Subject: [PATCH] Gradint update git-svn-id: http://svn.code.sf.net/p/e-guidedog/code/ssb22/gradint@482 29193198-4895-4776-b068-10539e920549 --- gradint-build/p | 53 +++++++++++++++++----------------- gradint-build/src/frontend.py | 15 ++++++++-- gradint-build/src/recording.py | 8 ++--- gradint-build/thindown.py | 1 + 4 files changed, 44 insertions(+), 33 deletions(-) diff --git a/gradint-build/p b/gradint-build/p index 77a5799..424669f 100644 --- a/gradint-build/p +++ b/gradint-build/p @@ -1,30 +1,29 @@ ---- gradint.py 2009-12-17 16:53:13.000000000 +0000 -+++ /tmp/Gradint.app/gradint.py 2009-12-17 17:03:49.000000000 +0000 -@@ -4310,9 +4310,9 @@ - editEntry.bind('<Return>',lambda *args:self.doEdit(editText,editEntry,row,col,filename)) - editEntry.bind('<Escape>',lambda *args:self.cancelEdit(editEntry,row,col,filename)) - self.scrollIntoView(editEntry) -- if hasattr(self.coords2buttons.get((row-1,col),""),"is_synth_label"): -- self.addLabel(row-1,col,localise("(synth'd)")) -- self.coords2buttons[(row-1,col)].is_synth_label = True -+ if hasattr(self.coords2buttons.get((row-1,col+1),""),"is_synth_label"): -+ self.addLabel(row-1,col+1,localise("(synth'd)")) -+ self.coords2buttons[(row-1,col+1)].is_synth_label = True - def doEdit(self,editText,editEntry,row,col,filename): - text = editText.get().encode("utf-8").strip(wsp) - if text: open(filename,"w").write(text+"\n") -@@ -4324,10 +4324,10 @@ +--- gradint.py 2009-12-17 17:38:29.000000000 +0000 ++++ /tmp/Gradint.app/gradint.py 2009-12-17 17:52:45.000000000 +0000 +@@ -4320,7 +4320,7 @@ + try: os.remove(filename) + except: pass + self.cancelEdit(editEntry,row,col,filename) +- if row+1 < self.addMoreRow and (row+1,col+1) in self.coords2buttons: self.scrollIntoView(self.coords2buttons[(row+1,col+1)]) # focus the next "synth" button if it exists (TODO do we want to press it as well, like file renaming?) ++ if row+1 < self.addMoreRow and (row+1,col+1) in self.coords2buttons: self.scrollIntoView(self.coords2buttons[(row+1,col+1)]) # focus the next "synth" button if it exists (don't press it as well like file renaming because it might be a variant etc, TODO can we skip variants?) def cancelEdit(self,editEntry,row,col,filename): editEntry.grid_forget() labelAdded = self.addSynthLabel(filename,row,col) -- if hasattr(self.coords2buttons.get((row-1,col),""),"is_synth_label"): -- if labelAdded: self.addLabel(row-1,col,localise("(synth'd)")) -- else: self.addButton(row-1,col,text=localise("Synthesize"),command=(lambda *args:self.startSynthEdit(None,row,col,filename))) -- self.coords2buttons[(row-1,col)].is_synth_label = True -+ if hasattr(self.coords2buttons.get((row-1,col+1),""),"is_synth_label"): -+ if labelAdded: self.addLabel(row-1,col+1,localise("(synth'd)")) -+ else: self.addButton(row-1,col+1,text=localise("Synthesize"),command=(lambda *args:self.startSynthEdit(None,row,col,filename))) -+ self.coords2buttons[(row-1,col+1)].is_synth_label = True - def all2mp3_or_zip(self): - self.CompressButton["text"] = localise("Compressing, please wait") - if got_program("lame"): wavToMp3(self.currentDir) # TODO not in the GUI thread !! (but lock our other buttons while it's doing it) +@@ -5175,9 +5175,14 @@ + + def focusButton(button): + button.focus() +- if macsound: # focus() should display the fact on Windows and Linux, but doesn't on OS X - need to make it default as well +- try: button.config(state="active") +- except: pass # maybe not a button ++ if macsound: # focus() should display the fact on Windows and Linux, but doesn't on OS X so: ++ def flashButton(button,state): ++ try: button.config(state=state) ++ except: pass # maybe not a button ++ for t in range(250,1000,250): # (NB avoid epilepsy's 5-30Hz!) ++ app.after(t,lambda *args:flashButton(button,"active")) ++ app.after(t+150,lambda *args:flashButton(button,"normal")) ++ # (Don't like flashing, but can't make it permanently active as it won't change when the focus does) + + def startTk(): + class Application(Tkinter.Frame): diff --git a/gradint-build/src/frontend.py b/gradint-build/src/frontend.py index 4b37d30..b0e738a 100644 --- a/gradint-build/src/frontend.py +++ b/gradint-build/src/frontend.py @@ -478,6 +478,17 @@ def make_extra_buttons_waiting_list(): for l in ls: if l.endswith(exclude_from_scan) and fileExists(d+os.sep+l+os.sep+shortDescriptionName): extra_buttons_waiting_list.append(ExtraButton(d+os.sep+l)) +def focusButton(button): + button.focus() + if macsound: # focus() should display the fact on Windows and Linux, but doesn't on OS X so: + def flashButton(button,state): + try: button.config(state=state) + except: pass # maybe not a button + for t in range(250,1000,250): # (NB avoid epilepsy's 5-30Hz!) + app.after(t,lambda *args:flashButton(button,"active")) + app.after(t+150,lambda *args:flashButton(button,"normal")) + # (Don't like flashing, but can't make it permanently active as it won't change when the focus does) + def startTk(): class Application(Tkinter.Frame): def __init__(self, master=None): @@ -617,7 +628,7 @@ def startTk(): self.remake_cancel_button(localise("Quit")) if not GUI_omit_statusline: self.Version.pack(fill=Tkinter.X,expand=1) if olpc or self.todo.set_main_menu=="test" or GUI_for_editing_only: self.showtest() # olpc: otherwise will just get a couple of options at the top and a lot of blank space (no way to centre it) - else: self.TestButton.focus() + else: focusButton(self.TestButton) del self.todo.set_main_menu self.restore_copyright() if hasattr(self.todo,"alert"): @@ -636,7 +647,7 @@ def startTk(): del self.todo.thindown if hasattr(self.todo,"add_briefinterrupt_button") and runner: self.BriefIntButton = addButton(self.CancelRow,localise("Brief interrupt"),self.briefInterrupt,{"side":"left"}) # on RHS of Cancel = reminescient of the stop and pause controls on a tape recorder - self.BriefIntButton.focus() + focusButton(self.BriefIntButton) del self.todo.add_briefinterrupt_button if hasattr(self.todo,"remove_briefinterrupt_button"): if hasattr(self,"BriefIntButton"): diff --git a/gradint-build/src/recording.py b/gradint-build/src/recording.py index 6ca986b..55abbd9 100644 --- a/gradint-build/src/recording.py +++ b/gradint-build/src/recording.py @@ -290,7 +290,7 @@ class RecorderControls: try: os.remove(filename) except: pass self.cancelEdit(editEntry,row,col,filename) - if row+1 < self.addMoreRow and (row+1,col+1) in self.coords2buttons: self.scrollIntoView(self.coords2buttons[(row+1,col+1)]) # focus the next "synth" button if it exists (TODO do we want to press it as well, like file renaming?) + if row+1 < self.addMoreRow and (row+1,col+1) in self.coords2buttons: self.scrollIntoView(self.coords2buttons[(row+1,col+1)]) # focus the next "synth" button if it exists (don't press it as well like file renaming because it might be a variant etc, TODO can we skip variants?) def cancelEdit(self,editEntry,row,col,filename): editEntry.grid_forget() labelAdded = self.addSynthLabel(filename,row,col) @@ -438,14 +438,14 @@ class RecorderControls: self.currentRecording = (filename,row,languageNo) self.coords2buttons[(row,3+3*languageNo)]["command"]=(lambda *args:self.doStop()) if app.scanrow.get()=="2": # "stop" - self.coords2buttons[(row,3+3*languageNo)].focus() + focusButton(self.coords2buttons[(row,3+3*languageNo)]) else: moved = 0 if app.scanrow.get()=="1": # move along 1st while languageNo+1<len(self.languagesToDraw): languageNo += 1 if (row,3+3*languageNo) in self.coords2buttons: - self.coords2buttons[(row,3+3*languageNo)].focus() + focusButton(self.coords2buttons[(row,3+3*languageNo)]) return languageNo = 0 # start of the row # fall-through - vertical movement @@ -454,7 +454,7 @@ class RecorderControls: if (r,3+3*languageNo) in self.coords2buttons: return self.scrollIntoView(self.coords2buttons[(r,3+3*languageNo)]) def scrollIntoView(self,button): - button.focus() + focusButton(button) self.continueScrollIntoView(button) def continueScrollIntoView(self,button): if not hasattr(self,"ourCanvas"): return # closing down? diff --git a/gradint-build/thindown.py b/gradint-build/thindown.py index a87cc3b..3a34f77 100644 --- a/gradint-build/thindown.py +++ b/gradint-build/thindown.py @@ -56,6 +56,7 @@ if "s60" in sys.argv: # S60 version "def renameUser(i,radioButton,parent,cancel=0):", "def deleteUser(i):", "def setupScrollbar(parent,rowNo):", +"def focusButton(button):", "class ExtraButton(object):", "def make_extra_buttons_waiting_list():", "def startTk():", -- GitLab