diff --git a/gui.py b/gui.py index 7a57a23..d693075 100644 --- a/gui.py +++ b/gui.py @@ -125,7 +125,7 @@ def set_clean_command(self, command): self.clean_command = command def do_clean(self): - self.app.clear() + self.app.clear(self.clean_command) self.redraw_lines() def set_pid_lookup(self, string): @@ -141,10 +141,25 @@ def set_pid_lookup_enabled(self, value): return self.pid_lookup_enabled = value + self.app.set_pid_filter_enabled(value) + + if self.pid_lookup_enabled: + self.button_pid.config(bg="green") + else: + self.button_pid.config(bg="grey") + def set_pid_mask(self, string): self.app.set_pid_mask(re.compile(string)) + def on_button_pid_pressed(self, event): + self.set_pid_lookup_enabled(not self.pid_lookup_enabled) + self.redraw_lines() + + def on_button_clear_pressed(self, event): + self.do_clean() + self.redraw_lines() + def __init__(self, app): self._filtered_count = 0 self.app = app @@ -196,6 +211,14 @@ def __init__(self, app): textvariable=self.sv_filter, width=45) self.textFilter.grid(row=0, column=1, padx=5, pady=10) + self.button_clear = Button(self.panelFrame, text="Clear Log") + self.button_clear.bind("", self.on_button_clear_pressed) + self.button_clear.grid(row=0,column=2, padx=20) + + self.button_pid = Button(self.panelFrame, text="PID") + self.button_pid.bind("", self.on_button_pid_pressed) + self.button_pid.grid(row=0, column=3, padx=20) + self.scrollbar = Scrollbar(self.textFrame) self.scrollbar['command'] = self.textbox.yview self.scrollbar.pack(side='right', fill='y') diff --git a/smartlog.pyw b/smartlog.pyw index b86d40f..0ccf3dc 100644 --- a/smartlog.pyw +++ b/smartlog.pyw @@ -38,7 +38,7 @@ parser.add_argument("--start_clean", default=False, action='store_const', const= help="executes clean command on startup.") parser.add_argument("--command_clean", default="adb logcat -c", help="specifies clean command.") -parser.add_argument("--pid_lookup", default="", help="specifies string for looking process id.") +parser.add_argument("--pid_lookup", default="oxygine init", help="specifies string for looking process id.") parser.add_argument("--pid_mask", default="\((.*?)\)", help="specifies regex to searching pid in a text line.") parser.add_argument("--file", default="", help="specifies log file to read.") @@ -78,6 +78,9 @@ _args = parser.parse_args() # IF DEBUG # _args.command_execute = "netstat -a" +# _args.command_clean = None + + file_name = default_file_name diff --git a/smcore.py b/smcore.py index 67f7d9d..4940a28 100644 --- a/smcore.py +++ b/smcore.py @@ -245,7 +245,6 @@ def set_pid_lookup_string(self, value): def set_pid_filter_enabled(self, value): self.pid_filter_enabled = value - self.pid = None if value: self.update_pid(self.buffer.get_lines()) @@ -293,7 +292,8 @@ def set_new_lines_callback(self, callback): self.new_line_callback = callback def do_filter(self, lines): - return [x for x in lines if x.can_show(self.filter, self.pid)] + pid = self.pid if self.pid_filter_enabled else None + return [x for x in lines if x.can_show(self.filter, pid)] def get_filtered_buffer(self): if self.filter or self.pid: