Buenas tardes estoy tratando de mostrar la hora en un statusbar en pyqt. Este es mi código:
from PyQt5.QtWidgets import QMainWindow,QApplication, QDesktopWidget,QLabel
from PyQt5.QtCore import *
from PyQt5 import uic
from PyQt5 import QtCore
import time
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("23.ui",self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.bmax.clicked.connect(self.W_Size)
self.bmin.clicked.connect(self.showMinimized)
self.bclose.clicked.connect(self.close)
self.statusbar.showMessage(self.hora) # error
self.statusbar.setStyleSheet("position:right;") # No cambia la posision del texto
def mousePressEvent(self,event):
if event.button() == QtCore.Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self,event):
if event.buttons() == QtCore.Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
def W_Size(self):
if self.isMaximized():
self.showNormal()
qRect = self.frameGeometry()
centerPoint = QDesktopWidget().availableGeometry().center()
qRect.moveCenter(centerPoint)
self.move(qRect.topLeft())
else:
self.showMaximized()
def hora(self):
self.time = ''
while True:
self.time2 = self.time.strftime("%I:%M:%S %p")
if self.time2 != self.time1:
self.time1 = self.time2
print(self.time1)
app = QApplication([])
p = Principal()
p.show()
app.exec_()
pero me lanza el siguiente error:
libpng warning: iCCP: CRC error
Traceback (most recent call last):
File "C:\Users\Angel\Desktop\23\1.py", line 53, in <module>
p = Principal()
File "C:\Users\Angel\Desktop\23\1.py", line 19, in __init__
self.statusbar.showMessage(self.hora)
TypeError: showMessage(self, str, msecs: int = 0): argument 1 has unexpected type 'method'
[Finished in 2.8s with exit code 1]
[shell_cmd: python -u "C:\Users\Angel\Desktop\23\1.py"]
[dir: C:\Users\Angel\Desktop\23]
[path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\ProgramData\chocolatey\bin;C:\Program Files\Java\jdk1.8.0_172\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Git\cmd;C:\Users\Angel\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\Angel\AppData\Local\Programs\Python\Python36\;C:\Users\Angel\AppData\Roaming\npm;C:\Users\Angel\AppData\Local\Yarn\bin;C:\Users\Angel\AppData\Local\Android\Sdk\platform-tools]