add timer
This commit is contained in:
@@ -5,7 +5,7 @@ from tkinter import Frame, Canvas, ttk, PhotoImage
|
||||
from PIL import Image, ImageChops
|
||||
|
||||
from ..config import DISPLAY_TYPES
|
||||
from . import NumberView, CircleView
|
||||
from . import NumberView, CircleView, TimerView
|
||||
|
||||
class CombinedView(tk.Frame):
|
||||
def __init__(self, parent,
|
||||
@@ -13,6 +13,7 @@ class CombinedView(tk.Frame):
|
||||
**kwargs):
|
||||
super().__init__(parent, **kwargs)
|
||||
self.views = []
|
||||
self.timer_view = None # Timer view is always active
|
||||
self.tare_command = tare_command
|
||||
self.calibrate_command = calibrate_command
|
||||
|
||||
@@ -26,12 +27,16 @@ class CombinedView(tk.Frame):
|
||||
self.im_size = (168, 144)
|
||||
self.center = (168 // 2, 144 // 2)
|
||||
|
||||
# Create timer view that's always active
|
||||
self.timer_view = TimerView(self.actions, self.im_size, self.center)
|
||||
|
||||
self.canvas = Canvas(self, width=168, height=144, background='white',
|
||||
highlightthickness=1, highlightbackground="black")
|
||||
self.canvas.pack()
|
||||
|
||||
|
||||
def update_views(self, selected_types: DISPLAY_TYPES):
|
||||
# Clear only the selectable views, not the timer
|
||||
for v in self.views:
|
||||
if v.ui is not None:
|
||||
v.ui.destroy()
|
||||
@@ -48,6 +53,13 @@ class CombinedView(tk.Frame):
|
||||
|
||||
def refresh(self, weight: float):
|
||||
ims = []
|
||||
|
||||
# Always include timer view
|
||||
if self.timer_view:
|
||||
timer_im = self.timer_view.update_weight(weight)
|
||||
ims.append(timer_im)
|
||||
|
||||
# Add other selected views
|
||||
for view in self.views:
|
||||
im = view.update_weight(weight)
|
||||
ims.append(im)
|
||||
|
||||
Reference in New Issue
Block a user