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.dump_view() function?
-
@RocketBlaster05 said:
#all necessary imports are present already. class Menu (ui.View): #main menu setup def __init__(self): ui.View.__init__(self) self.scene_view = scene.SceneView() self.present(hide_title_bar=True) self.scene_view.frame = self.bounds self.add_subview(self.scene_view) ui.load_view(‘MainMenu’).present(‘fullscreen’, hide_title_bar=True) def button_tapped_learn(Learn): #button on ui LearnText() #scene for what I am trying to present ui.load_view(‘LearnPage’).present(‘fullscreen’, hide_title_bar = True) #ui I want to present ui.loadview(‘MainMenu’).close() #line that doesn’t work but doesn’t give me an error. Tried subbing it for mm and other nicknames. class LearnText (Scene): def setup(self): self.background_color = ‘white’ if __name__ == ‘__main__’: Menu()
And just as a heads up, all of this code works as intended except for the close function
-
@RocketBlaster05 you didn't pass via a variable
Thé ui.load_view(‘MainMenu’) that your presented is not the same object as the ui.load_view(‘MainMenu’) that you closeself.mm = ui.load_view(‘MainMenu’) self.mm.present(‘fullscreen’, hide_title_bar=True) . . . self.mm.close()
-
This should work but without the pyui files, I can't test
class Menu (ui.View): #main menu setup def __init__(self): ui.View.__init__(self) self.scene_view = scene.SceneView() self.present(hide_title_bar=True) self.scene_view.frame = self.bounds self.add_subview(self.scene_view) self.mm = ui.load_view(‘MainMenu’) self.mm.present(‘fullscreen’, hide_title_bar=True) def button_tapped_learn(Learn): #button on ui global m LearnText() #scene for what I am trying to present m.mm.close() #line that doesn’t work but doesn’t give me an error. Tried subbing it for mm and other nicknames. m.mm = ui.load_view(‘LearnPage’) m.mm.present(‘fullscreen’, hide_title_bar = True) #ui I want to present class LearnText (Scene): def setup(self): self.background_color = ‘white’ if __name__ == ‘__main__’: global m m = Menu()
-
-
@RocketBlaster05 perhaps you could insert a time.sleep(0.2) between the first view closing and the new view presenting
-
@cvp I have tried the sleep function but it freezes the close animation as well. I can only assume I'd have to move the loading portion around or something. I hope I find this soon because my app will have a lot of UI in it and this is a very important part lol.
-
@RocketBlaster05 could you try this
def button_tapped_learn(Learn): #button on ui global m LearnText() #scene for what I am trying to present m.mm.close() ui.delay(start_LearnPage,0.2) def start_LearnPage(): global m m.mm = ui.load_view(‘LearnPage’) m.mm.present(‘fullscreen’, hide_title_bar = True) #ui I want to present
-
@cvp Finally! This is working perfectly! However I must say that either due to my Ipad or the length of the close() animation the shortest time I can get this to consistently work is 0.55 seconds. It is not an issue and I think it will be just fine. Thank you so much!
-
-
@RocketBlaster05 if you have several views with same kind of process, you could avoid additional def for each view by
from functools import partial . . . def button_tapped_learn(Learn): #button on ui global m LearnText() #scene for what I am trying to present m.mm.close() m.mm = ui.View(name='LearnPage') ui.delay(partial(m.mm.present,'fullscreen', hide_title_bar = True),0.55)