質問編集履歴
4
pythonとkivyは以下のバージョンを追記しました。
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -77,7 +77,11 @@ 
     | 
|
| 
       77 
77 
     | 
    
         
             
            MagicApp().run()
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
       79 
79 
     | 
    
         
             
            ```
         
     | 
| 
      
 80 
     | 
    
         
            +
            pythonとkivyは以下のバージョンを使用しています。
         
     | 
| 
       80 
81 
     | 
    
         | 
| 
      
 82 
     | 
    
         
            +
            python ver 3.7.1
         
     | 
| 
      
 83 
     | 
    
         
            +
            kivy ver 1.10.1
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
       81 
85 
     | 
    
         
             
            ```python
         
     | 
| 
       82 
86 
     | 
    
         
             
            Root:
         
     | 
| 
       83 
87 
     | 
    
         
             
            <Root>:
         
     | 
3
kvファイルのコードを追加しました。
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -78,6 +78,106 @@ 
     | 
|
| 
       78 
78 
     | 
    
         | 
| 
       79 
79 
     | 
    
         
             
            ```
         
     | 
| 
       80 
80 
     | 
    
         | 
| 
      
 81 
     | 
    
         
            +
            ```python
         
     | 
| 
      
 82 
     | 
    
         
            +
            Root:
         
     | 
| 
      
 83 
     | 
    
         
            +
            <Root>:
         
     | 
| 
      
 84 
     | 
    
         
            +
                canvas.before:
         
     | 
| 
      
 85 
     | 
    
         
            +
                    rgb:1,1,1
         
     | 
| 
      
 86 
     | 
    
         
            +
                    rectangle:
         
     | 
| 
      
 87 
     | 
    
         
            +
                        pos:self.pos
         
     | 
| 
      
 88 
     | 
    
         
            +
                        size:self.size
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            <Title@BoxLayout>:
         
     | 
| 
      
 92 
     | 
    
         
            +
                orientation: 'vertical'
         
     | 
| 
      
 93 
     | 
    
         
            +
                Label:
         
     | 
| 
      
 94 
     | 
    
         
            +
                    size_hint_y: 3
         
     | 
| 
      
 95 
     | 
    
         
            +
                    text:'魔方陣パズル'
         
     | 
| 
      
 96 
     | 
    
         
            +
                GoToButton:
         
     | 
| 
      
 97 
     | 
    
         
            +
                    no:1
         
     | 
| 
      
 98 
     | 
    
         
            +
                GoToButton:
         
     | 
| 
      
 99 
     | 
    
         
            +
                    no:2
         
     | 
| 
      
 100 
     | 
    
         
            +
                GoToButton:
         
     | 
| 
      
 101 
     | 
    
         
            +
                    no:3
         
     | 
| 
      
 102 
     | 
    
         
            +
            <GoToButton>:
         
     | 
| 
      
 103 
     | 
    
         
            +
                no: 0
         
     | 
| 
      
 104 
     | 
    
         
            +
                text: '問題' + str(self.no)
         
     | 
| 
      
 105 
     | 
    
         
            +
                on_press: app.root.gotoBoard(self.no)
         
     | 
| 
      
 106 
     | 
    
         
            +
                
         
     | 
| 
      
 107 
     | 
    
         
            +
            <Board>:
         
     | 
| 
      
 108 
     | 
    
         
            +
                no: 0
         
     | 
| 
      
 109 
     | 
    
         
            +
                orientation: 'vertical'
         
     | 
| 
      
 110 
     | 
    
         
            +
                Label:
         
     | 
| 
      
 111 
     | 
    
         
            +
                    text: 問題' + str(root.no)
         
     | 
| 
      
 112 
     | 
    
         
            +
                GridLayout:
         
     | 
| 
      
 113 
     | 
    
         
            +
                    id: board
         
     | 
| 
      
 114 
     | 
    
         
            +
                    rows:4
         
     | 
| 
      
 115 
     | 
    
         
            +
                    cols:4
         
     | 
| 
      
 116 
     | 
    
         
            +
                    size_hint_y:4
         
     | 
| 
      
 117 
     | 
    
         
            +
                    spacing:3
         
     | 
| 
      
 118 
     | 
    
         
            +
                BoxLayout:
         
     | 
| 
      
 119 
     | 
    
         
            +
                    orientation:'horizontal'
         
     | 
| 
      
 120 
     | 
    
         
            +
                    Button:
         
     | 
| 
      
 121 
     | 
    
         
            +
                        text:'もどる'
         
     | 
| 
      
 122 
     | 
    
         
            +
                        no_press:app.root.gotoTitle()
         
     | 
| 
      
 123 
     | 
    
         
            +
                    Button:
         
     | 
| 
      
 124 
     | 
    
         
            +
                        text:'チェック'
         
     | 
| 
      
 125 
     | 
    
         
            +
                        on_press: app.root.board.check()
         
     | 
| 
      
 126 
     | 
    
         
            +
            <Const@Label>:
         
     | 
| 
      
 127 
     | 
    
         
            +
                canvas.before:
         
     | 
| 
      
 128 
     | 
    
         
            +
                    Color:
         
     | 
| 
      
 129 
     | 
    
         
            +
                        rgb:0.6,1,1
         
     | 
| 
      
 130 
     | 
    
         
            +
                    Rectangle:
         
     | 
| 
      
 131 
     | 
    
         
            +
                        pos:self.pos
         
     | 
| 
      
 132 
     | 
    
         
            +
                        size:self.size
         
     | 
| 
      
 133 
     | 
    
         
            +
            <NumInput@textInput>:
         
     | 
| 
      
 134 
     | 
    
         
            +
                font_size:32
         
     | 
| 
      
 135 
     | 
    
         
            +
                hint_text: '-'
         
     | 
| 
      
 136 
     | 
    
         
            +
                input_filter: 'int'
         
     | 
| 
      
 137 
     | 
    
         
            +
                multiline: False
         
     | 
| 
      
 138 
     | 
    
         
            +
                padding: self.width/4, (self.height-self.line_height)/2
         
     | 
| 
      
 139 
     | 
    
         
            +
                on_text:
         
     | 
| 
      
 140 
     | 
    
         
            +
                    if len(self.text)>2:self.text = self.text[1:3]
         
     | 
| 
      
 141 
     | 
    
         
            +
                    if self.text=='':self.value=0
         
     | 
| 
      
 142 
     | 
    
         
            +
                    else:self.value = int(self.text)
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
            <CheckView@ModalView>:
         
     | 
| 
      
 145 
     | 
    
         
            +
                auto_dismiss: False
         
     | 
| 
      
 146 
     | 
    
         
            +
                background_color:0,0,0,0.5
         
     | 
| 
      
 147 
     | 
    
         
            +
                is_current : True
         
     | 
| 
      
 148 
     | 
    
         
            +
                size_hint: 0.5,0.5
         
     | 
| 
      
 149 
     | 
    
         
            +
                BoxLayout:
         
     | 
| 
      
 150 
     | 
    
         
            +
                    canvas.before:
         
     | 
| 
      
 151 
     | 
    
         
            +
                        Color:
         
     | 
| 
      
 152 
     | 
    
         
            +
                            rgb:1,1,0.9
         
     | 
| 
      
 153 
     | 
    
         
            +
                            Rectangle:
         
     | 
| 
      
 154 
     | 
    
         
            +
                                pos: self.pos
         
     | 
| 
      
 155 
     | 
    
         
            +
                                size: self.size
         
     | 
| 
      
 156 
     | 
    
         
            +
                    orientation: 'vertical'
         
     | 
| 
      
 157 
     | 
    
         
            +
                    padding:self.width/10
         
     | 
| 
      
 158 
     | 
    
         
            +
                    Label:
         
     | 
| 
      
 159 
     | 
    
         
            +
                        size_hint_y:4
         
     | 
| 
      
 160 
     | 
    
         
            +
                        text:'正解 :-)' if root.is_correct else '不正解 :-('
         
     | 
| 
      
 161 
     | 
    
         
            +
                    Button:
         
     | 
| 
      
 162 
     | 
    
         
            +
                        text: 'OK'
         
     | 
| 
      
 163 
     | 
    
         
            +
                        on_press:
         
     | 
| 
      
 164 
     | 
    
         
            +
                            root.dismiss()
         
     | 
| 
      
 165 
     | 
    
         
            +
                            if root.is_correct: app.root.gototitle()
         
     | 
| 
      
 166 
     | 
    
         
            +
                            
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
            <Label>:
         
     | 
| 
      
 169 
     | 
    
         
            +
                color: 0.5,025,0.25,1
         
     | 
| 
      
 170 
     | 
    
         
            +
                font_name: 'VL-Gothic-Regular.ttf'
         
     | 
| 
      
 171 
     | 
    
         
            +
                font_size :32
         
     | 
| 
      
 172 
     | 
    
         
            +
            <Button>:
         
     | 
| 
      
 173 
     | 
    
         
            +
                color:1,1,1,1
         
     | 
| 
      
 174 
     | 
    
         
            +
                font_size:24
         
     | 
| 
      
 175 
     | 
    
         
            +
                
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
            ```
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
       81 
181 
     | 
    
         
             
            ### 試したこと
         
     | 
| 
       82 
182 
     | 
    
         | 
| 
       83 
183 
     | 
    
         
             
            ここに問題に対して試したことを記載してください。
         
     | 
2
コードの表示を変更しました。
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         
            File without changes
         
     | 
1
コードの表示を変更しました。
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -21,9 +21,7 @@ 
     | 
|
| 
       21 
21 
     | 
    
         
             
             AttributeError: 'NoneType' object has no attribute 'gotoTitle'
         
     | 
| 
       22 
22 
     | 
    
         
             
            ### 該当のソースコード
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            ``` 
     | 
| 
      
 24 
     | 
    
         
            +
            ```python
         
     | 
| 
       25 
     | 
    
         
            -
            ソースコード
         
     | 
| 
       26 
     | 
    
         
            -
            ```
         
     | 
| 
       27 
25 
     | 
    
         
             
            from kivy.app import App
         
     | 
| 
       28 
26 
     | 
    
         
             
            from kivy.factory import Factory
         
     | 
| 
       29 
27 
     | 
    
         
             
            from kivy.uix.boxlayout import BoxLayout
         
     | 
| 
         @@ -78,6 +76,7 @@ 
     | 
|
| 
       78 
76 
     | 
    
         | 
| 
       79 
77 
     | 
    
         
             
            MagicApp().run()
         
     | 
| 
       80 
78 
     | 
    
         | 
| 
      
 79 
     | 
    
         
            +
            ```
         
     | 
| 
       81 
80 
     | 
    
         | 
| 
       82 
81 
     | 
    
         
             
            ### 試したこと
         
     | 
| 
       83 
82 
     | 
    
         |