-
Notifications
You must be signed in to change notification settings - Fork 159
/
main.py
31 lines (27 loc) · 980 Bytes
/
main.py
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
from fbs_runtime.application_context.PyQt5 import ApplicationContext
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout
import requests
import sys
class MainWindow(QWidget):
def __init__(self):
super().__init__()
text = QLabel()
text.setWordWrap(True)
button = QPushButton('Next quote >')
button.clicked.connect(lambda: text.setText(_get_quote()))
layout = QVBoxLayout()
layout.addWidget(text)
layout.addWidget(button)
layout.setAlignment(button, Qt.AlignHCenter)
self.setLayout(layout)
def _get_quote():
return requests.get('https://build-system.fman.io/quote').text
if __name__ == '__main__':
appctxt = ApplicationContext()
stylesheet = appctxt.get_resource('styles.qss')
appctxt.app.setStyleSheet(open(stylesheet).read())
window = MainWindow()
window.show()
exit_code = appctxt.app.exec_()
sys.exit(exit_code)