MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / DashGraph

Class DashGraph

DemoPrograms/Demo_Desktop_Widget_CPU_Dashboard.py:32–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31# DashGraph does the drawing of each graph
32class DashGraph(object):
33 def __init__(self, graph_elem, text_elem, starting_count, color):
34 self.graph_current_item = 0
35 self.graph_elem = graph_elem # type: sg.Graph
36 self.text_elem = text_elem
37 self.prev_value = starting_count
38 self.max_sent = 1
39 self.color = color
40 self.line_list = [] # list of currently visible lines. Used to delete oild figures
41
42 def graph_percentage_abs(self, value):
43 self.line_list.append(self.graph_elem.draw_line( # draw a line and add to list of lines
44 (self.graph_current_item, 0),
45 (self.graph_current_item, value),
46 color=self.color))
47 if self.graph_current_item >= GRAPH_WIDTH:
48 self.graph_elem.move(-1,0)
49 self.graph_elem.delete_figure(self.line_list[0]) # delete the oldest line
50 self.line_list = self.line_list[1:] # remove line id from list of lines
51 else:
52 self.graph_current_item += 1
53
54 def text_display(self, text):
55 self.text_elem.update(text)
56
57def main(location):
58 # A couple of "User defined elements" that combine several elements and enable bulk edits

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected