【发布时间】:2018-08-22 17:18:45
【问题描述】:
我怎样才能像这段代码一样在类中调用函数?我试过了,但我不能......这个想法是:我想更新 de 类中的另一个函数,而不是使用这段代码,但没有成功: app=MyApp() app.build.last1.text=time.strftime( "%H:%M:%S \n")
我是怎么做到的?
(...)
class PL1_detect(Button):
def update(self, dt):
global ModoPisca
global t
global ModoPisca2
global last2
#ModoPisca=0
def tpisca():
conta=0
global estado_PTT1
##clock(self, dt)
app=MyApp()
app.build.last1.text=time.strftime("%H:%M:%S \n")
#(here the problem: HOW I CAN CALL FUNCTION OF CLASS
MYAPP(APP) ????
(...)
class MyApp(App):
def build(self):
layout = FloatLayout(size=(800, 600))
# Make the background gray:
with layout.canvas.before:
Color(.2,.2,.2,1)
self.rect = Rectangle(size=(800,600), pos=layout.pos)
wimg = Image(source='logo.png', pos=(0,180))
last1=Label(text=(" "), pos=(-330, -110), font_size='17sp', bold=0)
return layout
if __name__ == '__main__':
MyApp().run()
【问题讨论】:
-
请格式化您的代码。 Python 对格式很敏感,python 程序员也是如此。
标签: python function class call