def delete_function(self,parent): global l_menu menu_name = self.eny3.get() func_name = self.eny8.get() if len(func_name) == 0: return if gui_message.ask('Do you really want to delete function [%s]?'%func_name): for i in range(len(l_menu)): if l_menu[i]['m_nam'] == menu_name: functions = l_menu[i]['m_items'] number_of_functions = len(functions) for j in range(number_of_functions): if functions[j]['i_nam'] == func_name: del l_menu[i]['m_items'][j] index = parent.menu.main_menu.component('%s-menu'%menu_name).index(func_name) parent.menu.main_menu.component('%s-menu'%menu_name).delete(index) self.functions.remove(func_name) try: os.remove('%s/PCMDI_GRAPHICS/%s_%s.py'%(os.environ['HOME'],menu_name,func_name)) except: pass try: os.remove('%s/PCMDI_GRAPHICS/%s_%s.pyo'%(os.environ['HOME'],menu_name,func_name)) except: pass self.eny8.clear() if len(self.functions) > 0: self.eny8.setlist(self.functions) break break gui_saved_settings.save_menus()
def del_top_menu(self, parent): global l_menu a = parent.menu.main_menu nam = self.eny9.get() if len(nam) == 0: return if not (gui_message.ask( 'Do you really want to\ndelete menu [%s]?' % nam)): return for i in range(len(l_menu)): if l_menu[i]['m_nam'] == nam: a.deletemenu(nam) del l_menu[i] #-------------------------------------- # Remove files from ~/PCMDI_GRAPHICS #-------------------------------------- menuname = glob(os.environ['HOME'] + '/PCMDI_GRAPHICS/' + nam + '.py') if menuname: os.remove(menuname) menuitems = glob(os.environ['HOME'] + '/PCMDI_GRAPHICS/' + nam + '_*.py*') for j in range(len(menuitems)): os.remove(menuitems[j]) for k in range(len(self.menus)): if self.menus[k] == nam: del self.menus[k] self.eny3.setlist(self.menus) self.eny9.setlist(self.menus) self.eny9.setentry('') if nam == self.eny3.get(): self.eny3.setentry('') self.functions = [] self.func_list = [] self.eny4.clear() self.eny5_file.clear() self.eny6.clear() self.eny7.clear() self.eny8.clear() break break gui_saved_settings.save_menus()
def del_top_menu(self,parent): global l_menu a = parent.menu.main_menu nam = self.eny9.get() if len(nam) == 0: return if not (gui_message.ask('Do you really want to\ndelete menu [%s]?'%nam)): return for i in range(len(l_menu)): if l_menu[i]['m_nam'] == nam: a.deletemenu(nam) del l_menu[i] #-------------------------------------- # Remove files from ~/PCMDI_GRAPHICS #-------------------------------------- menuname = glob(os.environ['HOME']+'/PCMDI_GRAPHICS/'+nam+'.py') if menuname: os.remove(menuname) menuitems = glob(os.environ['HOME']+'/PCMDI_GRAPHICS/'+nam+'_*.py*') for j in range(len(menuitems)): os.remove(menuitems[j]) for k in range(len(self.menus)): if self.menus[k] == nam: del self.menus[k] self.eny3.setlist(self.menus) self.eny9.setlist(self.menus) self.eny9.setentry('') if nam == self.eny3.get(): self.eny3.setentry('') self.functions = [] self.func_list = [] self.eny4.clear() self.eny5_file.clear() self.eny6.clear() self.eny7.clear() self.eny8.clear() break break gui_saved_settings.save_menus()
def delete_function(self, parent): global l_menu menu_name = self.eny3.get() func_name = self.eny8.get() if len(func_name) == 0: return if gui_message.ask('Do you really want to delete function [%s]?' % func_name): for i in range(len(l_menu)): if l_menu[i]['m_nam'] == menu_name: functions = l_menu[i]['m_items'] number_of_functions = len(functions) for j in range(number_of_functions): if functions[j]['i_nam'] == func_name: del l_menu[i]['m_items'][j] index = parent.menu.main_menu.component( '%s-menu' % menu_name).index(func_name) parent.menu.main_menu.component( '%s-menu' % menu_name).delete(index) self.functions.remove(func_name) try: os.remove( '%s/PCMDI_GRAPHICS/%s_%s.py' % (os.environ['HOME'], menu_name, func_name)) except: pass try: os.remove( '%s/PCMDI_GRAPHICS/%s_%s.pyo' % (os.environ['HOME'], menu_name, func_name)) except: pass self.eny8.clear() if len(self.functions) > 0: self.eny8.setlist(self.functions) break break gui_saved_settings.save_menus()