本文整理汇总了Python中PySide2.QtWidgets.QApplication.desktop方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.desktop方法的具体用法?Python QApplication.desktop怎么用?Python QApplication.desktop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide2.QtWidgets.QApplication
的用法示例。
在下文中一共展示了QApplication.desktop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QWebEngineView
# 需要导入模块: from PySide2.QtWidgets import QApplication [as 别名]
# 或者: from PySide2.QtWidgets.QApplication import desktop [as 别名]
self.webEngineView = QWebEngineView()
self.setCentralWidget(self.webEngineView)
initialUrl = 'http://qt.io'
self.addressLineEdit.setText(initialUrl)
self.webEngineView.load(QUrl(initialUrl))
self.webEngineView.page().titleChanged.connect(self.setWindowTitle)
self.webEngineView.page().urlChanged.connect(self.urlChanged)
def load(self):
url = QUrl.fromUserInput(self.addressLineEdit.text())
if url.isValid():
self.webEngineView.load(url)
def back(self):
self.webEngineView.page().triggerAction(QWebEnginePage.Back)
def forward(self):
self.webEngineView.page().triggerAction(QWebEnginePage.Forward)
def urlChanged(self, url):
self.addressLineEdit.setText(url.toString())
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWin = MainWindow()
availableGeometry = app.desktop().availableGeometry(mainWin)
mainWin.resize(availableGeometry.width() * 2 / 3, availableGeometry.height() * 2 / 3)
mainWin.show()
sys.exit(app.exec_())
示例2: DonutBreakdownChart
# 需要导入模块: from PySide2.QtWidgets import QApplication [as 别名]
# 或者: from PySide2.QtWidgets.QApplication import desktop [as 别名]
series2 = QtCharts.QPieSeries()
series2.setName("Renewables")
series2.append("Wood fuels", 319663)
series2.append("Hydro power", 45875)
series2.append("Wind power", 1060)
series3 = QtCharts.QPieSeries()
series3.setName("Others")
series3.append("Nuclear energy", 238789)
series3.append("Import energy", 37802)
series3.append("Other", 32441)
donut_breakdown = DonutBreakdownChart()
donut_breakdown.setAnimationOptions(QtCharts.QChart.AllAnimations)
donut_breakdown.setTitle("Total consumption of energy in Finland 2010")
donut_breakdown.legend().setAlignment(Qt.AlignRight)
donut_breakdown.add_breakdown_series(series1, Qt.red)
donut_breakdown.add_breakdown_series(series2, Qt.darkGreen)
donut_breakdown.add_breakdown_series(series3, Qt.darkBlue)
window = QMainWindow()
chart_view = QtCharts.QChartView(donut_breakdown)
chart_view.setRenderHint(QPainter.Antialiasing)
window.setCentralWidget(chart_view)
available_geometry = app.desktop().availableGeometry(window)
size = available_geometry.height() * 0.75
window.resize(size, size * 0.8)
window.show()
sys.exit(app.exec_())