def __init__(self, tcbase=None, change_call=None): """ Trace flag dictionary :tcbase: - parent - call basis must have tc_destroy to be called if we close :change_call: - call with change flag, value, if present """ self.flag_by_cb = {} # Dictionary hashed on cb widget self.data_by_flag = {} self.standalone = False # Set True if standalone operation if tcbase is None: SlTrace.lg("Standalone TraceControlWindow") root = Tk() frame = Frame(root) frame.pack() self.standalone = True root.withdraw() 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=False) self.top_frame = top_frame tc_all_button = Button(master=self.top_frame, text="SET ALL", command=self.select_all) tc_all_button.pack(side="left", fill="both", expand=False) tc_none_button = Button(master=self.top_frame, text="NONE", command=self.select_none) tc_none_button.pack(side="left", fill="both", expand=False) tc_bpt_button = Button(master=self.top_frame, text="BPT", command=self.breakpoint) tc_bpt_button.pack(side="left", fill="both", expand=False) self.show_list_which = "ALL" self.show_list_variable = StringVar() self.show_list_variable.set("Show SET") tc_show_button = Button(master=self.top_frame, textvariable=self.show_list_variable, command=self.show_list) tc_show_button.pack(side="left", fill="none", expand=False) self.tc_show_button = tc_show_button tc_frame = Frame(self.tc_mw) tc_frame.pack(side="top", fill="both", expand=True) self.tc_frame = tc_frame self.tc_text_frame = None # So we can destroy / resetup in create_flags_region self.flags_text = None self.sb = None self.create_flags_region(flags=SlTrace.getAllTraceFlags()) if SlTrace.trace("trace_flags"): self.list_ckbuttons()
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()