gpt4 book ai didi

python - PyQt 入门

转载 作者:太空狗 更新时间:2023-10-30 02:00:25 25 4
gpt4 key购买 nike

<分区>

我正在测试 使用 Python 和 Qt 进行快速 GUI 编程 中的一些示例,但在这里或哪里遇到了绊脚石。当我复制到以下练习时(逐字,从书中):

import sys
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)

try:
due = QTime.currentTime()
message = "Alert!"

if len(sys.argv) < 2:
raise ValueError

hours, mins = sys.argv[1].split(":")
due = QTime(int(hours), int(mins))

if not due.isValid():
raise ValueError
if len(sys.argv) > 2:
message = " ".join(sys.argv[2:])

except ValueError:
message = "Usage: alert.pyw HH:MM [optional message*]" # 24hr Clock

while QTime.currentTime() < due:
time.sleep(20) # 20 seconds

label = QLabel("<font color=red size=72><b>" + message + "</b></font>")

label.setWindowFlags(Qt.SplashScreen)
label.show()

QTimer.singleShot(60000, app.quit) # 1 minute

app.exec_()

我收到以下错误:

andy@ASUSix:~/Documents/Programming/Python/PyQt$ from: can't read /var/mail/PyQt4.QtCore
from: can't read /var/mail/PyQt4.QtGui
./alert.pyw: line 6: syntax error near unexpected token `('
./alert.pyw: line 6: `app = QApplication(sys.argv)

这里出了什么问题?我的 PATH 设置不正确吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com