summaryrefslogtreecommitdiffstats
path: root/python/python3-pmw/exercises.patch
blob: 44576577194e123c1c4197ae08058197938b9f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
--- Pmw-2.1.1/Pmw/Pmw_2_1_1/doc/exercises.orig.py	2024-01-16 20:29:25.109576174 +0200
+++ Pmw-2.1.1/Pmw/Pmw_2_1_1/doc/exercises.py	2024-01-16 20:41:17.246644768 +0200
@@ -1,10 +1,10 @@
-import tkinter 
+import tkinter
 import Pmw
- 
+
 class ThresholdScale(Pmw.MegaWidget):
     """ Megawidget containing a scale and an indicator.
     """
- 
+
     def __init__(self, parent = None, **kw):
         # Define the megawidget options.
         optiondefs = (
@@ -16,13 +16,13 @@
 	    ('value',       None,             Pmw.INITOPT),
         )
         self.defineoptions(kw, optiondefs)
- 
+
         # Initialise base class (after defining options).
         Pmw.MegaWidget.__init__(self, parent)
- 
+
         # Create the components.
         interior = self.interior()
- 
+
         # Create the indicator component.
         self.indicator = self.createcomponent('indicator',
                 (), None,
@@ -31,69 +31,69 @@
 			height = 16,
 			borderwidth = 2,
 			relief = 'raised')
- 
+
         # Create the value component.
         self.value = self.createcomponent('value',
                 (), None,
                 tkinter.Label, interior,
 		    width = 3)
- 
+
         # Create the scale component.
-	if self['orient'] == 'vertical':
-	    # The default scale range seems to be
-	    # the wrong way around - reverse it.
-	    from_ = 100
-	    to = 0
-	else:
-	    from_ = 0
-	    to = 100
+        if self['orient'] == 'vertical':
+            # The default scale range seems to be
+            # the wrong way around - reverse it.
+            from_ = 100
+            to = 0
+        else:
+            from_ = 0
+            to = 100
 
-        self.scale = self.createcomponent('scale',
-                (), None,
-                tkinter.Scale, interior,
-			orient = self['orient'],
-			command = self._doCommand,
-			tickinterval = 20,
-			length = 200,
-			from_ = from_,
-			to = to,
-			showvalue = 0)
- 
-        value = self['value']
-        if value is not None:
-            self.scale.set(value)
- 
-	# Use grid to position all components
-	if self['orient'] == 'vertical':
-	    self.indicator.grid(row = 1, column = 1)
-	    self.value.grid(row = 2, column = 1)
-	    self.scale.grid(row = 3, column = 1)
-	    # Create the label.
-	    self.createlabel(interior, childRows=3)
-	else:
-	    self.indicator.grid(row = 1, column = 1)
-	    self.value.grid(row = 1, column = 2)
-	    self.scale.grid(row = 1, column = 3)
-	    # Create the label.
-	    self.createlabel(interior, childCols=3)
+            self.scale = self.createcomponent('scale',
+                    (), None,
+                    tkinter.Scale, interior,
+                orient = self['orient'],
+                command = self._doCommand,
+                tickinterval = 20,
+                length = 200,
+                from_ = from_,
+                to = to,
+                showvalue = 0)
+
+            value = self['value']
+            if value is not None:
+                self.scale.set(value)
 
-        # Check keywords and initialise options.
-        self.initialiseoptions()
+        # Use grid to position all components
+        if self['orient'] == 'vertical':
+            self.indicator.grid(row = 1, column = 1)
+            self.value.grid(row = 2, column = 1)
+            self.scale.grid(row = 3, column = 1)
+            # Create the label.
+            self.createlabel(interior, childRows=3)
+        else:
+            self.indicator.grid(row = 1, column = 1)
+            self.value.grid(row = 1, column = 2)
+            self.scale.grid(row = 1, column = 3)
+            # Create the label.
+            self.createlabel(interior, childCols=3)
+
+            # Check keywords and initialise options.
+            self.initialiseoptions()
 
     def _doCommand(self, valueStr):
-	valueInt = self.scale.get()
-	colors = self['colors']
-	thresholds = self['threshold']
-	color = colors[-1]
-	for index in range(len(colors) - 1):
-	    if valueInt <= thresholds[index]:
-		color = colors[index]
-		break
-	self.indicator.configure(background = color)
-	self.value.configure(text = valueStr)
+        valueInt = self.scale.get()
+        colors = self['colors']
+        thresholds = self['threshold']
+        color = colors[-1]
+        for index in range(len(colors) - 1):
+            if valueInt <= thresholds[index]:
+                color = colors[index]
+                break
+        self.indicator.configure(background = color)
+        self.value.configure(text = valueStr)
 
 Pmw.forwardmethods(ThresholdScale, tkinter.Scale, 'scale')
- 
+
 # Initialise tkinter and Pmw.
 root = Pmw.initialise()
 root.title('Pmw ThresholdScale demonstration')