summaryrefslogtreecommitdiffstats
path: root/python/python3-pmw/exercises.patch
diff options
context:
space:
mode:
Diffstat (limited to 'python/python3-pmw/exercises.patch')
-rw-r--r--python/python3-pmw/exercises.patch154
1 files changed, 154 insertions, 0 deletions
diff --git a/python/python3-pmw/exercises.patch b/python/python3-pmw/exercises.patch
new file mode 100644
index 0000000000..4457657719
--- /dev/null
+++ b/python/python3-pmw/exercises.patch
@@ -0,0 +1,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')