def chamar_camera(nome,pc,objeto,label_passa,instance):
agora = datetime.now()
nome_arquivo = '%s_%s_%.4i_%.2i_%.2i_%.2i_%.2i_%.2i.jpg' % (nome,pc,agora.year,agora.month,agora.day,agora.hour,agora.minute,agora.second)
# Option 1 - These two lines work:
#def sair():print 'oi'
#camera.take_picture(nome_arquivo, sair)
# Option 2 - These two lines work too:
def sair(label_passa,nome_arquivo):print 'oi'
camera.take_picture(nome_arquivo,on_complete=sair(label_passa,nome_arquivo))
# Option 3 - But these don't:
#def sair(label_passa,nome_arquivo):label_passa.text = nome_arquivo
#camera.take_picture(nome_arquivo, on_complete=sair(label_passa,nome_arquivo))
def on_pause(self):return True
def on_resume(self):pass
在选项3上,我在标签小部件(label_passa)上写了一个文本(nome_arquivo),但会发生的是在激活相机之前写入文本。所以相机出现,我可以拍照,应用程序重新启动。我也尝试了一个" def sair():传递",但这不起作用。唯一有效的是" print",但在我的应用程序中,我需要在该标签中写一些内容并更新sqlite数据库。知道为什么在相机动作之前调用该功能吗? 谢谢!
答案 0 :(得分:0)
on_pause
和on_resume
应该被定义为App类的方法,而不是(就像你在这里)在chamar_camera
函数中本地定义的函数。