Add more infos
parent
2617ce35ac
commit
dbddbd36c5
|
@ -86,25 +86,47 @@ class InfoButton(Button):
|
|||
super(InfoButton, self).__init__(rect)
|
||||
|
||||
self.enabled = False
|
||||
self.cache = False
|
||||
|
||||
self.font = pygame.font.Font(None, 25)
|
||||
self.logo = pygame.image.load(os.path.dirname(os.path.realpath(__file__)) + '/raspberrypi.png').convert_alpha()
|
||||
|
||||
def date(self):
|
||||
if not self.cache:
|
||||
self.date_string = str(time.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
return self.date_string
|
||||
|
||||
def disk_usage(self):
|
||||
if not self.cache:
|
||||
st = os.statvfs('/')
|
||||
free = round(st.f_bavail * st.f_frsize / 1073741824)
|
||||
total = round(st.f_blocks * st.f_frsize / 1073741824)
|
||||
used = round((st.f_blocks - st.f_bfree) * st.f_frsize / 1073741824)
|
||||
|
||||
self.disk_usage_string = str(used) + "G / " + str(total) + "G (free: " + str(free) + "G)"
|
||||
|
||||
return self.disk_usage_string
|
||||
|
||||
def draw_on(self, screen):
|
||||
if self.enabled:
|
||||
screen.blit(self.logo, self.logo.get_rect())
|
||||
|
||||
top = self.logo.get_rect().height + 10
|
||||
|
||||
text = "COUNT: " + str(self.photoboite.capture_button.count)
|
||||
size = self.font.size(text)
|
||||
ren = self.font.render(text, True, (255, 255, 255))
|
||||
screen.blit(ren, (0, top))
|
||||
texts = [
|
||||
"DATE: " + self.date(),
|
||||
"COUNT: " + str(self.photoboite.capture_button.count),
|
||||
"FPS: " + str(self.photoboite.clock.get_fps()),
|
||||
"DISK USAGE:" + self.disk_usage()
|
||||
]
|
||||
|
||||
text = "FPS: " + str(self.photoboite.clock.get_fps())
|
||||
i = 0
|
||||
for text in texts:
|
||||
size = self.font.size(text)
|
||||
ren = self.font.render(text, True, (255, 255, 255))
|
||||
screen.blit(ren, (0, top + 20))
|
||||
screen.blit(ren, (0, top + i * 20))
|
||||
|
||||
i += 1
|
||||
|
||||
def run(self):
|
||||
if time.time() - self.timestamp > 0.5:
|
||||
|
|
Loading…
Reference in New Issue