2017-07-27 45 views
0

因此,我正在開發一個kivy項目,並且還在爲它學習語言(我的意思是python),我在這裏有這個小程序。所以在我的第一個屏幕上有一些語言按鈕,但我也有文字在第二頁中更改。我怎樣才能在課堂上調用其他課程的功能,或者我應該用不同的方式來改變課本?任何TIPP將是有益的:)謝謝Kivy在其他屏幕上調用函數

class ScreenOne(Screen): 
    def d_language(self): 
     self.hellolabel.text='Hallo' 
    def fr_language(self): 
     self.hellolabel.text='Bonjour' 

class ScreenTwo(Screen): 
    def d_languagetwo(self): 
     self.otherlabel.text='Zweite seite' 
    def fr_languagetwo(self): 
     self.otherlabel.text='Deuxième page' 
+0

喜利,看看[這] (https://stackoverflow.com/questions/45024151/calling-function-in-a-different-class-through-kivy-button/45025220#45025220)和[this](https://stackoverflow.com/questions/ 7965114 /主叫一個功能 - 從類合蟒-不同路)。另外,你的Button在哪裏?如果可能的話,添加更多代碼項目 – favcau

+0

感謝tipps :) Yoav Glazner的回答是我一直在尋找的主要內容 – Levi

回答

0

您可以使用屏幕經理去其他屏幕

def d_language(self): 
    self.hellolabel.text = 'Hallo' 
    #now change the other label 
    s2 = self.manager.get_screen('name of the other screen') 
    #or ... 
    #s2 = self.manager.screens[1] # will also work... 
    s2.otherlabel.text = 'Zweite seite' 
    #or ... 
    #s2.d_languagetwo() 

...

+0

非常感謝。我希望有這樣的事情,但是我在網上找不到任何東西 – Levi