Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5abc50

Browse files
committed
pep8 fixes
1 parent 5013dc8 commit c5abc50

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

lib/matplotlib/backends/qt4_editor/formlayout.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def to_qcolor(color):
107107
color = col2hex(color)
108108
except ValueError:
109109
#print('WARNING: ignoring invalid color %r' % color)
110-
return qcolor # return invalid QColor
111-
qcolor.setNamedColor(color) # set using hex color
112-
return qcolor # return valid QColor
110+
return qcolor # return invalid QColor
111+
qcolor.setNamedColor(color) # set using hex color
112+
return qcolor # return valid QColor
113113

114114

115115
class ColorLayout(QtGui.QHBoxLayout):
@@ -130,7 +130,7 @@ def __init__(self, color, parent=None):
130130
def update_color(self):
131131
color = self.text()
132132
qcolor = to_qcolor(color)
133-
self.colorbtn.color = qcolor # defaults to black if not qcolor.isValid()
133+
self.colorbtn.color = qcolor # defaults to black if not qcolor.isValid()
134134

135135
def update_text(self, color):
136136
self.lineedit.setText(color.name())
@@ -141,7 +141,9 @@ def text(self):
141141

142142
def font_is_installed(font):
143143
"""Check if font is installed"""
144-
return [fam for fam in QtGui.QFontDatabase().families() if six.text_type(fam)==font]
144+
return [fam for fam in QtGui.QFontDatabase().families()
145+
if six.text_type(fam) == font]
146+
145147

146148
def tuple_to_qfont(tup):
147149
"""
@@ -162,10 +164,12 @@ def tuple_to_qfont(tup):
162164
font.setBold(bold)
163165
return font
164166

167+
165168
def qfont_to_tuple(font):
166169
return (six.text_type(font.family()), int(font.pointSize()),
167170
font.italic(), font.bold())
168171

172+
169173
class FontLayout(QtGui.QGridLayout):
170174
"""Font selection"""
171175
def __init__(self, value, parent=None):
@@ -214,6 +218,7 @@ def is_edit_valid(edit):
214218

215219
return state == QtGui.QDoubleValidator.Acceptable
216220

221+
217222
class FormWidget(QtGui.QWidget):
218223
def __init__(self, data, comment="", parent=None):
219224
QtGui.QWidget.__init__(self, parent)
@@ -264,8 +269,8 @@ def setup(self):
264269
selindex = value.pop(0)
265270
field = QtGui.QComboBox(self)
266271
if isinstance(value[0], (list, tuple)):
267-
keys = [ key for key, _val in value ]
268-
value = [ val for _key, val in value ]
272+
keys = [key for key, _val in value]
273+
value = [val for _key, val in value]
269274
else:
270275
keys = value
271276
field.addItems(value)
@@ -274,15 +279,15 @@ def setup(self):
274279
elif selindex in keys:
275280
selindex = keys.index(selindex)
276281
elif not isinstance(selindex, int):
277-
print("Warning: '%s' index is invalid (label: " \
282+
print("Warning: '%s' index is invalid (label: "
278283
"%s, value: %s)" % (selindex, label, value), file=STDERR)
279284
selindex = 0
280285
field.setCurrentIndex(selindex)
281286
elif isinstance(value, bool):
282287
field = QtGui.QCheckBox(self)
283288
if value:
284289
field.setCheckState(QtCore.Qt.Checked)
285-
else :
290+
else:
286291
field.setCheckState(QtCore.Qt.Unchecked)
287292
elif isinstance(value, float):
288293
field = QtGui.QLineEdit(repr(value), self)
@@ -364,7 +369,7 @@ def setup(self):
364369
widget.setup()
365370

366371
def get(self):
367-
return [ widget.get() for widget in self.widgetlist]
372+
return [widget.get() for widget in self.widgetlist]
368373

369374

370375
class FormTabWidget(QtGui.QWidget):
@@ -376,7 +381,7 @@ def __init__(self, datalist, comment="", parent=None):
376381
self.setLayout(layout)
377382
self.widgetlist = []
378383
for data, title, comment in datalist:
379-
if len(data[0])==3:
384+
if len(data[0]) == 3:
380385
widget = FormComboWidget(data, comment=comment, parent=self)
381386
else:
382387
widget = FormWidget(data, comment=comment, parent=self)
@@ -389,7 +394,7 @@ def setup(self):
389394
widget.setup()
390395

391396
def get(self):
392-
return [ widget.get() for widget in self.widgetlist]
397+
return [widget.get() for widget in self.widgetlist]
393398

394399

395400
class FormDialog(QtGui.QDialog):
@@ -404,7 +409,7 @@ def __init__(self, data, title="", comment="",
404409
if isinstance(data[0][0], (list, tuple)):
405410
self.formwidget = FormTabWidget(data, comment=comment,
406411
parent=self)
407-
elif len(data[0])==3:
412+
elif len(data[0]) == 3:
408413
self.formwidget = FormComboWidget(data, comment=comment,
409414
parent=self)
410415
else:
@@ -418,7 +423,7 @@ def __init__(self, data, title="", comment="",
418423

419424
# Button box
420425
self.bbox = bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
421-
|QtGui.QDialogButtonBox.Cancel)
426+
| QtGui.QDialogButtonBox.Cancel)
422427
self.connect(self.formwidget, QtCore.SIGNAL('update_buttons()'),
423428
self.update_buttons)
424429
if self.apply_callback is not None:
@@ -502,7 +507,6 @@ def fedit(data, title="", comment="", icon=None, parent=None, apply=None):
502507
return dialog.get()
503508

504509

505-
506510
if __name__ == "__main__":
507511

508512
def create_datalist_example():
@@ -529,6 +533,7 @@ def create_datagroup_example():
529533

530534
#--------- datalist example
531535
datalist = create_datalist_example()
536+
532537
def apply_test(data):
533538
print("data:", data)
534539
print("result:", fedit(datalist, title="Example",

0 commit comments

Comments
 (0)