2017-03-01 6 views
0

私は描画のための簡単なアプリケーションを作成しました。私はこのエラーを得た: それは私にこのエラーを示し、なぜ が、私は理解していない「pythonw.exeは動作を停止しました」、私は助けをしてみたい:) Kivy-simple drawing app

私kivyコード:

from kivy.app import App 
# kivy.require("1.8.0") 
from kivy.uix.widget import Widget 
from kivy.graphics import Line 
from kivy.lang import Builder 
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition 

class Painter(Widget): 
    def on_touch_down(self, touch): 
     with self.canvas: 
      touch.ud["line"] = Line(points=(touch.x,touch.y)) 

    def on_touch_move(self, touch): 
     touch.ud["line"].points += [touch.x,touch.y] 


class MainScreen(Screen): 
    pass 

class AnotherScreen(Screen): 
    pass 

class ScreenManegmant(ScreenManager): 
    pass 

presention = Builder.load_file("main1.kv") 



class SimpleKivy(App): 
    def build(self): 
     return presention 

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

私kv.language code(main1.kv):

#: import FadeTransition kivy.uix.screenmanager.FadeTransition 

ScreenManegmant: 
    transition: FadeTransition() 
    MainScreen: 
    AnotherScreen: 

<MainScreen>: 
    name: "main" 
    Button: 
     on_release: app.root.current= "other" 
     text: "next" 
     font_size: 50 



<AnotherScreen>: 
    name: "other" 

    FloatLayout: 
     Painter 
     Button: 
      on_release: app.root.current= "main" 
      text: "back" 
      font_size: 25 
      color: 0,1,0,1 
      size_hint: 0.3,0.2 
      pos_hint: {"left":1,"up":1} 

誰かがそれをどのように修正できるか知っていますか?

答えて

0

このアプリは私のために働く。 touch.ud["line"]が作成される前にタッチが既に動いているので、私がトランジションで描画を開始するとエラーになります。キーがon_touch_moveメソッドに存在するかどうかを確認してから、それを修正することができます。

また、アイドルではなくcmdから実行してみてください。

class Painter(Widget): 
    def on_touch_down(self, touch): 
     with self.canvas: 
      touch.ud["line"] = Line(points=(touch.x,touch.y)) 

    def on_touch_move(self, touch): 
     if "line" not in touch.ud: 
      touch.ud["line"] = Line(points=(touch.x,touch.y)) 
     touch.ud["line"].points += [touch.x,touch.y] 
+0

私はScreenManagmentを使った非常に単純なアプリケーションを作成したときに同じエラーが発生したとは思わない。私は次の答えでアプリを書いた。 –

+0

@ShaharBitanはアイドル状態からではなく、cmdから実行しましたか? – EL3PHANTEN

+0

はい、その動作していません –