MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / Gauge

Class Gauge

DemoPrograms/Demo_Desktop_Widget_CPU_Gauge.py:22–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20"""
21
22class Gauge():
23 def mapping(func, sequence, *argc):
24 """
25 Map function with extra argument, not for tuple.
26 : Parameters
27 func - function to call.
28 sequence - list for iteration.
29 argc - more arguments for func.
30 : Return
31 list of func(element of sequence, *argc)
32 """
33 if isinstance(sequence, list):
34 return list(map(lambda i: func(i, *argc), sequence))
35 else:
36 return func(sequence, *argc)
37
38 def add(number1, number2):
39 """
40 Add two number
41 : Parameter
42 number1 - number to add.
43 numeer2 - number to add.
44 : Return
45 Addition result for number1 and number2.
46 """
47 return number1 + number2
48
49 def limit(number):
50 """
51 Limit angle in range 0 ~ 360
52 : Parameter
53 number: angle degree.
54 : Return
55 angel degree in 0 ~ 360, return 0 if number < 0, 360 if number > 360.
56 """
57 return max(min(360, number), 0)
58 class Clock():
59 """
60 Draw background circle or arc
61 All angles defined as clockwise from negative x-axis.
62 """
63
64 def __init__(self, center_x=0, center_y=0, radius=100, start_angle=0,
65 stop_angle=360, fill_color='white', line_color='black', line_width=2, graph_elem=None):
66
67 instance = Gauge.mapping(isinstance, [center_x, center_y, radius, start_angle,
68 stop_angle, line_width], (int, float)) + Gauge.mapping(isinstance,
69 [fill_color, line_color], str)
70 if False in instance:
71 raise ValueError
72 start_angle, stop_angle = Gauge.limit(start_angle), Gauge.limit(stop_angle)
73 self.all = [center_x, center_y, radius, start_angle, stop_angle,
74 fill_color, line_color, line_width]
75 self.figure = []
76 self.graph_elem = graph_elem
77 self.new()
78
79 def new(self):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected