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.
Make a dialog if I press the „x“
-
@mikael I have first tried to change target action of close UIButton, possible but not so easy because some consequences.
-
-
That here is my code, but it doesn‘t work really:
import ui import console from scene import * class Scene(ui.View): def __init__(self): self.background_color = 'gray' self.name = 'Test' #def close(self,sender): self.paused = True if console.alert('Close Scene?','','Yes','No',hide_cancel_button=True) == 1: self.view.close() self.paused = False s = Scene() s.present('fullscreen')
-
@Python567 why is your Scene an ui.View? See @mikael 's code
-
@Python567 if you want to use an ui.View, try
import ui import console from scene import * class Scene(ui.View): def __init__(self): self.background_color = 'gray' self.name = 'Test' def will_close(self): #self.paused = True if console.alert('Close Scene?','','Yes','No',hide_cancel_button=True) == 2: return #self.paused = False s = Scene() s.present('fullscreen')
-
-
@cvp if I click „no“ on your code, the skript will close completely!
-
@Python567 you're right. Shame on me. I forgot that, like scene.stop, view.will_close allow to add process at end but not to avoid closing. Thus, you have to present without title and to build your own close button
-
import ui import console class Scene(ui.View): def __init__(self): self.background_color = 'gray' self.name = 'Test' self.add_subview(ui.Button(frame=(2,12,32,32),title='x',action=self.bclose)) def bclose(self,sender): if console.alert('Close Scene?','','Yes','No',hide_cancel_button=True) == 2: return self.close() s = Scene() s.present('fullscreen', hide_title_bar=True)
-
@cvp thanks