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.
Mixing ui and scene
-
When you want to use both the
ui
andscene
modules together, SceneViewer can act as a plug-compatible replacement forscene.run()
. Of course, scene.gravity() no longer works but more on that in a follow up post.In your code, replace:
scene.run(MyScene()) #with... import ui SceneViewer(MyScene()) class SceneViewer(ui.View): def __init__(self, in_scene): self.present('full_screen', hide_title_bar = True) scene_view = scene.SceneView(frame=self.frame) scene_view.scene = in_scene self.add_subview(scene_view) self.add_subview(self.close_button()) def close_action(self, sender): self.close() def close_button(self): the_button = ui.Button(title='X') the_button.x = self.width - the_button.width the_button.y = the_button.height / 2 the_button.action = self.close_action the_button.font=('<system-bold>', 20) return the_button