-
Notifications
You must be signed in to change notification settings - Fork 4
/
osx_main.py
26 lines (19 loc) · 856 Bytes
/
osx_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
import rumps
import work_percent
def main(start, end, decimal_places):
# Make menu item to show what time is set when a user clicks on the percentage
menu_item = rumps.MenuItem('Time set from {} to {}'.format(start, end))
percent_tracker = work_percent.WorkPercent(start, end, decimal_places)
app = WorkPercentApp(percent_tracker, decimal_places)
app.menu.add(menu_item)
app.run()
class WorkPercentApp(rumps.App):
def __init__(self, percent_tracker, decimal_places):
super().__init__("Work Percentage App")
self.percent_tracker = percent_tracker
self.decimal_places = decimal_places
# Run every second
@rumps.timer(1)
def refresh_timer(self, _):
display_string = '{0:.{1}f}%'.format(self.percent_tracker.work_percent(), self.decimal_places)
self.title = display_string