diff --git a/bin/gyrocontroller b/bin/gyrocontroller --- a/bin/gyrocontroller +++ b/bin/gyrocontroller @@ -87,9 +87,6 @@ class TkGyro(Tk.Canvas, AbstractSimpleCo Tk.Canvas.__init__(self, master, bg='black', bd=0, highlightthickness=0, confine=None) AbstractSimpleController.__init__(self, subnames) - self.send_levels_loop() - def pack(self, *args, **kw): - Tk.Canvas.pack(self, *args, **kw) height = int(self.winfo_screenheight()) width = int(self.winfo_screenwidth()) self.left = self.create_rectangle((0, 0, width / 2, height), @@ -97,10 +94,11 @@ class TkGyro(Tk.Canvas, AbstractSimpleCo self.right = self.create_rectangle((width / 2, 0, width, height), tags='right', fill='black') + # the text is disabled so that it doesn't receive events self.modetext = self.create_text((width / 2, height / 2), font='Courier 200', fill='white', text=self.keep_solo_mode, - tags='middle', state='disabled') - self.flashtextafter = '' + state='disabled') + self.flashtextafter = '' # current after timer for displaying text def setfill(item, color): self.itemconfig(item, fill=color) @@ -124,11 +122,15 @@ class TkGyro(Tk.Canvas, AbstractSimpleCo lambda evt, item=item, color=color: setfill(item, color), '+') self.tag_bind(tag, '', lambda evt, method=method: method(), '+') - self.tag_bind(tag, '', setlevel, '+') - self.tag_bind(tag, '', - lambda evt: self.toggle_keep_mode()) - self.tag_bind(tag, '', - lambda evt: self.clear_kept_levels()) + + # B2+drag sets current level, double-B2 resets kept levels + self.tag_bind('all', '', setlevel, '+') + self.tag_bind('all', '', + lambda evt: self.clear_kept_levels()) + # B3 toggles between keep and solo mode + self.tag_bind('all', '', lambda evt: self.toggle_keep_mode()) + + self.send_levels_loop() def toggle_keep_mode(self): AbstractSimpleController.toggle_keep_mode(self) self.show_current_mode() @@ -158,21 +160,23 @@ class TkGyro(Tk.Canvas, AbstractSimpleCo self.send_levels() if __name__ == "__main__": + import sys, fileinput + subnames = sys.argv[1:] + if not subnames: + subnames = [line.strip() for line in fileinput.input()] + root = Tk.Tk() - # these are hints to Fvwm2 if you add this to your .fvwm2rc: # Style "*NOTITLE*" NoTitle # Style "*NOBORDER*" BorderWidth 0, NoHandles # Style "*ONTOP*" StaysOnTop Sticky + # hopefully, there's a better way to do this within Tk root.title("NOTITLE NOBORDER ONTOP") - - # for some reason, this doesn't make it fill the screen root.wm_geometry('%sx%s' % (root.winfo_screenwidth(), root.winfo_screenheight())) - gyro = TkGyro(root, [str(i) for i in range(1, 11)]) + gyro = TkGyro(root, subnames) gyro.pack(fill='both', expand=1) - gyro.focus_get() root.bind('', lambda evt: root.destroy()) root.maxsize(root.winfo_screenwidth(), root.winfo_screenheight()) Tk.mainloop()