awulll
awulll

Reputation: 161

Function "on_complete" called before "completed" on kivy app with plyer

It's me again! Well, that's really strange. I'using kivy for make an App for Android. I can use the camera, but or the app resets or do something strange. Here is the problem:

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

On option 3, I write a text (nome_arquivo) on a label widget (label_passa), but what happens is that the text is wrote before the camera be activated. So the camera appear, I can take a picture and the App restarts. I also tried just a "def sair(): pass", but this doesn't work. The only thing working is an "print", but on my app I need to write something in that label and update an sqlite database. Any idea why the function is being called before the camera action? Thanks!

Upvotes: 0

Views: 108

Answers (1)

inclement
inclement

Reputation: 29468

on_pause and on_resume should be defined as methods of your App class, not (as you have here) functions defined locally within the chamar_camera function.

Upvotes: 0

Related Questions