diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-04-13 03:13:38 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-04-13 03:13:38 +0200 |
commit | 2d40789d934e9b1f77d8dea4baba54ed4ea99680 (patch) | |
tree | b4d12d6aefe692a9979d411502ed049629555400 | |
parent | print location (diff) | |
download | nightshift-2d40789d934e9b1f77d8dea4baba54ed4ea99680.tar.gz nightshift-2d40789d934e9b1f77d8dea4baba54ed4ea99680.tar.bz2 nightshift-2d40789d934e9b1f77d8dea4baba54ed4ea99680.tar.xz |
reduce flicker and make text on focused button bold0.2
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/interface.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/interface.py b/src/interface.py index 4dad289..805d6e2 100644 --- a/src/interface.py +++ b/src/interface.py @@ -55,24 +55,26 @@ def user_interface(): def ui_print(): + _button = lambda *i : ('[\033[1m%s\033[m]' if ui_state['focus'] in i else '<%s>') temperature = tuple([red_temperature] + list(red_temperatures)) brightness = [b * 100 for b in [red_brightness] + list(red_brightnesses)] - print('\033[H\033[2J', end = '') + print('\033[H', end = '') if red_running: lat, lon = red_location _if = lambda pn, v : pn[0] if v >= 0 else pn[1] - print('Location: %.4f°%s %.4f°%s' % (abs(lat), _if('NS', lat), abs(lon), _if('EW', lon))) - print('Temperature: %.0f K (day: %.0f K, night: %.0f K)' % tuple(temperature)) - print('Brightness: %.0f %% (day: %.0f %%, night: %.0f %%)' % tuple(brightness)) - print('Dayness: %.0f %%' % (red_period * 100)) - print('Enabled' if red_status else 'Disabled') - print() - print(('[%s]' if ui_state['focus'] == 0 else '<%s>') % ('Disable' if red_status else 'Enable'), end=' ') - print(('[%s]' if ui_state['focus'] == 1 else '<%s>') % 'Kill') + print('\033[2KLocation: %.4f°%s %.4f°%s' % (abs(lat), _if('NS', lat), abs(lon), _if('EW', lon))) + print('\033[2KTemperature: %.0f K (day: %.0f K, night: %.0f K)' % tuple(temperature)) + print('\033[2KBrightness: %.0f %% (day: %.0f %%, night: %.0f %%)' % tuple(brightness)) + print('\033[2KDayness: %.0f %%' % (red_period * 100)) + print('\033[2KEnabled' if red_status else 'Disabled') + print('\033[2K\n\033[2K', end = '') + print(_button(0) % ('Disable' if red_status else 'Enable'), end=' ') + print(_button(1) % 'Kill') else: - print('Not running') - print() - print('[%s]' % 'Revive') + print('\033[2KNot running') + print('\033[2K\n\033[2K', end = '') + print(_button(0, 1) % 'Revive') + print('\033[J') def ui_read(): |