Mercurial > libervia-desktop-kivy
comparison src/cagou/plugins/plugin_wid_chat.py @ 68:4a1e1012337e
chat: fixed chat messages width
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 17 Dec 2016 14:34:45 +0100 |
parents | 5f7f72c2635f |
children | 46d962910801 |
comparison
equal
deleted
inserted
replaced
67:5f7f72c2635f | 68:4a1e1012337e |
---|---|
154 | 154 |
155 def on_width(self, instance, width): | 155 def on_width(self, instance, width): |
156 if len(self.children) == 1: | 156 if len(self.children) == 1: |
157 wid = self.children[0] | 157 wid = self.children[0] |
158 if isinstance(wid, Label): | 158 if isinstance(wid, Label): |
159 # we have simple text | |
159 try: | 160 try: |
160 full_width = wid._full_width | 161 full_width = wid._full_width |
161 except AttributeError: | 162 except AttributeError: |
163 # on first time, we need the required size | |
164 # for the full text, without width limit | |
162 wid.size_hint = (None, None) | 165 wid.size_hint = (None, None) |
163 wid.texture_update() | 166 wid.texture_update() |
164 full_width = wid._full_width = wid.texture_size[0] | 167 full_width = wid._full_width = wid.texture_size[0] |
168 | |
165 if full_width > width: | 169 if full_width > width: |
166 wid.text_size = width, None | 170 wid.text_size = width, None |
171 wid.width = width | |
167 else: | 172 else: |
168 wid.text_size = None, None | 173 wid.text_size = None, None |
174 wid.texture_update() | |
175 wid.width = wid.texture_size[0] | |
169 self.content_width = wid.width + self.padding[0] + self.padding[2] | 176 self.content_width = wid.width + self.padding[0] + self.padding[2] |
170 else: | 177 else: |
171 wid.size_hint(1, None) | 178 wid.size_hint(1, None) |
172 wid.height = 100 | 179 wid.height = 100 |
173 self.content_width = self.width | 180 self.content_width = self.width |