def execute(self): self.gui.distributeInitialData(self.initial_data) self.gui.distributeData(self.data) screen_w, screen_h = screen_width(), screen_height() if self.max_size is None: self.max_size = screen_w / 2, screen_h / 3 if self.min_size is None: self.min_size = screen_w / 2, screen_h / 4 self.gui.max_size = self.max_size self.gui.min_size = self.min_size resultMap = {} if self.gui.findChild(name="okButton"): resultMap["okButton"] = OK if self.gui.findChild(name="cancelButton"): resultMap["cancelButton"] = CANCEL if self.gui.findChild(name="yesButton"): resultMap["noButton"] = NO if self.gui.findChild(name="yesButton"): resultMap["yesButton"] = YES ok = self.gui.execute(resultMap) if ok: return self.getOkResult() return self.getCancelResult()
def execute(self): self.gui.distributeInitialData(self.initial_data) self.gui.distributeData(self.data) screen_w, screen_h = screen_width(), screen_height() if self.max_size is None: self.max_size = screen_w // 2, screen_h // 3 if self.min_size is None: self.min_size = screen_w // 2, screen_h // 4 self.gui.max_size = self.max_size self.gui.min_size = self.min_size resultMap = {} if self.gui.findChild(name="okButton"): resultMap["okButton"] = OK if self.gui.findChild(name="cancelButton"): resultMap["cancelButton"] = CANCEL if self.gui.findChild(name="yesButton"): resultMap["noButton"] = NO if self.gui.findChild(name="yesButton"): resultMap["yesButton"] = YES ok = self.gui.execute(resultMap) if ok: return self.getOkResult() return self.getCancelResult()
def new_f(*args, **kwargs): try: return pychan.tools.applyOnlySuitable(f, *args, **kwargs) except Exception, e: dialog = XMLDialog(StringIO(EXCEPTION_CATCHER_XML), initial_data={"message": str(e)}) tb = traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback) dialog.gui.findChild(name="traceback").text = "".join(tb) dialog.min_size = screen_width() / 2, 3 * screen_height() / 4 dialog.max_size = screen_width() / 2, 3 * screen_height() / 4 result = dialog.execute() if result == YES: return new_f(*args, **kwargs) elif result == NO: return raise
def new_f(*args,**kwargs): try: return pychan.tools.applyOnlySuitable(f,*args,**kwargs) except Exception, e: dialog = XMLDialog(StringIO(EXCEPTION_CATCHER_XML), initial_data={'message':str(e)} ) tb = traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback) dialog.gui.findChild(name="traceback").text = "".join(tb) dialog.min_size = screen_width()/2,3*screen_height()/4 dialog.max_size = screen_width()/2,3*screen_height()/4 result = dialog.execute() if result == YES: return new_f(*args,**kwargs) elif result == NO: return raise
def select(message="", options=[], caption="Message"): text = _make_text(message) dialog = XMLDialog(StringIO(SELECT_BOX_XML), initial_data={"message": text, "window": caption}) dialog.size = screen_width() / 3, 2 * screen_height() / 3 dialog.gui.findChild(name="message").max_width = screen_width() / 2 - 50 listbox = dialog.gui.findChild(name="selection") listbox.items = options if dialog.execute(): return listbox.selected_item return None
def select(message="",options=[],caption="Message"): text = _make_text(message) dialog = XMLDialog(StringIO(SELECT_BOX_XML), initial_data={'message':text,'window':caption}) dialog.size = screen_width()/3, 2*screen_height()/3 dialog.gui.findChild(name="message").max_width = screen_width()/2 - 50 listbox = dialog.gui.findChild(name="selection") listbox.items = options if dialog.execute(): return listbox.selected_item return None
def select(message="", options=[], caption="Message"): text = _make_text(message) dialog = XMLDialog(StringIO(SELECT_BOX_XML)) dialog.size = screen_width() // 3, (2 * screen_height()) // 3 dialog.gui.findChild(name="message").max_width = screen_width() // 2 - 50 dialog.gui.findChild(name="message").text = text dialog.gui.findChild(name="window").title = caption listbox = dialog.gui.findChild(name="selection") listbox.items = options if dialog.execute(): return listbox.selected_item return None
def select(message="",options=[],caption="Message"): text = _make_text(message) dialog = XMLDialog(StringIO(SELECT_BOX_XML)) dialog.size = screen_width() // 3, (2 * screen_height()) // 3 dialog.gui.findChild(name="message").max_width = screen_width() // 2 - 50 dialog.gui.findChild(name="message").text = text dialog.gui.findChild(name="window").title = caption listbox = dialog.gui.findChild(name="selection") listbox.items = options if dialog.execute(): return listbox.selected_item return None
def placeWidget(widget,position): """ Place a widget according to a string defining relative coordinates to screen borders. The position definition has to be of the form: C{"<x_pos><x_delta>:<y_pos><y_delta>"} C{<x_pos>} may be one of: - left - right - center - explicit C{<y_pos>} may be one of: - top - bottom - center - explicit C{explicit} means that the widgets x or y position will not be touched. The rest should be self explanatory. C{<x_delta>} and C{<y_delta>} must be of the form: +pixel_number or -pixel_number. Or comletely omitted. Note that the sign has to be there for for positive deltas, too. For brevity two shortcuts exist: - "explict" -> "explict:explict" - "automatic" -> "center:center" A few examples:: "right-20:top" "center:top+10" "center:center" @param widget: The PyChan widget. @param position: A position definition. If the position cannot be parsed a L{PyChanException} is thrown. """ if position == EXPLICIT: return x_pos,x_delta,y_pos,y_delta = _parsePosition(position) x,y = widget.position w,h = widget.size if x_pos == CENTER: x = (screen_width()-w)/2 + x_delta if y_pos == CENTER: y = (screen_height()-h)/2 + y_delta if x_pos == LEFT: x = x_delta if y_pos == TOP: y = y_delta if x_pos == RIGHT: x = screen_width() - w + x_delta if y_pos == BOTTOM: y = screen_height() - h + y_delta widget.position = x,y
def placeWidget(widget, position): """ Place a widget according to a string defining relative coordinates to screen borders. The position definition has to be of the form: C{"<x_pos><x_delta>:<y_pos><y_delta>"} C{<x_pos>} may be one of: - left - right - center - explicit C{<y_pos>} may be one of: - top - bottom - center - explicit C{explicit} means that the widgets x or y position will not be touched. The rest should be self explanatory. C{<x_delta>} and C{<y_delta>} must be of the form: +pixel_number or -pixel_number. Or completely omitted. Note that the sign has to be there for for positive deltas, too. For brevity two shortcuts exist: - "explicit" -> "explicit:explicit" - "automatic" -> "center:center" A few examples:: "right-20:top" "center:top+10" "center:center" @param widget: The PyChan widget. @param position: A position definition. If the position cannot be parsed a L{PyChanException} is thrown. """ if position == EXPLICIT: return x_pos, x_delta, y_pos, y_delta = _parsePosition(position) x, y = widget.position w, h = widget.size if x_pos == CENTER: x = (screen_width() - w) // 2 + x_delta if y_pos == CENTER: y = (screen_height() - h) // 2 + y_delta if x_pos == LEFT: x = x_delta if y_pos == TOP: y = y_delta if x_pos == RIGHT: x = screen_width() - w + x_delta if y_pos == BOTTOM: y = screen_height() - h + y_delta widget.position = x, y