Python Forum
pyqt6 and random emoji
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyqt6 and random emoji
#1
Just thought it was kinda cool.

from PyQt6.QtWidgets import (QLabel, QApplication, QWidget, QMainWindow, QVBoxLayout, QPushButton)
import random as rnd
class Window(QMainWindow):
    def __init__(self):
        super().__init__()
        container = QVBoxLayout()

        self.label = QLabel()
        self.label.setStyleSheet('font-size: 100px;')

        button = QPushButton('Random Emoji')
        button.pressed.connect(self.get_emoji)

        container.addWidget(self.label)
        container.addWidget(button)

        widget = QWidget()
        widget.setLayout(container)
        self.setCentralWidget(widget)

        self.get_emoji()

    def get_emoji(self):
        emojies = {
            'fireman': '\U0001F468\U0000200D\U0001F692',
            'astronaut': '\U0001F469\U0000200D\U0001F680',
            'police': '\U0001F46E', 'king': '\U0001FAC5', 'santa': '\U0001F385',
            'royal guard': '\U0001F482', 'walking': '\U0001F6B6', 'monkey': '\U0001F412',
            'ninja': '\U0001F977', 'gorilla': '\U0001F98D', 'fox': '\U0001F98A', 'mushroom': '\U0001F344',
            'worker': '\U0001F477', 'hut': '\U0001F6D6', 'house': '\U0001F3E0', 'castle': '\U0001F3F0',
            'stone head': '\U0001F5FF', 'flag': '\U0001F1FA\U0001F1F8'
        }
        
        keys = [key for key in emojies.keys()]

        key = rnd.choice(keys)

        self.label.setText(emojies[key])



app = QApplication([])
window = Window()
window.show()
app.exec()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
pyqt6 and random emoji - by menator01 - Sep-19-2022, 06:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Basic PyQt6 Example of a timer menator01 0 4,603 May-27-2022, 05:24 PM
Last Post: menator01
  PyQt6 Version of weather app menator01 3 3,237 Jan-30-2022, 12:32 AM
Last Post: menator01

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020