kivy.factory.FactoryException: неизвестный класс - PullRequest
0 голосов
/ 19 января 2020

Hello.py

import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.anchorlayout import AnchorLayout

Builder.load_file('toolbox.kv')
Builder.load_file('drawingspace.kv')
Builder.load_file('generaloptions.kv')
Builder.load_file('statusbar.kv')

class ComicCreator(AnchorLayout):

        pass


class HelloApp(App):
    def build(self):
        return ComicCreator()

if __name__=="__main__":
    HelloApp().run()

hello.kv

<ComicCreator>:
    AnchorLayout:
        anchor_x:"left"
        anchor_y:"top"
        ToolBox:
            id:_tool_box
            size_hint:None,None
            width:100
    Anchor_Layout:
        anchor_x:"right"
        anchor_y:"top"
        DrawingSpace:
            size_hint:None,None
            width:root.width - _tool_box.width
            height:root.height - _general_options.height - _status_bar.height

    AnchorLayout:
        anchor_x:"center"
        anchor_y:"bottom"
        BoxLayout:
            orientation:"vertical"
            GeneralOptions:
                id:_general_options
                size_hint:1,None
                height:48
            StatusBar:
                id:_status_bar
                size_hint:1,None
                height:24

пространство для рисования. kv

<DrawingSpace@RelativeLayout>:
    Label:
        markup: True
        text: "[size=32px][color=#3e6643]The[/color] [sub]Comic[/sub][i] [b]Creator[/b][/i][/size]"

toolbox.kv

<ToolButton@ToggleButton>:
    size_hint:None,None
    size:48,48
    group:'tool'

<ToolBox@GridLayout>:
    cols:2
    padding:2
    ToolButton:
        text:'O'
    ToolButton:
        text:"/"
    ToolButton:
        text:"?"

generaloptions.kv

<GeneralOptions@BoxLayout>:
    orientation:"horizontal"
    padding:2
    Button:
        text:'Clear'
    Button:
        text:"Remove"
    ToggleButton:
        text:"Group"
    Button:
        text:"Color"
    ToggleButton:
        text:"Gestures"
...