aboutsummaryrefslogtreecommitdiffstats
path: root/examples/corelib
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2023-12-05 13:00:27 +0100
committerAdrian Herrmann <adrian.herrmann@qt.io>2023-12-06 11:52:07 +0100
commit592c734e57b00040329b49dfbe11869980dff88a (patch)
tree79fa3498cb974e5026415971ec83107b92b65919 /examples/corelib
parentc0329cff9d7378b8bf6a17baeb97bf5a240977fc (diff)
Examples: Fix a number of flake8 errors (part 1)
First batch, including low-hanging fruit like Alignments, whitespaces, line length, indents, etc. Pick-to: 6.6 Change-Id: I55966876077f7fddfdc82cbe376677af9995f329 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/corelib')
-rw-r--r--examples/corelib/settingseditor/settingseditor.py35
-rw-r--r--examples/corelib/threads/mandelbrot.py18
2 files changed, 27 insertions, 26 deletions
diff --git a/examples/corelib/settingseditor/settingseditor.py b/examples/corelib/settingseditor/settingseditor.py
index ca4369149..0a3f7748b 100644
--- a/examples/corelib/settingseditor/settingseditor.py
+++ b/examples/corelib/settingseditor/settingseditor.py
@@ -166,7 +166,7 @@ class MainWindow(QMainWindow):
@Slot()
def open_inifile(self):
file_name, _ = QFileDialog.getOpenFileName(self, "Open INI File",
- '', "INI Files (*.ini *.conf)")
+ '', "INI Files (*.ini *.conf)")
if file_name:
self.load_ini_file(file_name)
@@ -181,7 +181,8 @@ class MainWindow(QMainWindow):
@Slot()
def open_property_list(self):
file_name, _ = QFileDialog.getOpenFileName(self,
- "Open Property List", '', "Property List Files (*.plist)")
+ "Open Property List", '',
+ "Property List Files (*.plist)")
if file_name:
settings = QSettings(file_name, QSettings.NativeFormat)
@@ -191,8 +192,8 @@ class MainWindow(QMainWindow):
@Slot()
def open_registry_path(self):
path, ok = QInputDialog.getText(self, "Open Registry Path",
- "Enter the path in the Windows registry:",
- QLineEdit.Normal, 'HKEY_CURRENT_USER\\')
+ "Enter the path in the Windows registry:",
+ QLineEdit.Normal, 'HKEY_CURRENT_USER\\')
if ok and path != '':
settings = QSettings(path, QSettings.NativeFormat)
@@ -202,8 +203,8 @@ class MainWindow(QMainWindow):
@Slot()
def about(self):
QMessageBox.about(self, "About Settings Editor",
- "The <b>Settings Editor</b> example shows how to access "
- "application settings using Qt.")
+ "The <b>Settings Editor</b> example shows how to access "
+ "application settings using Qt.")
def create_actions(self):
self._open_settings_act = QAction("&Open Application Settings...",
@@ -217,35 +218,35 @@ class MainWindow(QMainWindow):
def create_actions(self):
self.open_settings_action = QAction("&Open Application Settings...",
- self, shortcut="Ctrl+O", triggered=self.open_settings)
+ self, shortcut="Ctrl+O", triggered=self.open_settings)
self.open_ini_file_action = QAction("Open I&NI File...", self,
- shortcut="Ctrl+N", triggered=self.open_inifile)
+ shortcut="Ctrl+N", triggered=self.open_inifile)
- self.open_property_list_action = QAction("Open macOS &Property List...",
- self, shortcut="Ctrl+P", triggered=self.open_property_list)
+ self.open_property_list_action = QAction("Open macOS &Property List...", self,
+ shortcut="Ctrl+P",
+ triggered=self.open_property_list)
if sys.platform != 'darwin':
self.open_property_list_action.setEnabled(False)
self.open_registry_path_action = QAction(
- "Open Windows &Registry Path...", self, shortcut="Ctrl+G",
- triggered=self.open_registry_path)
+ "Open Windows &Registry Path...", self, shortcut="Ctrl+G",
+ triggered=self.open_registry_path)
if sys.platform != 'win32':
self.open_registry_path_action.setEnabled(False)
self.refresh_action = QAction("&Refresh", self, shortcut="Ctrl+R",
- enabled=False, triggered=self.settings_tree.refresh)
+ enabled=False, triggered=self.settings_tree.refresh)
- self.exit_action = QAction("E&xit", self, shortcut="Ctrl+Q",
- triggered=self.close)
+ self.exit_action = QAction("E&xit", self, shortcut="Ctrl+Q", triggered=self.close)
self.auto_refresh_action = QAction("&Auto-Refresh", self,
- shortcut="Ctrl+A", checkable=True, enabled=False)
+ shortcut="Ctrl+A", checkable=True, enabled=False)
self.auto_refresh_action.triggered[bool].connect(self.settings_tree.set_auto_refresh)
self.auto_refresh_action.triggered[bool].connect(self.refresh_action.setDisabled)
self.fallbacks_action = QAction("&Fallbacks", self,
- shortcut="Ctrl+F", checkable=True, enabled=False)
+ shortcut="Ctrl+F", checkable=True, enabled=False)
self.fallbacks_action.triggered[bool].connect(self.settings_tree.set_fallbacks_enabled)
self.about_action = QAction("&About", self, triggered=self.about)
diff --git a/examples/corelib/threads/mandelbrot.py b/examples/corelib/threads/mandelbrot.py
index f9cc4559b..4689813d4 100644
--- a/examples/corelib/threads/mandelbrot.py
+++ b/examples/corelib/threads/mandelbrot.py
@@ -53,7 +53,8 @@ class RenderThread(QThread):
self.abort = False
for i in range(RenderThread.colormap_size):
- self.colormap.append(self.rgb_from_wave_length(380.0 + (i * 400.0 / RenderThread.colormap_size)))
+ self.colormap.append(
+ self.rgb_from_wave_length(380.0 + (i * 400.0 / RenderThread.colormap_size)))
def stop(self):
self.mutex.lock()
@@ -132,7 +133,8 @@ class RenderThread(QThread):
if num_iterations < max_iterations:
image.setPixel(x + half_width, y + half_height,
- self.colormap[num_iterations % RenderThread.colormap_size])
+ self.colormap[
+ num_iterations % RenderThread.colormap_size])
all_black = False
else:
image.setPixel(x + half_width, y + half_height, qRgb(0, 0, 0))
@@ -221,7 +223,7 @@ class MandelbrotWidget(QWidget):
if self.pixmap.isNull():
painter.setPen(Qt.white)
painter.drawText(self.rect(), Qt.AlignCenter,
- "Rendering initial image, please wait...")
+ "Rendering initial image, please wait...")
return
if self._cur_scale == self._pixmap_scale:
@@ -250,10 +252,10 @@ class MandelbrotWidget(QWidget):
painter.setPen(Qt.NoPen)
painter.setBrush(QColor(0, 0, 0, 127))
painter.drawRect((self.width() - text_width) / 2 - 5, 0, text_width + 10,
- metrics.lineSpacing() + 5)
+ metrics.lineSpacing() + 5)
painter.setPen(Qt.white)
painter.drawText((self.width() - text_width) / 2,
- metrics.leading() + metrics.ascent(), text)
+ metrics.leading() + metrics.ascent(), text)
def resizeEvent(self, event):
self.thread.render(self._center_x, self._center_y, self._cur_scale, self.size())
@@ -317,15 +319,13 @@ class MandelbrotWidget(QWidget):
def zoom(self, zoomFactor):
self._cur_scale *= zoomFactor
self.update()
- self.thread.render(self._center_x, self._center_y, self._cur_scale,
- self.size())
+ self.thread.render(self._center_x, self._center_y, self._cur_scale, self.size())
def scroll(self, deltaX, deltaY):
self._center_x += deltaX * self._cur_scale
self._center_y += deltaY * self._cur_scale
self.update()
- self.thread.render(self._center_x, self._center_y, self._cur_scale,
- self.size())
+ self.thread.render(self._center_x, self._center_y, self._cur_scale, self.size())
if __name__ == '__main__':