def SetRuby(self, e=None, *, ruby_=None): slc = self.editor.GetSelection() if slc[0] == slc[1]: MessageBox("選択されたテキストがありません", "エラー", style=OK) return if not ruby_: dialog = TextEntryDialog(None, "振り仮名を入力してください", "振り仮名を設定") if dialog.ShowModal() == ID_CANCEL: return dialog.Destroy() res = dialog.GetValue() if not res: MessageBox("空欄にはできません", "エラー", style=OK) return else: res = ruby_ tmp = self.editor.GetValue() if linesep == "\r\n": newlines = tmp[:slc[0]].count("\n") else: newlines = 0 slc = slc[0] - newlines, slc[1] - newlines tmp = tmp[:slc[0]], tmp[slc[0]:slc[1]], tmp[slc[1]:] if linesep in tmp[1]: MessageBox("改行を挟むことはできません。", "エラー", style=OK) self.editor.SetValue(tmp[0] + f"|{tmp[1]}《{res}》" + tmp[2]) self.editor.SetInsertionPoint(slc[1] + newlines + len(res) + 3)
def OnLeftDClick(self, event): """ """ dlg = TextEntryDialog(None, _("Message"), _("Enter message"), self._pyutObject.getInstanceName(), OK | CANCEL | CENTRE) if dlg.ShowModal() == ID_OK: self._pyutObject.setInstanceName(dlg.GetValue()) dlg.Destroy()
def __create_test(self, page): modal = TextEntryDialog(self, u'Enter test case name', u'Create new test case') if modal.ShowModal() == ID_OK: test_case_name = modal.GetValue() if StringUtils.is_test_case_name_correct(test_case_name): page.create_new_test_case(test_case_name) else: show_dialog_bad_name(self, test_case_name, 'test_search')
def __create_method(self, page): modal = TextEntryDialog(self, u'Enter method name', u'Create method') if modal.ShowModal() == ID_OK: method_name = modal.GetValue() if StringUtils.is_method_name_correct(method_name): page.create_method(method_name) else: show_dialog_bad_name(self, method_name, 'search', 'login', 'fill_data')
def OnLeftDClick(self, event): """ Callback for left double clicks. """ dlg = TextEntryDialog(None, _("Message"), _("Enter message"), self._pyutSDMessage.getMessage(), OK | CANCEL | CENTRE) if dlg.ShowModal() == ID_OK: self._pyutSDMessage.setMessage(dlg.GetValue()) dlg.Destroy()
def load_config(): if not exists(config_path): config = {"user": {"password": "", "mailaddr": ""}, "post-to": ""} dialog = TextEntryDialog(None, "メールアドレスを入力してください。", "投稿元アドレスを設定") if dialog.ShowModal() == ID_CANCEL: raise Canceled() dialog.Destroy() res = dialog.GetValue() if not res: raise ValueError("空欄にはできません。") config["user"]["mailaddr"] = res dialog = TextEntryDialog(None, "パスワードを入力してください。", "投稿元アドレスのパスワードを設定") if dialog.ShowModal() == ID_CANCEL: raise Canceled() dialog.Destroy() res = dialog.GetValue() if not res: raise ValueError("空欄にはできません。") config["user"]["password"] = res dialog = TextEntryDialog(None, "投稿先メールアドレスを入力してください。", "投稿先アドレスを設定") if dialog.ShowModal() == ID_CANCEL: raise Canceled() dialog.Destroy() res = dialog.GetValue() if not res: raise ValueError("空欄にはできません。") config["post-to"] = res if not exists(default_wd): makedirs(default_wd) with open(config_path, 'w') as f: dump(config, f) else: with open(config_path) as f: config = load(f) return config
def Post(self, e): if len(self.editor.GetValue()) < 10: MessageBox("投稿するためには10文字以上必要です。", "エラー", style=OK) return dialog = TextEntryDialog(None, "小説のタイトルを設定してください", "小説タイトルを設定") dialog.ShowModal() dialog.Destroy() try: self.stat.SetStatusText("投稿中...", 1) send(dialog.GetValue(), self.editor.GetValue(), load_config(), self._sent) except ValueError as err: MessageBox(str(err), "エラー", style=OK) return except Canceled: return
def doAction(self, x: int, y: int): """ Do the current action at coordinates x, y. Args: x: x coord where the action must take place y: y coord where the action must take place """ self.logger.debug( f'doAction: {self._currentAction} ACTION_SELECTOR: {ACTION_SELECTOR}' ) umlFrame = self._treeNotebookHandler.getCurrentFrame() if umlFrame is None: return self.resetStatusText() if self._currentAction == ACTION_SELECTOR: return SKIP_EVENT elif self._currentAction == ACTION_NEW_CLASS: self.createOglClass(umlFrame=umlFrame, x=x, y=y) elif self._currentAction == ACTION_NEW_TEXT: self._createNewText(umlFrame, x, y) elif self._currentAction == ACTION_NEW_NOTE: self._createNewNote(umlFrame, x, y) elif self._currentAction == ACTION_NEW_ACTOR: pyutActor = umlFrame.createNewActor(x, y) if not self._currentActionPersistent: self._currentAction = ACTION_SELECTOR self.selectTool(self._tools[0]) dlg = TextEntryDialog(umlFrame, "Actor name", "Enter actor name", pyutActor.getName(), OK | CANCEL | CENTRE) if dlg.ShowModal() == ID_OK: pyutActor.setName(dlg.GetValue()) dlg.Destroy() umlFrame.Refresh() elif self._currentAction == ACTION_NEW_USECASE: pyutUseCase = umlFrame.createNewUseCase(x, y) if not self._currentActionPersistent: self._currentAction = ACTION_SELECTOR self.selectTool(self._tools[0]) dlg = DlgEditUseCase(umlFrame, -1, pyutUseCase) dlg.Destroy() umlFrame.Refresh() elif self._currentAction == ACTION_NEW_SD_INSTANCE: try: from org.pyut.ui.UmlSequenceDiagramsFrame import UmlSequenceDiagramsFrame if not isinstance(umlFrame, UmlSequenceDiagramsFrame): PyutUtils.displayError( _("A SD INSTANCE can't be added to a class diagram. You must create a sequence diagram." )) return instance = umlFrame.createNewSDInstance(x, y) if not self._currentActionPersistent: self._currentAction = ACTION_SELECTOR self.selectTool(self._tools[0]) dlg = TextEntryDialog(umlFrame, "Instance name", "Enter instance name", instance.getInstanceName(), OK | CANCEL | CENTRE) if dlg.ShowModal() == ID_OK: instance.setInstanceName(dlg.GetValue()) dlg.Destroy() umlFrame.Refresh() except (ValueError, Exception) as e: PyutUtils.displayError( _(f"An error occurred while trying to do this action {e}")) umlFrame.Refresh() elif self._currentAction == ACTION_ZOOM_IN: return SKIP_EVENT elif self._currentAction == ACTION_ZOOM_OUT: umlFrame.DoZoomOut(x, y) umlFrame.Refresh() self.updateTitle() else: return SKIP_EVENT return EVENT_PROCESSED