def OnReplace(self, event): pos = self._get_insert_pos() try: b = re.compile(self._get_find(), re.DOTALL) except Exception, e: common.showerror(self, str(e)) return
def copy_mo(self): langpath = os.path.join(self.mainframe.workpath, 'lang') dirs = [d for d in os.listdir(langpath) if os.path.isdir(os.path.join(langpath, d))] files = glob.glob(os.path.join(self.mainframe.workpath, 'plugins/*/*.mo')) import shutil for f in files: fname = os.path.splitext(os.path.basename(f))[0] flag = False for lang in dirs: if fname.endswith(lang): flag = True break if not flag: lang = fname[-5:] try: os.makedirs(os.path.join(self.mainframe.workpath, 'lang', fname[-5:])) except Exception, e: error.traceback() common.showerror(self, str(e)) continue dst = os.path.join(self.mainframe.workpath, 'lang', lang, os.path.basename(f)) try: shutil.copyfile(f, dst) except Exception, e: error.traceback() common.showerror(self, str(e)) continue
def OnApply(self, event): dlg = wx.MessageDialog( self, tr("Do you want to apply these changes?\nThese changes will not be undo." ), tr("Confirm"), wx.OK | wx.CANCEL | wx.ICON_INFORMATION) ret = dlg.ShowModal() dlg.Destroy() if ret == wx.ID_CANCEL: return for i in range(self.filenames.GetItemCount() - 1, -1, -1): if not self.filenames.getFlag(i): continue filename = self.fileinfos[self.filenames.GetItemData(i)] path = os.path.dirname(filename) if self.chk_remainsufix.GetValue(): ext = os.path.splitext(filename)[1] else: ext = '' f = self.filenames.getCell(i, 2) if f: newf = os.path.join(path, f + ext) try: os.rename(filename, newf) self.filenames.delline(i) except Exception, e: common.showerror(self, str(e)) self.filenames.setFlag(i, False) else: self.filenames.setFlag(i, False)
def copy_mo(self): langpath = os.path.join(self.mainframe.workpath, 'lang') dirs = [ d for d in os.listdir(langpath) if os.path.isdir(os.path.join(langpath, d)) ] files = glob.glob( os.path.join(self.mainframe.workpath, 'plugins/*/*.mo')) import shutil for f in files: fname = os.path.splitext(os.path.basename(f))[0] flag = False for lang in dirs: if fname.endswith(lang): flag = True break if not flag: lang = fname[-5:] try: os.makedirs( os.path.join(self.mainframe.workpath, 'lang', fname[-5:])) except Exception, e: error.traceback() common.showerror(self, str(e)) continue dst = os.path.join(self.mainframe.workpath, 'lang', lang, os.path.basename(f)) try: shutil.copyfile(f, dst) except Exception, e: error.traceback() common.showerror(self, str(e)) continue
def OnBlogWindow(win, event): try: win.mainframe.createBlogWindow() win.panel.showPage('Blog') except: error.traceback() common.showerror(win, tr('There is something wrong as running Blog Edit'))
def writefile(mainframe, filename, siteno, text, user=None, password=None): if siteno >= len(mainframe.pref.ftp_sites): common.showerror(mainframe, tr("Can't find the FTP site.")) return site = mainframe.pref.sites_info[mainframe.pref.ftp_sites[siteno]] if not user: user = site['user'] if not password: password = site['password'] flag, user, password = getuserpassword(mainframe, siteno) if not flag: common.setmessage(mainframe, tr('Connection canceled')) return ftp = FTP() #connect try: ftp.connect(site['ip'], site['port']) ftp.login(user, password) ftp.set_pasv(site['pasv']) import StringIO f = StringIO.StringIO(text) ftp.storbinary("STOR %s" % common.decode_string(filename), f) ftp.quit() ftp.close() return True except Exception, msg: error.traceback() common.showerror(mainframe, msg)
def OnStart(self, event=None): if not self.status: if not self.me or self.me == '*': common.showerror(self, tr("Username should not be empty or '*'")) self.txtName.SetFocus() return ip = self.txtIP.GetValue() if not ip: common.showerror(self, tr("Host address cannot be empty!")) self.txtIP.SetFocus() return port = int(self.txtPort.GetValue()) self.pref.pairprog_host = ip self.pref.pairprog_port = port self.pref.pairprog_username = self.me self.pref.save() try: self.server = Server.start_server(ip, port, self.servercommands) if self.server: self.AddUser(self.me, manager=True) self.change_status('startserver') self.callplugin('start', self, 'server') except: common.warn(tr("Start server error!")) error.traceback() else: self.server.shut_down() self.server = None self.change_status('stopserver') self.callplugin('stop', self, 'server')
def OnDelete(self, event): item = self.tree.GetSelection() if not self.is_ok(item): return parent = self.tree.GetItemParent(item) filename = self.get_node_filename(item) dlg = wx.MessageDialog(self, tr('Do you want to delete %s ?') % filename, tr("Message"), wx.YES_NO | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: if os.path.exists(filename): if os.path.isdir(filename): try: shutil.rmtree(filename) except: error.traceback() common.showerror( self, tr('Cannot delete directory %s!') % filename) return else: try: os.remove(filename) except: error.traceback() common.showerror( self, tr('Cannot delete file %s!') % filename) return self.tree.Delete(item) if self.tree.GetChildrenCount(parent) == 0: self.tree.Collapse(parent) self.tree.SetItemImage(parent, self.close_image, wx.TreeItemIcon_Normal) dlg.Destroy()
def delete(self): index = self.list.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) if index >= 0: flag = self.list.GetItemData(index) if flag == 2: return pathname = self.list.GetItemText(index) dlg = wx.MessageDialog(self, tr("Do you want to delete %s?") % pathname, tr("Delete"), wx.YES_NO | wx.ICON_QUESTION) answer = dlg.ShowModal() if answer == wx.ID_YES: if flag == 0: #dir try: self.ftp.rmd(common.decode_string(pathname)) except Exception, msg: error.traceback() common.showerror(self, msg) return elif flag == 1: #file try: self.ftp.delete(common.decode_string(pathname)) except Exception, msg: error.traceback() common.showerror(self, msg) return self.refresh(self.curpath)
def OnDjangoFunc(win, event): _id = event.GetId() try: if hasattr(win, "IDPM_DJANGO_STARTAPP") and _id == win.IDPM_DJANGO_STARTAPP: OnDjangoStartApp(win) elif hasattr(win, "IDPM_DJANGO_INSTALLAPP") and _id == win.IDPM_DJANGO_INSTALLAPP: d = Casing.Casing(OnDjangoInstallApp, win) v = Casing.new_obj() v.count = 0 # d.onprocess(onprocess, v=v, timestep=0.1) # d.onsuccess(onsuccess) # d.onexception(onsuccess) d.start_thread() elif hasattr(win, "IDPM_DJANGO_INSTALLSYSAPP_ADMIN") and _id == win.IDPM_DJANGO_INSTALLSYSAPP_ADMIN: d = Casing.Casing(OnDjangoInstallConApp, win, "admin") v = Casing.new_obj() # d.onprocess(onprocess, v=v, timestep=0.1) # d.onsuccess(onsuccess) # d.onexception(onsuccess) d.start_thread() elif hasattr(win, "IDPM_DJANGO_RUNSERVER") and _id == win.IDPM_DJANGO_RUNSERVER: OnDjangoRunServer(win) elif hasattr(win, "IDPM_DJANGO_RUNSHELL") and _id == win.IDPM_DJANGO_RUNSHELL: OnDjangoRunShell(win) elif hasattr(win, "IDPM_DJANGO_DOT") and _id == win.IDPM_DJANGO_DOT: OnCreateDot(win) except: error.traceback() common.showerror(win, tr("There is some wrong as executing the menu."))
def connect(self): self.running = True site = self.pref.sites_info[self.pref.ftp_sites[self.cmbSite.GetSelection()]] self.ftp = FTP() #connect try: common.setmessage(self.mainframe, tr('Connecting to %s (%s:%s)...') % (site['name'],site['ip'], site['port'])) self.ftp.connect(site['ip'], site['port']) flag, user, password = self.getuserpassword(self.cmbSite.GetSelection(), self.txtUser.GetValue(), self.txtPassword.GetValue()) if not flag: common.setmessage(self.mainframe, tr('Connection canceled')) self.ftp = None self.alive = False self.running = False return common.setmessage(self.mainframe, tr('Logging in...')) self.ftp.login(user, password) except socket.error, msg: error.traceback() common.showerror(self, msg[1]) self.ftp = None self.running = False return
def OnScriptItems(win, event): import wx.lib.dialogs import traceback from modules import common eid = event.GetId() index = win.scriptmenu_ids.index(eid) filename = win.pref.scripts[index][1] try: scripttext = open(common.encode_path(filename), 'rU').read() except: common.showerror(win, tr("Can't open the file %s.") % filename) return try: code = compile((scripttext + '\n'), common.encode_path(filename), 'exec') except: d = wx.lib.dialogs.ScrolledMessageDialog(win, (tr("Error compiling script.\n\nTraceback:\n\n") + ''.join(traceback.format_exception(*sys.exc_info()))), tr("Error"), wx.DefaultPosition, wx.Size(400,300)) d.ShowModal() d.Destroy() return try: namespace = locals() exec code in namespace except: d = wx.lib.dialogs.ScrolledMessageDialog(win, (tr("Error running script.\n\nTraceback:\n\n") + ''.join(traceback.format_exception(*sys.exc_info()))), tr("Error"), wx.DefaultPosition, wx.Size(400,300)) d.ShowModal() d.Destroy() return
def OnAddSubDir(self, event): item = self.tree.GetSelection() if not self.is_ok(item): return filename = self.get_node_filename(item) foldername = 'NewFolder' if self.isFile(item): item = self.tree.GetItemParent(item) filename = self.get_node_filename(item) if os.path.exists(os.path.join(filename, foldername)): common.showerror( self, tr('Directory %s has existed!') % os.path.join(filename, foldername)) return try: os.mkdir(os.path.join(filename, foldername)) except: error.traceback() common.showerror( self, tr('Create directory %s error!') % os.path.join(filename, foldername)) return node = self.addnode(item, filename, foldername, self.close_image, self.open_image, self.getid(), self.DIR_NODE) self.tree.SetItemHasChildren(node, True) wx.CallAfter(self.tree.Expand, item) wx.CallAfter(self.tree.EditLabel, node)
def readfile(mainframe, filename, siteno, user=None, password=None): if siteno >= len(mainframe.pref.ftp_sites): common.showerror(mainframe, tr("Can't find the FTP site.")) return site = mainframe.pref.sites_info[mainframe.pref.ftp_sites[siteno]] if not user: user = site['user'] if not password: password = site['password'] flag, user, password = getuserpassword(mainframe, siteno) if not flag: common.setmessage(mainframe, tr('Connection canceled')) return ftp = FTP() try: ftp.connect(site['ip'], site['port']) ftp.login(user, password) ftp.set_pasv(site['pasv']) data = [] def getdata(d, data=data): data.append(d) ftp.retrbinary("RETR %s" % common.decode_string(filename), getdata) ftp.quit() ftp.close() text = ''.join(data) return text except Exception, msg: error.traceback() common.showerror(mainframe, msg)
def rename(self): index = self.list.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) if index >= 0: pathname = self.list.GetItemText(index) dlg = MyTextEntry(self, tr("Name Input"), tr('Input a new name:'), '') answer = dlg.ShowModal() if answer == wx.ID_OK: newpath = dlg.GetValue() if not newpath: return flag = self.list.GetItemData(index) if flag != 2: #dir try: self.ftp.rename(common.decode_string(pathname), common.decode_string(newpath)) except Exception, msg: error.traceback() common.showerror(self, msg) return if self.refresh(self.curpath): index = self.list.FindItem(-1, newpath) self.list.SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_MASK_STATE)
def newdir(self): dirname = '' dlg = MyTextEntry(self, tr("Directory Input"), tr('Input a new directory:'), '') answer = dlg.ShowModal() if answer == wx.ID_OK: dirname = dlg.GetValue() if not dirname: return #check if the new name has existed index = self.list.FindItem(-1, dirname) if index > -1: common.showerror( self, tr('The directory already exists.\nPlease input another one.' )) return try: self.ftp.mkd(common.decode_string(dirname)) except Exception, msg: error.traceback() common.showerror(self, msg) return if self.refresh(self.curpath): index = self.list.FindItem(-1, dirname) self.list.SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_MASK_STATE)
def OnApply(self, event): dlg = wx.MessageDialog(self, tr("Do you want to apply these changes?\nThese changes will not be undo."), tr("Confirm"), wx.OK | wx.CANCEL | wx.ICON_INFORMATION) ret = dlg.ShowModal() dlg.Destroy() if ret == wx.ID_CANCEL: return for i in range(self.filenames.GetItemCount()-1, -1, -1): if not self.filenames.getFlag(i): continue filename = self.fileinfos[self.filenames.GetItemData(i)] path = os.path.dirname(filename) if self.chk_remainsufix.GetValue(): ext = os.path.splitext(filename)[1] else: ext = '' f = self.filenames.getCell(i, 2) if f: newf = os.path.join(path, f+ext) try: os.rename(filename, newf) self.filenames.delline(i) except Exception, e: common.showerror(self, str(e)) self.filenames.setFlag(i, False) else: self.filenames.setFlag(i, False)
def delete(self, postid=''): if not postid: index = self.list.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) if index == -1: common.showmessage(self.mainframe, tr('You should select on entry first!')) return filename = self.data[index] tree = Tree() tree.read_from_xml(file(filename).read()) data = tree['entry'] postid = data['postid'] common.setmessage(self.mainframe, tr('Deleting entry...')) site = self.pref.blog_sites_info[self.pref.blog_sites[self.cmbSite.GetSelection()]] try: server = xmlrpclib.ServerProxy(site['url']) result = server.blogger.deletePost('', postid, site['user'], site['password'], False) if result: common.showmessage(self.mainframe, tr('Delete is successful!')) self.list.DeleteItem(index) else: common.showerror(self.mainframe, tr('Delete error!')) except Exception, msg: error.traceback() common.showerror(self.mainframe, msg)
def newfile(self): filename = '' dlg = MyTextEntry(self, tr("Filename Input"), tr('Input a new filename:'), '') answer = dlg.ShowModal() if answer == wx.ID_OK: filename = dlg.GetValue() if not filename: return #check if the new name has existed index = self.list.FindItem(-1, filename) if index > -1: common.showerror(self, tr('The filename already exists.\nPlease input another one.')) return from StringIO import StringIO f = StringIO('') try: self.ftp.storbinary('STOR %s' % common.decode_string(filename), f) except Exception, msg: error.traceback() common.showerror(self, msg) return if self.refresh(self.curpath): index = self.list.FindItem(-1, filename) self.list.SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_MASK_STATE)
def OnDelete(self, event): item = self.tree.GetSelection() if not self.is_ok(item): return parent = self.tree.GetItemParent(item) filename = self.get_node_filename(item) dlg = wx.MessageDialog(self, tr('Do you want to delete %s ?') % filename, tr("Message"), wx.YES_NO | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: if os.path.exists(filename): if os.path.isdir(filename): try: shutil.rmtree(filename) except: error.traceback() common.showerror(self, tr('Cannot delete directory %s!') % filename) return else: try: os.remove(filename) except: error.traceback() common.showerror(self, tr('Cannot delete file %s!') % filename) return self.tree.Delete(item) if self.tree.GetChildrenCount(parent) == 0: self.tree.Collapse(parent) self.tree.SetItemImage(parent, self.close_image, wx.TreeItemIcon_Normal) dlg.Destroy()
def OnDocumentVoiceConfig(win, event): if not win.pytts: try: import pyTTS win.pytts = pyTTS.Create() win.pytts_flag = pyTTS.tts_is_xml, pyTTS.tts_async win.pytts.OnEndStream = win.OnTTSEndStream except: error.traceback() common.showerror(win, tr("Can't import pyTTS module, please install it first.")) return voices = win.pytts.GetVoiceNames() if not voices: common.showerror(win, tr("There is no available voices installed")) return if not win.pref.voice_name: win.pref.voice_name = voices[0] dialog = [ ('single', 'voice_name', win.pref.voice_name, tr('Voice names:'), zip(voices, voices)), ('int', 'tts_rate', win.pref.tts_rate, tr('TTS speak rate:'), None) ] from modules.EasyGuider import EasyDialog dlg = EasyDialog.EasyDialog(win, title=tr("Text to Speech setting"), elements=dialog) values = None if dlg.ShowModal() == wx.ID_OK: values = dlg.GetValue() dlg.Destroy() win.pref.tts_rate = values['tts_rate'] win.pref.voice_name = values['voice_name'] win.pref.save()
def read_snippet_file(self, filename, type, expand): try: e = ElementTree(file=filename) def f(): title = e.find('snippet/properties/title') nodes = e.find('snippet/content') data = {'type':'root', 'filename':filename, 'element':nodes, 'etree':e, 'caption':title.text} node = self.add_new_folder(self.root, title.text, data, modified=False) def add_nodes(root, nodes): for n in nodes: if n.tag == 'node': obj = self.add_new_node(root, n.attrib['caption'], data={'element':n}, modified=False) elif n.tag == 'folder': obj = self.add_new_folder(root, n.attrib['caption'], data={'element':n}, modified=False) add_nodes(obj, n.getchildren()) if expand: self.tree.Expand(root) add_nodes(node, nodes) wx.CallAfter(self.tree.SelectItem, node) if type == 'new': wx.CallAfter(self.tree.EditLabel, node) self._save_files() wx.CallAfter(f) except: error.traceback() common.showerror(tr("There are some errors as openning the Snippet file"))
def OnConnect(self, event=None): if not self.status: if not self.me or self.me == '*': common.showerror(self, tr("Username should not be empty or '*'")) self.txtName.SetFocus() return ip = self.txtIP.GetValue() if not ip: common.showerror(self, tr("Host address cannot be empty!")) self.txtIP.SetFocus() return port = int(self.txtPort.GetValue()) self.pref.pairprog_host = ip self.pref.pairprog_port = port self.pref.pairprog_username = self.me self.pref.save() # try: self.client = Client.start_client(ip, port, self.clientcommands) if self.client: self.client.call('join', self.me) self.change_status('connectserver') self.callplugin('start', self, 'client') # except: # common.warn(tr("Connect to server error!")) # error.traceback() else: self.client.close() self.client = None self.change_status('disconnectserver') self.callplugin('stop', self, 'client')
def connect(self): self.running = True site = self.pref.sites_info[self.pref.ftp_sites[ self.cmbSite.GetSelection()]] self.ftp = FTP() #connect try: common.setmessage( self.mainframe, tr('Connecting to %s (%s:%s)...') % (site['name'], site['ip'], site['port'])) self.ftp.connect(site['ip'], site['port']) flag, user, password = self.getuserpassword( self.cmbSite.GetSelection(), self.txtUser.GetValue(), self.txtPassword.GetValue()) if not flag: common.setmessage(self.mainframe, tr('Connection canceled')) self.ftp = None self.alive = False self.running = False return common.setmessage(self.mainframe, tr('Logging in...')) self.ftp.login(user, password) except socket.error, msg: error.traceback() common.showerror(self, msg[1]) self.ftp = None self.running = False return
def newfile(self): filename = '' dlg = MyTextEntry(self, tr("Filename Input"), tr('Input a new filename:'), '') answer = dlg.ShowModal() if answer == wx.ID_OK: filename = dlg.GetValue() if not filename: return #check if the new name has existed index = self.list.FindItem(-1, filename) if index > -1: common.showerror( self, tr('The filename already exists.\nPlease input another one.' )) return from StringIO import StringIO f = StringIO('') try: self.ftp.storbinary('STOR %s' % common.decode_string(filename), f) except Exception, msg: error.traceback() common.showerror(self, msg) return if self.refresh(self.curpath): index = self.list.FindItem(-1, filename) self.list.SetItemState(index, wx.LIST_STATE_SELECTED, wx.LIST_MASK_STATE)
def OnDocbookEnclose(editor): #find the docbook.acp file docbookini = common.getConfigPathFile('docbook_xml.ini') from modules import dict4ini x = dict4ini.DictIni(docbookini) taglist = x.default.taglist taglist.sort() #popup a selection win if taglist: from modules.EasyGuider import EasyDialog dialog = [ ('single', 'tagname', taglist[0], tr('Select a tag:'), taglist), ] dlg = EasyDialog.EasyDialog(editor, tr('Select a DocBook Element Name'), dialog) values = None if dlg.ShowModal() == wx.ID_OK: values = dlg.GetValue() dlg.Destroy() if values: tagname = values['tagname'] text = editor.GetSelectedText() editor.BeginUndoAction() if text: editor.ReplaceSelection('') if x.tag_values.has_key(tagname): settext(editor, [x.tag_values[tagname]]) else: editor.AddText('<%s>%s</%s>' % (tagname, text, tagname)) pos = editor.GetCurrentPos() - len(values['tagname']) - 3 editor.GotoPos(pos) editor.EndUndoAction() else: common.showerror(editor, tr("There are not tags defined in conf/docbook_xml.ini."))
def new(self, filename='', encoding='', delay=False, defaulttext='', language='', documenttype='texteditor'): doc = None if filename: for document in self.getDocuments(): #if the file has been opened if document.isMe(filename, documenttype): self.switch(document, delay) doc = document break else: #the file hasn't been opened #if current page is empty and has not been modified if (self.document != None) and self.document.canopenfile( filename, documenttype): #use current page , donot open a new page try: self.document.openfile(filename, encoding, delay, defaulttext) except MyUnicodeException, e: error.traceback() e.ShowMessage() doc = self.document except: error.traceback() common.showerror( self, tr("Can't open the file %s.") % filename) doc = self.document
def OnDocbookProjectFunc(win, event): _id = event.GetId() try: if _id == win.IDPM_DOCBOOK_PROJECT_ENCLOSE: OnDocbookEnclose(win) except: error.traceback() common.showerror(win, tr("There is some wrong as executing the menu."))
def OnJQueryProjectFunc(win, event): _id = event.GetId() try: if _id == win.IDPM_JQUERY_PROJECT_CREATE_COMMENT: OnJQueryProjectCreateComment(win) except: error.traceback() common.showerror(win, tr("There is some wrong as executing the menu."))
def OnToolSpellCheck(win, event): try: from enchant.checker import SpellChecker except: common.showerror(win, tr('You should install PyEnchant module first.\n Or there are something wrong as import the module')) return p = win.createSpellCheckWindow() win.panel.showPage(p)
def OnDjangoProjectFunc(win, event): _id = event.GetId() try: if _id == win.IDPM_DJANGO_PROJECT_NEW_MODEL: OnDjangoProjectNewModel(win) except: error.traceback() common.showerror(win, tr("There is some wrong as executing the menu."))
def getcurrentpath(self): #current path try: self.curpath = common.encode_string(self.ftp.pwd()) except Exception, msg: common.showerror(self, msg) error.traceback() self.curpath = ''
def openfile(win, filename): import shutil if filename and win.pref.auto_make_bak: bakfile = filename + '.bak' try: shutil.copyfile(filename, bakfile) except Exception, mesg: common.showerror(win, mesg)
def disconnect(self): try: if self.ftp and self.alive: if self.running: self.ftp.abort() self.ftp.quit() except Exception, msg: error.traceback() common.showerror(self, msg)
def setBin(self, bin): try: if bin: self.ftp.voidcmd('TYPE I') else: self.ftp.voidcmd('TYPE A') except Exception, msg: common.showerror(self, msg) return False
def save_snippet(self, node): root = self.get_root_node(node) data = self.get_node_data(root) try: data['etree'].write(data['filename'], 'utf-8') self.set_modify(root, False) self.deal_recent(data['filename']) except: error.traceback() common.showerror(self, tr("There is something wrong as saving the snippet file."))
def OnOK(self, event): scripts = [] for description, filename, shortcut in self.list.GetValue(): scripts.append((description+'\t'+shortcut, filename)) if (description == '') or (description == 'Change the description'): common.showerror(self, tr("The description must not be empty or ") + '"Change the description"' + tr('.\nPlease change them first!')) return self.pref.scripts = scripts[:] self.pref.save() event.Skip()
def OnToolSpellCheck(win, event): try: from enchant.checker import SpellChecker except: common.showerror( win, tr('You should install PyEnchant module first.\n Or there are something wrong as import the module' )) return p = win.createSpellCheckWindow() win.panel.showPage(p)
def open_recent_files(win, index): filename = win.pref.recent_files[index] try: f = file(filename) f.close() except: common.showerror(win, tr("Can't open the file %s.") % filename) del win.pref.recent_files[index] win.pref.save() return win.editctrl.new(filename)
def OnCreateDot(win): import djangodot path = win.get_node_filename(win.tree.GetSelection()) if os.path.isdir(path) and os.path.exists(os.path.join(path, 'models.py')): app = path dotfile = os.path.join(path, app+'.dot') imagefile = os.path.join(path, app+'.png') djangodot.createdotfile(os.path.basename(app), dotfile) create_dot_and_show(Globals.mainframe, imagefile, dotfile) else: common.showerror(win, tr("Current directory seems not a real Django app"))
def OnCreateDot(win): import djangodot path = win.get_node_filename(win.tree.GetSelection()) if os.path.isdir(path) and os.path.exists(os.path.join(path, 'models.py')): app = path dotfile = os.path.join(path, app + '.dot') imagefile = os.path.join(path, app + '.png') djangodot.createdotfile(os.path.basename(app), dotfile) create_dot_and_show(Globals.mainframe, imagefile, dotfile) else: common.showerror(win, tr("Current directory seems not a real Django app"))
def OnWeb2pyProjectFunc(win, event): _id = event.GetId() try: if _id == win.IDPM_WEB2PY_PROJECT_CONTROLLERS_VIEW: OnWeb2pyProjectControllersView(win) elif _id == win.IDPM_WEB2PY_PROJECT_CONTROLLERS_WEB: OnWeb2pyProjectControllersWeb(win) except: error.traceback() common.showerror(win, tr("There is some wrong as executing the menu."))