Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
UI launching a scene
-
Hi all,
I have made a game (which I have posted about before) using the
scene
module.I am trying to get a pyui file to launch the scene. After some trial and error I managed it like this:
import ui from black_white import * from time import sleep from scene import run @ui.in_background def start(sender): run(Game(), show_fps=False) v = ui.load_view() v.present('sheet', hide_title_bar = True)
black_white
is the name of the script running my sceneGame
.I could only get it to work by running the scene 'inside' the UI. I had to import
time.sleep
andscene.run
as my script needs them, which seems quite messy. When I try to close the UI viewv
at the end of thestart
function, everything closes!Does anyone know of a better way to do this?
-
You might be able to use a SceneView. Maybe it's just me, but I couldn't understand your question clearly. So this might not be the answer. But oh well.
You can create a SceneView:
sv = ui.SceneView()
Add your scene as a parameter of "sv", then use
main_view.add_subview(sv)
in your function.
Your button calls the function, the just clear the main_view and call the line above. -
Here you can find an example PhotoTextV2.
It's a ui.View with two scrollviews. One for buttons and another one for the scene.SceneView.edit: Have you tried ui.delay instead of time.sleep?
-