创建带有文本文件列表的切换按钮

时间:2019-03-08 04:48:20

标签: python button kivy kivy-language auto-generate

因此,我试图创建一个切换按钮列表,这些按钮根据从文本文件中提取的列表进行填充。切换所有列出的项目后,将出现一个按钮,用于将列表导出到新的文本文件中,并移到新窗口中。目前,我有一些东西会生成一个按钮,但不会生成一个列表,并且我不知道在切换所有按钮时如何生成按钮。

Workstation.py

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout


class WorkstationWindow(BoxLayout):

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


class WorkstationApp(App):

def build(self):
    return WorkstationWindow()


if __name__ == "__main__":
oa = WorkstationApp()

oa.run()

Workstation.kv

<FlatButton@ButtonBehavior+Label>:
font_size: 14

<WorkstationWindow>:
id: main_win
orientation: 'vertical'
canvas.before:
    Color:
        rgba: (1,1,1, 1)
    Rectangle:
        size: self.size
        pos: self.pos

BoxLayout:
    id: header
    size_hint_y: None
    height: 40
    canvas.before:
        Color:
            rgba: (.06, .45, .45, 1)
        Rectangle:
            size: self.size
            pos: self.pos
    Label:
        text: 'Order #'
        size_hint_x: .9
        bold: True
        color: (1,1,1,1)
    FlatButton:
        id: loggedin_user
        text: 'Order #'
        color: (1,1,1,1)

    FlatButton:
        id: loggedin_user
        text: 'Order #'
        color: (1,1,1,1)

BoxLayout:
    spacing: 10
    canvas.before:
        Color:
            rgba: (0,0,0,255)
        Rectangle:
            size: self.size
            pos: self.pos
    Button:
        text: 'Current Items 1:'
        background_normal: ''
        background_color: (.06, .32, .32, 1)

    Button:
        id: cur_product
        text: 'Current Items 2'
        background_normal: ''
        background_color: (.06, .4, .4, 1)
    Button:
        id: cur_price
        text: 'Current Items 3'
        background_normal: ''
        background_color: (.06, .65, .65, 1)

    Button:
        id: cur_price
        text: 'Current Items 3'
        background_normal: ''
        background_color: (.06, .65, .65, 1)

List.txt

面包

梅奥

生菜

0 个答案:

没有答案