{"id":21135,"date":"2024-01-12T11:06:18","date_gmt":"2024-01-12T03:06:18","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/?p=21135"},"modified":"2024-01-12T11:06:18","modified_gmt":"2024-01-12T03:06:18","slug":"pyqt5%e5%bc%80%e5%8f%91%e5%ae%89%e5%8d%93app%e6%93%8d%e4%bd%9c%e5%8a%9e%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2024\/21135\/","title":{"rendered":"pyqt5\u5f00\u53d1\u5b89\u5353app\u64cd\u4f5c\u529e\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"
PyQt5\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684Python GUI\u6846\u67b6\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u5f00\u53d1\u591a\u5e73\u53f0\u5e94\u7528\u7a0b\u5e8f\u3002\u540c\u65f6\uff0c\u901a\u8fc7QPython\u548cPyQt5\u7684\u7ed3\u5408\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aAndroid\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n
\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6b65\u9aa4\uff0c\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528PyQt5\u5f00\u53d1\u5b89\u5353\u5e94\u7528\uff1a<\/p>\n
1. \u5b89\u88c5PyQt5<\/p>\n
\u5b89\u88c5PyQt5\u4e4b\u524d\u9700\u8981\u5b89\u88c5Python\u73af\u5883\uff0c\u63a8\u8350\u4f7f\u7528Python3\u3002\u901a\u8fc7pip\u547d\u4ee4\u5373\u53ef\u5b89\u88c5PyQt5\uff1a`pip install PyQt5`<\/p>\n
2. \u5b89\u88c5 QPython<\/p>\n
QPython\u662f\u4e00\u4e2a\u8fd0\u884cPython\u7684\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\uff0c\u63d0\u4f9b\u4e86Python\u89e3\u91ca\u5668\u3001\u6807\u51c6\u5e93\u3001\u7f16\u8f91\u5668\u7b49\u529f\u80fd\u3002\u53ef\u4ee5\u5728Play Store\u4e2d\u641c\u7d22QPython\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n
3. \u5f00\u53d1\u5e94\u7528<\/p>\n
\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u5728QPython\u7684\u7f16\u8f91\u5668\u4e2d\u7f16\u5199\u4ee3\u7801\uff0c\u4f7f\u7528PyQt5\u7684\u8bed\u6cd5\u8fdb\u884c\u5f00\u53d1\u3002\u5bf9\u4e8e\u5e38\u89c1\u7684UI\u63a7\u4ef6\uff0c\u53ef\u4ee5\u901a\u8fc7Qt\u5b89\u5353app\u5236\u4f5c<\/a> Designer\u8fdb\u884c\u53ef\u89c6\u5316\u5f00\u53d1\u3002<\/p>\n \u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528PyQt5\u7684\u4f8b\u5b50\uff1a<\/p>\n “`<\/p>\n import sys<\/p>\n from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton<\/p>\n class Example(QWidget):<\/p>\n def __init__(self):<\/p>\n super().__init__()<\/p>\n self.initUI()<\/p>\n def initUI(self):<\/p>\n self.lbl = QLabel(“Hello World!”, self)<\/p>\n self.lbl.move(50, 50)<\/p>\n btn = QPushButton(“Quit”, self)<\/p>\n btn.clicked.connect(self.close)<\/p>\n btn.move(50, 100)<\/p>\n self.setGeometry(300, 300, 250, 150)<\/p>\n self.setWindowTitle(‘Hello World’)<\/p>\n