title: Building turn-based game with Kivy
body: <p>I am building a Python implementation of the turn-based game "Mancala" for a project at school. I already have a basic game with I/O from the console. Now I need to integrate graphics with Kivy into the project.
  In short, the board of the game inherits Kivy's <code>GridLayout</code> and the pits are Kivy's <code>Button</code>s. A problem I run into is that to run the Kivy app, I need to call <code>app.run()</code>, and this method runs indefinitely. This is an issue because I have already implemented a base game without graphics with my own looper <a href="https://github.com/katzuv/mancala-no-graphics/blob/master/game.py#L18" rel="nofollow noreferrer">here</a>, so if I run the Kivy app, the whole program just waits and practically stops.
  My question is how do I integrate Kivy's loop (<code>app.run()</code>) with my own loop. I thought about calling all the game's logic from <code>on_press</code> of the pressed button, but that's a design I prefer not to pursue. Another solution I thought of was using two separate threads, one running Kivy's loop and another running my loop, but I do not have any of experience with threads.</p>
  
  <p>The whole project can be found <a href="https://github.com/katzuv/mancala-no-graphics" rel="nofollow noreferrer">here</a> (yes, I know the repo's name is now incorrect :-)).
  Thanks a lot!</p>