community icon indicating copy to clipboard operation
community copied to clipboard

Snippet for Twisted + Kivy

Open tito opened this issue 15 years ago • 12 comments

Need.

tito avatar Jul 28 '11 21:07 tito

like a small code snippet to show how to integrate twisted reactor into kivy event loop (can we run it in separate thread)?

or a specific/standard way of integrating twisted with kivy?

hansent avatar Aug 28 '11 19:08 hansent

Yes, snippet about how to integrate twisted reactor in kivy loop. Kivy as master, twisted as slave.

tito avatar Aug 30 '11 08:08 tito

like this?

https://gist.github.com/1181570

hansent avatar Aug 30 '11 18:08 hansent

does not stop correctly, any idea why?

hansent avatar Aug 30 '11 18:08 hansent

this is better, stops correctly and handles SIGINT https://gist.github.com/1181789

hansent avatar Aug 30 '11 19:08 hansent

Very nice, but i would prefer if that could be done withing https://github.com/tito/kivy/blob/master/kivy/support.py ? I think we have global start/stop global app event (not App class). If not, maybe add it, and plug twisted on it.

Then, as gobject integration, we could do:

from kivy.support import install_twisted_iteration
install_twisted_iteration()

Does that make more sense to you too ?

tito avatar Aug 30 '11 19:08 tito

Where in the documentation should this go?

I think maybe one of these :

  1. Technical FAQ (maybe hard to find?)
  2. Programming Guide after Designing with Kivy Language

possible but probably overkill:

  • put twistedapp in an extension ?
  • Add TwistedApp to kivy/app.py, and add it to the module documentation ?

hansent avatar Aug 30 '11 19:08 hansent

agreed: install_twisted_iteration will be best. I will add it there.

kivy/supprt is not part of documentation though, should I add it in API docs under Kivy Framework?

hansent avatar Aug 30 '11 19:08 hansent

Not technical faq, but definitively in the Programming Guide, maybe new section about "Integrate other frameworks with Kivy" or something like that.

But most of the documentation should go in kivy/support.py for twisted. I really don't think we need a TwistedApp. If i would do like that, gobject have their own event loop, twisted too, etc. Best is to abstract them in support.py, and use install() before using the framework. The App class is not changed at all, and the user can still use the framework in his own way.

Just a matter of reorganisation, since you already got everything running :)

Mathieu

Where in the documentation should this go?

I think maybe one of these :

  1. Technical FAQ (maybe hard to find?)
  2. Programming Guide after Designing with Kivy Language

possible but probably overkill:

  • put twistedapp in an extension ?
  • Add TwistedApp to kivy/app.py, and add it to the module documentation ?

Reply to this email directly or view it on GitHub: https://github.com/tito/kivy/issues/214#issuecomment-1947611

tito avatar Aug 30 '11 19:08 tito

yep

agreed: install_twisted_iteration will be best. I will add it there.

kivy/supprt is not part of documentation though, should I add it in API docs under Kivy Framework?

Reply to this email directly or view it on GitHub: https://github.com/tito/kivy/issues/214#issuecomment-1947657

tito avatar Aug 30 '11 19:08 tito

ready to be closed after pull-request is merged

hansent avatar Sep 06 '11 19:09 hansent

Just to note that Hansent gist solved my issue that I asked in this SO page : http://stackoverflow.com/questions/25784607/why-in-windows-i-can-run-kivy-app-run-from-within-twisted-reactor-callinthread. I think it's better if the above gist is included in this guide : http://kivy.org/docs/guide/other-frameworks.html#using-twisted-inside-kivy

Thanks!

swdevbali avatar Sep 11 '14 23:09 swdevbali