
import sys
from PyQt5.QtWidgets import QApplication, QLabel, QLineEdit, QPushButton, QVBoxLayout, QWidget
def execute_code():
code = code_input.text()
exec(code)
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("我的Python代码执行器")
window.setGeometry(400, 400, 400, 200)
code_label = QLabel("输入要执行的Python代码:")
code_input = QLineEdit()
code_input.setFixedSize(400, 200)
execute_button = QPushButton("执行")
layout = QVBoxLayout()
layout.addWidget(code_label)
layout.addWidget(code_input)
layout.addWidget(execute_button)
window.setLayout(layout)
execute_button.clicked.connect(execute_code)
window.show()
sys.exit(app.exec_())
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38