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

Class Gauge

DemoPrograms/Demo_Desktop_Widget_RAM_Gauge.py:31–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected