From d2e935862423cc248b98129a07463d530abf918a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 15 Mar 2021 08:24:26 +0800 Subject: [PATCH] bugfix --- kivyblocks/widgetExt/messager.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kivyblocks/widgetExt/messager.py b/kivyblocks/widgetExt/messager.py index 3e0f8bc..698cd56 100644 --- a/kivyblocks/widgetExt/messager.py +++ b/kivyblocks/widgetExt/messager.py @@ -2,15 +2,15 @@ from kivy.uix.popup import Popup from kivy.clock import Clock from kivy.uix.boxlayout import BoxLayout from kivy.uix.textinput import TextInput -from appPublic.Singleton import SingletonDecorator -@SingletonDecorator class Messager: - def __init__(self, show_time=0): + def __init__(self, show_time=0, title=None): self.show_time = show_time + self.title = title if title else 'Message' self.time_task = None self.w = Popup(content=BoxLayout(orientation='vertical'), - title="Error info",size_hint=(0.8,0.8)) + title=self.title, + size_hint=(0.8,0.8)) self.messager = TextInput(size=self.w.content.size, multiline=True,readonly=True) self.w.content.add_widget(self.messager) @@ -20,14 +20,15 @@ class Messager: self.time_task = Clock.schedule_once(self.hide, self.show_time) def show_error(self,e): - self.w.title = "error" - self.messager.text = str(e) + self.messager.text = '%s[error]%s\n' % (self.messager.text,str(e)) self.w.open() self.set_time_task() + def clear_messages(self): + self.messager.text = '' + def show_info(self,info): - self.w.title = "info" - self.messager.text = str(info) + self.messager.text = '%s[info]%s\n' % (self.messager.text, info) self.w.open() self.set_time_task()