def on_delete_cmd(self, event): # Ask for delete confirmation cmd_name = self.list_cmds.GetStringSelection() if cmd_name == "": return msg = "Deleting a command cannot be undone.\n\n" \ "Are you sure that you want to delete the " \ "command '%s'?" % cmd_name should_delete = cjr.warn_yes_no(self, msg) # Delete the command if the user has confirmed they want to if should_delete == wx.ID_YES: # Delete the script file class_name = self.tree_classes.get_selected_class_name() cmd_path = self.__get_cmd_path(class_name, cmd_name) os.remove( cmd_path ) # Delete the class directory if there's no commmands left class_path = self.__get_class_path(class_name) if len( filedlg.get_file_list( class_path, ['lua'] ) ) == 0: try: os.rmdir( class_path ) except: cjr.show_error_message( "Unable to delete the class commands directory '" + class_path + "'.\n" \ "Maybe is it not empty or is another application using it?\n" \ "Please, remove it manually." ) # Delete the command from the nclass in memory servers.get_script_server().refreshclass( str(class_name) ) # Remove the command from the commands list self.list_cmds.Delete( self.list_cmds.GetSelection() ) self.__update_buttons()
def on_delete_cmd(self, event): # Ask for delete confirmation cmd_name = self.list_cmds.GetStringSelection() if cmd_name == "": return msg = "Deleting a command cannot be undone.\n\n" \ "Are you sure that you want to delete the " \ "command '%s'?" % cmd_name should_delete = cjr.warn_yes_no(self, msg) # Delete the command if the user has confirmed they want to if should_delete == wx.ID_YES: # Delete the script file class_name = self.tree_classes.get_selected_class_name() cmd_path = self.__get_cmd_path(class_name, cmd_name) os.remove(cmd_path) # Delete the class directory if there's no commmands left class_path = self.__get_class_path(class_name) if len(filedlg.get_file_list(class_path, ['lua'])) == 0: try: os.rmdir(class_path) except: cjr.show_error_message( "Unable to delete the class commands directory '" + class_path + "'.\n" \ "Maybe is it not empty or is another application using it?\n" \ "Please, remove it manually." ) # Delete the command from the nclass in memory servers.get_script_server().refreshclass(str(class_name)) # Remove the command from the commands list self.list_cmds.Delete(self.list_cmds.GetSelection()) self.__update_buttons()
def __get_commands_of_class(self, item, class_name): # Get all the file names in the directory wc:libs/classes/<class_name> # Each file name is the prototype of a command for that class return filedlg.get_file_list( self.__get_class_path(class_name), ['lua'] )
def __update_combo_local_texture(self): selection = self.combo_local_texture.GetStringSelection() self.combo_local_texture.Clear() self.combo_local_texture.AppendItems( filedlg.get_file_list( self.get_textures_path(), ['dds'], autoextension=False, recursive=True) ) if selection != "": self.combo_local_texture.SetStringSelection( selection )
def __update_combo_local_texture(self): selection = self.combo_local_texture.GetStringSelection() self.combo_local_texture.Clear() self.combo_local_texture.AppendItems( filedlg.get_file_list(self.get_textures_path(), ['dds'], autoextension=False, recursive=True)) if selection != "": self.combo_local_texture.SetStringSelection(selection)
def __set_properties(self): self.button_reload.Disable() # Python modules (except start up module) modules = filedlg.get_file_list('outgui:', ['pyc']) try: modules.remove('outgui') except: pass self.list_modules.AppendItems(modules)
def __set_properties(self): self.button_reload.Disable() # Python modules (except start up module) modules = filedlg.get_file_list( 'outgui:', ['pyc'] ) try: modules.remove( 'outgui' ) except: pass self.list_modules.AppendItems( modules )
def get_class_commands(class_name, inherited_cmds=False): """Return the prototype of all the scripted commands for a class""" path = format.append_to_path(ClassesPath, class_name) path = format.mangle_path(path) cmds_list = filedlg.get_file_list(path, ['lua']) if inherited_cmds: class_name = servers.get_kernel_server().getsuperclass(class_name) if class_name != ':null:': cmds_list.extend(get_class_commands(class_name, True)) cmds_list.sort() return cmds_list
def get_class_commands(class_name, inherited_cmds = False): """Return the prototype of all the scripted commands for a class""" path = format.append_to_path( ClassesPath, class_name ) path = format.mangle_path( path ) cmds_list = filedlg.get_file_list( path, ['lua'] ) if inherited_cmds: class_name = servers.get_kernel_server().getsuperclass( class_name ) if class_name != ':null:': cmds_list.extend( get_class_commands(class_name, True) ) cmds_list.sort() return cmds_list
def __get_commands_of_class(self, item, class_name): # Get all the file names in the directory wc:libs/classes/<class_name> # Each file name is the prototype of a command for that class return filedlg.get_file_list(self.__get_class_path(class_name), ['lua'])