def run(self, pos=None): """Show the dialog as modal. Won't return until the dialog has been closed. @param pos Tuple (x, y). Position for the dialog. Defaults to None. @return The command that closed the dialog. """ self.area.getWxWidget().Fit(self) # We'll listen to the common dialog commands (ok, cancel) # ourselves. events.addCommandListener(self.handleCommand) # The command that closes the dialog. We'll assume the dialog # gets closed. self.closingCommand = 'cancel' if self.recommendedSize is not None: self.SetSize(self.recommendedSize) if pos: self.MoveXY(*pos) else: self.Centre() # Won't return until the dialog closes. self.ShowModal() # Stop listening. events.removeCommandListener(self.handleCommand) return self.closingCommand
def destroy(self): """Destroy the widget.""" # Remove the notification listener of this widget. events.removeNotifyListener(self.onNotify) events.removeCommandListener(self.onCommand) w = self.getWxWidget() # Detach from the containing sizer. sizer = w.GetContainingSizer() if sizer: sizer.Detach(w) w.Destroy()