snakeware

Python-based Linux distro for x86-64 and RPi
git clone git://squid-tech.com/snakeware.git
Log | Files | Refs | README

commit 979de2b807521a20f427d49e5aec815c24355099
parent 28a3e68d38d38703faae18b9c9e0502a81e70b63
Author: Josh Moore <jxm5210@g.rit.edu>
Date:   Sat, 30 May 2020 09:31:50 -0400

Merge pull request #12 from Abdur-rahmaanJ/clock-add

Added clock under tools
Diffstat:
Asnakewm/apps/tools/clock/README.txt | 6++++++
Asnakewm/apps/tools/clock/__init__.py | 13+++++++++++++
Asnakewm/apps/tools/clock/clock.py | 45+++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/snakewm/apps/tools/clock/README.txt b/snakewm/apps/tools/clock/README.txt @@ -0,0 +1,5 @@ +Clock by Abdur-Rahmaan Janhangeer + +github: https://github.com/Abdur-rahmaanJ +mail: arj.python@gmail.com +date: 30 May 2020+ \ No newline at end of file diff --git a/snakewm/apps/tools/clock/__init__.py b/snakewm/apps/tools/clock/__init__.py @@ -0,0 +1,13 @@ +from .clock import SnakeClock + +def load(manager, params): + """ + Create and launch a new instance of SnakeCalc. + """ + # default position + pos = (100, 100) + + if params is not None and len(params) > 0: + pos = params[0] + + SnakeClock(pos, manager) diff --git a/snakewm/apps/tools/clock/clock.py b/snakewm/apps/tools/clock/clock.py @@ -0,0 +1,44 @@ +import pygame +import pygame_gui + +import time + +class SnakeClock(pygame_gui.elements.UIWindow): + + def __init__(self, pos, manager): + super().__init__( + pygame.Rect(pos, (300, 100)), + manager=manager, + window_display_title='clock', + object_id='#clockterm', + resizable=True + ) + + self.textbox = pygame_gui.elements.UITextBox( + '', + relative_rect=pygame.Rect(0, 1, 268, 40), + manager=manager, + container=self, + anchors={ + 'left': 'left', + 'right': 'right', + 'top': 'top', + 'bottom': 'bottom' + } + ) + + + + def process_event(self, event): + super().process_event(event) + + def update(self, time_delta): + super().update(time_delta) + + t = time.localtime() + current_time = time.strftime("%H:%M:%S", t) + self.set_text(current_time) + + def set_text(self, text): + self.textbox.html_text = text + self.textbox.rebuild()+ \ No newline at end of file