user3077503
user3077503

Reputation:

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>")

Upvotes: 0

Views: 4200

Answers (2)

Lester_wu
Lester_wu

Reputation: 171

Because QLabel() is in PyQt5.QtWidgets, please try following : from PyQt5.QtWidgets import QLabel

Upvotes: 1

antimatter
antimatter

Reputation: 3480

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

from PyQt5.QtWidgets import *

Upvotes: 2

Related Questions