refactored and added clear_messages
This commit is contained in:
parent
706f97d95f
commit
df74472937
@ -116,6 +116,7 @@ class Application(wmoo.Application):
|
||||
ic("")
|
||||
ic(f"recepient: {recepient}")
|
||||
ic(f"message: {message}")
|
||||
self.clear_messages()
|
||||
|
||||
def draw_string(self, xstart, ystart, text):
|
||||
"""
|
||||
@ -175,25 +176,21 @@ class Application(wmoo.Application):
|
||||
for index, line in enumerate(self.lines[:6]):
|
||||
self.draw_string(9, 6 + (index * line_height), line[0])
|
||||
|
||||
def toggle_backlight(self, event):
|
||||
def toggle_backlite(self):
|
||||
"""
|
||||
Toggle the state of the dockapp background
|
||||
|
||||
Parameters:
|
||||
"""
|
||||
self.backlit = 1 - self.backlit
|
||||
self.draw_background()
|
||||
self.draw_all_text()
|
||||
|
||||
def backlight_off(self, event):
|
||||
def backlite_off(self):
|
||||
"""
|
||||
Turn off the backlight mode in response to a mouseclick
|
||||
|
||||
Parameters:
|
||||
"""
|
||||
self._flasher = 0
|
||||
if self.backlit:
|
||||
self.toggle_backlight(True)
|
||||
self.toggle_backlite()
|
||||
|
||||
def update(self):
|
||||
"""
|
||||
@ -206,7 +203,27 @@ class Application(wmoo.Application):
|
||||
self._count = 0
|
||||
if self._flasher:
|
||||
self._flasher -= 1
|
||||
self.toggle_backlight(True)
|
||||
self.toggle_backlite()
|
||||
|
||||
def clear_messages(self):
|
||||
"""
|
||||
Turn of backlite and zero out messages
|
||||
"""
|
||||
self.backlite_off()
|
||||
|
||||
def handle_buttonrelease(self, event):
|
||||
"""
|
||||
On left click zero out recieved messages and turn off backlite
|
||||
|
||||
Parameters:
|
||||
event (dict):
|
||||
button (int): 1 left click, 2 middle click, 3 right click
|
||||
type (str): buttonrelease
|
||||
x (int): x position of click
|
||||
y (int): y position of click
|
||||
"""
|
||||
if event['button'] == 1:
|
||||
self.clear_messages()
|
||||
|
||||
|
||||
def run_glib_mainloop():
|
||||
@ -240,7 +257,7 @@ def main():
|
||||
# 6x7 grey1=1 grey2=10 green1=18 green2=27
|
||||
app.draw_background()
|
||||
app.draw_all_text()
|
||||
app.addCallback(app.backlight_off, 'buttonrelease', area=(2,2,62,62))
|
||||
app.addCallback(app.handle_buttonrelease, 'buttonrelease', area=(2,2,62,62))
|
||||
|
||||
# Start the GLib main loop in a separate thread
|
||||
glib_thread = threading.Thread(target=run_glib_mainloop, daemon=True)
|
||||
|
Loading…
Reference in New Issue
Block a user