简体   繁体   中英

PyQt5 QLabel errors

In PyQT4 there is a QLabel()

While when I use it in PyQT5 it throws an undefined error.

Can anyone one tell me what is Qlabel in the PyQT4 ?

Or maybe I am wrong?

Here is my code:

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

app = QGuiApplication(sys.argv)
try:
    due = QTime.currentTime()
    message = "Alert!"
    if len(sys.argv) < 2 :
        raise ValueError
    hours, min = sys.argv[1].split(":")
    due = Qtime(int(hours), int(min))
    if not due.isValid():
        raise ValueError
    if len(sys.argv) > 2 :
        message = " ".join(sys.argv[2:])
except ValueError :
    message = "Alert: alert.pyw"

if QTime.currentTime() < due :
    time.sleep(20) #20 Seconds
label = QLabel("<p>Message</p>")

You should read the docs I posted. Add this import statement with the others:

from PyQt5.QtWidgets import *

由于QLabel()位于PyQt5.QtWidgets中,请尝试以下操作: 从PyQt5.QtWidgets导入QLabel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM