paint.kv 3.2 KB
Newer Older
I逗's avatar
I逗 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
#:import C kivy.utils.get_color_from_hex
    
<BottomColorButton@ToggleButton>:
    
    group: 'color'
    background_normal: 'radio_background_normal.png'
    background_down: 'radio_background_down.png'
    border: (3, 3, 3, 3)
    on_release: app.draw_canvas_widget.change_color(self.background_color)
    
<LineWidgetButton@ToggleButton>:
    
    group: 'line_width'
    color: C('#2c3e50')
    background_color: C('#ecf0f1')
    background_normal: 'radio_background_normal.png'
    background_down: 'radio_background_down.png'
    border: (3, 3, 3, 3)
    on_release: app.draw_canvas_widget.change_line_width(self.text)

<DrawCanvasWidget>:

    canvas.before:
        Color:
            rgba: 1, 1, 1, 1
        Rectangle:
            # self here refers to the widget i.e FloatLayout
            pos: self.pos
            size: self.size
    BoxLayout:
    
        orientation: 'horizontal'
        padding: 2
        spacing: 2
        x: 0
        top: root.top
        size_hint: None, None
        size: 280, 40
        LineWidgetButton:        
            text: 'Thin'
        LineWidgetButton:        
            text: 'Normal'
            state: 'down'
        LineWidgetButton:        
            text: 'Thick'
        Button:
            text: 'Clear'
            on_release: root.clear_canvas()

    BoxLayout:
        id: botton_box
        orientation: 'horizontal'

        padding: 2
        spacing: 2
        size: root.width, 40
        
        BottomColorButton:
            background_color: C('#19caad')
            state: 'down'
        BottomColorButton:             
            background_color: C('#8cc7b5')         
        BottomColorButton:             
            background_color: C('#a0eee1')         
        BottomColorButton:
            background_color: C('#bee7e9')         
        BottomColorButton:             
            background_color: C('#beedc7')         
        BottomColorButton:             
            background_color: C('#d6d5b7')
        BottomColorButton:             
            background_color: C('#d1ba74')         
        BottomColorButton:             
            background_color: C('#e6ceac')         
        BottomColorButton:             
            background_color: C('#ecad9e')         
        BottomColorButton:             
            background_color: C('#f4606c')         
        BottomColorButton:             
            background_color: C('#3498db')         
        BottomColorButton:             
            background_color: C('#1abc9c')         
        BottomColorButton:             
            background_color: C('#2ecc71')         
        BottomColorButton:             
            background_color: C('#f1c40f')         
        BottomColorButton:             
            background_color: C('#e67e22')         
        BottomColorButton:             
            background_color: C('#e74c3c')         
        BottomColorButton:             
            background_color: C('#9b59b6')         
        BottomColorButton:
            background_color: C('#ecf0f1')         
        BottomColorButton:             
            background_color: C('#95a5a6')         
        BottomColorButton:             
            background_color: C('#000000')