Skip to content

Commit ad03a54

Browse files
authored
Merge pull request #190 from robotools/super
Super
2 parents 8303f24 + a6f6568 commit ad03a54

21 files changed

+61
-52
lines changed

Demos/TinyTextEditor/TinyTextEditor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22
from PyObjCTools import AppHelper
33
from tinyTextEditorDocumentWindow import TinyTextEditorDocumentWindow
44
from io import open
5+
from objc import super
56

67

78
class TinyTextEditorDocument(NSDocument):
8-
9+
910
def init(self):
10-
self = super(TinyTextEditorDocument, self).init()
11+
self = super().init()
1112
self.vanillaWindowController = TinyTextEditorDocumentWindow()
1213
self.vanillaWindowController.assignToDocument(self)
13-
return self
14-
14+
return self
15+
1516
def readFromFile_ofType_(self, path, tp):
1617
# refer to the NSDocument reference for information about this method
1718
f = open(path, 'r', encoding='utf-8')
1819
text = f.read()
1920
f.close()
2021
self.vanillaWindowController.setText(text)
2122
return True
22-
23+
2324
def writeWithBackupToFile_ofType_saveOperation_(self, fileName, fileType, operation):
2425
# refer to the NSDocument reference for information about this method
2526
text = self.vanillaWindowController.getText()

Lib/vanilla/dialogs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from objc import selector
22
from objc import python_method
3+
from objc import super
34
from Foundation import NSObject
45
from AppKit import NSAlert, NSSavePanel, NSOpenPanel, NSAlertStyleCritical, NSAlertStyleInformational, NSAlertStyleWarning, NSAlertFirstButtonReturn, NSAlertSecondButtonReturn, NSAlertThirdButtonReturn, NSOKButton, NSURL, NSImage
56

@@ -43,7 +44,7 @@ def windowWillClose_(self, notification):
4344
class BaseMessageDialog(BasePanel):
4445

4546
def initWithWindow_resultCallback_(cls, parentWindow=None, resultCallback=None):
46-
self = super(BaseMessageDialog, cls).initWithWindow_resultCallback_(parentWindow, resultCallback)
47+
self = super().initWithWindow_resultCallback_(parentWindow, resultCallback)
4748
self.messageText = ""
4849
self.informativeText = ""
4950
self.alertStyle = NSAlertStyleInformational
@@ -139,7 +140,7 @@ def completionHandler_(self, returnCode):
139140
class PutFilePanel(BasePutGetPanel):
140141

141142
def initWithWindow_resultCallback_cancelCallback_(self, parentWindow=None, resultCallback=None, cancelCallback=None):
142-
self = super(PutFilePanel, self).initWithWindow_resultCallback_cancelCallback_(parentWindow, resultCallback, cancelCallback)
143+
self = super().initWithWindow_resultCallback_cancelCallback_(parentWindow, resultCallback, cancelCallback)
143144
self.messageText = None
144145
self.title = None
145146
self.fileTypes = None
@@ -186,7 +187,7 @@ def completionHandler_(self, returnCode):
186187
class GetFileOrFolderPanel(BasePutGetPanel):
187188

188189
def initWithWindow_resultCallback_cancelCallback_(self, parentWindow=None, resultCallback=None, cancelCallback=None):
189-
self = super(GetFileOrFolderPanel, self).initWithWindow_resultCallback_cancelCallback_(parentWindow, resultCallback, cancelCallback)
190+
self = super().initWithWindow_resultCallback_cancelCallback_(parentWindow, resultCallback, cancelCallback)
190191
self.messageText = None
191192
self.title = None
192193
self.directory = None

Lib/vanilla/vanillaBase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import platform
2+
from objc import super
23

34
from Foundation import NSObject
45
from AppKit import NSFont, NSRegularControlSize, NSSmallControlSize, NSMiniControlSize, \

Lib/vanilla/vanillaBox.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import objc
1+
from objc import super
22
from AppKit import NSBox, NSColor, NSFont, NSSmallControlSize, NSNoTitle, NSLineBorder, NSBoxSeparator, NSBoxCustom
33
from vanilla.vanillaBase import VanillaBaseObject, _breakCycles, osVersionCurrent, osVersion10_10
44

@@ -91,13 +91,13 @@ def _adjustPosSize(self, frame):
9191
title = "None"
9292
boxType = "Box-" + title
9393
self.frameAdjustments = self.allFrameAdjustments[boxType]
94-
return super(Box, self)._adjustPosSize(frame)
94+
return super()._adjustPosSize(frame)
9595

9696
def _getContentView(self):
9797
return self._nsObject.contentView()
9898

9999
def _breakCycles(self):
100-
super(Box, self)._breakCycles()
100+
super()._breakCycles()
101101
view = self._nsObject.contentView()
102102
if view is not None:
103103
_breakCycles(view)
@@ -196,7 +196,7 @@ def __init__(self):
196196
"""
197197

198198
def __init__(self, posSize):
199-
super(HorizontalLine, self).__init__(posSize)
199+
super().__init__(posSize)
200200

201201

202202
class VerticalLine(_Line):
@@ -230,4 +230,4 @@ def __init__(self):
230230
"""
231231

232232
def __init__(self, posSize):
233-
super(VerticalLine, self).__init__(posSize)
233+
super().__init__(posSize)

Lib/vanilla/vanillaButton.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(self, posSize, title, callback=None, sizeStyle="regular"):
9797
self._nsObject.setButtonType_(self.nsButtonType)
9898

9999
def _testForDeprecatedAttributes(self):
100-
super(Button, self)._testForDeprecatedAttributes()
100+
super()._testForDeprecatedAttributes()
101101
from warnings import warn
102102
if hasattr(self, "_nsBezelStyle"):
103103
warn(DeprecationWarning("The _nsBezelStyle attribute is deprecated. Use the nsBezelStyle attribute."))
@@ -209,7 +209,7 @@ def buttonCallback(self, sender):
209209
frameAdjustments = None
210210

211211
def __init__(self, posSize, title, callback=None, sizeStyle="regular"):
212-
super(SquareButton, self).__init__(posSize=posSize, title=title, callback=callback, sizeStyle=sizeStyle)
212+
super().__init__(posSize=posSize, title=title, callback=callback, sizeStyle=sizeStyle)
213213

214214

215215
_imagePositionMap = {
@@ -296,7 +296,7 @@ def buttonCallback(self, sender):
296296
def __init__(self, posSize,
297297
imagePath=None, imageNamed=None, imageObject=None,
298298
title=None, bordered=True, imagePosition="top", callback=None, sizeStyle="regular"):
299-
super(ImageButton, self).__init__(posSize, title=title, callback=callback, sizeStyle=sizeStyle)
299+
super().__init__(posSize, title=title, callback=callback, sizeStyle=sizeStyle)
300300
image = None
301301
if imagePath is not None:
302302
image = NSImage.alloc().initWithContentsOfFile_(imagePath)
@@ -394,7 +394,7 @@ def __init__(self, posSize, callback=None, page=None, anchor=None):
394394
if callback is None:
395395
if page is not None or anchor is not None:
396396
callback = self._helpBookCallback
397-
super(HelpButton, self).__init__(posSize, title="", callback=callback)
397+
super().__init__(posSize, title="", callback=callback)
398398

399399
def _helpBookCallback(self, sender):
400400
from Carbon import AH

Lib/vanilla/vanillaCheckBox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class _CheckBoxStandardBuild(Button):
8080
}
8181

8282
def __init__(self, posSize, title, callback=None, value=False, sizeStyle="regular"):
83-
super(_CheckBoxStandardBuild, self).__init__(posSize, title, callback=callback, sizeStyle=sizeStyle)
83+
super().__init__(posSize, title, callback=callback, sizeStyle=sizeStyle)
8484
self.set(value)
8585

8686
def set(self, value):
@@ -133,7 +133,7 @@ class _CheckBoxManualBuildTextButton(Button):
133133
frameAdjustments = None
134134

135135
def __init__(self, posSize, title, callback, sizeStyle):
136-
super(_CheckBoxManualBuildTextButton, self).__init__(posSize, title=title, callback=callback)
136+
super().__init__(posSize, title=title, callback=callback)
137137
self._nsObject.setBordered_(False)
138138
self._setSizeStyle(sizeStyle)
139139
self._nsObject.setAlignment_(NSTextAlignmentLeft)

Lib/vanilla/vanillaComboBox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ def __init__(self, posSize, items, completes=True, continuous=False,
115115
self._nsObject.setFormatter_(formatter)
116116

117117
def _breakCycles(self):
118-
super(ComboBox, self)._breakCycles()
118+
super()._breakCycles()
119119
self._delegate = None
120120

121121
def _setCallback(self, callback):
122-
super(ComboBox, self)._setCallback(callback)
122+
super()._setCallback(callback)
123123
if callback is not None:
124124
self._delegate = VanillaComboBoxDelegate.alloc().init()
125125
self._delegate._continuous = self._continuous

Lib/vanilla/vanillaDrawer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _getContentView(self):
111111
return self._nsObject.contentView()
112112

113113
def _breakCycles(self):
114-
super(Drawer, self)._breakCycles()
114+
super()._breakCycles()
115115
view = self._getContentView()
116116
if view is not None:
117117
_breakCycles(view)

Lib/vanilla/vanillaEditText.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(self, posSize, text="", callback=None, continuous=True, readOnly=Fa
104104
self._nsObject.cell().setPlaceholderString_(placeholder)
105105

106106
def _testForDeprecatedAttributes(self):
107-
super(EditText, self)._testForDeprecatedAttributes()
107+
super()._testForDeprecatedAttributes()
108108
from warnings import warn
109109
if hasattr(self, "_textFieldClass"):
110110
warn(DeprecationWarning("The _textFieldClass attribute is deprecated. Use the nsTextFieldClass attribute."))

Lib/vanilla/vanillaGroup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ def __init__(self, posSize, blendingMode=None, dropSettings=None):
124124
def __setattr__(self, attr, value):
125125
# __init__
126126
if not hasattr(self, "_visualEffectGroup") or attr == "_visualEffectGroup":
127-
super(Group, self).__setattr__(attr, value)
127+
super().__setattr__(attr, value)
128128
# adding a vanilla subview: add to the visual effect view
129129
elif hasattr(self, "_visualEffectGroup") and isinstance(value, VanillaBaseObject) and hasattr(value, "_posSize"):
130130
setattr(self._visualEffectGroup, attr, value)
131131
# fallback: add to the main view
132132
else:
133-
super(Group, self).__setattr__(attr, value)
133+
super().__setattr__(attr, value)
134134

135135
def __delattr__(self, attr):
136136
if hasattr(self, attr):
137-
super(Group, self).__delattr__(attr)
137+
super().__delattr__(attr)
138138
elif hasattr(self, "_visualEffectView"):
139139
delattr(self._visualEffectView, attr)
140140

0 commit comments

Comments
 (0)