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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| class Window(QMainWindow):
def __init__(self, hour, day, wallpaper):
super().__init__()
#self.acceptDrops()
# set the title
self.setWindowTitle(win_title)
# this will hide the title bar
self.setWindowFlag(Qt.WindowType.FramelessWindowHint)
# setting the geometry of window
self.setGeometry(0, 0, 1920, 1080)
# creating label
self.label = QLabel(self)
# loading image
#self.pixmap = QPixmap(path)
self.pixmap = QPixmap.fromImage(wallpaper)
# adding image to label
self.label.setPixmap(self.pixmap)
# Optional, resize label to image size
self.label.resize(self.pixmap.width(),
self.pixmap.height())
# creating label1
self.label1 = QLabel(self)
self.label1.resize(1920, 1080)
self.label1.setText(hour)
self.label1.setFont(QFont('French Script MT', 200))
self.label1.move(0, -150)
self.label1.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.label1.setStyleSheet("color : black; font-weight: bold")
#QT_SCALE_FACTOR = 1.25
# create pyqt5 app
app = QApplication.instance()
if not app:
app = QApplication(sys.argv)
#getWallpaper()
date = time.strftime('%A, %d %B, %Y %H:%M:%S').capitalize()
date = date.split(' ')
hour = date[-1]
day = ' '.join((date[0:-1]))
#win = Window(hour, day, wallpaper)
#win.import_meteo()
win.show()
#win.hide()
QTimer.singleShot(200, boucle)
screen = app.primaryScreen()
size = screen.size()
print('Size: %d x %d' % (size.width(), size.height()))
rect = screen.availableGeometry()
print('Available: %d x %d' % (rect.width(), rect.height()))
app.exec() |
Partager