Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure the display is updated when resuming the app #69

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def build(self):
Window.clearcolor = (0, 0, 0, 1)
self.icon = PATH_IMAGES + "logo.png"

def on_resume(self):
current_screen_name = self.root_window.children[0].current
self.root_window.children[0].get_screen(current_screen_name).refresh()
return super().on_resume()

def on_start(self):
if MOBILE_MODE:
Window.update_viewport()
Expand Down
4 changes: 2 additions & 2 deletions screens/menu.kv
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
Label:
id: start_label
text: root.start_label_text
size_hint: 1, 0.25
size_hint: 0.7, 0.25
pos_hint: {"center_x": 0.5, "center_y": 0.45}
font_size: 50*root.font_ratio
font_name: root.font_name
color: TITLE_FONT_COLOR
outline_width: 2
outline_color: (1,1,1,1)
Button:
size_hint: 1, 0.25
size_hint: 0.7, 0.25
pos_hint: {"center_x": 0.5, "center_y": 0.45}
background_color: 0, 0, 0, 0
on_release:
Expand Down
10 changes: 10 additions & 0 deletions tools/kivy_tools/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
### Kivy imports ###

from kivy.core.window import Window
from kivy.clock import Clock
from kivy.uix.screenmanager import Screen
from kivy.uix.label import Label
from kivy.properties import (
StringProperty,
NumericProperty,
Expand Down Expand Up @@ -206,3 +208,11 @@ def enable_widget(self, widget_id: str):
widget.opacity = 1
widget.disabled = False
widget.pos_hint = self.temp_pos[widget_id]

def refresh(self):
self.label_widget = Label(text=" ", pos_hint={"x": 1, "y": 1})
self.add_widget(self.label_widget)
Clock.schedule_once(self.post_refresh)

def post_refresh(self, *args):
self.remove_widget(self.label_widget)