kivy에는 뭔가 이해할 수없는 부분이 있으며 누군가가 빛을 비출 수 있기를 바랍니다. 나는이 주제에 대해 많은 독서를 해왔지만 단지 내 머리 속에 연결되는 것처럼 보이지 않습니다.Kivy 버튼을 기능으로 연결
필자의 문제는 기능을 kivy 버튼과 연결 한 것입니다.
def Math():
print 1+1
내가 뭔가 더 복잡하고 싶으면 : 는 지금은 간단한 기능을 수행하는 방법을 배우려고 노력하고
def Math(a,b):
print a^2 + b^2
a
및 b
이 kivy에서 입력 라벨 (label)을하고, 버튼을 클릭하면 답이 인쇄됩니다.
이
내가 지금까지 무엇을 가지고 :from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition
from kivy.uix.widget import Widget
from kivy.uix.floatlayout import FloatLayout
#######``Logics``#######
class Math(FloatLayout):
def add(self):
print 1+1
#######``Windows``#######
class MainScreen(Screen):
pass
class AnotherScreen(Screen):
pass
class ScreenManagement(ScreenManager):
pass
presentation = Builder.load_file("GUI_Style.kv")
class MainApp(App):
def build(self):
return presentation
if __name__ == "__main__":
MainApp().run()
이 내 kivy 언어 파일입니다
import NoTransition kivy.uix.screenmanager.NoTransition
ScreenManagement:
transition: NoTransition()
MainScreen:
AnotherScreen:
<MainScreen>:
name: "main"
FloatLayout:
Button:
on_release: app.root.current = "other"
text: "Next Screen"
font_size: 50
color: 0,1,0,1
font_size: 25
size_hint: 0.3,0.2
pos_hint: {"right":1, "top":1}
<AnotherScreen>:
name: "other"
FloatLayout:
Button:
color: 0,1,0,1
font_size: 25
size_hint: 0.3,0.2
text: "add"
pos_hint: {"x":0, "y":0}
on_release: root.add
Button:
color: 0,1,0,1
font_size: 25
size_hint: 0.3,0.2
text: "Back Home"
on_release: app.root.current = "main"
pos_hint: {"right":1, "top":1}
AnotherScreen 인스턴스이지만,이
add
이없는