aboutsummaryrefslogtreecommitdiffstats
path: root/examples/charts
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-03-24 13:32:45 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-03-29 08:07:47 +0100
commitfaa2de3d4758b1c679685d41df0e4634f1069c83 (patch)
tree39ac361775c06eb9e90f1a91b7a9836785b50b4e /examples/charts
parentcc1bdbe5ecc39c0986fff64ad3f8ab0adae3771b (diff)
Port non-QWidget examples to snake case
Task-number: PYSIDE-1112 Change-Id: I0be4d2124663bbf8973432b066a0a49facab18b3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/charts')
-rw-r--r--examples/charts/callout/callout.py50
-rw-r--r--examples/charts/chartthemes/main.py24
-rw-r--r--examples/charts/chartthemes/themewidget.ui10
-rw-r--r--examples/charts/chartthemes/ui_themewidget.py19
-rw-r--r--examples/charts/donutbreakdown/donutbreakdown.py4
-rw-r--r--examples/charts/legend/legend.py4
-rw-r--r--examples/charts/lineandbar/lineandbar.py58
-rw-r--r--examples/charts/linechart/linechart.py6
-rw-r--r--examples/charts/logvalueaxis/logvalueaxis.py38
-rw-r--r--examples/charts/memoryusage/memoryusage.py62
-rw-r--r--examples/charts/piechart/piechart.py6
-rw-r--r--examples/charts/temperaturerecords/temperaturerecords.py20
12 files changed, 151 insertions, 150 deletions
diff --git a/examples/charts/callout/callout.py b/examples/charts/callout/callout.py
index a5751a4b5..747f20072 100644
--- a/examples/charts/callout/callout.py
+++ b/examples/charts/callout/callout.py
@@ -80,36 +80,36 @@ class Callout(QGraphicsItem):
# establish the position of the anchor point in relation to _rect
above = anchor.y() <= self._rect.top()
- aboveCenter = (anchor.y() > self._rect.top() and
+ above_center = (anchor.y() > self._rect.top() and
anchor.y() <= self._rect.center().y())
- belowCenter = (anchor.y() > self._rect.center().y() and
+ below_center = (anchor.y() > self._rect.center().y() and
anchor.y() <= self._rect.bottom())
below = anchor.y() > self._rect.bottom()
- onLeft = anchor.x() <= self._rect.left()
- leftOfCenter = (anchor.x() > self._rect.left() and
+ on_left = anchor.x() <= self._rect.left()
+ left_of_center = (anchor.x() > self._rect.left() and
anchor.x() <= self._rect.center().x())
- rightOfCenter = (anchor.x() > self._rect.center().x() and
+ right_of_center = (anchor.x() > self._rect.center().x() and
anchor.x() <= self._rect.right())
- onRight = anchor.x() > self._rect.right()
+ on_right = anchor.x() > self._rect.right()
# get the nearest _rect corner.
- x = (onRight + rightOfCenter) * self._rect.width()
- y = (below + belowCenter) * self._rect.height()
- cornerCase = ((above and onLeft) or (above and onRight) or
- (below and onLeft) or (below and onRight))
+ x = (on_right + right_of_center) * self._rect.width()
+ y = (below + below_center) * self._rect.height()
+ corner_case = ((above and on_left) or (above and on_right) or
+ (below and on_left) or (below and on_right))
vertical = abs(anchor.x() - x) > abs(anchor.y() - y)
- x1 = (x + leftOfCenter * 10 - rightOfCenter * 20 + cornerCase *
- int(not vertical) * (onLeft * 10 - onRight * 20))
- y1 = (y + aboveCenter * 10 - belowCenter * 20 + cornerCase *
+ x1 = (x + left_of_center * 10 - right_of_center * 20 + corner_case *
+ int(not vertical) * (on_left * 10 - on_right * 20))
+ y1 = (y + above_center * 10 - below_center * 20 + corner_case *
vertical * (above * 10 - below * 20))
point1.setX(x1)
point1.setY(y1)
- x2 = (x + leftOfCenter * 20 - rightOfCenter * 10 + cornerCase *
- int(not vertical) * (onLeft * 20 - onRight * 10))
- y2 = (y + aboveCenter * 20 - belowCenter * 10 + cornerCase *
+ x2 = (x + left_of_center * 20 - right_of_center * 10 + corner_case *
+ int(not vertical) * (on_left * 20 - on_right * 10))
+ y2 = (y + above_center * 20 - below_center * 10 + corner_case *
vertical * (above * 20 - below * 10))
point2.setX(x2)
point2.setY(y2)
@@ -134,7 +134,7 @@ class Callout(QGraphicsItem):
else:
event.setAccepted(False)
- def setText(self, text):
+ def set_text(self, text):
self._text = text
metrics = QFontMetrics(self._font)
self._textRect = QRectF(metrics.boundingRect(
@@ -143,10 +143,10 @@ class Callout(QGraphicsItem):
self.prepareGeometryChange()
self._rect = self._textRect.adjusted(-5, -5, 5, 5)
- def setAnchor(self, point):
+ def set_anchor(self, point):
self._anchor = QPointF(point)
- def updateGeometry(self):
+ def update_geometry(self):
self.prepareGeometryChange()
self.setPos(self._chart.mapToPosition(
self._anchor) + QPointF(10, -50))
@@ -201,10 +201,10 @@ class View(QGraphicsView):
self._callouts = []
self._tooltip = Callout(self._chart)
- self.series.clicked.connect(self.keepCallout)
+ self.series.clicked.connect(self.keep_callout)
self.series.hovered.connect(self.tooltip)
- self.series2.clicked.connect(self.keepCallout)
+ self.series2.clicked.connect(self.keep_callout)
self.series2.hovered.connect(self.tooltip)
self.setMouseTracking(True)
@@ -232,7 +232,7 @@ class View(QGraphicsView):
self._coordY.setText(f"Y: {y:.2f}")
QGraphicsView.mouseMoveEvent(self, event)
- def keepCallout(self):
+ def keep_callout(self):
self._callouts.append(self._tooltip)
self._tooltip = Callout(self._chart)
@@ -243,10 +243,10 @@ class View(QGraphicsView):
if state:
x = point.x()
y = point.y()
- self._tooltip.setText(f"X: {x:.2f} \nY: {y:.2f} ")
- self._tooltip.setAnchor(point)
+ self._tooltip.set_text(f"X: {x:.2f} \nY: {y:.2f} ")
+ self._tooltip.set_anchor(point)
self._tooltip.setZValue(11)
- self._tooltip.updateGeometry()
+ self._tooltip.update_geometry()
self._tooltip.show()
else:
self._tooltip.hide()
diff --git a/examples/charts/chartthemes/main.py b/examples/charts/chartthemes/main.py
index 63808a607..a5df1236c 100644
--- a/examples/charts/chartthemes/main.py
+++ b/examples/charts/chartthemes/main.py
@@ -71,34 +71,34 @@ class ThemeWidget(QWidget):
self.populate_legendbox()
# Area Chart
- chart_view = QChartView(self.create_areachart())
+ chart_view = QChartView(self.create_areachart())
self.ui.gridLayout.addWidget(chart_view, 1, 0)
self.charts.append(chart_view)
# Pie Chart
- chart_view = QChartView(self.createPieChart())
+ chart_view = QChartView(self.create_pie_chart())
chart_view.setSizePolicy(QSizePolicy.Ignored,
QSizePolicy.Ignored)
self.ui.gridLayout.addWidget(chart_view, 1, 1)
self.charts.append(chart_view)
# Line Chart
- chart_view = QChartView(self.createLineChart())
+ chart_view = QChartView(self.create_line_chart())
self.ui.gridLayout.addWidget(chart_view, 1, 2)
self.charts.append(chart_view)
# Bar Chart
- chart_view = QChartView(self.createBarChart())
+ chart_view = QChartView(self.create_bar_chart())
self.ui.gridLayout.addWidget(chart_view, 2, 0)
self.charts.append(chart_view)
# Spline Chart
- chart_view = QChartView(self.createSplineChart())
+ chart_view = QChartView(self.create_spline_chart())
self.ui.gridLayout.addWidget(chart_view, 2, 1)
self.charts.append(chart_view)
# Scatter Chart
- chart_view = QChartView(self.create_scatterchart())
+ chart_view = QChartView(self.create_scatterchart())
self.ui.gridLayout.addWidget(chart_view, 2, 2)
self.charts.append(chart_view)
@@ -111,7 +111,7 @@ class ThemeWidget(QWidget):
pal.setColor(QPalette.WindowText, QColor(0x404044))
qApp.setPalette(pal)
- self.updateUI()
+ self.update_ui()
def generate_random_data(self, list_count, value_max, value_count):
@@ -189,7 +189,7 @@ class ThemeWidget(QWidget):
return chart
- def createBarChart(self):
+ def create_bar_chart(self):
chart = QChart()
chart.setTitle("Bar chart")
@@ -209,7 +209,7 @@ class ThemeWidget(QWidget):
return chart
- def createLineChart(self):
+ def create_line_chart(self):
chart = QChart()
chart.setTitle("Line chart")
@@ -229,7 +229,7 @@ class ThemeWidget(QWidget):
return chart
- def createPieChart(self):
+ def create_pie_chart(self):
chart = QChart()
chart.setTitle("Pie chart")
@@ -247,7 +247,7 @@ class ThemeWidget(QWidget):
return chart
- def createSplineChart(self):
+ def create_spline_chart(self):
chart = QChart()
chart.setTitle("Spline chart")
name = "Series "
@@ -285,7 +285,7 @@ class ThemeWidget(QWidget):
return chart
- def updateUI(self):
+ def update_ui(self):
def set_colors(window_color, text_color):
pal = self.window().palette()
pal.setColor(QPalette.Window, window_color)
diff --git a/examples/charts/chartthemes/themewidget.ui b/examples/charts/chartthemes/themewidget.ui
index 9ea2bb7c4..ad1e02f06 100644
--- a/examples/charts/chartthemes/themewidget.ui
+++ b/examples/charts/chartthemes/themewidget.ui
@@ -76,28 +76,28 @@
<sender>themeComboBox</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>ThemeWidgetForm</receiver>
- <slot>updateUI()</slot>
+ <slot>update_ui()</slot>
</connection>
<connection>
<sender>antialiasCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>ThemeWidgetForm</receiver>
- <slot>updateUI()</slot>
+ <slot>update_ui()</slot>
</connection>
<connection>
<sender>legendComboBox</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>ThemeWidgetForm</receiver>
- <slot>updateUI()</slot>
+ <slot>update_ui()</slot>
</connection>
<connection>
<sender>animatedComboBox</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>ThemeWidgetForm</receiver>
- <slot>updateUI()</slot>
+ <slot>update_ui()</slot>
</connection>
</connections>
<slots>
- <slot>updateUI()</slot>
+ <slot>update_ui()</slot>
</slots>
</ui>
diff --git a/examples/charts/chartthemes/ui_themewidget.py b/examples/charts/chartthemes/ui_themewidget.py
index d2fdf55bc..e6e937dae 100644
--- a/examples/charts/chartthemes/ui_themewidget.py
+++ b/examples/charts/chartthemes/ui_themewidget.py
@@ -3,19 +3,19 @@
################################################################################
## Form generated from reading UI file 'themewidget.ui'
##
-## Created by: Qt User Interface Compiler version 5.14.0
+## Created by: Qt User Interface Compiler version 6.2.0
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
-from PySide6.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
- QRect, QSize, QUrl, Qt)
-from PySide6.QtGui import (QColor, QFont, QIcon, QPixmap)
+from PySide6.QtCore import *
+from PySide6.QtGui import *
from PySide6.QtWidgets import *
+
class Ui_ThemeWidgetForm(object):
def setupUi(self, ThemeWidgetForm):
- if ThemeWidgetForm.objectName():
+ if not ThemeWidgetForm.objectName():
ThemeWidgetForm.setObjectName(u"ThemeWidgetForm")
ThemeWidgetForm.resize(900, 600)
self.gridLayout = QGridLayout(ThemeWidgetForm)
@@ -67,10 +67,10 @@ class Ui_ThemeWidgetForm(object):
self.retranslateUi(ThemeWidgetForm)
- self.themeComboBox.currentIndexChanged.connect(ThemeWidgetForm.updateUI)
- self.antialiasCheckBox.toggled.connect(ThemeWidgetForm.updateUI)
- self.legendComboBox.currentIndexChanged.connect(ThemeWidgetForm.updateUI)
- self.animatedComboBox.currentIndexChanged.connect(ThemeWidgetForm.updateUI)
+ self.themeComboBox.currentIndexChanged.connect(ThemeWidgetForm.update_ui)
+ self.antialiasCheckBox.toggled.connect(ThemeWidgetForm.update_ui)
+ self.legendComboBox.currentIndexChanged.connect(ThemeWidgetForm.update_ui)
+ self.animatedComboBox.currentIndexChanged.connect(ThemeWidgetForm.update_ui)
QMetaObject.connectSlotsByName(ThemeWidgetForm)
# setupUi
@@ -80,5 +80,6 @@ class Ui_ThemeWidgetForm(object):
self.animatedLabel.setText(QCoreApplication.translate("ThemeWidgetForm", u"Animation:", None))
self.legendLabel.setText(QCoreApplication.translate("ThemeWidgetForm", u"Legend:", None))
self.antialiasCheckBox.setText(QCoreApplication.translate("ThemeWidgetForm", u"Anti-aliasing", None))
+ pass
# retranslateUi
diff --git a/examples/charts/donutbreakdown/donutbreakdown.py b/examples/charts/donutbreakdown/donutbreakdown.py
index 51b0956ca..320156bc9 100644
--- a/examples/charts/donutbreakdown/donutbreakdown.py
+++ b/examples/charts/donutbreakdown/donutbreakdown.py
@@ -59,7 +59,7 @@ class MainSlice(QPieSlice):
def get_breakdown_series(self):
return self.breakdown_series
- def setName(self, name):
+ def set_name(self, name):
self.name = name
def name(self):
@@ -83,7 +83,7 @@ class DonutBreakdownChart(QChart):
# add breakdown series as a slice to center pie
main_slice = MainSlice(breakdown_series)
- main_slice.setName(breakdown_series.name())
+ main_slice.set_name(breakdown_series.name())
main_slice.setValue(breakdown_series.sum())
self.main_series.append(main_slice)
diff --git a/examples/charts/legend/legend.py b/examples/charts/legend/legend.py
index 71fd94885..639e28f68 100644
--- a/examples/charts/legend/legend.py
+++ b/examples/charts/legend/legend.py
@@ -156,7 +156,7 @@ class MainWidget(QWidget):
self.legend_height.setMaximum(chart_viewrect.height())
self.legend_height.setValue(75)
- def hideLegendSpinbox(self):
+ def hide_legend_spinbox(self):
self.legend_settings.setVisible(False)
def toggle_attached(self):
@@ -172,7 +172,7 @@ class MainWidget(QWidget):
else:
legend.attachToChart()
legend.setBackgroundVisible(False)
- self.hideLegendSpinbox()
+ self.hide_legend_spinbox()
self.update()
def add_barset(self):
diff --git a/examples/charts/lineandbar/lineandbar.py b/examples/charts/lineandbar/lineandbar.py
index 219da17b5..a3601c162 100644
--- a/examples/charts/lineandbar/lineandbar.py
+++ b/examples/charts/lineandbar/lineandbar.py
@@ -65,46 +65,46 @@ class TestChart(QMainWindow):
self.set3.append([5, 6, 7, 3, 4, 5])
self.set4.append([9, 7, 5, 3, 1, 2])
- self.barSeries = QBarSeries()
- self.barSeries.append(self.set0)
- self.barSeries.append(self.set1)
- self.barSeries.append(self.set2)
- self.barSeries.append(self.set3)
- self.barSeries.append(self.set4)
-
- self.lineSeries = QLineSeries()
- self.lineSeries.setName("trend")
- self.lineSeries.append(QPoint(0, 4))
- self.lineSeries.append(QPoint(1, 15))
- self.lineSeries.append(QPoint(2, 20))
- self.lineSeries.append(QPoint(3, 4))
- self.lineSeries.append(QPoint(4, 12))
- self.lineSeries.append(QPoint(5, 17))
+ self._bar_series = QBarSeries()
+ self._bar_series.append(self.set0)
+ self._bar_series.append(self.set1)
+ self._bar_series.append(self.set2)
+ self._bar_series.append(self.set3)
+ self._bar_series.append(self.set4)
+
+ self._line_series = QLineSeries()
+ self._line_series.setName("trend")
+ self._line_series.append(QPoint(0, 4))
+ self._line_series.append(QPoint(1, 15))
+ self._line_series.append(QPoint(2, 20))
+ self._line_series.append(QPoint(3, 4))
+ self._line_series.append(QPoint(4, 12))
+ self._line_series.append(QPoint(5, 17))
self.chart = QChart()
- self.chart.addSeries(self.barSeries)
- self.chart.addSeries(self.lineSeries)
+ self.chart.addSeries(self._bar_series)
+ self.chart.addSeries(self._line_series)
self.chart.setTitle("Line and barchart example")
self.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
- self.axisX = QBarCategoryAxis()
- self.axisX.append(self.categories)
- self.chart.setAxisX(self.axisX, self.lineSeries)
- self.chart.setAxisX(self.axisX, self.barSeries)
- self.axisX.setRange("Jan", "Jun")
+ self._axis_x = QBarCategoryAxis()
+ self._axis_x.append(self.categories)
+ self.chart.setAxisX(self._axis_x, self._line_series)
+ self.chart.setAxisX(self._axis_x, self._bar_series)
+ self._axis_x.setRange("Jan", "Jun")
- self.axisY = QValueAxis()
- self.chart.setAxisY(self.axisY, self.lineSeries)
- self.chart.setAxisY(self.axisY, self.barSeries)
- self.axisY.setRange(0, 20)
+ self._axis_y = QValueAxis()
+ self.chart.setAxisY(self._axis_y, self._line_series)
+ self.chart.setAxisY(self._axis_y, self._bar_series)
+ self._axis_y.setRange(0, 20)
self.chart.legend().setVisible(True)
self.chart.legend().setAlignment(Qt.AlignBottom)
- self.chartView = QChartView(self.chart)
- self.chartView.setRenderHint(QPainter.Antialiasing)
+ self._chart_view = QChartView(self.chart)
+ self._chart_view.setRenderHint(QPainter.Antialiasing)
- self.setCentralWidget(self.chartView)
+ self.setCentralWidget(self._chart_view)
if __name__ == "__main__":
diff --git a/examples/charts/linechart/linechart.py b/examples/charts/linechart/linechart.py
index 84cd0c8b3..ce81c36d8 100644
--- a/examples/charts/linechart/linechart.py
+++ b/examples/charts/linechart/linechart.py
@@ -69,10 +69,10 @@ class TestChart(QMainWindow):
self.chart.createDefaultAxes()
self.chart.setTitle("Simple line chart example")
- self.chartView = QChartView(self.chart)
- self.chartView.setRenderHint(QPainter.Antialiasing)
+ self._chart_view = QChartView(self.chart)
+ self._chart_view.setRenderHint(QPainter.Antialiasing)
- self.setCentralWidget(self.chartView)
+ self.setCentralWidget(self._chart_view)
if __name__ == "__main__":
diff --git a/examples/charts/logvalueaxis/logvalueaxis.py b/examples/charts/logvalueaxis/logvalueaxis.py
index c5e90c584..180940b73 100644
--- a/examples/charts/logvalueaxis/logvalueaxis.py
+++ b/examples/charts/logvalueaxis/logvalueaxis.py
@@ -64,25 +64,25 @@ class TestChart(QMainWindow):
self.chart.legend().hide()
self.chart.setTitle("Logarithmic axis example")
- self.axisX = QValueAxis()
- self.axisX.setTitleText("Data point")
- self.axisX.setLabelFormat("%i")
- self.axisX.setTickCount(self.series.count())
- self.chart.addAxis(self.axisX, Qt.AlignBottom)
- self.series.attachAxis(self.axisX)
-
- self.axisY = QLogValueAxis()
- self.axisY.setTitleText("Values")
- self.axisY.setLabelFormat("%g")
- self.axisY.setBase(8.0)
- self.axisY.setMinorTickCount(-1)
- self.chart.addAxis(self.axisY, Qt.AlignLeft)
- self.series.attachAxis(self.axisY)
-
- self.chartView = QChartView(self.chart)
- self.chartView.setRenderHint(QPainter.Antialiasing)
-
- self.setCentralWidget(self.chartView)
+ self._axis_x = QValueAxis()
+ self._axis_x.setTitleText("Data point")
+ self._axis_x.setLabelFormat("%i")
+ self._axis_x.setTickCount(self.series.count())
+ self.chart.addAxis(self._axis_x, Qt.AlignBottom)
+ self.series.attachAxis(self._axis_x)
+
+ self._axis_y = QLogValueAxis()
+ self._axis_y.setTitleText("Values")
+ self._axis_y.setLabelFormat("%g")
+ self._axis_y.setBase(8.0)
+ self._axis_y.setMinorTickCount(-1)
+ self.chart.addAxis(self._axis_y, Qt.AlignLeft)
+ self.series.attachAxis(self._axis_y)
+
+ self._chart_view = QChartView(self.chart)
+ self._chart_view.setRenderHint(QPainter.Antialiasing)
+
+ self.setCentralWidget(self._chart_view)
if __name__ == "__main__":
diff --git a/examples/charts/memoryusage/memoryusage.py b/examples/charts/memoryusage/memoryusage.py
index 032e79541..aac03b00f 100644
--- a/examples/charts/memoryusage/memoryusage.py
+++ b/examples/charts/memoryusage/memoryusage.py
@@ -48,48 +48,48 @@ from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtCharts import QChart, QChartView, QPieSeries
-def runProcess(command, arguments):
+def run_process(command, arguments):
process = QProcess()
process.start(command, arguments)
process.waitForFinished()
std_output = process.readAllStandardOutput().data().decode('utf-8')
return std_output.split('\n')
-def getMemoryUsage():
+def get_memory_usage():
result = []
if sys.platform == 'win32':
# Windows: Obtain memory usage in KB from 'tasklist'
- for line in runProcess('tasklist', [])[3:]:
+ for line in run_process('tasklist', [])[3:]:
if len(line) >= 74:
command = line[0:23].strip()
if command.endswith('.exe'):
command = command[0:len(command) - 4]
- memoryUsage = float(line[64:74].strip().replace(',', '').replace('.', ''))
+ memory_usage = float(line[64:74].strip().replace(',', '').replace('.', ''))
legend = ''
- if memoryUsage > 10240:
- mb = memoryUsage / 1024
+ if memory_usage > 10240:
+ mb = memory_usage / 1024
legend = f'{command} {mb}M'
else:
- legend = f'{command} {memoryUsage}K'
- result.append([legend, memoryUsage])
+ legend = f'{command} {memory_usage}K'
+ result.append([legend, memory_usage])
else:
# Unix: Obtain memory usage percentage from 'ps'
- psOptions = ['-e', 'v']
- memoryColumn = 8
- commandColumn = 9
+ ps_options = ['-e', 'v']
+ memory_column = 8
+ command_column = 9
if sys.platform == 'darwin':
- psOptions = ['-e', '-v']
- memoryColumn = 11
- commandColumn = 12
- for line in runProcess('ps', psOptions):
+ ps_options = ['-e', '-v']
+ memory_column = 11
+ command_column = 12
+ for line in run_process('ps', ps_options):
tokens = line.split(None)
- if len(tokens) > commandColumn and "PID" not in tokens: # Percentage and command
- command = tokens[commandColumn]
+ if len(tokens) > command_column and "PID" not in tokens: # Percentage and command
+ command = tokens[command_column]
if not command.startswith('['):
command = os.path.basename(command)
- memoryUsage = round(float(tokens[memoryColumn].replace(',', '.')))
- legend = f'{command} {memoryUsage}%'
- result.append([legend, memoryUsage])
+ memory_usage = round(float(tokens[memory_column].replace(',', '.')))
+ legend = f'{command} {memory_usage}%'
+ result.append([legend, memory_usage])
result.sort(key = lambda x: x[1], reverse=True)
return result
@@ -101,12 +101,12 @@ class MainWindow(QMainWindow):
self.setWindowTitle('Memory Usage')
- memoryUsage = getMemoryUsage()
- if len(memoryUsage) > 5:
- memoryUsage = memoryUsage[0:4]
+ memory_usage = get_memory_usage()
+ if len(memory_usage) > 5:
+ memory_usage = memory_usage[0:4]
self.series = QPieSeries()
- for item in memoryUsage:
+ for item in memory_usage:
self.series.append(item[0], item[1])
slice = self.series.slices()[0]
@@ -114,14 +114,14 @@ class MainWindow(QMainWindow):
slice.setLabelVisible()
self.chart = QChart()
self.chart.addSeries(self.series)
- self.chartView = QChartView(self.chart)
- self.setCentralWidget(self.chartView)
+ self._chart_view = QChartView(self.chart)
+ self.setCentralWidget(self._chart_view)
if __name__ == '__main__':
app = QApplication(sys.argv)
- mainWin = MainWindow()
- availableGeometry = mainWin.screen().availableGeometry()
- size = availableGeometry.height() * 3 / 4
- mainWin.resize(size, size)
- mainWin.show()
+ main_win = MainWindow()
+ available_geometry = main_win.screen().availableGeometry()
+ size = available_geometry.height() * 3 / 4
+ main_win.resize(size, size)
+ main_win.show()
sys.exit(app.exec_())
diff --git a/examples/charts/piechart/piechart.py b/examples/charts/piechart/piechart.py
index 29947263d..ebb602b0c 100644
--- a/examples/charts/piechart/piechart.py
+++ b/examples/charts/piechart/piechart.py
@@ -71,10 +71,10 @@ class TestChart(QMainWindow):
self.chart.setTitle('Simple piechart example')
self.chart.legend().hide()
- self.chartView = QChartView(self.chart)
- self.chartView.setRenderHint(QPainter.Antialiasing)
+ self._chart_view = QChartView(self.chart)
+ self._chart_view.setRenderHint(QPainter.Antialiasing)
- self.setCentralWidget(self.chartView)
+ self.setCentralWidget(self._chart_view)
if __name__ == "__main__":
diff --git a/examples/charts/temperaturerecords/temperaturerecords.py b/examples/charts/temperaturerecords/temperaturerecords.py
index 3a8a86f42..b37b70db2 100644
--- a/examples/charts/temperaturerecords/temperaturerecords.py
+++ b/examples/charts/temperaturerecords/temperaturerecords.py
@@ -69,16 +69,16 @@ class MainWindow(QMainWindow):
categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"]
- axisX = QBarCategoryAxis()
- axisX.append(categories)
- axisX.setTitleText("Month")
- chart.addAxis(axisX, Qt.AlignBottom)
- axisY = QValueAxis()
- axisY.setRange(-52, 52)
- axisY.setTitleText("Temperature [&deg;C]")
- chart.addAxis(axisY, Qt.AlignLeft)
- series.attachAxis(axisX)
- series.attachAxis(axisY)
+ axis_x = QBarCategoryAxis()
+ axis_x.append(categories)
+ axis_x.setTitleText("Month")
+ chart.addAxis(axis_x, Qt.AlignBottom)
+ axis_y = QValueAxis()
+ axis_y.setRange(-52, 52)
+ axis_y.setTitleText("Temperature [&deg;C]")
+ chart.addAxis(axis_y, Qt.AlignLeft)
+ series.attachAxis(axis_x)
+ series.attachAxis(axis_y)
chart.legend().setVisible(True)
chart.legend().setAlignment(Qt.AlignBottom)