MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / Gauge

Class Gauge

DemoPrograms/Demo_Desktop_Widget_Count_To_A_Goal.py:30–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

make_windowFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected