Popiv中的Python Kivy ListAdapter文本换行

时间:2014-08-04 19:16:46

标签: python kivy

我一直在尝试从列表中包装文本,但我不知道如何包装简单标签的文本。

我有一个字符串列表,我想在Popup中用ListView显示它并包装

class SomeClass(Screen):

    def __init__(self, **kwargs):
        super(SomeClass, self).__init__(**kwargs)
        # TextInput + ListView
        ...
        # Popup

        lv_adapter = SimpleListAdapter(data=string_list,cls=Label)
        lv = ListView(adapter=lv_adapter)
        self.popup = Popup(title='A very large title ..... ....... .... ....',
                           content=lv,size_hint=[.9,.8])

    def some_function(self, *args):
        if <some_condition>:
            self.popup.open()

扩展弹出窗口的图像 http://oi60.tinypic.com/2cyh5j8.jpg

萎缩的弹出窗口的图像 http://oi61.tinypic.com/2hg4r4m.jpg

解决方案:

我找到了另一种在ListView中包装文本的方法,在BoxLayout中使用Label,这里是代码:

class SomeClass(Screen):

    def poplb_update(self, *args):
        self.poplb.text_size = self.popup.size

    def some_function(self):
        self.popup.open()


    def __init__(self, **kwargs):
        super(SomeClass, self).__init__(**kwargs)

        # Some code
        . . .

        # Popup
        self.popup = Popup(title=popupTitle,size_hint=[.9,.6])
        self.popbox = BoxLayout()
        self.poplb = Label(text=stringPopup,font_size=25,strip=True,
                           text_size=self.popup.size)
        self.popup.bind(size=self.poplb_update)
        self.popbox.add_widget(self.poplb)
        self.popup.content = self.popbox

0 个答案:

没有答案