Changeset - 60b6471fb0d2
[Not reviewed]
default
0 1 0
David McClosky - 20 years ago 2005-06-16 06:32:36
dmcc@bigasterisk.com
TkGyro: stamp current sub+level when toggling modes
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
bin/gyrocontroller
Show inline comments
 
@@ -48,48 +48,49 @@ class AbstractSimpleController(SubClient
 
        self.subnames = subnames
 
        self.refresh()
 
    def refresh(self):
 
        # reload subs from disk
 
        self.submasters = Submasters()
 
        self.all_subs = circcycle(self.subnames)
 
        self.current_sub = self.submasters.get_sub_by_name(self.all_subs.next())
 
        self.current_level = 1.0
 
        self.kept_levels = {} # subname : level [0..1]
 
        self.keep_solo_mode = 'keep' # either 'keep' or 'solo'
 
    def clear_kept_levels(self):
 
        self.kept_levels.clear()
 
    def next(self):
 
        if self.keep_solo_mode == 'keep':
 
            self.kept_levels[self.current_sub] = self.current_level
 

	
 
        self.current_sub = self.submasters.get_sub_by_name(self.all_subs.next())
 
    def prev(self):
 
        if self.keep_solo_mode == 'keep':
 
            self.kept_levels[self.current_sub] = self.current_level
 

	
 
        self.current_sub = self.submasters.get_sub_by_name(self.all_subs.prev())
 
    def toggle_keep_mode(self):
 
        if self.keep_solo_mode == 'keep':
 
            self.kept_levels[self.current_sub] = self.current_level
 
            self.keep_solo_mode = 'solo'
 
        else:
 
            self.keep_solo_mode = 'keep'
 

	
 
    def get_levels_as_sub(self):
 
        if self.keep_solo_mode == 'keep':
 
            # send all levels in self.kept_levels
 
            levelsub = combine_subdict(self.kept_levels)
 
        else:
 
            levelsub = self.current_sub * self.current_level
 

	
 
        return levelsub
 

	
 
class TkGyro(Tk.Canvas, AbstractSimpleController):
 
    def __init__(self, master, subnames):
 
        Tk.Canvas.__init__(self, master, bg='black', bd=0, highlightthickness=0,
 
            confine=None)
 
        AbstractSimpleController.__init__(self, subnames)
 
        height = int(self.winfo_screenheight())
 
        width = int(self.winfo_screenwidth())
 
        self.left = self.create_rectangle((0, 0, width / 2, height),
 
            tags='left', fill='black')
 
        self.right = self.create_rectangle((width / 2, 0, width, height),
 
            tags='right', fill='black')
0 comments (0 inline, 0 general)