From c42b0f4c9e7383cc2fd159466fd483e9b4a309aa Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 22 Feb 2021 09:14:59 +0800 Subject: [PATCH] bugfix --- kivyblocks/baseWidget.py | 10 +++++++++- kivyblocks/markdown.py | 10 +--------- kivyblocks/widgetExt/inputext.py | 2 ++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/kivyblocks/baseWidget.py b/kivyblocks/baseWidget.py index 5e8d240..e84d386 100755 --- a/kivyblocks/baseWidget.py +++ b/kivyblocks/baseWidget.py @@ -1,4 +1,5 @@ import sys +import math from traceback import print_exc from kivy.properties import ObjectProperty, StringProperty @@ -163,11 +164,18 @@ class Text(Label): self.i18n.addI18nWidget(self) self.otext = kw.get('text','') if self.wrap: - font_size = self.font_size + self.size_hint_y = None self.text_size = self.width, None + self.bind(width=self.set_widget_height) if self.bgcolor: self.color = self.bgcolor + def set_widget_height(self, *args): + self.text_size = self.width, None + rows = len(self.text) * (self.font_size * 0.621) / self.width + rows = math.ceil(rows) + self.height = rows * self.font_size * 1.5 + def get_wraped_size(self): if self.text: self._label.refresh() diff --git a/kivyblocks/markdown.py b/kivyblocks/markdown.py index de485e8..39ca012 100644 --- a/kivyblocks/markdown.py +++ b/kivyblocks/markdown.py @@ -29,16 +29,8 @@ description file format def setChildMinWidth(self, *args): print('size changed') - for c in self._inner.children: + for i,c in enumerate(self._inner.children): c.width = self.width - if isinstance(c, Factory.Text): - _, h = c.get_wraped_size() - clen = CSize(1) - if not h or h < clen: - c.height = clen - else: - c.height = h - self._inner.do_layout() def load_text(self, *args): print('source fired, hahaha', *args) diff --git a/kivyblocks/widgetExt/inputext.py b/kivyblocks/widgetExt/inputext.py index e8b1b17..2f3f0c6 100755 --- a/kivyblocks/widgetExt/inputext.py +++ b/kivyblocks/widgetExt/inputext.py @@ -50,6 +50,8 @@ class StrInput(TextInput): "multiline":False, "halign":"left", "hint_text":"", + "text_language":"zh_CN", + "write_tab":False } a.update(kv) w = kv.get('width',1)