diff --git a/bin/pytop-0-0-1-x64.deb b/bin/pytop-0-0-1-x64.deb index 69f1e72..4f4ef33 100644 Binary files a/bin/pytop-0-0-1-x64.deb and b/bin/pytop-0-0-1-x64.deb differ diff --git a/images/pic1.png b/images/pic1.png new file mode 100644 index 0000000..409ee7a Binary files /dev/null and b/images/pic1.png differ diff --git a/src/Pytop/PyTop.py b/src/Pytop/PyTop.py index ffd93a7..0bf676f 100755 --- a/src/Pytop/PyTop.py +++ b/src/Pytop/PyTop.py @@ -1,5 +1,10 @@ #!/usr/bin/python3 +# Python imports +import inspect + +from setproctitle import setproctitle + # Gtk imports import gi, faulthandler, signal gi.require_version('Gtk', '3.0') @@ -8,14 +13,9 @@ from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GLib -# Python imports -import inspect - -from setproctitle import setproctitle - # Application imports from utils import Settings -from signal_classes import CrossClassSignals, GridSignals, TaskbarSignals +from signal_classes import CrossClassSignals, GridSignals, TaskbarSignals, DrawSignals class Main: @@ -58,7 +58,8 @@ class Main: # Then, builder connects to any signals it needs. classes = [CrossClassSignals(settings), GridSignals(settings), - TaskbarSignals(settings)] + TaskbarSignals(settings), + DrawSignals(settings)] handlers = {} for c in classes: diff --git a/src/Pytop/resources/PyTop.glade b/src/Pytop/resources/PyTop.glade index 1c08dea..01b77e9 100644 --- a/src/Pytop/resources/PyTop.glade +++ b/src/Pytop/resources/PyTop.glade @@ -7,6 +7,14 @@ inode/directory + + 1 + 100 + 1 + 1 + 10 + + False 800 @@ -76,14 +84,15 @@ True False - + True - True - in + False + vertical - + True - False + True + in True @@ -93,6 +102,63 @@ + + True + True + 0 + + + + + True + False + + + True + True + True + True + rgb(138,226,52) + + + + False + True + 1 + + + + + 60 + True + False + + + + + True + True + 2 + + + + + True + True + brushSizeProp + + + False + True + 2 + + + + + False + True + 2 + diff --git a/src/Pytop/signal_classes/DrawSignals.py b/src/Pytop/signal_classes/DrawSignals.py new file mode 100755 index 0000000..b47ee2b --- /dev/null +++ b/src/Pytop/signal_classes/DrawSignals.py @@ -0,0 +1,164 @@ +#!/usr/bin/python3 + + +# Python Imports +from __future__ import division +import cairo, psutil + + +# GTK Imports +from gi.repository import GObject +from gi.repository import GLib + + + + + +class DrawSignals: + def __init__(self, settings): + self.settings = settings + self.builder = self.settings.returnBuilder() + + self.drawArea = self.builder.get_object("drawArea") + self.brushSizeProp = self.builder.get_object("brushSizeProp") + self.brushColorProp = self.builder.get_object("brushColorProp") + self.messageWidget = self.builder.get_object("messageWidget") + self.messageLabel = self.builder.get_object("messageLabel") + + self.cpu_percents = [] + self.doDrawBackground = False + self.isDrawing = False + self.surface = None + self.aw = None # Draw area width + self.ah = None # Draw area height + self.xStep = None # For x-axis 60 sec steps + self.yStep = None # For y-axis %s + + rgba = self.brushColorProp.get_rgba() + self.brushColorVal = [rgba.red, rgba.green, rgba.blue, rgba.alpha] + self.brushSizeVal = self.brushSizeProp.get_value() + self.updateSpeed = 100 # 1 sec = 1000ms + + self.success = "#88cc27" + self.warning = "#ffa800" + self.error = "#ff0000" + + self.good = [0.53, 0.8, 0.15, 1.0] + self.warning = [1.0, 0.66, 0.0, 1.0] + self.danger = [1.0, 0.0, 0.0, 1.0] + + # Note: y-axis on draw area goes from top to bottom when increasing. + # Need to do the math such that you subtract from max height to start from bottom to go up + # self.linePoints.append([1 * xStep, ah - (23 * yStep)]) # 23% + # self.linePoints.append([2 * xStep, ah - (60 * yStep)]) # 60% + # self.drawPointLine() + # del self.linePoints[0:1] + # self.linePoints.append([3 * xStep, ah - (44 * yStep)]) # 44% + + + + def updateCPUPoints(self): + # Clears screen when enough points exist and unshifts the + # first point to keep fixed range + self.drawBackground(self.brush, self.aw, self.ah) + del self.cpu_percents[0:1] + + precent = psutil.cpu_percent() + self.cpu_percents.append(precent) + self.drawPointLine() # Will re-draw every point + self.drawArea.queue_draw() + + return True + + + def drawPointLine(self): + self.brush.set_line_width(self.brushSizeVal) + self.brush.set_line_cap(1) # 0 = BUTT, 1 = ROUND, 2 = SQUARE + + oldX = 0.0 + oldP = 0.0 + i = 1 + for p in self.cpu_percents: + # set color depending on usage... + rgba = self.brushColorVal + if p > 50.0: + rgba = self.warning + if p > 85.0: + rgba = self.danger + + self.brush.set_source_rgba(rgba[0], rgba[1], rgba[2], rgba[3]) + + # Movbe to prev. point if any + if oldP is not 0.0 and oldX is not 0.0: + x = oldX + y = float(self.ah) - (oldP * self.yStep) + self.brush.move_to(x, y) + + # Draw line to the new point from old point + x2 = i * self.xStep + y2 = float(self.ah) - (p * self.yStep) + self.brush.line_to(x2, y2) + self.brush.stroke() + + # Collect info to use as prev. pint + oldX = x2 + oldP = p + i += 1 + + + def onConfigure(self, area, eve, data = None): + aw = area.get_allocated_width() + ah = area.get_allocated_height() + self.aw = aw + self.ah = ah + self.xStep = aw / 200 # For x-axis + self.yStep = ah / 100 # For y-axis %s + self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, aw, ah) + self.brush = cairo.Context(self.surface) + + self.drawBackground(self.brush, aw, ah) + if not self.isDrawing: + self.fillCPUPercents() + self.startCPUGraph() + self.isDrawing = True + + return False + + # Fill with y bank with 50%s + def fillCPUPercents(self): + self.cpu_percents = [50.0] * 198 + + + # Draw background white + def drawBackground(self, brush, aw, ah): + brush.rectangle(0, 0, aw, ah) # x, y, width, height + brush.set_source_rgba(1, 1, 1, 1.0) # x, y, width, height + + if not self.doDrawBackground: # If transparent or white + self.brush.set_operator(0); + + brush.fill() + self.brush.set_operator(1); # reset the brush after filling bg... + + + # Starting graph generation + def startCPUGraph(self): + GObject.timeout_add(self.updateSpeed, self.updateCPUPoints) + + + def onDraw(self, area, brush): + if self.surface is not None: + brush.set_source_surface(self.surface, 0.0, 0.0) + brush.paint() + else: + print("No surface info...") + + return False + + + def onColorSet(self, widget): + rgba = widget.get_rgba() + self.brushColorVal = [rgba.red, rgba.green, rgba.blue, rgba.alpha] + + def onBrushSizeChange(self, widget): + self.brushSizeVal = self.brushSizeProp.get_value() diff --git a/src/Pytop/signal_classes/__init__.py b/src/Pytop/signal_classes/__init__.py index 6bfa30d..00e056b 100644 --- a/src/Pytop/signal_classes/__init__.py +++ b/src/Pytop/signal_classes/__init__.py @@ -1,3 +1,4 @@ from signal_classes.CrossClassSignals import CrossClassSignals +from signal_classes.DrawSignals import DrawSignals from signal_classes.GridSignals import GridSignals from signal_classes.TaskbarSignals import TaskbarSignals diff --git a/src/Pytop/signal_classes/__pycache__/CrossClassSignals.cpython-36.pyc b/src/Pytop/signal_classes/__pycache__/CrossClassSignals.cpython-36.pyc new file mode 100644 index 0000000..7f37669 Binary files /dev/null and b/src/Pytop/signal_classes/__pycache__/CrossClassSignals.cpython-36.pyc differ diff --git a/src/Pytop/signal_classes/__pycache__/GridSignals.cpython-36.pyc b/src/Pytop/signal_classes/__pycache__/GridSignals.cpython-36.pyc new file mode 100644 index 0000000..8545049 Binary files /dev/null and b/src/Pytop/signal_classes/__pycache__/GridSignals.cpython-36.pyc differ diff --git a/src/Pytop/signal_classes/__pycache__/TaskbarSignals.cpython-36.pyc b/src/Pytop/signal_classes/__pycache__/TaskbarSignals.cpython-36.pyc new file mode 100644 index 0000000..781c6a3 Binary files /dev/null and b/src/Pytop/signal_classes/__pycache__/TaskbarSignals.cpython-36.pyc differ diff --git a/src/Pytop/signal_classes/__pycache__/__init__.cpython-36.pyc b/src/Pytop/signal_classes/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..3a2b068 Binary files /dev/null and b/src/Pytop/signal_classes/__pycache__/__init__.cpython-36.pyc differ diff --git a/src/Pytop/utils/__pycache__/Dragging.cpython-36.pyc b/src/Pytop/utils/__pycache__/Dragging.cpython-36.pyc new file mode 100644 index 0000000..2a3ab95 Binary files /dev/null and b/src/Pytop/utils/__pycache__/Dragging.cpython-36.pyc differ diff --git a/src/Pytop/utils/__pycache__/FileHandler.cpython-36.pyc b/src/Pytop/utils/__pycache__/FileHandler.cpython-36.pyc new file mode 100644 index 0000000..b8c3303 Binary files /dev/null and b/src/Pytop/utils/__pycache__/FileHandler.cpython-36.pyc differ diff --git a/src/Pytop/utils/__pycache__/Settings.cpython-36.pyc b/src/Pytop/utils/__pycache__/Settings.cpython-36.pyc new file mode 100644 index 0000000..c7ceeb7 Binary files /dev/null and b/src/Pytop/utils/__pycache__/Settings.cpython-36.pyc differ diff --git a/src/Pytop/utils/__pycache__/__init__.cpython-36.pyc b/src/Pytop/utils/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..74594fc Binary files /dev/null and b/src/Pytop/utils/__pycache__/__init__.cpython-36.pyc differ diff --git a/src/Pytop/widgets/__pycache__/Grid.cpython-36.pyc b/src/Pytop/widgets/__pycache__/Grid.cpython-36.pyc new file mode 100644 index 0000000..234cad4 Binary files /dev/null and b/src/Pytop/widgets/__pycache__/Grid.cpython-36.pyc differ diff --git a/src/Pytop/widgets/__pycache__/Icon.cpython-36.pyc b/src/Pytop/widgets/__pycache__/Icon.cpython-36.pyc new file mode 100644 index 0000000..36a5e6f Binary files /dev/null and b/src/Pytop/widgets/__pycache__/Icon.cpython-36.pyc differ diff --git a/src/Pytop/widgets/__pycache__/__init__.cpython-36.pyc b/src/Pytop/widgets/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..3166e35 Binary files /dev/null and b/src/Pytop/widgets/__pycache__/__init__.cpython-36.pyc differ diff --git a/src/Pytop/widgets/icon_manager/__pycache__/__init__.cpython-36.pyc b/src/Pytop/widgets/icon_manager/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..e6b5c50 Binary files /dev/null and b/src/Pytop/widgets/icon_manager/__pycache__/__init__.cpython-36.pyc differ diff --git a/src/Pytop/widgets/icon_manager/__pycache__/easybuttons.cpython-36.pyc b/src/Pytop/widgets/icon_manager/__pycache__/easybuttons.cpython-36.pyc new file mode 100644 index 0000000..c6edf71 Binary files /dev/null and b/src/Pytop/widgets/icon_manager/__pycache__/easybuttons.cpython-36.pyc differ diff --git a/src/Pytop/widgets/icon_manager/__pycache__/execute.cpython-36.pyc b/src/Pytop/widgets/icon_manager/__pycache__/execute.cpython-36.pyc new file mode 100644 index 0000000..009ff11 Binary files /dev/null and b/src/Pytop/widgets/icon_manager/__pycache__/execute.cpython-36.pyc differ diff --git a/src/Pytop/widgets/icon_manager/__pycache__/filemonitor.cpython-36.pyc b/src/Pytop/widgets/icon_manager/__pycache__/filemonitor.cpython-36.pyc new file mode 100644 index 0000000..f781eca Binary files /dev/null and b/src/Pytop/widgets/icon_manager/__pycache__/filemonitor.cpython-36.pyc differ