コード例 #1
0
 def enter_entry(self, event):
     flag = self.flag_by_cb[event.widget]
     old_level = SlTrace.getLevel(flag)
     _, flag, text_var = self.data_by_flag[flag]
     entry_text = text_var.get()
     new_level = str2val(entry_text, old_level)        
     self.set_trace_level(flag, new_level, change_cb=False)  # No select for Entry
コード例 #2
0
 def show_list(self):
     """ Select buttons to show
     """
     if self.show_list_which == "ALL":
         self.show_list_which = "JUST_SET"
         self.show_list_variable.set("Show ALL")
         just_flags = []
         for flag in SlTrace.getTraceFlags():
             val = SlTrace.getLevel(flag)
             if type(val) != bool:
                 just_flags.append(flag) # Include all non-boolean
             elif val:
                 just_flags.append(flag)
     else:
         self.show_list_which = "ALL"
         self.show_list_variable.set("Show SET")
         just_flags = SlTrace.getTraceFlags()
         
     self.create_flags_region(just_flags)
コード例 #3
0
 def report_change(flag, val, cklist=None):
     SlTrace.lg("changed: %s = %d" % (flag, val))
     new_val = SlTrace.getLevel(flag)
     SlTrace.lg("New val: %s = %d" % (flag, new_val))
     if cklist is not None:
         cklist.list_ckbuttons()
コード例 #4
0
    def create_flags_region(self, flags=None):
        if self.tc_text_frame is not None:
            self.tc_text_frame.pack_forget()
            self.tc_text_frame.destroy()
            self.tc_text_frame = None
            
        if self.sb is not None:
            self.sb.destroy()
        self.update()                           # Show progress
        self.tc_text_frame = Frame(self.tc_frame)
        self.tc_text_frame.pack(side="top", fill="both", expand=True)

        self.start = 0
        self.sb = Scrollbar(master=self.tc_text_frame, orient="vertical")
        max_width = 5
        min_height = 10
        t_height = min_height
        max_height = 20
        nfound = 0
        for flag in flags:
            val = SlTrace.getLevel(flag)
            width = len(flag)
            if callable(val):
                val_len = 5
            elif type(val) == bool:
                val_len = 2
            else:
                val_len = len(str(val))
            width += val_len
            if width > max_width:
                max_width = width
            nfound += 1
        win_width = max_width
        if nfound < min_height:
            t_height = min_height
        if nfound > max_height:
            t_height = max_height
            
        text = Text(self.tc_text_frame, width=win_width, height=t_height,
                    yscrollcommand=self.sb.set,
                    state=DISABLED)
        self.sb.config(command=text.yview)
        self.sb.pack(side="right",fill="y")
        text.pack(side="top", fill="both", expand=True)
        self.update()                           # Show progress
        self.flag_by_cb = {}             # Dictionary hashed on cb widget
        self.data_by_flag = {}
        for flag in sorted(flags):
            level = SlTrace.getLevel(flag)
            if type(level) == bool:
                var = BooleanVar()
                var.set(level)
                ####fmt_text = "%-*s" % (max_width, flag)
                fmt_text = flag
                cb = Checkbutton(text, text=fmt_text, padx=0, pady=0, bd=0, variable = var, bg="white")
                self.flag_by_cb[cb] = flag
                self.data_by_flag[flag] = (cb, flag, var)
                text.config(state=NORMAL)
                text.window_create("end", window=cb)
                text.insert("end", "\n")
                text.config(state=DISABLED)
                cb.bind("<Button-1>", self.select_button)
            elif type(level) == int or type(level) == float or type(level) == str:
                if type(level) == int:
                    var = IntVar()
                elif type(level) == float:
                    var = DoubleVar()
                elif type(level) == str:
                    var = StringVar()
                var.set(level)
                var_width = len(str(level)) + 2
                text_var = StringVar()
                text_var.set(f"{level:{var_width}}")
                ####fmt_text = "%-*s" % (max_width, flag)
                fmt_text = flag
                ent = Entry(text, width=var_width, textvariable=text_var)
                self.flag_by_cb[ent] = flag
                self.data_by_flag[flag] = (ent, flag, text_var)     # field is what we need
                text.config(state=NORMAL)
                text.window_create("end", window=ent)
                text.insert("end", fmt_text)
                text.insert("end", "\n")
                text.config(state=DISABLED)
                ent.bind("<Return>", self.enter_entry)
            elif callable(level):
                fmt_text = "%-*s" % (max_width, flag)
                btn = Button(text, text=flag, command=level)
                self.flag_by_cb[btn] = flag
                self.data_by_flag[flag] = (btn, flag, None)     # field is what we need
                text.config(state=NORMAL)
                text.window_create("end", window=btn)
                text.insert("end", "\n")
                
            ###cb.pack()
        self.update()                           # Show progress
        if self.standalone:
            atexit.register(self.on_exit)
            self.update_loop()
コード例 #5
0
 def select_button(self, event):
     flag = self.flag_by_cb[event.widget]
     cb, flag, var = self.data_by_flag[flag]
     val = SlTrace.getLevel(flag)        # Variable doesn't seem to work for us
     val = not val                           # Keep value in strace
     self.set_trace_level(flag, val, change_cb=False)  # CB already set
コード例 #6
0
 def getLevel(self, flag):
     return SlTrace.getLevel(flag)
コード例 #7
0
    def __init__(self, tcbase, change_call=None):
        """ Trace flag dictionary
        :tcbase: - parent - call basis must have tc_destroy to be called if we close
        :strace: Reference to SlTrace object
        :change_call: - call with change flag, value
        """
        ###Toplevel.__init__(self, parent)
        self.tcbase = tcbase
        
        self.change_call = change_call

                    
        self.tc_mw = Toplevel()
        tc_x0 = 800
        tc_y0 = 100
        tc_w = 200
        tc_h = 200
        tc_geo = "%dx%d+%d+%d" % (tc_w, tc_h, tc_x0, tc_y0)
        self.tc_mw.geometry(tc_geo)
        self.tc_mw.title("Trace")
        top_frame = Frame(self.tc_mw)
        self.tc_mw.protocol("WM_DELETE_WINDOW", self.delete_tc_window)
        top_frame.pack(side="top", fill="both", expand=True)
        self.top_frame = top_frame
        tc_all_button = Button(master=self.top_frame, text="ALL", command=self.select_all)
        tc_all_button.pack(side="left", fill="both", expand=True)
        tc_none_button = Button(master=self.top_frame, text="NONE", command=self.select_none)
        tc_none_button.pack(side="left", fill="both", expand=True)
        tc_bpt_button = Button(master=self.top_frame, text="BPT", command=self.breakpoint)
        tc_bpt_button.pack(side="left", fill="both", expand=True)
        tc_frame = Frame(self.tc_mw)
        tc_frame.pack(side="top", fill="both", expand=True)
        self.tc_frame = tc_frame
        
        self.start = 0
        self.sb = Scrollbar(master=self.tc_frame, orient="vertical")
        max_width = 5
        min_height = 10
        t_height = min_height
        max_height = 20
        nfound = 0
        for flag in SlTrace.getAllTraceFlags():
            if len(flag) > max_width:
                max_width = len(flag)
            nfound += 1
        win_width = max_width
        if nfound < min_height:
            t_height = min_height
        if nfound > max_height:
            t_height = max_height
        text = Text(self.tc_frame, width=win_width, height=t_height, yscrollcommand=self.sb.set)
        self.sb.config(command=text.yview)
        self.sb.pack(side="right",fill="y")
        text.pack(side="top", fill="both", expand=True)
        self.flag_by_cb = {}             # Dictionary hashed on cb widget
        self.data_by_flag = {}
        for flag in sorted(SlTrace.getAllTraceFlags()):
            level = SlTrace.getLevel(flag)
            var = BooleanVar()
            var.set(level)
            fmt_text = "%-*s" % (max_width, flag)
            cb = Checkbutton(text, text=fmt_text, padx=0, pady=0, bd=0, variable = var)
            self.flag_by_cb[cb] = flag
            self.data_by_flag[flag] = (cb, flag, var)
            text.window_create("end", window=cb)
            text.insert("end", "\n")
            cb.bind("<Button-1>", self.select_button)
            ###cb.pack()
        self.list_ckbuttons()