Skip to content

Commit

Permalink
Buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
zendorx committed Feb 9, 2017
1 parent 03bf49d commit f00e445
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
25 changes: 24 additions & 1 deletion gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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("<Button-1>", 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("<Button-1>", 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')
Expand Down
5 changes: 4 additions & 1 deletion smartlog.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -78,6 +78,9 @@ _args = parser.parse_args()

# IF DEBUG
# _args.command_execute = "netstat -a"
# _args.command_clean = None



file_name = default_file_name

Expand Down
4 changes: 2 additions & 2 deletions smcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f00e445

Please sign in to comment.