Skip to content

Instantly share code, notes, and snippets.

@gdamjan
Created January 27, 2019 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdamjan/14dde395c2e727196143d878773f8e33 to your computer and use it in GitHub Desktop.
Save gdamjan/14dde395c2e727196143d878773f8e33 to your computer and use it in GitHub Desktop.
PyQt5 QButton, emoji and QDesktopServices.openUrl
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtCore import pyqtSlot, QUrl
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Button demo")
button = QPushButton('Click me \U0001F951', self)
button.clicked.connect(self.on_click)
@pyqtSlot()
def on_click(self):
print('PyQt5 button click')
url = QUrl('http://example.com')
QDesktopServices.openUrl(url)
if __name__ == '__main__':
app = QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment