artiq/artiq/applets/big_number.py

31 lines
812 B
Python
Raw Normal View History

#!/usr/bin/env python3
2016-01-03 00:46:33 +08:00
from PyQt5 import QtWidgets
2016-01-03 00:46:33 +08:00
from artiq.applets.simple import SimpleApplet
class NumberWidget(QtWidgets.QLCDNumber):
def __init__(self, args):
QtWidgets.QLCDNumber.__init__(self)
self.setDigitCount(args.digit_count)
self.dataset_name = args.dataset
2016-01-10 22:12:00 +08:00
def data_changed(self, data, mods):
2016-01-03 00:46:33 +08:00
try:
n = float(data[self.dataset_name][1])
except (KeyError, ValueError, TypeError):
n = "---"
self.display(n)
def main():
applet = SimpleApplet(NumberWidget)
applet.add_dataset("dataset", "dataset to show")
applet.argparser.add_argument("--digit-count", type=int, default=10,
help="total number of digits to show")
applet.run()
if __name__ == "__main__":
main()