def show_page(self, id, type="page", change_history=True): """ Where which is a tuple (type, id): * (page, page_id) * (search, search_string) """ if self.help_system is None: display_error_message( _("Could not find markdown Python package. It is needed by the help system."), self.GetParent()) return if change_history: same_page_as_last = False if self.current_pos != -1: _, current_id = self.history[self.current_pos] if id == current_id: same_page_as_last = True if same_page_as_last is False: self.history = self.history[:self.current_pos + 1] self.history.append((type, id)) self.current_pos += 1 self._update_buttons() if type == "page": self.html_window.SetPage(self._generate_page(id)) elif type == "search": self.html_window.SetPage(self.help_system.get_search_results_page(id)) self.Show() self.Raise()
def show_page(self, id, type="page", change_history=True): """ Where which is a tuple (type, id): * (page, page_id) * (search, search_string) """ if self.help_system is None: display_error_message( _("Could not find markdown Python package. It is needed by the help system. See the Timeline website or the doc/installing.rst file for instructions how to install it." ), self.GetParent()) return if change_history: same_page_as_last = False if self.current_pos != -1: current_type, current_id = self.history[self.current_pos] if id == current_id: same_page_as_last = True if same_page_as_last == False: self.history = self.history[:self.current_pos + 1] self.history.append((type, id)) self.current_pos += 1 self._update_buttons() if type == "page": self.html_window.SetPage(self._generate_page(id)) elif type == "search": self.html_window.SetPage( self.help_system.get_search_results_page(id)) self.Show() self.Raise()
def save(self): category = self.view.get_category() if not self._category_is_given(category) and self.selected_event_ids == []: display_error_message(_("You must select a category!")) else: self._save_category_in_events(category) self.view.close()
def save(self): category = self.view.get_category() if not self._category_is_given( category) and self.selected_event_ids == []: display_error_message(_("You must select a category!")) else: self._save_category_in_events(category) self.view.close()
def ok_button_clicked(self, evt): try: if self.view.GetTime() is None: raise ValueError(_("Invalid date")) except ValueError as ex: display_error_message(ex_msg(ex)) else: self.view.Close()
def _set_milestone_time_period(self): try: t = self.view.GetTime() if t is None: raise DateTimeError() self._milestone.set_time_period(TimePeriod(t, t)) except: display_error_message(_("You can't save a milestone with an invalid date/time")) raise(DateTimeError())
def on_return(self): try: self.time = self.time_picker.get_value() if not self.checkbox.IsChecked(): gt = gregorian.from_time(self.time) gt.hour = 12 self.time = gt.to_time() except ValueError, ex: display_error_message(ex_msg(ex))
def _save_application_config(self): self.config.set_window_size(self.GetSize()) self.config.set_window_pos(self.GetPosition()) self.config.window_maximized = self.IsMaximized() self.config.sidebar_width = self.main_panel.get_sidebar_width() try: self.config.write() except IOError as ex: friendly = _("Unable to write configuration file.") msg = "%s\n\n%s" % (friendly, ex_msg(ex)) display_error_message(msg, self)
def _period_for_all_visible_events(self): try: visible_events = self._all_visible_events() if len(visible_events) > 0: start = self._first_time(visible_events) end = self._last_time(visible_events) return TimePeriod(start, end).zoom(-1) else: return None except ValueError as ex: display_error_message(ex.message) return None
def _period_for_all_visible_events(self): try: visible_events = self._all_visible_events() if len(visible_events) > 0: start = self._first_time(visible_events) end = self._last_time(visible_events) return TimePeriod(start, end).zoom(-1) else: return None except ValueError as ex: display_error_message(str(ex)) return None
def ok_button_clicked(self, evt): try: time = self.view.GetTime() if time is None: raise ValueError(_("Invalid date")) if self.time_type.is_date_time_type(): if not self.view.ShowTimeIsChecked(): gt = self.time_type.get_utils().from_time(time) gt.hour = 12 self.view.SetTime(gt.to_time()) except ValueError, ex: display_error_message(ex_msg(ex))
def run(self, main_frame): if not has_pysvg_module(): display_error_message(_("Could not find pysvg Python package. It is needed to export to SVG."), self) return helper = WildcardHelper(_("SVG files"), ["svg"]) wildcard = helper.wildcard_string() dialog = wx.FileDialog(main_frame, message=_("Export to SVG"), wildcard=wildcard, style=wx.FD_SAVE) if dialog.ShowModal() == wx.ID_OK: path = helper.get_path(dialog) overwrite_question = _("File '%s' exists. Overwrite?") % path if (not os.path.exists(path) or _ask_question(overwrite_question, main_frame) == wx.YES): main_frame.main_panel.timeline_panel.timeline_canvas.SaveAsSvg(path) dialog.Destroy()
def run(self, main_frame): if not has_pysvg_module(): display_error_message(_("Could not find pysvg Python package. It is needed to export to SVG."), self) return helper = WildcardHelper(_("SVG files"), ["svg"]) wildcard = helper.wildcard_string() dialog = wx.FileDialog(main_frame, message=_("Export to SVG"), wildcard=wildcard, style=wx.FD_SAVE) if dialog.ShowModal() == wx.ID_OK: path = helper.get_path(dialog) overwrite_question = _("File '%s' exists. Overwrite?") % path if (not os.path.exists(path) or _ask_question(overwrite_question, main_frame) == wx.YES): scene = main_frame.main_panel.get_scene() view_properties = main_frame.main_panel.get_view_properties() export(path, scene, view_properties) dialog.Destroy()
def _date_button_on_click(self, evt): try: wx_date = self.controller.date_tuple_to_wx_date(self.date_picker.get_value()) calendar_popup = CalendarPopup(self, wx_date, self.config) calendar_popup.Bind(wx.calendar.EVT_CALENDAR_SEL_CHANGED, self._calendar_on_date_changed) calendar_popup.Bind(wx.calendar.EVT_CALENDAR, self._calendar_on_date_changed_dclick) btn = evt.GetEventObject() pos = btn.ClientToScreen((0,0)) sz = btn.GetSize() calendar_popup.Position(pos, (0, sz[1])) calendar_popup.Popup() self.calendar_popup = calendar_popup except ValueError: display_error_message(_("Invalid date"))
def _date_button_on_click(self, evt): try: wx_date = self.controller.date_tuple_to_wx_date( self.date_picker.get_value()) calendar_popup = CalendarPopup(self, wx_date, self.config) calendar_popup.Bind(wx.calendar.EVT_CALENDAR_SEL_CHANGED, self._calendar_on_date_changed) calendar_popup.Bind(wx.calendar.EVT_CALENDAR, self._calendar_on_date_changed_dclick) btn = evt.GetEventObject() pos = btn.ClientToScreen((0, 0)) sz = btn.GetSize() calendar_popup.Position(pos, (0, sz[1])) calendar_popup.Popup() self.calendar_popup = calendar_popup except ValueError: display_error_message(_("Invalid date"))
def DisplayErrorMessage(self, message): display_error_message(message, parent=self)
def DisplayInvalidName(self, message): display_error_message(message, self) _set_focus_and_select(self.txt_name)
def InvalidTargetDir(self, message): display_error_message(message) self.tb_target_dir.SetFocus()
def open_timeline_if_exists(self, path): if os.path.exists(path): self.open_timeline(path) else: display_error_message( _("File '%s' does not exist.") % path, self._main_frame)
def display_invalid_name(self, message): display_error_message(message, self) _set_focus_and_select(self.txt_name)
def DisplayInvalidPeriod(self, message): guiutils.display_error_message(message, self)
def HandleInvalidName(self, name): msg = _("Category name '%s' not valid. Must be non-empty.") display_error_message(msg % name, self) _set_focus_and_select(self.txt_name)
def _DisplayInvalidInput(self, message, control): guiutils.display_error_message(message, self) guiutils._set_focus_and_select(control)
def HandleUsedName(self, name): msg = _("Category name '%s' already in use.") display_error_message(msg % name, self) _set_focus_and_select(self.txt_name)
def _btn_copy_on_click(self, evt): if wx.TheClipboard.Open(): self._copy_text_to_clipboard() else: display_error_message(_("Unable to copy to clipboard."))
def DisplayErrorMessage(self, message, focus_widget=None): display_error_message(message, parent=self) if focus_widget is not None: _set_focus_and_select(focus_widget)
def HandleDateErrors(self, error_count): display_error_message( _("%d Events not duplicated due to missing dates.") % error_count)
def open_timeline_if_exists(self, path): if os.path.exists(path): self.open_timeline(path) else: display_error_message(_("File '%s' does not exist.") % path, self._main_frame)