bugfix
This commit is contained in:
parent
bde00ed1b6
commit
c42b0f4c9e
@ -1,4 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
|
import math
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
|
|
||||||
from kivy.properties import ObjectProperty, StringProperty
|
from kivy.properties import ObjectProperty, StringProperty
|
||||||
@ -163,11 +164,18 @@ class Text(Label):
|
|||||||
self.i18n.addI18nWidget(self)
|
self.i18n.addI18nWidget(self)
|
||||||
self.otext = kw.get('text','')
|
self.otext = kw.get('text','')
|
||||||
if self.wrap:
|
if self.wrap:
|
||||||
font_size = self.font_size
|
self.size_hint_y = None
|
||||||
self.text_size = self.width, None
|
self.text_size = self.width, None
|
||||||
|
self.bind(width=self.set_widget_height)
|
||||||
if self.bgcolor:
|
if self.bgcolor:
|
||||||
self.color = 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):
|
def get_wraped_size(self):
|
||||||
if self.text:
|
if self.text:
|
||||||
self._label.refresh()
|
self._label.refresh()
|
||||||
|
@ -29,16 +29,8 @@ description file format
|
|||||||
|
|
||||||
def setChildMinWidth(self, *args):
|
def setChildMinWidth(self, *args):
|
||||||
print('size changed')
|
print('size changed')
|
||||||
for c in self._inner.children:
|
for i,c in enumerate(self._inner.children):
|
||||||
c.width = self.width
|
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):
|
def load_text(self, *args):
|
||||||
print('source fired, hahaha', *args)
|
print('source fired, hahaha', *args)
|
||||||
|
@ -50,6 +50,8 @@ class StrInput(TextInput):
|
|||||||
"multiline":False,
|
"multiline":False,
|
||||||
"halign":"left",
|
"halign":"left",
|
||||||
"hint_text":"",
|
"hint_text":"",
|
||||||
|
"text_language":"zh_CN",
|
||||||
|
"write_tab":False
|
||||||
}
|
}
|
||||||
a.update(kv)
|
a.update(kv)
|
||||||
w = kv.get('width',1)
|
w = kv.get('width',1)
|
||||||
|
Loading…
Reference in New Issue
Block a user