Пример #1
0
    def run(self, params):
        assert self._application.mainWindow is not None
        assert self._application.mainWindow.pagePanel is not None

        with DateFormatDialog(
                self._application.mainWindow,
                _(u"Date format\n(empty string - format from program setting)"
                  ), _(u"Date format"), u"") as dlg:
            if dlg.ShowModal() == wx.ID_OK:
                params = u' format="{}"'.format(
                    dlg.Value) if len(dlg.Value) != 0 else u""
                text = u"(:{}{}:)".format(self.getCommandName(), params)

                self._application.mainWindow.pagePanel.pageView.codeEditor.replaceText(
                    text)
Пример #2
0
def insertCurrentDate(parent, editor):
    """
    Вызвать диалог для выбора формата даты и вставить в редактор текущую дату согласно выбранному формату.

    parent - родительское окно для диалога
    editor - текстовое поле ввода, куда надо вставить дату (экземпляр класса TextEditor)
    """
    config = GeneralGuiConfig(Application.config)
    initial = config.recentDateTimeFormat.value

    with DateFormatDialog(parent, _(u"Enter format of the date"),
                          _(u"Date format"), initial) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            dateStr = datetime.now().strftime(dlg.Value)
            editor.replaceText(dateStr)
            config.recentDateTimeFormat.value = dlg.Value