From 77c752701f8a1e12f69ef838fae5cc250912023f Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 20 May 2022 21:19:52 +0300 Subject: [PATCH] - refactored the code for the file registration and for the keywords update into its own class to make the main class smaller - when creating new files the file names are added to the beginning of the keywords list for the usage of Qt auto-completer --- CHANGELOG.md | 2 + appCommon/RegisterFileKeywords.py | 710 +++++++++++++++++++++ appEditors/AppGerberEditor.py | 10 +- appEditors/AppTextEditor.py | 2 +- appGUI/preferences/PreferencesUIManager.py | 2 +- appMain.py | 656 ++----------------- appObjects/AppObject.py | 5 - appObjects/AppObjectTemplate.py | 7 +- appObjects/ObjectCollection.py | 24 +- appPlugins/ToolShell.py | 2 - 10 files changed, 777 insertions(+), 643 deletions(-) create mode 100644 appCommon/RegisterFileKeywords.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b1a2cdc..d4ba6b4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ CHANGELOG for FlatCAM Evo beta 20.05.2022 - small fix for a bug that interfere with running the 2D graphic mode +- refactored the code for the file registration and for the keywords update into its own class to make the main class smaller +- when creating new files the file names are added to the beginning of the keywords list for the usage of Qt auto-completer 19.05.2022 diff --git a/appCommon/RegisterFileKeywords.py b/appCommon/RegisterFileKeywords.py new file mode 100644 index 00000000..d09da33a --- /dev/null +++ b/appCommon/RegisterFileKeywords.py @@ -0,0 +1,710 @@ + +from PyQt6.QtCore import pyqtSignal +from PyQt6 import QtCore + +from dataclasses import dataclass +import ctypes +import winreg +from copy import deepcopy +import os +import sys +import typing + +if typing.TYPE_CHECKING: + import appMain + + +@dataclass +class KeyWords: + """ + Holds the keywords recognized by the application + """ + + tcl_commands = [ + 'add_aperture', 'add_circle', 'add_drill', 'add_poly', 'add_polygon', 'add_polyline', + 'add_rectangle', 'add_rect', 'add_slot', + 'aligndrill', 'aligndrillgrid', 'bbox', 'buffer', 'clear', 'cncjob', 'cutout', + 'del', 'drillcncjob', 'export_dxf', 'edxf', 'export_excellon', + 'export_exc', + 'export_gcode', 'export_gerber', 'export_svg', 'ext', 'exteriors', 'follow', + 'geo_union', 'geocutout', 'get_active', 'get_bounds', 'get_names', 'get_path', + 'get_sys', 'help', + 'interiors', 'isolate', 'join_excellon', + 'join_geometry', 'list_sys', 'list_pp', 'milld', 'mills', 'milldrills', 'millslots', + 'mirror', 'ncc', + 'ncr', 'new', 'new_geometry', 'new_gerber', 'new_excellon', 'non_copper_regions', + 'offset', + 'open_dxf', 'open_excellon', 'open_gcode', 'open_gerber', 'open_project', 'open_svg', + 'options', 'origin', + 'paint', 'panelize', 'plot_all', 'plot_objects', 'plot_status', 'quit_app', + 'save', 'save_project', + 'save_sys', 'scale', 'set_active', 'set_origin', 'set_path', 'set_sys', + 'skew', 'subtract_poly', 'subtract_rectangle', + 'version', 'write_gcode' + ] + + # those need to be duplicated in self.options["util_autocomplete_keywords"] but within a string + default_keywords = [ + 'Berta_CNC', 'Default_no_M6', 'Desktop', 'Documents', 'FlatConfig', 'FlatPrj', + 'False', 'GRBL_11', 'GRL_11_no_M6', 'GRBL_laser', 'grbl_laser_eleks_drd', + 'GRBL_laser_z', 'ISEL_CNC', 'ISEL_ICP_CNC', + 'Line_xyz', 'Marlin', + 'Marlin_laser_FAN_pin', 'Marlin_laser_Spindle_pin', 'NCCAD9', 'Marius', 'My Documents', + 'Paste_1', 'Repetier', 'Roland_MDX_20', 'Roland_MDX_540', + 'Toolchange_Manual', 'Toolchange_Probe_MACH3', + 'True', 'Users', + 'all', 'auto', 'axis', + 'axisoffset', 'box', 'center_x', 'center_y', 'center', 'columns', 'combine', 'connect', + 'contour', 'default', + 'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz', 'dpp', + 'dwelltime', 'extracut_length', 'endxy', 'endz', 'f', 'factor', 'feedrate', + 'feedrate_z', 'gridoffsety', 'gridx', 'gridy', + 'has_offset', 'holes', 'hpgl', 'iso_type', 'join', 'keep_scripts', + 'las_min_pwr', 'las_power', 'margin', 'marlin', 'method', + 'milled_dias', 'minoffset', 'min_bounds', 'name', 'offset', 'opt_type', 'order', + 'outname', 'overlap', 'obj_name', + 'p_coords', 'passes', 'postamble', 'pp', 'ppname_e', 'ppname_g', + 'preamble', 'radius', 'ref', 'rest', 'rows', 'shellvar_', 'scale_factor', + 'spacing_columns', + 'spacing_rows', 'spindlespeed', 'startz', 'startxy', + 'toolchange_xy', 'toolchangez', 'travelz', + 'tooldia', 'use_threads', 'value', + 'x', 'x0', 'x1', 'x_dist', 'y', 'y0', 'y1', 'y_dist', 'z_cut', 'z_move' + ] + + tcl_keywords = [ + 'after', 'append', 'apply', 'argc', 'argv', 'argv0', 'array', 'attemptckalloc', 'attemptckrealloc', + 'auto_execok', 'auto_import', 'auto_load', 'auto_mkindex', 'auto_path', 'auto_qualify', 'auto_reset', + 'bgerror', 'binary', 'break', 'case', 'catch', 'cd', 'chan', 'ckalloc', 'ckfree', 'ckrealloc', 'clock', + 'close', 'concat', 'continue', 'coroutine', 'dde', 'dict', 'encoding', 'env', 'eof', 'error', 'errorCode', + 'errorInfo', 'eval', 'exec', 'exit', 'expr', 'fblocked', 'fconfigure', 'fcopy', 'file', 'fileevent', + 'filename', 'flush', 'for', 'foreach', 'format', 'gets', 'glob', 'global', 'history', 'http', 'if', 'incr', + 'info', 'interp', 'join', 'lappend', 'lassign', 'lindex', 'linsert', 'list', 'llength', 'load', 'lrange', + 'lrepeat', 'lreplace', 'lreverse', 'lsearch', 'lset', 'lsort', 'mathfunc', 'mathop', 'memory', 'msgcat', + 'my', 'namespace', 'next', 'nextto', 'open', 'package', 'parray', 'pid', 'pkg_mkIndex', 'platform', + 'proc', 'puts', 'pwd', 're_syntax', 'read', 'refchan', 'regexp', 'registry', 'regsub', 'rename', 'return', + 'safe', 'scan', 'seek', 'self', 'set', 'socket', 'source', 'split', 'string', 'subst', 'switch', + 'tailcall', 'Tcl', 'Tcl_Access', 'Tcl_AddErrorInfo', 'Tcl_AddObjErrorInfo', 'Tcl_AlertNotifier', + 'Tcl_Alloc', 'Tcl_AllocHashEntryProc', 'Tcl_AllocStatBuf', 'Tcl_AllowExceptions', 'Tcl_AppendAllObjTypes', + 'Tcl_AppendElement', 'Tcl_AppendExportList', 'Tcl_AppendFormatToObj', 'Tcl_AppendLimitedToObj', + 'Tcl_AppendObjToErrorInfo', 'Tcl_AppendObjToObj', 'Tcl_AppendPrintfToObj', 'Tcl_AppendResult', + 'Tcl_AppendResultVA', 'Tcl_AppendStringsToObj', 'Tcl_AppendStringsToObjVA', 'Tcl_AppendToObj', + 'Tcl_AppendUnicodeToObj', 'Tcl_AppInit', 'Tcl_AppInitProc', 'Tcl_ArgvInfo', 'Tcl_AsyncCreate', + 'Tcl_AsyncDelete', 'Tcl_AsyncInvoke', 'Tcl_AsyncMark', 'Tcl_AsyncProc', 'Tcl_AsyncReady', + 'Tcl_AttemptAlloc', 'Tcl_AttemptRealloc', 'Tcl_AttemptSetObjLength', 'Tcl_BackgroundError', + 'Tcl_BackgroundException', 'Tcl_Backslash', 'Tcl_BadChannelOption', 'Tcl_CallWhenDeleted', 'Tcl_Canceled', + 'Tcl_CancelEval', 'Tcl_CancelIdleCall', 'Tcl_ChannelBlockModeProc', 'Tcl_ChannelBuffered', + 'Tcl_ChannelClose2Proc', 'Tcl_ChannelCloseProc', 'Tcl_ChannelFlushProc', 'Tcl_ChannelGetHandleProc', + 'Tcl_ChannelGetOptionProc', 'Tcl_ChannelHandlerProc', 'Tcl_ChannelInputProc', 'Tcl_ChannelName', + 'Tcl_ChannelOutputProc', 'Tcl_ChannelProc', 'Tcl_ChannelSeekProc', 'Tcl_ChannelSetOptionProc', + 'Tcl_ChannelThreadActionProc', 'Tcl_ChannelTruncateProc', 'Tcl_ChannelType', 'Tcl_ChannelVersion', + 'Tcl_ChannelWatchProc', 'Tcl_ChannelWideSeekProc', 'Tcl_Chdir', 'Tcl_ClassGetMetadata', + 'Tcl_ClassSetConstructor', 'Tcl_ClassSetDestructor', 'Tcl_ClassSetMetadata', 'Tcl_ClearChannelHandlers', + 'Tcl_CloneProc', 'Tcl_Close', 'Tcl_CloseProc', 'Tcl_CmdDeleteProc', 'Tcl_CmdInfo', + 'Tcl_CmdObjTraceDeleteProc', 'Tcl_CmdObjTraceProc', 'Tcl_CmdProc', 'Tcl_CmdTraceProc', + 'Tcl_CommandComplete', 'Tcl_CommandTraceInfo', 'Tcl_CommandTraceProc', 'Tcl_CompareHashKeysProc', + 'Tcl_Concat', 'Tcl_ConcatObj', 'Tcl_ConditionFinalize', 'Tcl_ConditionNotify', 'Tcl_ConditionWait', + 'Tcl_Config', 'Tcl_ConvertCountedElement', 'Tcl_ConvertElement', 'Tcl_ConvertToType', + 'Tcl_CopyObjectInstance', 'Tcl_CreateAlias', 'Tcl_CreateAliasObj', 'Tcl_CreateChannel', + 'Tcl_CreateChannelHandler', 'Tcl_CreateCloseHandler', 'Tcl_CreateCommand', 'Tcl_CreateEncoding', + 'Tcl_CreateEnsemble', 'Tcl_CreateEventSource', 'Tcl_CreateExitHandler', 'Tcl_CreateFileHandler', + 'Tcl_CreateHashEntry', 'Tcl_CreateInterp', 'Tcl_CreateMathFunc', 'Tcl_CreateNamespace', + 'Tcl_CreateObjCommand', 'Tcl_CreateObjTrace', 'Tcl_CreateSlave', 'Tcl_CreateThread', + 'Tcl_CreateThreadExitHandler', 'Tcl_CreateTimerHandler', 'Tcl_CreateTrace', + 'Tcl_CutChannel', 'Tcl_DecrRefCount', 'Tcl_DeleteAssocData', 'Tcl_DeleteChannelHandler', + 'Tcl_DeleteCloseHandler', 'Tcl_DeleteCommand', 'Tcl_DeleteCommandFromToken', 'Tcl_DeleteEvents', + 'Tcl_DeleteEventSource', 'Tcl_DeleteExitHandler', 'Tcl_DeleteFileHandler', 'Tcl_DeleteHashEntry', + 'Tcl_DeleteHashTable', 'Tcl_DeleteInterp', 'Tcl_DeleteNamespace', 'Tcl_DeleteThreadExitHandler', + 'Tcl_DeleteTimerHandler', 'Tcl_DeleteTrace', 'Tcl_DetachChannel', 'Tcl_DetachPids', 'Tcl_DictObjDone', + 'Tcl_DictObjFirst', 'Tcl_DictObjGet', 'Tcl_DictObjNext', 'Tcl_DictObjPut', 'Tcl_DictObjPutKeyList', + 'Tcl_DictObjRemove', 'Tcl_DictObjRemoveKeyList', 'Tcl_DictObjSize', 'Tcl_DiscardInterpState', + 'Tcl_DiscardResult', 'Tcl_DontCallWhenDeleted', 'Tcl_DoOneEvent', 'Tcl_DoWhenIdle', + 'Tcl_DriverBlockModeProc', 'Tcl_DriverClose2Proc', 'Tcl_DriverCloseProc', 'Tcl_DriverFlushProc', + 'Tcl_DriverGetHandleProc', 'Tcl_DriverGetOptionProc', 'Tcl_DriverHandlerProc', 'Tcl_DriverInputProc', + 'Tcl_DriverOutputProc', 'Tcl_DriverSeekProc', 'Tcl_DriverSetOptionProc', 'Tcl_DriverThreadActionProc', + 'Tcl_DriverTruncateProc', 'Tcl_DriverWatchProc', 'Tcl_DriverWideSeekProc', 'Tcl_DStringAppend', + 'Tcl_DStringAppendElement', 'Tcl_DStringEndSublist', 'Tcl_DStringFree', 'Tcl_DStringGetResult', + 'Tcl_DStringInit', 'Tcl_DStringLength', 'Tcl_DStringResult', 'Tcl_DStringSetLength', + 'Tcl_DStringStartSublist', 'Tcl_DStringTrunc', 'Tcl_DStringValue', 'Tcl_DumpActiveMemory', + 'Tcl_DupInternalRepProc', 'Tcl_DuplicateObj', 'Tcl_EncodingConvertProc', 'Tcl_EncodingFreeProc', + 'Tcl_EncodingType', 'tcl_endOfWord', 'Tcl_Eof', 'Tcl_ErrnoId', 'Tcl_ErrnoMsg', 'Tcl_Eval', 'Tcl_EvalEx', + 'Tcl_EvalFile', 'Tcl_EvalObjEx', 'Tcl_EvalObjv', 'Tcl_EvalTokens', 'Tcl_EvalTokensStandard', 'Tcl_Event', + 'Tcl_EventCheckProc', 'Tcl_EventDeleteProc', 'Tcl_EventProc', 'Tcl_EventSetupProc', 'Tcl_EventuallyFree', + 'Tcl_Exit', 'Tcl_ExitProc', 'Tcl_ExitThread', 'Tcl_Export', 'Tcl_ExposeCommand', 'Tcl_ExprBoolean', + 'Tcl_ExprBooleanObj', 'Tcl_ExprDouble', 'Tcl_ExprDoubleObj', 'Tcl_ExprLong', 'Tcl_ExprLongObj', + 'Tcl_ExprObj', 'Tcl_ExprString', 'Tcl_ExternalToUtf', 'Tcl_ExternalToUtfDString', 'Tcl_FileProc', + 'Tcl_Filesystem', 'Tcl_Finalize', 'Tcl_FinalizeNotifier', 'Tcl_FinalizeThread', 'Tcl_FindCommand', + 'Tcl_FindEnsemble', 'Tcl_FindExecutable', 'Tcl_FindHashEntry', 'tcl_findLibrary', 'Tcl_FindNamespace', + 'Tcl_FirstHashEntry', 'Tcl_Flush', 'Tcl_ForgetImport', 'Tcl_Format', 'Tcl_FreeHashEntryProc', + 'Tcl_FreeInternalRepProc', 'Tcl_FreeParse', 'Tcl_FreeProc', 'Tcl_FreeResult', + 'Tcl_Free·\xa0Tcl_FreeEncoding', 'Tcl_FSAccess', 'Tcl_FSAccessProc', 'Tcl_FSChdir', + 'Tcl_FSChdirProc', 'Tcl_FSConvertToPathType', 'Tcl_FSCopyDirectory', 'Tcl_FSCopyDirectoryProc', + 'Tcl_FSCopyFile', 'Tcl_FSCopyFileProc', 'Tcl_FSCreateDirectory', 'Tcl_FSCreateDirectoryProc', + 'Tcl_FSCreateInternalRepProc', 'Tcl_FSData', 'Tcl_FSDeleteFile', 'Tcl_FSDeleteFileProc', + 'Tcl_FSDupInternalRepProc', 'Tcl_FSEqualPaths', 'Tcl_FSEvalFile', 'Tcl_FSEvalFileEx', + 'Tcl_FSFileAttrsGet', 'Tcl_FSFileAttrsGetProc', 'Tcl_FSFileAttrsSet', 'Tcl_FSFileAttrsSetProc', + 'Tcl_FSFileAttrStrings', 'Tcl_FSFileSystemInfo', 'Tcl_FSFilesystemPathTypeProc', + 'Tcl_FSFilesystemSeparatorProc', 'Tcl_FSFreeInternalRepProc', 'Tcl_FSGetCwd', 'Tcl_FSGetCwdProc', + 'Tcl_FSGetFileSystemForPath', 'Tcl_FSGetInternalRep', 'Tcl_FSGetNativePath', 'Tcl_FSGetNormalizedPath', + 'Tcl_FSGetPathType', 'Tcl_FSGetTranslatedPath', 'Tcl_FSGetTranslatedStringPath', + 'Tcl_FSInternalToNormalizedProc', 'Tcl_FSJoinPath', 'Tcl_FSJoinToPath', 'Tcl_FSLinkProc', + 'Tcl_FSLink·\xa0Tcl_FSListVolumes', 'Tcl_FSListVolumesProc', 'Tcl_FSLoadFile', 'Tcl_FSLoadFileProc', + 'Tcl_FSLstat', 'Tcl_FSLstatProc', 'Tcl_FSMatchInDirectory', 'Tcl_FSMatchInDirectoryProc', + 'Tcl_FSMountsChanged', 'Tcl_FSNewNativePath', 'Tcl_FSNormalizePathProc', 'Tcl_FSOpenFileChannel', + 'Tcl_FSOpenFileChannelProc', 'Tcl_FSPathInFilesystemProc', 'Tcl_FSPathSeparator', 'Tcl_FSRegister', + 'Tcl_FSRemoveDirectory', 'Tcl_FSRemoveDirectoryProc', 'Tcl_FSRenameFile', 'Tcl_FSRenameFileProc', + 'Tcl_FSSplitPath', 'Tcl_FSStat', 'Tcl_FSStatProc', 'Tcl_FSUnloadFile', 'Tcl_FSUnloadFileProc', + 'Tcl_FSUnregister', 'Tcl_FSUtime', 'Tcl_FSUtimeProc', 'Tcl_GetAccessTimeFromStat', 'Tcl_GetAlias', + 'Tcl_GetAliasObj', 'Tcl_GetAssocData', 'Tcl_GetBignumFromObj', 'Tcl_GetBlocksFromStat', + 'Tcl_GetBlockSizeFromStat', 'Tcl_GetBoolean', 'Tcl_GetBooleanFromObj', 'Tcl_GetByteArrayFromObj', + 'Tcl_GetChangeTimeFromStat', 'Tcl_GetChannel', 'Tcl_GetChannelBufferSize', 'Tcl_GetChannelError', + 'Tcl_GetChannelErrorInterp', 'Tcl_GetChannelHandle', 'Tcl_GetChannelInstanceData', 'Tcl_GetChannelMode', + 'Tcl_GetChannelName', 'Tcl_GetChannelNames', 'Tcl_GetChannelNamesEx', 'Tcl_GetChannelOption', + 'Tcl_GetChannelThread', 'Tcl_GetChannelType', 'Tcl_GetCharLength', 'Tcl_GetClassAsObject', + 'Tcl_GetCommandFromObj', 'Tcl_GetCommandFullName', 'Tcl_GetCommandInfo', 'Tcl_GetCommandInfoFromToken', + 'Tcl_GetCommandName', 'Tcl_GetCurrentNamespace', 'Tcl_GetCurrentThread', 'Tcl_GetCwd', + 'Tcl_GetDefaultEncodingDir', 'Tcl_GetDeviceTypeFromStat', 'Tcl_GetDouble', 'Tcl_GetDoubleFromObj', + 'Tcl_GetEncoding', 'Tcl_GetEncodingFromObj', 'Tcl_GetEncodingName', 'Tcl_GetEncodingNameFromEnvironment', + 'Tcl_GetEncodingNames', 'Tcl_GetEncodingSearchPath', 'Tcl_GetEnsembleFlags', 'Tcl_GetEnsembleMappingDict', + 'Tcl_GetEnsembleNamespace', 'Tcl_GetEnsembleParameterList', 'Tcl_GetEnsembleSubcommandList', + 'Tcl_GetEnsembleUnknownHandler', 'Tcl_GetErrno', 'Tcl_GetErrorLine', 'Tcl_GetFSDeviceFromStat', + 'Tcl_GetFSInodeFromStat', 'Tcl_GetGlobalNamespace', 'Tcl_GetGroupIdFromStat', 'Tcl_GetHashKey', + 'Tcl_GetHashValue', 'Tcl_GetHostName', 'Tcl_GetIndexFromObj', 'Tcl_GetIndexFromObjStruct', 'Tcl_GetInt', + 'Tcl_GetInterpPath', 'Tcl_GetIntFromObj', 'Tcl_GetLinkCountFromStat', 'Tcl_GetLongFromObj', + 'Tcl_GetMaster', 'Tcl_GetMathFuncInfo', 'Tcl_GetModeFromStat', 'Tcl_GetModificationTimeFromStat', + 'Tcl_GetNameOfExecutable', 'Tcl_GetNamespaceUnknownHandler', 'Tcl_GetObjectAsClass', 'Tcl_GetObjectCommand', + 'Tcl_GetObjectFromObj', 'Tcl_GetObjectName', 'Tcl_GetObjectNamespace', 'Tcl_GetObjResult', 'Tcl_GetObjType', + 'Tcl_GetOpenFile', 'Tcl_GetPathType', 'Tcl_GetRange', 'Tcl_GetRegExpFromObj', 'Tcl_GetReturnOptions', + 'Tcl_Gets', 'Tcl_GetServiceMode', 'Tcl_GetSizeFromStat', 'Tcl_GetSlave', 'Tcl_GetsObj', + 'Tcl_GetStackedChannel', 'Tcl_GetStartupScript', 'Tcl_GetStdChannel', 'Tcl_GetString', + 'Tcl_GetStringFromObj', 'Tcl_GetStringResult', 'Tcl_GetThreadData', 'Tcl_GetTime', 'Tcl_GetTopChannel', + 'Tcl_GetUniChar', 'Tcl_GetUnicode', 'Tcl_GetUnicodeFromObj', 'Tcl_GetUserIdFromStat', 'Tcl_GetVar', + 'Tcl_GetVar2', 'Tcl_GetVar2Ex', 'Tcl_GetVersion', 'Tcl_GetWideIntFromObj', 'Tcl_GlobalEval', + 'Tcl_GlobalEvalObj', 'Tcl_GlobTypeData', 'Tcl_HashKeyType', 'Tcl_HashStats', 'Tcl_HideCommand', + 'Tcl_IdleProc', 'Tcl_Import', 'Tcl_IncrRefCount', 'Tcl_Init', 'Tcl_InitCustomHashTable', + 'Tcl_InitHashTable', 'Tcl_InitMemory', 'Tcl_InitNotifier', 'Tcl_InitObjHashTable', 'Tcl_InitStubs', + 'Tcl_InputBlocked', 'Tcl_InputBuffered', 'tcl_interactive', 'Tcl_Interp', 'Tcl_InterpActive', + 'Tcl_InterpDeleted', 'Tcl_InterpDeleteProc', 'Tcl_InvalidateStringRep', 'Tcl_IsChannelExisting', + 'Tcl_IsChannelRegistered', 'Tcl_IsChannelShared', 'Tcl_IsEnsemble', 'Tcl_IsSafe', 'Tcl_IsShared', + 'Tcl_IsStandardChannel', 'Tcl_JoinPath', 'Tcl_JoinThread', 'tcl_library', 'Tcl_LimitAddHandler', + 'Tcl_LimitCheck', 'Tcl_LimitExceeded', 'Tcl_LimitGetCommands', 'Tcl_LimitGetGranularity', + 'Tcl_LimitGetTime', 'Tcl_LimitHandlerDeleteProc', 'Tcl_LimitHandlerProc', 'Tcl_LimitReady', + 'Tcl_LimitRemoveHandler', 'Tcl_LimitSetCommands', 'Tcl_LimitSetGranularity', 'Tcl_LimitSetTime', + 'Tcl_LimitTypeEnabled', 'Tcl_LimitTypeExceeded', 'Tcl_LimitTypeReset', 'Tcl_LimitTypeSet', + 'Tcl_LinkVar', 'Tcl_ListMathFuncs', 'Tcl_ListObjAppendElement', 'Tcl_ListObjAppendList', + 'Tcl_ListObjGetElements', 'Tcl_ListObjIndex', 'Tcl_ListObjLength', 'Tcl_ListObjReplace', + 'Tcl_LogCommandInfo', 'Tcl_Main', 'Tcl_MainLoopProc', 'Tcl_MakeFileChannel', 'Tcl_MakeSafe', + 'Tcl_MakeTcpClientChannel', 'Tcl_MathProc', 'TCL_MEM_DEBUG', 'Tcl_Merge', 'Tcl_MethodCallProc', + 'Tcl_MethodDeclarerClass', 'Tcl_MethodDeclarerObject', 'Tcl_MethodDeleteProc', 'Tcl_MethodIsPublic', + 'Tcl_MethodIsType', 'Tcl_MethodName', 'Tcl_MethodType', 'Tcl_MutexFinalize', 'Tcl_MutexLock', + 'Tcl_MutexUnlock', 'Tcl_NamespaceDeleteProc', 'Tcl_NewBignumObj', 'Tcl_NewBooleanObj', + 'Tcl_NewByteArrayObj', 'Tcl_NewDictObj', 'Tcl_NewDoubleObj', 'Tcl_NewInstanceMethod', 'Tcl_NewIntObj', + 'Tcl_NewListObj', 'Tcl_NewLongObj', 'Tcl_NewMethod', 'Tcl_NewObj', 'Tcl_NewObjectInstance', + 'Tcl_NewStringObj', 'Tcl_NewUnicodeObj', 'Tcl_NewWideIntObj', 'Tcl_NextHashEntry', 'tcl_nonwordchars', + 'Tcl_NotifierProcs', 'Tcl_NotifyChannel', 'Tcl_NRAddCallback', 'Tcl_NRCallObjProc', 'Tcl_NRCmdSwap', + 'Tcl_NRCreateCommand', 'Tcl_NREvalObj', 'Tcl_NREvalObjv', 'Tcl_NumUtfChars', 'Tcl_Obj', 'Tcl_ObjCmdProc', + 'Tcl_ObjectContextInvokeNext', 'Tcl_ObjectContextIsFiltering', 'Tcl_ObjectContextMethod', + 'Tcl_ObjectContextObject', 'Tcl_ObjectContextSkippedArgs', 'Tcl_ObjectDeleted', 'Tcl_ObjectGetMetadata', + 'Tcl_ObjectGetMethodNameMapper', 'Tcl_ObjectMapMethodNameProc', 'Tcl_ObjectMetadataDeleteProc', + 'Tcl_ObjectSetMetadata', 'Tcl_ObjectSetMethodNameMapper', 'Tcl_ObjGetVar2', 'Tcl_ObjPrintf', + 'Tcl_ObjSetVar2', 'Tcl_ObjType', 'Tcl_OpenCommandChannel', 'Tcl_OpenFileChannel', 'Tcl_OpenTcpClient', + 'Tcl_OpenTcpServer', 'Tcl_OutputBuffered', 'Tcl_PackageInitProc', 'Tcl_PackageUnloadProc', 'Tcl_Panic', + 'Tcl_PanicProc', 'Tcl_PanicVA', 'Tcl_ParseArgsObjv', 'Tcl_ParseBraces', 'Tcl_ParseCommand', 'Tcl_ParseExpr', + 'Tcl_ParseQuotedString', 'Tcl_ParseVar', 'Tcl_ParseVarName', 'tcl_patchLevel', 'tcl_pkgPath', + 'Tcl_PkgPresent', 'Tcl_PkgPresentEx', 'Tcl_PkgProvide', 'Tcl_PkgProvideEx', 'Tcl_PkgRequire', + 'Tcl_PkgRequireEx', 'Tcl_PkgRequireProc', 'tcl_platform', 'Tcl_PosixError', 'tcl_precision', + 'Tcl_Preserve', 'Tcl_PrintDouble', 'Tcl_PutEnv', 'Tcl_QueryTimeProc', 'Tcl_QueueEvent', 'tcl_rcFileName', + 'Tcl_Read', 'Tcl_ReadChars', 'Tcl_ReadRaw', 'Tcl_Realloc', 'Tcl_ReapDetachedProcs', 'Tcl_RecordAndEval', + 'Tcl_RecordAndEvalObj', 'Tcl_RegExpCompile', 'Tcl_RegExpExec', 'Tcl_RegExpExecObj', 'Tcl_RegExpGetInfo', + 'Tcl_RegExpIndices', 'Tcl_RegExpInfo', 'Tcl_RegExpMatch', 'Tcl_RegExpMatchObj', 'Tcl_RegExpRange', + 'Tcl_RegisterChannel', 'Tcl_RegisterConfig', 'Tcl_RegisterObjType', 'Tcl_Release', 'Tcl_ResetResult', + 'Tcl_RestoreInterpState', 'Tcl_RestoreResult', 'Tcl_SaveInterpState', 'Tcl_SaveResult', 'Tcl_ScaleTimeProc', + 'Tcl_ScanCountedElement', 'Tcl_ScanElement', 'Tcl_Seek', 'Tcl_ServiceAll', 'Tcl_ServiceEvent', + 'Tcl_ServiceModeHook', 'Tcl_SetAssocData', 'Tcl_SetBignumObj', 'Tcl_SetBooleanObj', + 'Tcl_SetByteArrayLength', 'Tcl_SetByteArrayObj', 'Tcl_SetChannelBufferSize', 'Tcl_SetChannelError', + 'Tcl_SetChannelErrorInterp', 'Tcl_SetChannelOption', 'Tcl_SetCommandInfo', 'Tcl_SetCommandInfoFromToken', + 'Tcl_SetDefaultEncodingDir', 'Tcl_SetDoubleObj', 'Tcl_SetEncodingSearchPath', 'Tcl_SetEnsembleFlags', + 'Tcl_SetEnsembleMappingDict', 'Tcl_SetEnsembleParameterList', 'Tcl_SetEnsembleSubcommandList', + 'Tcl_SetEnsembleUnknownHandler', 'Tcl_SetErrno', 'Tcl_SetErrorCode', 'Tcl_SetErrorCodeVA', + 'Tcl_SetErrorLine', 'Tcl_SetExitProc', 'Tcl_SetFromAnyProc', 'Tcl_SetHashValue', 'Tcl_SetIntObj', + 'Tcl_SetListObj', 'Tcl_SetLongObj', 'Tcl_SetMainLoop', 'Tcl_SetMaxBlockTime', + 'Tcl_SetNamespaceUnknownHandler', 'Tcl_SetNotifier', 'Tcl_SetObjErrorCode', 'Tcl_SetObjLength', + 'Tcl_SetObjResult', 'Tcl_SetPanicProc', 'Tcl_SetRecursionLimit', 'Tcl_SetResult', 'Tcl_SetReturnOptions', + 'Tcl_SetServiceMode', 'Tcl_SetStartupScript', 'Tcl_SetStdChannel', 'Tcl_SetStringObj', + 'Tcl_SetSystemEncoding', 'Tcl_SetTimeProc', 'Tcl_SetTimer', 'Tcl_SetUnicodeObj', 'Tcl_SetVar', + 'Tcl_SetVar2', 'Tcl_SetVar2Ex', 'Tcl_SetWideIntObj', 'Tcl_SignalId', 'Tcl_SignalMsg', 'Tcl_Sleep', + 'Tcl_SourceRCFile', 'Tcl_SpliceChannel', 'Tcl_SplitList', 'Tcl_SplitPath', 'Tcl_StackChannel', + 'Tcl_StandardChannels', 'tcl_startOfNextWord', 'tcl_startOfPreviousWord', 'Tcl_Stat', 'Tcl_StaticPackage', + 'Tcl_StringCaseMatch', 'Tcl_StringMatch', 'Tcl_SubstObj', 'Tcl_TakeBignumFromObj', 'Tcl_TcpAcceptProc', + 'Tcl_Tell', 'Tcl_ThreadAlert', 'Tcl_ThreadQueueEvent', 'Tcl_Time', 'Tcl_TimerProc', 'Tcl_Token', + 'Tcl_TraceCommand', 'tcl_traceCompile', 'tcl_traceEval', 'Tcl_TraceVar', 'Tcl_TraceVar2', + 'Tcl_TransferResult', 'Tcl_TranslateFileName', 'Tcl_TruncateChannel', 'Tcl_Ungets', 'Tcl_UniChar', + 'Tcl_UniCharAtIndex', 'Tcl_UniCharCaseMatch', 'Tcl_UniCharIsAlnum', 'Tcl_UniCharIsAlpha', + 'Tcl_UniCharIsControl', 'Tcl_UniCharIsDigit', 'Tcl_UniCharIsGraph', 'Tcl_UniCharIsLower', + 'Tcl_UniCharIsPrint', 'Tcl_UniCharIsPunct', 'Tcl_UniCharIsSpace', 'Tcl_UniCharIsUpper', + 'Tcl_UniCharIsWordChar', 'Tcl_UniCharLen', 'Tcl_UniCharNcasecmp', 'Tcl_UniCharNcmp', 'Tcl_UniCharToLower', + 'Tcl_UniCharToTitle', 'Tcl_UniCharToUpper', 'Tcl_UniCharToUtf', 'Tcl_UniCharToUtfDString', 'Tcl_UnlinkVar', + 'Tcl_UnregisterChannel', 'Tcl_UnsetVar', 'Tcl_UnsetVar2', 'Tcl_UnstackChannel', 'Tcl_UntraceCommand', + 'Tcl_UntraceVar', 'Tcl_UntraceVar2', 'Tcl_UpdateLinkedVar', 'Tcl_UpdateStringProc', 'Tcl_UpVar', + 'Tcl_UpVar2', 'Tcl_UtfAtIndex', 'Tcl_UtfBackslash', 'Tcl_UtfCharComplete', 'Tcl_UtfFindFirst', + 'Tcl_UtfFindLast', 'Tcl_UtfNext', 'Tcl_UtfPrev', 'Tcl_UtfToExternal', 'Tcl_UtfToExternalDString', + 'Tcl_UtfToLower', 'Tcl_UtfToTitle', 'Tcl_UtfToUniChar', 'Tcl_UtfToUniCharDString', 'Tcl_UtfToUpper', + 'Tcl_ValidateAllMemory', 'Tcl_Value', 'Tcl_VarEval', 'Tcl_VarEvalVA', 'Tcl_VarTraceInfo', + 'Tcl_VarTraceInfo2', 'Tcl_VarTraceProc', 'tcl_version', 'Tcl_WaitForEvent', 'Tcl_WaitPid', + 'Tcl_WinTCharToUtf', 'Tcl_WinUtfToTChar', 'tcl_wordBreakAfter', 'tcl_wordBreakBefore', 'tcl_wordchars', + 'Tcl_Write', 'Tcl_WriteChars', 'Tcl_WriteObj', 'Tcl_WriteRaw', 'Tcl_WrongNumArgs', 'Tcl_ZlibAdler32', + 'Tcl_ZlibCRC32', 'Tcl_ZlibDeflate', 'Tcl_ZlibInflate', 'Tcl_ZlibStreamChecksum', 'Tcl_ZlibStreamClose', + 'Tcl_ZlibStreamEof', 'Tcl_ZlibStreamGet', 'Tcl_ZlibStreamGetCommandName', 'Tcl_ZlibStreamInit', + 'Tcl_ZlibStreamPut', 'tcltest', 'tell', 'throw', 'time', 'tm', 'trace', 'transchan', 'try', 'unknown', + 'unload', 'unset', 'update', 'uplevel', 'upvar', 'variable', 'vwait', 'while', 'yield', 'yieldto', 'zlib' + ] + + +@dataclass +class Extensions: + """ + Holds the file extensions recognized by the application + """ + + grb_list = [ + 'art', 'bot', 'bsm', 'cmp', 'crc', 'crs', 'dim', 'g4', 'gb0', 'gb1', 'gb2', 'gb3', 'gb5', + 'gb6', 'gb7', 'gb8', 'gb9', 'gbd', 'gbl', 'gbo', 'gbp', 'gbr', 'gbs', 'gdo', 'ger', 'gko', + 'gml', 'gm1', 'gm2', 'gm3', 'grb', 'gtl', 'gto', 'gtp', 'gts', 'ly15', 'ly2', 'mil', 'outline', + 'pho', 'plc', 'pls', 'smb', 'smt', 'sol', 'spb', 'spt', 'ssb', 'sst', 'stc', 'sts', 'top', + 'tsm' + ] + + exc_list = ['drd', 'drl', 'drill', 'exc', 'ncd', 'tap', 'txt', 'xln'] + + gcode_list = [ + 'cnc', 'din', 'dnc', 'ecs', 'eia', 'fan', 'fgc', 'fnc', 'gc', 'gcd', 'gcode', 'h', 'hnc', + 'i', 'min', 'mpf', 'mpr', 'nc', 'ncc', 'ncg', 'ngc', 'ncp', 'out', 'ply', 'rol', + 'sbp', 'tap', 'xpi' + ] + svg_list = ['svg'] + dxf_list = ['dxf'] + pdf_list = ['pdf'] + prj_list = ['flatprj'] + conf_list = ['flatconfig'] + + +class RegisterFK(QtCore.QObject): + """ + Will associate the application with some files with certain extensions. It will also update the Qt autocompleter. + """ + + def __init__(self, + ui: 'appMain.MainGUI', + inform_sig: pyqtSignal, + options_dict: 'appMain.AppOptions', + shell: 'appMain.FCShell', + log: ('appMain.AppLogging', 'appMain.logging'), + keywords: KeyWords, + extensions: Extensions): + + super().__init__() + self.ui = ui + self.shell = shell + self.log = log + self.inform = inform_sig + self.options = options_dict + self.keywords = keywords + + self.tcl_keywords = self.keywords.tcl_keywords + self.tcl_commands_list = self.keywords.tcl_commands + self.default_keywords = self.keywords.default_keywords + + self.exc_list = extensions.exc_list + self.grb_list = extensions.grb_list + self.gcode_list = extensions.gcode_list + + autocomplete_kw_list = self.options['util_autocomplete_keywords'].replace(' ', '').split(',') + self.myKeywords = self.tcl_commands_list + autocomplete_kw_list + self.tcl_keywords + + # initial register of keywords for the shell + self.register_keywords(self.myKeywords) + + self.connect_signals() + + # ########################################################################################################### + # ##################################### Register files with FlatCAM; ####################################### + # ################################### It works only for Windows for now #################################### + # ########################################################################################################### + if sys.platform == 'win32' and self.options["first_run"] is True: + self.on_register_files() + + def connect_signals(self): + # ########################################################################################################### + # ####################################### FILE ASSOCIATIONS SIGNALS ######################################### + # ########################################################################################################### + self.ui.util_pref_form.fa_excellon_group.restore_btn.clicked.connect( + lambda: self.restore_extensions(ext_type='excellon')) + self.ui.util_pref_form.fa_gcode_group.restore_btn.clicked.connect( + lambda: self.restore_extensions(ext_type='gcode')) + self.ui.util_pref_form.fa_gerber_group.restore_btn.clicked.connect( + lambda: self.restore_extensions(ext_type='gerber')) + + self.ui.util_pref_form.fa_excellon_group.del_all_btn.clicked.connect( + lambda: self.delete_all_extensions(ext_type='excellon')) + self.ui.util_pref_form.fa_gcode_group.del_all_btn.clicked.connect( + lambda: self.delete_all_extensions(ext_type='gcode')) + self.ui.util_pref_form.fa_gerber_group.del_all_btn.clicked.connect( + lambda: self.delete_all_extensions(ext_type='gerber')) + + self.ui.util_pref_form.fa_excellon_group.add_btn.clicked.connect( + lambda: self.add_extension(ext_type='excellon')) + self.ui.util_pref_form.fa_gcode_group.add_btn.clicked.connect( + lambda: self.add_extension(ext_type='gcode')) + self.ui.util_pref_form.fa_gerber_group.add_btn.clicked.connect( + lambda: self.add_extension(ext_type='gerber')) + + self.ui.util_pref_form.fa_excellon_group.del_btn.clicked.connect( + lambda: self.del_extension(ext_type='excellon')) + self.ui.util_pref_form.fa_gcode_group.del_btn.clicked.connect( + lambda: self.del_extension(ext_type='gcode')) + self.ui.util_pref_form.fa_gerber_group.del_btn.clicked.connect( + lambda: self.del_extension(ext_type='gerber')) + + # connect the 'Apply' buttons from the Preferences/File Associations + self.ui.util_pref_form.fa_excellon_group.exc_list_btn.clicked.connect( + lambda: self.on_register_files(obj_type='excellon')) + self.ui.util_pref_form.fa_gcode_group.gco_list_btn.clicked.connect( + lambda: self.on_register_files(obj_type='gcode')) + self.ui.util_pref_form.fa_gerber_group.grb_list_btn.clicked.connect( + lambda: self.on_register_files(obj_type='gerber')) + + # ########################################################################################################### + # ########################################### KEYWORDS SIGNALS ############################################## + # ########################################################################################################### + self.ui.util_pref_form.kw_group.restore_btn.clicked.connect( + lambda: self.restore_extensions(ext_type='keyword')) + self.ui.util_pref_form.kw_group.del_all_btn.clicked.connect( + lambda: self.delete_all_extensions(ext_type='keyword')) + self.ui.util_pref_form.kw_group.add_btn.clicked.connect( + lambda: self.add_extension(ext_type='keyword')) + self.ui.util_pref_form.kw_group.del_btn.clicked.connect( + lambda: self.del_extension(ext_type='keyword')) + + def register_keywords(self, keywords=None): + if keywords is None: + self.shell.command_line().set_model_data(self.myKeywords) + return + self.myKeywords = keywords + self.shell.command_line().set_model_data(self.myKeywords) + + def prepend_keyword(self, kw, update=True): + self.myKeywords.insert(0, kw) + if update: + self.register_keywords(self.myKeywords) + + def append_keyword(self, kw, update=True): + self.myKeywords.append(kw) + if update: + self.register_keywords(self.myKeywords) + + def remove_keyword(self, kw, update=True): + self.myKeywords.remove(kw) + if update: + self.register_keywords(self.myKeywords) + + @staticmethod + def set_reg(name, root_pth, new_reg_path_par, value): + # create the keys + try: + winreg.CreateKey(root_pth, new_reg_path_par) + with winreg.OpenKey(root_pth, new_reg_path_par, 0, winreg.KEY_WRITE) as registry_key: + winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value) + return True + except WindowsError: + return False + + @staticmethod + def delete_reg(root_pth, reg_path, key_to_del): + # delete key in registry + key_to_del_path = reg_path + key_to_del + try: + winreg.DeleteKey(root_pth, key_to_del_path) + return True + except WindowsError: + return False + + def on_register_files(self, obj_type=None): + """ + Called whenever there is a need to register file extensions with FlatCAM. + Works only in Windows and should be called only when FlatCAM is run in Windows. + + :param obj_type: the type of object to be register for. + Can be: 'gerber', 'excellon' or 'gcode'. 'geometry' is not used for the moment. + + :return: None + """ + self.log.debug("Manufacturing files extensions are registered with FlatCAM.") + + # find if the current user is admin + try: + is_admin = os.getuid() == 0 + except AttributeError: + is_admin = ctypes.windll.shell32.IsUserAnAdmin() == 1 + + if is_admin is True: + root_path = winreg.HKEY_LOCAL_MACHINE + else: + root_path = winreg.HKEY_CURRENT_USER + + if obj_type is None or obj_type == 'excellon': + self.register_excellon_extension(root_path) + + if obj_type is None or obj_type == 'gcode': + self.register_gcode_extension(root_path) + + if obj_type is None or obj_type == 'gerber': + self.register_gerber_extension(root_path) + + def register_excellon_extension(self, root_path): + new_reg_path = 'Software\\Classes\\' + + exc_list = \ + self.ui.util_pref_form.fa_excellon_group.exc_list_text.get_value().replace(' ', '').split(',') + exc_list = [x for x in exc_list if x != ''] + + # register all keys in the Preferences window + for ext in exc_list: + new_k = new_reg_path + '.%s' % ext + self.set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') + + # and unregister those that are no longer in the Preferences windows but are in the file + for ext in self.options["fa_excellon"].replace(' ', '').split(','): + if ext not in exc_list: + self.delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) + + # now write the updated extensions to the self.options + # new_ext = '' + # for ext in exc_list: + # new_ext = new_ext + ext + ', ' + # self.options["fa_excellon"] = new_ext + self.inform.emit('[success] %s' % _("Extensions registered.")) # noqa + + def register_gerber_extension(self, root_path): + new_reg_path = 'Software\\Classes\\' + + grb_list = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().replace(' ', '').split(',') + grb_list = [x for x in grb_list if x != ''] + + # register all keys in the Preferences window + for ext in grb_list: + new_k = new_reg_path + '.%s' % ext + self.set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') + + # and unregister those that are no longer in the Preferences windows but are in the file + for ext in self.options["fa_gerber"].replace(' ', '').split(','): + if ext not in grb_list: + self.delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) + + self.inform.emit('[success] %s' % _("Extensions registered.")) # noqa + + def register_gcode_extension(self, root_path): + new_reg_path = 'Software\\Classes\\' + + gco_list = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().replace(' ', '').split(',') + gco_list = [x for x in gco_list if x != ''] + + # register all keys in the Preferences window + for ext in gco_list: + new_k = new_reg_path + '.%s' % ext + self.set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') + + # and unregister those that are no longer in the Preferences windows but are in the file + for ext in self.options["fa_gcode"].replace(' ', '').split(','): + if ext not in gco_list: + self.delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) + + self.inform.emit('[success] %s' % _("Extensions registered.")) # noqa + + def add_extension(self, ext_type): + """ + Add a file extension to the list for a specific object + + :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword + :return: + """ + + if ext_type == 'excellon': + self.add_excellon_extension() + if ext_type == 'gcode': + self.add_gcode_extension() + if ext_type == 'gerber': + self.add_gerber_extension() + if ext_type == 'keyword': + self.add_keyword_in_preferences_gui() + + def add_excellon_extension(self): + new_ext = self.ui.util_pref_form.fa_excellon_group.ext_entry.get_value() + if new_ext == '': + return + + old_val = self.ui.util_pref_form.fa_excellon_group.exc_list_text.get_value().replace(' ', '').split(',') + if new_ext in old_val: + return + old_val.append(new_ext) + old_val.sort() + self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value(', '.join(old_val)) + + def add_gerber_extension(self): + new_ext = self.ui.util_pref_form.fa_gerber_group.ext_entry.get_value() + if new_ext == '': + return + + old_val = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().replace(' ', '').split(',') + if new_ext in old_val: + return + old_val.append(new_ext) + old_val.sort() + self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value(', '.join(old_val)) + + def add_gcode_extension(self): + new_ext = self.ui.util_pref_form.fa_gcode_group.ext_entry.get_value() + if new_ext == '': + return + + old_val = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().replace(' ', '').split(',') + if new_ext in old_val: + return + old_val.append(new_ext) + old_val.sort() + self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value(', '.join(old_val)) + + def add_keyword_in_preferences_gui(self, kw=None): + new_kw = self.ui.util_pref_form.kw_group.kw_entry.get_value() if kw is None else kw + if new_kw == '': + return + + old_val = self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') + if new_kw in old_val: + return + old_val.append(new_kw) + old_val.sort() + self.ui.util_pref_form.kw_group.kw_list_text.set_value(', '.join(old_val)) + + # update the self.myKeywords so the model is updated + autocomplete_kw_list = self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') + self.myKeywords = self.tcl_commands_list + autocomplete_kw_list + self.tcl_keywords + self.register_keywords(self.myKeywords) + + def del_extension(self, ext_type): + """ + Remove a file extension from the list for a specific object + + :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword + :return: + """ + if ext_type == 'excellon': + self.delete_excellon_extension() + if ext_type == 'gcode': + self.delete_gcode_extension() + if ext_type == 'gerber': + self.delete_gerber_extension() + if ext_type == 'keyword': + self.delete_keyword_in_preferences_gui() + + def delete_excellon_extension(self): + new_ext = self.ui.util_pref_form.fa_excellon_group.ext_entry.get_value() + if new_ext == '': + return + + old_val = self.ui.util_pref_form.fa_excellon_group.exc_list_text.get_value().replace(' ', '').split(',') + if new_ext not in old_val: + return + old_val.remove(new_ext) + old_val.sort() + self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value(', '.join(old_val)) + + def delete_gerber_extension(self): + new_ext = self.ui.util_pref_form.fa_gerber_group.ext_entry.get_value() + if new_ext == '': + return + + old_val = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().replace(' ', '').split(',') + if new_ext not in old_val: + return + old_val.remove(new_ext) + old_val.sort() + self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value(', '.join(old_val)) + + def delete_gcode_extension(self): + new_ext = self.ui.util_pref_form.fa_gcode_group.ext_entry.get_value() + if new_ext == '': + return + + old_val = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().replace(' ', '').split(',') + if new_ext not in old_val: + return + old_val.remove(new_ext) + old_val.sort() + self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value(', '.join(old_val)) + + def delete_keyword_in_preferences_gui(self, kw=None): + new_kw = kw if kw is not None else self.ui.util_pref_form.kw_group.kw_entry.get_value() + if new_kw == '': + return + + old_val = self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') + if new_kw not in old_val: + return + old_val.remove(new_kw) + old_val.sort() + self.ui.util_pref_form.kw_group.kw_list_text.set_value(', '.join(old_val)) + + # update the self.myKeywords so the model is updated + autocomplete_kw_list = self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') + self.myKeywords = self.tcl_commands_list + autocomplete_kw_list + self.tcl_keywords + self.register_keywords(self.myKeywords) + + def restore_extensions(self, ext_type): + """ + Restore all file extensions associations with FlatCAM, for a specific object + + :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword + :return: + """ + + if ext_type == 'excellon': + # don't add 'txt' to the associations (too many files are .txt and not Excellon) but keep it in the list + # for the ability to open Excellon files with .txt extension + new_exc_list = deepcopy(self.exc_list) + + try: + new_exc_list.remove('txt') + except ValueError: + pass + self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value(', '.join(new_exc_list)) + if ext_type == 'gcode': + self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value(', '.join(self.gcode_list)) + if ext_type == 'gerber': + self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value(', '.join(self.grb_list)) + if ext_type == 'keyword': + self.ui.util_pref_form.kw_group.kw_list_text.set_value(', '.join(self.default_keywords)) + + # update the self.myKeywords so the model is updated + self.myKeywords = self.tcl_commands_list + self.default_keywords + self.tcl_keywords + self.shell.command_line().set_model_data(self.myKeywords) + + def delete_all_extensions(self, ext_type): + """ + Delete all file extensions associations with FlatCAM, for a specific object + + :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword + :return: + """ + + if ext_type == 'excellon': + self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value('') + if ext_type == 'gcode': + self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value('') + if ext_type == 'gerber': + self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value('') + if ext_type == 'keyword': + self.ui.util_pref_form.kw_group.kw_list_text.set_value('') + + # update the self.myKeywords so the model is updated + self.myKeywords = self.tcl_commands_list + self.tcl_keywords + self.register_keywords(self.myKeywords) diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index b6f46142..3dcb8d2e 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -2522,7 +2522,7 @@ class SelectEditorGrb(QtCore.QObject, DrawTool): self.draw_app.visible = True # make sure that the cursor text from the FCPath is deleted - if self.draw_app.app.plotcanvas.text_cursor.parent and self.draw_app.app.use_3d_engine: + if self.draw_app.app.use_3d_engine and self.draw_app.app.plotcanvas.text_cursor.parent: self.draw_app.app.plotcanvas.text_cursor.parent = None self.draw_app.app.plotcanvas.view.camera.zoom_callback = lambda *args: None @@ -5258,17 +5258,17 @@ class AppGerberEditor(QtCore.QObject): def draw_selection_area_handler(self, start_pos, end_pos, sel_type): """ - :param start_pos: mouse position when the selection LMB click was done - :param end_pos: mouse position when the left mouse button is released - :param sel_type: if True it's a left to right selection (enclosure), if False it's a 'touch' selection + :param start_pos: mouse position when the selection LMB click was done + :param end_pos: mouse position when the left mouse button is released + :param sel_type: if True it's a left to right selection (enclosure), if False it's a 'touch' selection :return: """ poly_selection = Polygon([start_pos, (end_pos[0], start_pos[1]), end_pos, (start_pos[0], end_pos[1])]) sel_aperture = set() self.ui.apertures_table.clearSelection() - self.app.delete_selection_shape() + for storage in self.storage_dict: for obj in self.storage_dict[storage]['geometry']: if 'solid' in obj.geo: diff --git a/appEditors/AppTextEditor.py b/appEditors/AppTextEditor.py index eb1e5d6a..ec3d1084 100644 --- a/appEditors/AppTextEditor.py +++ b/appEditors/AppTextEditor.py @@ -175,7 +175,7 @@ class AppTextEditor(QtWidgets.QWidget): # self.button_copy_all.clicked.connect(self.handleCopyAll) - self.code_editor.set_model_data(self.app.myKeywords) + self.code_editor.set_model_data(self.app.regFK.myKeywords) self.code_edited = '' diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index 1e2decf1..612e653e 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -1117,7 +1117,7 @@ class PreferencesUIManager(QtCore.QObject): self.ui.pref_apply_button.setStyleSheet("") self.ui.pref_apply_button.setIcon(QtGui.QIcon(self.ui.app.resource_location + '/apply32.png')) - self.inform.emit('%s' % _("Preferences applied.")) + self.inform.emit('%s' % _("Preferences applied.")) # noqa # make sure we update the self.current_defaults dict used to undo changes to self.defaults self.defaults.current_defaults.update(self.defaults) diff --git a/appMain.py b/appMain.py index d93eba3c..f4aecb28 100644 --- a/appMain.py +++ b/appMain.py @@ -55,6 +55,7 @@ from appCommon.Common import LoudDict from appCommon.Common import color_variant from appCommon.Common import ExclusionAreas from appCommon.Common import AppLogging +from appCommon.RegisterFileKeywords import RegisterFK, Extensions, KeyWords from Bookmark import BookmarkManager from appDatabase import ToolsDB2 @@ -397,23 +398,6 @@ class App(QtCore.QObject): # if Tools DB are changed/edited in the Edit -> Tools Database tab the value will be set to True self.tools_db_changed_flag = False - self.grb_list = ['art', 'bot', 'bsm', 'cmp', 'crc', 'crs', 'dim', 'g4', 'gb0', 'gb1', 'gb2', 'gb3', 'gb5', - 'gb6', 'gb7', 'gb8', 'gb9', 'gbd', 'gbl', 'gbo', 'gbp', 'gbr', 'gbs', 'gdo', 'ger', 'gko', - 'gml', 'gm1', 'gm2', 'gm3', 'grb', 'gtl', 'gto', 'gtp', 'gts', 'ly15', 'ly2', 'mil', 'outline', - 'pho', 'plc', 'pls', 'smb', 'smt', 'sol', 'spb', 'spt', 'ssb', 'sst', 'stc', 'sts', 'top', - 'tsm'] - - self.exc_list = ['drd', 'drl', 'drill', 'exc', 'ncd', 'tap', 'txt', 'xln'] - - self.gcode_list = ['cnc', 'din', 'dnc', 'ecs', 'eia', 'fan', 'fgc', 'fnc', 'gc', 'gcd', 'gcode', 'h', 'hnc', - 'i', 'min', 'mpf', 'mpr', 'nc', 'ncc', 'ncg', 'ngc', 'ncp', 'out', 'ply', 'rol', - 'sbp', 'tap', 'xpi'] - self.svg_list = ['svg'] - self.dxf_list = ['dxf'] - self.pdf_list = ['pdf'] - self.prj_list = ['flatprj'] - self.conf_list = ['flatconfig'] - # last used filters self.last_op_gerber_filter = None self.last_op_excellon_filter = None @@ -648,250 +632,6 @@ class App(QtCore.QObject): qdarksheet.STYLE_SHEET = dark_style_sheet.D_STYLE_SHEET self.qapp.setStyleSheet(qdarktheme.load_stylesheet()) - # ########################################################################################################### - # ####################################### Auto-complete KEYWORDS ############################################ - # ######################## Setup after the Defaults class was instantiated ################################## - # ########################################################################################################### - self.tcl_commands_list = ['add_aperture', 'add_circle', 'add_drill', 'add_poly', 'add_polygon', 'add_polyline', - 'add_rectangle', 'add_rect', 'add_slot', - 'aligndrill', 'aligndrillgrid', 'bbox', 'buffer', 'clear', 'cncjob', 'cutout', - 'del', 'drillcncjob', 'export_dxf', 'edxf', 'export_excellon', - 'export_exc', - 'export_gcode', 'export_gerber', 'export_svg', 'ext', 'exteriors', 'follow', - 'geo_union', 'geocutout', 'get_active', 'get_bounds', 'get_names', 'get_path', - 'get_sys', 'help', - 'interiors', 'isolate', 'join_excellon', - 'join_geometry', 'list_sys', 'list_pp', 'milld', 'mills', 'milldrills', 'millslots', - 'mirror', 'ncc', - 'ncr', 'new', 'new_geometry', 'new_gerber', 'new_excellon', 'non_copper_regions', - 'offset', - 'open_dxf', 'open_excellon', 'open_gcode', 'open_gerber', 'open_project', 'open_svg', - 'options', 'origin', - 'paint', 'panelize', 'plot_all', 'plot_objects', 'plot_status', 'quit_app', - 'save', 'save_project', - 'save_sys', 'scale', 'set_active', 'set_origin', 'set_path', 'set_sys', - 'skew', 'subtract_poly', 'subtract_rectangle', - 'version', 'write_gcode' - ] - - # those need to be duplicated in self.options["util_autocomplete_keywords"] but within a string - self.default_keywords = ['Berta_CNC', 'Default_no_M6', 'Desktop', 'Documents', 'FlatConfig', 'FlatPrj', - 'False', 'GRBL_11', 'GRL_11_no_M6', 'GRBL_laser', 'grbl_laser_eleks_drd', - 'GRBL_laser_z', 'ISEL_CNC', 'ISEL_ICP_CNC', - 'Line_xyz', 'Marlin', - 'Marlin_laser_FAN_pin', 'Marlin_laser_Spindle_pin', 'NCCAD9', 'Marius', 'My Documents', - 'Paste_1', 'Repetier', 'Roland_MDX_20', 'Roland_MDX_540', - 'Toolchange_Manual', 'Toolchange_Probe_MACH3', - 'True', 'Users', - 'all', 'auto', 'axis', - 'axisoffset', 'box', 'center_x', 'center_y', 'center', 'columns', 'combine', 'connect', - 'contour', 'default', - 'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz', 'dpp', - 'dwelltime', 'extracut_length', 'endxy', 'endz', 'f', 'factor', 'feedrate', - 'feedrate_z', 'gridoffsety', 'gridx', 'gridy', - 'has_offset', 'holes', 'hpgl', 'iso_type', 'join', 'keep_scripts', - 'las_min_pwr', 'las_power', 'margin', 'marlin', 'method', - 'milled_dias', 'minoffset', 'min_bounds', 'name', 'offset', 'opt_type', 'order', - 'outname', 'overlap', 'obj_name', - 'p_coords', 'passes', 'postamble', 'pp', 'ppname_e', 'ppname_g', - 'preamble', 'radius', 'ref', 'rest', 'rows', 'shellvar_', 'scale_factor', - 'spacing_columns', - 'spacing_rows', 'spindlespeed', 'startz', 'startxy', - 'toolchange_xy', 'toolchangez', 'travelz', - 'tooldia', 'use_threads', 'value', - 'x', 'x0', 'x1', 'x_dist', 'y', 'y0', 'y1', 'y_dist', 'z_cut', 'z_move' - ] - - self.tcl_keywords = [ - 'after', 'append', 'apply', 'argc', 'argv', 'argv0', 'array', 'attemptckalloc', 'attemptckrealloc', - 'auto_execok', 'auto_import', 'auto_load', 'auto_mkindex', 'auto_path', 'auto_qualify', 'auto_reset', - 'bgerror', 'binary', 'break', 'case', 'catch', 'cd', 'chan', 'ckalloc', 'ckfree', 'ckrealloc', 'clock', - 'close', 'concat', 'continue', 'coroutine', 'dde', 'dict', 'encoding', 'env', 'eof', 'error', 'errorCode', - 'errorInfo', 'eval', 'exec', 'exit', 'expr', 'fblocked', 'fconfigure', 'fcopy', 'file', 'fileevent', - 'filename', 'flush', 'for', 'foreach', 'format', 'gets', 'glob', 'global', 'history', 'http', 'if', 'incr', - 'info', 'interp', 'join', 'lappend', 'lassign', 'lindex', 'linsert', 'list', 'llength', 'load', 'lrange', - 'lrepeat', 'lreplace', 'lreverse', 'lsearch', 'lset', 'lsort', 'mathfunc', 'mathop', 'memory', 'msgcat', - 'my', 'namespace', 'next', 'nextto', 'open', 'package', 'parray', 'pid', 'pkg_mkIndex', 'platform', - 'proc', 'puts', 'pwd', 're_syntax', 'read', 'refchan', 'regexp', 'registry', 'regsub', 'rename', 'return', - 'safe', 'scan', 'seek', 'self', 'set', 'socket', 'source', 'split', 'string', 'subst', 'switch', - 'tailcall', 'Tcl', 'Tcl_Access', 'Tcl_AddErrorInfo', 'Tcl_AddObjErrorInfo', 'Tcl_AlertNotifier', - 'Tcl_Alloc', 'Tcl_AllocHashEntryProc', 'Tcl_AllocStatBuf', 'Tcl_AllowExceptions', 'Tcl_AppendAllObjTypes', - 'Tcl_AppendElement', 'Tcl_AppendExportList', 'Tcl_AppendFormatToObj', 'Tcl_AppendLimitedToObj', - 'Tcl_AppendObjToErrorInfo', 'Tcl_AppendObjToObj', 'Tcl_AppendPrintfToObj', 'Tcl_AppendResult', - 'Tcl_AppendResultVA', 'Tcl_AppendStringsToObj', 'Tcl_AppendStringsToObjVA', 'Tcl_AppendToObj', - 'Tcl_AppendUnicodeToObj', 'Tcl_AppInit', 'Tcl_AppInitProc', 'Tcl_ArgvInfo', 'Tcl_AsyncCreate', - 'Tcl_AsyncDelete', 'Tcl_AsyncInvoke', 'Tcl_AsyncMark', 'Tcl_AsyncProc', 'Tcl_AsyncReady', - 'Tcl_AttemptAlloc', 'Tcl_AttemptRealloc', 'Tcl_AttemptSetObjLength', 'Tcl_BackgroundError', - 'Tcl_BackgroundException', 'Tcl_Backslash', 'Tcl_BadChannelOption', 'Tcl_CallWhenDeleted', 'Tcl_Canceled', - 'Tcl_CancelEval', 'Tcl_CancelIdleCall', 'Tcl_ChannelBlockModeProc', 'Tcl_ChannelBuffered', - 'Tcl_ChannelClose2Proc', 'Tcl_ChannelCloseProc', 'Tcl_ChannelFlushProc', 'Tcl_ChannelGetHandleProc', - 'Tcl_ChannelGetOptionProc', 'Tcl_ChannelHandlerProc', 'Tcl_ChannelInputProc', 'Tcl_ChannelName', - 'Tcl_ChannelOutputProc', 'Tcl_ChannelProc', 'Tcl_ChannelSeekProc', 'Tcl_ChannelSetOptionProc', - 'Tcl_ChannelThreadActionProc', 'Tcl_ChannelTruncateProc', 'Tcl_ChannelType', 'Tcl_ChannelVersion', - 'Tcl_ChannelWatchProc', 'Tcl_ChannelWideSeekProc', 'Tcl_Chdir', 'Tcl_ClassGetMetadata', - 'Tcl_ClassSetConstructor', 'Tcl_ClassSetDestructor', 'Tcl_ClassSetMetadata', 'Tcl_ClearChannelHandlers', - 'Tcl_CloneProc', 'Tcl_Close', 'Tcl_CloseProc', 'Tcl_CmdDeleteProc', 'Tcl_CmdInfo', - 'Tcl_CmdObjTraceDeleteProc', 'Tcl_CmdObjTraceProc', 'Tcl_CmdProc', 'Tcl_CmdTraceProc', - 'Tcl_CommandComplete', 'Tcl_CommandTraceInfo', 'Tcl_CommandTraceProc', 'Tcl_CompareHashKeysProc', - 'Tcl_Concat', 'Tcl_ConcatObj', 'Tcl_ConditionFinalize', 'Tcl_ConditionNotify', 'Tcl_ConditionWait', - 'Tcl_Config', 'Tcl_ConvertCountedElement', 'Tcl_ConvertElement', 'Tcl_ConvertToType', - 'Tcl_CopyObjectInstance', 'Tcl_CreateAlias', 'Tcl_CreateAliasObj', 'Tcl_CreateChannel', - 'Tcl_CreateChannelHandler', 'Tcl_CreateCloseHandler', 'Tcl_CreateCommand', 'Tcl_CreateEncoding', - 'Tcl_CreateEnsemble', 'Tcl_CreateEventSource', 'Tcl_CreateExitHandler', 'Tcl_CreateFileHandler', - 'Tcl_CreateHashEntry', 'Tcl_CreateInterp', 'Tcl_CreateMathFunc', 'Tcl_CreateNamespace', - 'Tcl_CreateObjCommand', 'Tcl_CreateObjTrace', 'Tcl_CreateSlave', 'Tcl_CreateThread', - 'Tcl_CreateThreadExitHandler', 'Tcl_CreateTimerHandler', 'Tcl_CreateTrace', - 'Tcl_CutChannel', 'Tcl_DecrRefCount', 'Tcl_DeleteAssocData', 'Tcl_DeleteChannelHandler', - 'Tcl_DeleteCloseHandler', 'Tcl_DeleteCommand', 'Tcl_DeleteCommandFromToken', 'Tcl_DeleteEvents', - 'Tcl_DeleteEventSource', 'Tcl_DeleteExitHandler', 'Tcl_DeleteFileHandler', 'Tcl_DeleteHashEntry', - 'Tcl_DeleteHashTable', 'Tcl_DeleteInterp', 'Tcl_DeleteNamespace', 'Tcl_DeleteThreadExitHandler', - 'Tcl_DeleteTimerHandler', 'Tcl_DeleteTrace', 'Tcl_DetachChannel', 'Tcl_DetachPids', 'Tcl_DictObjDone', - 'Tcl_DictObjFirst', 'Tcl_DictObjGet', 'Tcl_DictObjNext', 'Tcl_DictObjPut', 'Tcl_DictObjPutKeyList', - 'Tcl_DictObjRemove', 'Tcl_DictObjRemoveKeyList', 'Tcl_DictObjSize', 'Tcl_DiscardInterpState', - 'Tcl_DiscardResult', 'Tcl_DontCallWhenDeleted', 'Tcl_DoOneEvent', 'Tcl_DoWhenIdle', - 'Tcl_DriverBlockModeProc', 'Tcl_DriverClose2Proc', 'Tcl_DriverCloseProc', 'Tcl_DriverFlushProc', - 'Tcl_DriverGetHandleProc', 'Tcl_DriverGetOptionProc', 'Tcl_DriverHandlerProc', 'Tcl_DriverInputProc', - 'Tcl_DriverOutputProc', 'Tcl_DriverSeekProc', 'Tcl_DriverSetOptionProc', 'Tcl_DriverThreadActionProc', - 'Tcl_DriverTruncateProc', 'Tcl_DriverWatchProc', 'Tcl_DriverWideSeekProc', 'Tcl_DStringAppend', - 'Tcl_DStringAppendElement', 'Tcl_DStringEndSublist', 'Tcl_DStringFree', 'Tcl_DStringGetResult', - 'Tcl_DStringInit', 'Tcl_DStringLength', 'Tcl_DStringResult', 'Tcl_DStringSetLength', - 'Tcl_DStringStartSublist', 'Tcl_DStringTrunc', 'Tcl_DStringValue', 'Tcl_DumpActiveMemory', - 'Tcl_DupInternalRepProc', 'Tcl_DuplicateObj', 'Tcl_EncodingConvertProc', 'Tcl_EncodingFreeProc', - 'Tcl_EncodingType', 'tcl_endOfWord', 'Tcl_Eof', 'Tcl_ErrnoId', 'Tcl_ErrnoMsg', 'Tcl_Eval', 'Tcl_EvalEx', - 'Tcl_EvalFile', 'Tcl_EvalObjEx', 'Tcl_EvalObjv', 'Tcl_EvalTokens', 'Tcl_EvalTokensStandard', 'Tcl_Event', - 'Tcl_EventCheckProc', 'Tcl_EventDeleteProc', 'Tcl_EventProc', 'Tcl_EventSetupProc', 'Tcl_EventuallyFree', - 'Tcl_Exit', 'Tcl_ExitProc', 'Tcl_ExitThread', 'Tcl_Export', 'Tcl_ExposeCommand', 'Tcl_ExprBoolean', - 'Tcl_ExprBooleanObj', 'Tcl_ExprDouble', 'Tcl_ExprDoubleObj', 'Tcl_ExprLong', 'Tcl_ExprLongObj', - 'Tcl_ExprObj', 'Tcl_ExprString', 'Tcl_ExternalToUtf', 'Tcl_ExternalToUtfDString', 'Tcl_FileProc', - 'Tcl_Filesystem', 'Tcl_Finalize', 'Tcl_FinalizeNotifier', 'Tcl_FinalizeThread', 'Tcl_FindCommand', - 'Tcl_FindEnsemble', 'Tcl_FindExecutable', 'Tcl_FindHashEntry', 'tcl_findLibrary', 'Tcl_FindNamespace', - 'Tcl_FirstHashEntry', 'Tcl_Flush', 'Tcl_ForgetImport', 'Tcl_Format', 'Tcl_FreeHashEntryProc', - 'Tcl_FreeInternalRepProc', 'Tcl_FreeParse', 'Tcl_FreeProc', 'Tcl_FreeResult', - 'Tcl_Free·\xa0Tcl_FreeEncoding', 'Tcl_FSAccess', 'Tcl_FSAccessProc', 'Tcl_FSChdir', - 'Tcl_FSChdirProc', 'Tcl_FSConvertToPathType', 'Tcl_FSCopyDirectory', 'Tcl_FSCopyDirectoryProc', - 'Tcl_FSCopyFile', 'Tcl_FSCopyFileProc', 'Tcl_FSCreateDirectory', 'Tcl_FSCreateDirectoryProc', - 'Tcl_FSCreateInternalRepProc', 'Tcl_FSData', 'Tcl_FSDeleteFile', 'Tcl_FSDeleteFileProc', - 'Tcl_FSDupInternalRepProc', 'Tcl_FSEqualPaths', 'Tcl_FSEvalFile', 'Tcl_FSEvalFileEx', - 'Tcl_FSFileAttrsGet', 'Tcl_FSFileAttrsGetProc', 'Tcl_FSFileAttrsSet', 'Tcl_FSFileAttrsSetProc', - 'Tcl_FSFileAttrStrings', 'Tcl_FSFileSystemInfo', 'Tcl_FSFilesystemPathTypeProc', - 'Tcl_FSFilesystemSeparatorProc', 'Tcl_FSFreeInternalRepProc', 'Tcl_FSGetCwd', 'Tcl_FSGetCwdProc', - 'Tcl_FSGetFileSystemForPath', 'Tcl_FSGetInternalRep', 'Tcl_FSGetNativePath', 'Tcl_FSGetNormalizedPath', - 'Tcl_FSGetPathType', 'Tcl_FSGetTranslatedPath', 'Tcl_FSGetTranslatedStringPath', - 'Tcl_FSInternalToNormalizedProc', 'Tcl_FSJoinPath', 'Tcl_FSJoinToPath', 'Tcl_FSLinkProc', - 'Tcl_FSLink·\xa0Tcl_FSListVolumes', 'Tcl_FSListVolumesProc', 'Tcl_FSLoadFile', 'Tcl_FSLoadFileProc', - 'Tcl_FSLstat', 'Tcl_FSLstatProc', 'Tcl_FSMatchInDirectory', 'Tcl_FSMatchInDirectoryProc', - 'Tcl_FSMountsChanged', 'Tcl_FSNewNativePath', 'Tcl_FSNormalizePathProc', 'Tcl_FSOpenFileChannel', - 'Tcl_FSOpenFileChannelProc', 'Tcl_FSPathInFilesystemProc', 'Tcl_FSPathSeparator', 'Tcl_FSRegister', - 'Tcl_FSRemoveDirectory', 'Tcl_FSRemoveDirectoryProc', 'Tcl_FSRenameFile', 'Tcl_FSRenameFileProc', - 'Tcl_FSSplitPath', 'Tcl_FSStat', 'Tcl_FSStatProc', 'Tcl_FSUnloadFile', 'Tcl_FSUnloadFileProc', - 'Tcl_FSUnregister', 'Tcl_FSUtime', 'Tcl_FSUtimeProc', 'Tcl_GetAccessTimeFromStat', 'Tcl_GetAlias', - 'Tcl_GetAliasObj', 'Tcl_GetAssocData', 'Tcl_GetBignumFromObj', 'Tcl_GetBlocksFromStat', - 'Tcl_GetBlockSizeFromStat', 'Tcl_GetBoolean', 'Tcl_GetBooleanFromObj', 'Tcl_GetByteArrayFromObj', - 'Tcl_GetChangeTimeFromStat', 'Tcl_GetChannel', 'Tcl_GetChannelBufferSize', 'Tcl_GetChannelError', - 'Tcl_GetChannelErrorInterp', 'Tcl_GetChannelHandle', 'Tcl_GetChannelInstanceData', 'Tcl_GetChannelMode', - 'Tcl_GetChannelName', 'Tcl_GetChannelNames', 'Tcl_GetChannelNamesEx', 'Tcl_GetChannelOption', - 'Tcl_GetChannelThread', 'Tcl_GetChannelType', 'Tcl_GetCharLength', 'Tcl_GetClassAsObject', - 'Tcl_GetCommandFromObj', 'Tcl_GetCommandFullName', 'Tcl_GetCommandInfo', 'Tcl_GetCommandInfoFromToken', - 'Tcl_GetCommandName', 'Tcl_GetCurrentNamespace', 'Tcl_GetCurrentThread', 'Tcl_GetCwd', - 'Tcl_GetDefaultEncodingDir', 'Tcl_GetDeviceTypeFromStat', 'Tcl_GetDouble', 'Tcl_GetDoubleFromObj', - 'Tcl_GetEncoding', 'Tcl_GetEncodingFromObj', 'Tcl_GetEncodingName', 'Tcl_GetEncodingNameFromEnvironment', - 'Tcl_GetEncodingNames', 'Tcl_GetEncodingSearchPath', 'Tcl_GetEnsembleFlags', 'Tcl_GetEnsembleMappingDict', - 'Tcl_GetEnsembleNamespace', 'Tcl_GetEnsembleParameterList', 'Tcl_GetEnsembleSubcommandList', - 'Tcl_GetEnsembleUnknownHandler', 'Tcl_GetErrno', 'Tcl_GetErrorLine', 'Tcl_GetFSDeviceFromStat', - 'Tcl_GetFSInodeFromStat', 'Tcl_GetGlobalNamespace', 'Tcl_GetGroupIdFromStat', 'Tcl_GetHashKey', - 'Tcl_GetHashValue', 'Tcl_GetHostName', 'Tcl_GetIndexFromObj', 'Tcl_GetIndexFromObjStruct', 'Tcl_GetInt', - 'Tcl_GetInterpPath', 'Tcl_GetIntFromObj', 'Tcl_GetLinkCountFromStat', 'Tcl_GetLongFromObj', - 'Tcl_GetMaster', 'Tcl_GetMathFuncInfo', 'Tcl_GetModeFromStat', 'Tcl_GetModificationTimeFromStat', - 'Tcl_GetNameOfExecutable', 'Tcl_GetNamespaceUnknownHandler', 'Tcl_GetObjectAsClass', 'Tcl_GetObjectCommand', - 'Tcl_GetObjectFromObj', 'Tcl_GetObjectName', 'Tcl_GetObjectNamespace', 'Tcl_GetObjResult', 'Tcl_GetObjType', - 'Tcl_GetOpenFile', 'Tcl_GetPathType', 'Tcl_GetRange', 'Tcl_GetRegExpFromObj', 'Tcl_GetReturnOptions', - 'Tcl_Gets', 'Tcl_GetServiceMode', 'Tcl_GetSizeFromStat', 'Tcl_GetSlave', 'Tcl_GetsObj', - 'Tcl_GetStackedChannel', 'Tcl_GetStartupScript', 'Tcl_GetStdChannel', 'Tcl_GetString', - 'Tcl_GetStringFromObj', 'Tcl_GetStringResult', 'Tcl_GetThreadData', 'Tcl_GetTime', 'Tcl_GetTopChannel', - 'Tcl_GetUniChar', 'Tcl_GetUnicode', 'Tcl_GetUnicodeFromObj', 'Tcl_GetUserIdFromStat', 'Tcl_GetVar', - 'Tcl_GetVar2', 'Tcl_GetVar2Ex', 'Tcl_GetVersion', 'Tcl_GetWideIntFromObj', 'Tcl_GlobalEval', - 'Tcl_GlobalEvalObj', 'Tcl_GlobTypeData', 'Tcl_HashKeyType', 'Tcl_HashStats', 'Tcl_HideCommand', - 'Tcl_IdleProc', 'Tcl_Import', 'Tcl_IncrRefCount', 'Tcl_Init', 'Tcl_InitCustomHashTable', - 'Tcl_InitHashTable', 'Tcl_InitMemory', 'Tcl_InitNotifier', 'Tcl_InitObjHashTable', 'Tcl_InitStubs', - 'Tcl_InputBlocked', 'Tcl_InputBuffered', 'tcl_interactive', 'Tcl_Interp', 'Tcl_InterpActive', - 'Tcl_InterpDeleted', 'Tcl_InterpDeleteProc', 'Tcl_InvalidateStringRep', 'Tcl_IsChannelExisting', - 'Tcl_IsChannelRegistered', 'Tcl_IsChannelShared', 'Tcl_IsEnsemble', 'Tcl_IsSafe', 'Tcl_IsShared', - 'Tcl_IsStandardChannel', 'Tcl_JoinPath', 'Tcl_JoinThread', 'tcl_library', 'Tcl_LimitAddHandler', - 'Tcl_LimitCheck', 'Tcl_LimitExceeded', 'Tcl_LimitGetCommands', 'Tcl_LimitGetGranularity', - 'Tcl_LimitGetTime', 'Tcl_LimitHandlerDeleteProc', 'Tcl_LimitHandlerProc', 'Tcl_LimitReady', - 'Tcl_LimitRemoveHandler', 'Tcl_LimitSetCommands', 'Tcl_LimitSetGranularity', 'Tcl_LimitSetTime', - 'Tcl_LimitTypeEnabled', 'Tcl_LimitTypeExceeded', 'Tcl_LimitTypeReset', 'Tcl_LimitTypeSet', - 'Tcl_LinkVar', 'Tcl_ListMathFuncs', 'Tcl_ListObjAppendElement', 'Tcl_ListObjAppendList', - 'Tcl_ListObjGetElements', 'Tcl_ListObjIndex', 'Tcl_ListObjLength', 'Tcl_ListObjReplace', - 'Tcl_LogCommandInfo', 'Tcl_Main', 'Tcl_MainLoopProc', 'Tcl_MakeFileChannel', 'Tcl_MakeSafe', - 'Tcl_MakeTcpClientChannel', 'Tcl_MathProc', 'TCL_MEM_DEBUG', 'Tcl_Merge', 'Tcl_MethodCallProc', - 'Tcl_MethodDeclarerClass', 'Tcl_MethodDeclarerObject', 'Tcl_MethodDeleteProc', 'Tcl_MethodIsPublic', - 'Tcl_MethodIsType', 'Tcl_MethodName', 'Tcl_MethodType', 'Tcl_MutexFinalize', 'Tcl_MutexLock', - 'Tcl_MutexUnlock', 'Tcl_NamespaceDeleteProc', 'Tcl_NewBignumObj', 'Tcl_NewBooleanObj', - 'Tcl_NewByteArrayObj', 'Tcl_NewDictObj', 'Tcl_NewDoubleObj', 'Tcl_NewInstanceMethod', 'Tcl_NewIntObj', - 'Tcl_NewListObj', 'Tcl_NewLongObj', 'Tcl_NewMethod', 'Tcl_NewObj', 'Tcl_NewObjectInstance', - 'Tcl_NewStringObj', 'Tcl_NewUnicodeObj', 'Tcl_NewWideIntObj', 'Tcl_NextHashEntry', 'tcl_nonwordchars', - 'Tcl_NotifierProcs', 'Tcl_NotifyChannel', 'Tcl_NRAddCallback', 'Tcl_NRCallObjProc', 'Tcl_NRCmdSwap', - 'Tcl_NRCreateCommand', 'Tcl_NREvalObj', 'Tcl_NREvalObjv', 'Tcl_NumUtfChars', 'Tcl_Obj', 'Tcl_ObjCmdProc', - 'Tcl_ObjectContextInvokeNext', 'Tcl_ObjectContextIsFiltering', 'Tcl_ObjectContextMethod', - 'Tcl_ObjectContextObject', 'Tcl_ObjectContextSkippedArgs', 'Tcl_ObjectDeleted', 'Tcl_ObjectGetMetadata', - 'Tcl_ObjectGetMethodNameMapper', 'Tcl_ObjectMapMethodNameProc', 'Tcl_ObjectMetadataDeleteProc', - 'Tcl_ObjectSetMetadata', 'Tcl_ObjectSetMethodNameMapper', 'Tcl_ObjGetVar2', 'Tcl_ObjPrintf', - 'Tcl_ObjSetVar2', 'Tcl_ObjType', 'Tcl_OpenCommandChannel', 'Tcl_OpenFileChannel', 'Tcl_OpenTcpClient', - 'Tcl_OpenTcpServer', 'Tcl_OutputBuffered', 'Tcl_PackageInitProc', 'Tcl_PackageUnloadProc', 'Tcl_Panic', - 'Tcl_PanicProc', 'Tcl_PanicVA', 'Tcl_ParseArgsObjv', 'Tcl_ParseBraces', 'Tcl_ParseCommand', 'Tcl_ParseExpr', - 'Tcl_ParseQuotedString', 'Tcl_ParseVar', 'Tcl_ParseVarName', 'tcl_patchLevel', 'tcl_pkgPath', - 'Tcl_PkgPresent', 'Tcl_PkgPresentEx', 'Tcl_PkgProvide', 'Tcl_PkgProvideEx', 'Tcl_PkgRequire', - 'Tcl_PkgRequireEx', 'Tcl_PkgRequireProc', 'tcl_platform', 'Tcl_PosixError', 'tcl_precision', - 'Tcl_Preserve', 'Tcl_PrintDouble', 'Tcl_PutEnv', 'Tcl_QueryTimeProc', 'Tcl_QueueEvent', 'tcl_rcFileName', - 'Tcl_Read', 'Tcl_ReadChars', 'Tcl_ReadRaw', 'Tcl_Realloc', 'Tcl_ReapDetachedProcs', 'Tcl_RecordAndEval', - 'Tcl_RecordAndEvalObj', 'Tcl_RegExpCompile', 'Tcl_RegExpExec', 'Tcl_RegExpExecObj', 'Tcl_RegExpGetInfo', - 'Tcl_RegExpIndices', 'Tcl_RegExpInfo', 'Tcl_RegExpMatch', 'Tcl_RegExpMatchObj', 'Tcl_RegExpRange', - 'Tcl_RegisterChannel', 'Tcl_RegisterConfig', 'Tcl_RegisterObjType', 'Tcl_Release', 'Tcl_ResetResult', - 'Tcl_RestoreInterpState', 'Tcl_RestoreResult', 'Tcl_SaveInterpState', 'Tcl_SaveResult', 'Tcl_ScaleTimeProc', - 'Tcl_ScanCountedElement', 'Tcl_ScanElement', 'Tcl_Seek', 'Tcl_ServiceAll', 'Tcl_ServiceEvent', - 'Tcl_ServiceModeHook', 'Tcl_SetAssocData', 'Tcl_SetBignumObj', 'Tcl_SetBooleanObj', - 'Tcl_SetByteArrayLength', 'Tcl_SetByteArrayObj', 'Tcl_SetChannelBufferSize', 'Tcl_SetChannelError', - 'Tcl_SetChannelErrorInterp', 'Tcl_SetChannelOption', 'Tcl_SetCommandInfo', 'Tcl_SetCommandInfoFromToken', - 'Tcl_SetDefaultEncodingDir', 'Tcl_SetDoubleObj', 'Tcl_SetEncodingSearchPath', 'Tcl_SetEnsembleFlags', - 'Tcl_SetEnsembleMappingDict', 'Tcl_SetEnsembleParameterList', 'Tcl_SetEnsembleSubcommandList', - 'Tcl_SetEnsembleUnknownHandler', 'Tcl_SetErrno', 'Tcl_SetErrorCode', 'Tcl_SetErrorCodeVA', - 'Tcl_SetErrorLine', 'Tcl_SetExitProc', 'Tcl_SetFromAnyProc', 'Tcl_SetHashValue', 'Tcl_SetIntObj', - 'Tcl_SetListObj', 'Tcl_SetLongObj', 'Tcl_SetMainLoop', 'Tcl_SetMaxBlockTime', - 'Tcl_SetNamespaceUnknownHandler', 'Tcl_SetNotifier', 'Tcl_SetObjErrorCode', 'Tcl_SetObjLength', - 'Tcl_SetObjResult', 'Tcl_SetPanicProc', 'Tcl_SetRecursionLimit', 'Tcl_SetResult', 'Tcl_SetReturnOptions', - 'Tcl_SetServiceMode', 'Tcl_SetStartupScript', 'Tcl_SetStdChannel', 'Tcl_SetStringObj', - 'Tcl_SetSystemEncoding', 'Tcl_SetTimeProc', 'Tcl_SetTimer', 'Tcl_SetUnicodeObj', 'Tcl_SetVar', - 'Tcl_SetVar2', 'Tcl_SetVar2Ex', 'Tcl_SetWideIntObj', 'Tcl_SignalId', 'Tcl_SignalMsg', 'Tcl_Sleep', - 'Tcl_SourceRCFile', 'Tcl_SpliceChannel', 'Tcl_SplitList', 'Tcl_SplitPath', 'Tcl_StackChannel', - 'Tcl_StandardChannels', 'tcl_startOfNextWord', 'tcl_startOfPreviousWord', 'Tcl_Stat', 'Tcl_StaticPackage', - 'Tcl_StringCaseMatch', 'Tcl_StringMatch', 'Tcl_SubstObj', 'Tcl_TakeBignumFromObj', 'Tcl_TcpAcceptProc', - 'Tcl_Tell', 'Tcl_ThreadAlert', 'Tcl_ThreadQueueEvent', 'Tcl_Time', 'Tcl_TimerProc', 'Tcl_Token', - 'Tcl_TraceCommand', 'tcl_traceCompile', 'tcl_traceEval', 'Tcl_TraceVar', 'Tcl_TraceVar2', - 'Tcl_TransferResult', 'Tcl_TranslateFileName', 'Tcl_TruncateChannel', 'Tcl_Ungets', 'Tcl_UniChar', - 'Tcl_UniCharAtIndex', 'Tcl_UniCharCaseMatch', 'Tcl_UniCharIsAlnum', 'Tcl_UniCharIsAlpha', - 'Tcl_UniCharIsControl', 'Tcl_UniCharIsDigit', 'Tcl_UniCharIsGraph', 'Tcl_UniCharIsLower', - 'Tcl_UniCharIsPrint', 'Tcl_UniCharIsPunct', 'Tcl_UniCharIsSpace', 'Tcl_UniCharIsUpper', - 'Tcl_UniCharIsWordChar', 'Tcl_UniCharLen', 'Tcl_UniCharNcasecmp', 'Tcl_UniCharNcmp', 'Tcl_UniCharToLower', - 'Tcl_UniCharToTitle', 'Tcl_UniCharToUpper', 'Tcl_UniCharToUtf', 'Tcl_UniCharToUtfDString', 'Tcl_UnlinkVar', - 'Tcl_UnregisterChannel', 'Tcl_UnsetVar', 'Tcl_UnsetVar2', 'Tcl_UnstackChannel', 'Tcl_UntraceCommand', - 'Tcl_UntraceVar', 'Tcl_UntraceVar2', 'Tcl_UpdateLinkedVar', 'Tcl_UpdateStringProc', 'Tcl_UpVar', - 'Tcl_UpVar2', 'Tcl_UtfAtIndex', 'Tcl_UtfBackslash', 'Tcl_UtfCharComplete', 'Tcl_UtfFindFirst', - 'Tcl_UtfFindLast', 'Tcl_UtfNext', 'Tcl_UtfPrev', 'Tcl_UtfToExternal', 'Tcl_UtfToExternalDString', - 'Tcl_UtfToLower', 'Tcl_UtfToTitle', 'Tcl_UtfToUniChar', 'Tcl_UtfToUniCharDString', 'Tcl_UtfToUpper', - 'Tcl_ValidateAllMemory', 'Tcl_Value', 'Tcl_VarEval', 'Tcl_VarEvalVA', 'Tcl_VarTraceInfo', - 'Tcl_VarTraceInfo2', 'Tcl_VarTraceProc', 'tcl_version', 'Tcl_WaitForEvent', 'Tcl_WaitPid', - 'Tcl_WinTCharToUtf', 'Tcl_WinUtfToTChar', 'tcl_wordBreakAfter', 'tcl_wordBreakBefore', 'tcl_wordchars', - 'Tcl_Write', 'Tcl_WriteChars', 'Tcl_WriteObj', 'Tcl_WriteRaw', 'Tcl_WrongNumArgs', 'Tcl_ZlibAdler32', - 'Tcl_ZlibCRC32', 'Tcl_ZlibDeflate', 'Tcl_ZlibInflate', 'Tcl_ZlibStreamChecksum', 'Tcl_ZlibStreamClose', - 'Tcl_ZlibStreamEof', 'Tcl_ZlibStreamGet', 'Tcl_ZlibStreamGetCommandName', 'Tcl_ZlibStreamInit', - 'Tcl_ZlibStreamPut', 'tcltest', 'tell', 'throw', 'time', 'tm', 'trace', 'transchan', 'try', 'unknown', - 'unload', 'unset', 'update', 'uplevel', 'upvar', 'variable', 'vwait', 'while', 'yield', 'yieldto', 'zlib' - ] - - self.autocomplete_kw_list = self.options['util_autocomplete_keywords'].replace(' ', '').split(',') - self.myKeywords = self.tcl_commands_list + self.autocomplete_kw_list + self.tcl_keywords - # ############################################################################################################ # ################################### Set LOG verbosity ###################################################### # ############################################################################################################ @@ -1076,6 +816,20 @@ class App(QtCore.QObject): self.log.debug("Stardate: %s" % self.date) self.log.debug("TCL Shell has been initialized.") + # ########################################################################################################### + # ####################################### Auto-complete KEYWORDS ############################################ + # ######################## Setup after the Defaults class was instantiated ################################## + # ########################################################################################################### + self.regFK = RegisterFK( + ui=self.ui, + inform_sig=self.inform, + options_dict=self.options, + shell=self.shell, + log=self.log, + keywords=KeyWords(), + extensions=Extensions() + ) + # ########################################################################################################### # ########################################### AUTOSAVE SETUP ################################################ # ########################################################################################################### @@ -1313,13 +1067,6 @@ class App(QtCore.QObject): self.worker_task.emit({'fcn': self.version_check, 'params': []}) # self.thr2.start(QtCore.QThread.Priority.LowPriority) - # ########################################################################################################### - # ##################################### Register files with FlatCAM; ####################################### - # ################################### It works only for Windows for now #################################### - # ########################################################################################################### - if sys.platform == 'win32' and self.options["first_run"] is True: - self.on_register_files() - # ########################################################################################################### # ################################## ADDING FlatCAM EDITORS section ######################################### # ########################################################################################################### @@ -1392,7 +1139,7 @@ class App(QtCore.QObject): # if running headless always have the systray to be able to quit the app correctly self.trayIcon = AppSystemTray(app=self, icon=QtGui.QIcon(self.resource_location + - '/app32.png'), + '/app32.png'), headless=True, parent=self.parent_w) else: @@ -1502,57 +1249,6 @@ class App(QtCore.QObject): # when there are arguments at application startup this get launched self.args_at_startup[list].connect(self.on_startup_args) - # ########################################################################################################### - # ####################################### FILE ASSOCIATIONS SIGNALS ######################################### - # ########################################################################################################### - self.ui.util_pref_form.fa_excellon_group.restore_btn.clicked.connect( - lambda: self.restore_extensions(ext_type='excellon')) - self.ui.util_pref_form.fa_gcode_group.restore_btn.clicked.connect( - lambda: self.restore_extensions(ext_type='gcode')) - self.ui.util_pref_form.fa_gerber_group.restore_btn.clicked.connect( - lambda: self.restore_extensions(ext_type='gerber')) - - self.ui.util_pref_form.fa_excellon_group.del_all_btn.clicked.connect( - lambda: self.delete_all_extensions(ext_type='excellon')) - self.ui.util_pref_form.fa_gcode_group.del_all_btn.clicked.connect( - lambda: self.delete_all_extensions(ext_type='gcode')) - self.ui.util_pref_form.fa_gerber_group.del_all_btn.clicked.connect( - lambda: self.delete_all_extensions(ext_type='gerber')) - - self.ui.util_pref_form.fa_excellon_group.add_btn.clicked.connect( - lambda: self.add_extension(ext_type='excellon')) - self.ui.util_pref_form.fa_gcode_group.add_btn.clicked.connect( - lambda: self.add_extension(ext_type='gcode')) - self.ui.util_pref_form.fa_gerber_group.add_btn.clicked.connect( - lambda: self.add_extension(ext_type='gerber')) - - self.ui.util_pref_form.fa_excellon_group.del_btn.clicked.connect( - lambda: self.del_extension(ext_type='excellon')) - self.ui.util_pref_form.fa_gcode_group.del_btn.clicked.connect( - lambda: self.del_extension(ext_type='gcode')) - self.ui.util_pref_form.fa_gerber_group.del_btn.clicked.connect( - lambda: self.del_extension(ext_type='gerber')) - - # connect the 'Apply' buttons from the Preferences/File Associations - self.ui.util_pref_form.fa_excellon_group.exc_list_btn.clicked.connect( - lambda: self.on_register_files(obj_type='excellon')) - self.ui.util_pref_form.fa_gcode_group.gco_list_btn.clicked.connect( - lambda: self.on_register_files(obj_type='gcode')) - self.ui.util_pref_form.fa_gerber_group.grb_list_btn.clicked.connect( - lambda: self.on_register_files(obj_type='gerber')) - - # ########################################################################################################### - # ########################################### KEYWORDS SIGNALS ############################################## - # ########################################################################################################### - self.ui.util_pref_form.kw_group.restore_btn.clicked.connect( - lambda: self.restore_extensions(ext_type='keyword')) - self.ui.util_pref_form.kw_group.del_all_btn.clicked.connect( - lambda: self.delete_all_extensions(ext_type='keyword')) - self.ui.util_pref_form.kw_group.add_btn.clicked.connect( - lambda: self.add_extension(ext_type='keyword')) - self.ui.util_pref_form.kw_group.del_btn.clicked.connect( - lambda: self.del_extension(ext_type='keyword')) - # ########################################################################################################### # ########################################### GUI SIGNALS ################################################### # ########################################################################################################### @@ -2754,7 +2450,7 @@ class App(QtCore.QObject): msgbox = FCMessageBox(parent=self.ui) title = _("Exit Editor") txt = _("Do you want to save the changes?") - msgbox.setWindowTitle(title) # taskbar still shows it + msgbox.setWindowTitle(title) # taskbar still shows it msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/app128.png')) msgbox.setText('%s' % title) msgbox.setInformativeText(txt) @@ -4299,272 +3995,6 @@ class App(QtCore.QObject): with open(config_file, 'w') as f: f.writelines(data) - def on_register_files(self, obj_type=None): - """ - Called whenever there is a need to register file extensions with FlatCAM. - Works only in Windows and should be called only when FlatCAM is run in Windows. - - :param obj_type: the type of object to be register for. - Can be: 'gerber', 'excellon' or 'gcode'. 'geometry' is not used for the moment. - - :return: None - """ - self.log.debug("Manufacturing files extensions are registered with FlatCAM.") - - new_reg_path = 'Software\\Classes\\' - # find if the current user is admin - try: - is_admin = os.getuid() == 0 - except AttributeError: - is_admin = ctypes.windll.shell32.IsUserAnAdmin() == 1 - - if is_admin is True: - root_path = winreg.HKEY_LOCAL_MACHINE - else: - root_path = winreg.HKEY_CURRENT_USER - - # create the keys - def set_reg(name, root_pth, new_reg_path_par, value): - try: - winreg.CreateKey(root_pth, new_reg_path_par) - with winreg.OpenKey(root_pth, new_reg_path_par, 0, winreg.KEY_WRITE) as registry_key: - winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value) - return True - except WindowsError: - return False - - # delete key in registry - def delete_reg(root_pth, reg_path, key_to_del): - key_to_del_path = reg_path + key_to_del - try: - winreg.DeleteKey(root_pth, key_to_del_path) - return True - except WindowsError: - return False - - if obj_type is None or obj_type == 'excellon': - exc_list = \ - self.ui.util_pref_form.fa_excellon_group.exc_list_text.get_value().replace(' ', '').split(',') - exc_list = [x for x in exc_list if x != ''] - - # register all keys in the Preferences window - for ext in exc_list: - new_k = new_reg_path + '.%s' % ext - set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') - - # and unregister those that are no longer in the Preferences windows but are in the file - for ext in self.options["fa_excellon"].replace(' ', '').split(','): - if ext not in exc_list: - delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) - - # now write the updated extensions to the self.options - # new_ext = '' - # for ext in exc_list: - # new_ext = new_ext + ext + ', ' - # self.options["fa_excellon"] = new_ext - self.inform.emit('[success] %s' % _("Selected Excellon file extensions registered with FlatCAM.")) - - if obj_type is None or obj_type == 'gcode': - gco_list = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().replace(' ', '').split(',') - gco_list = [x for x in gco_list if x != ''] - - # register all keys in the Preferences window - for ext in gco_list: - new_k = new_reg_path + '.%s' % ext - set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') - - # and unregister those that are no longer in the Preferences windows but are in the file - for ext in self.options["fa_gcode"].replace(' ', '').split(','): - if ext not in gco_list: - delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) - - self.inform.emit('[success] %s' % - _("Selected GCode file extensions registered with FlatCAM.")) - - if obj_type is None or obj_type == 'gerber': - grb_list = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().replace(' ', '').split(',') - grb_list = [x for x in grb_list if x != ''] - - # register all keys in the Preferences window - for ext in grb_list: - new_k = new_reg_path + '.%s' % ext - set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') - - # and unregister those that are no longer in the Preferences windows but are in the file - for ext in self.options["fa_gerber"].replace(' ', '').split(','): - if ext not in grb_list: - delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) - - self.inform.emit('[success] %s' % _("Selected Gerber file extensions registered with FlatCAM.")) - - def add_extension(self, ext_type): - """ - Add a file extension to the list for a specific object - - :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword - :return: - """ - - if ext_type == 'excellon': - new_ext = self.ui.util_pref_form.fa_excellon_group.ext_entry.get_value() - if new_ext == '': - return - - old_val = self.ui.util_pref_form.fa_excellon_group.exc_list_text.get_value().replace(' ', '').split(',') - if new_ext in old_val: - return - old_val.append(new_ext) - old_val.sort() - self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value(', '.join(old_val)) - if ext_type == 'gcode': - new_ext = self.ui.util_pref_form.fa_gcode_group.ext_entry.get_value() - if new_ext == '': - return - - old_val = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().replace(' ', '').split(',') - if new_ext in old_val: - return - old_val.append(new_ext) - old_val.sort() - self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value(', '.join(old_val)) - if ext_type == 'gerber': - new_ext = self.ui.util_pref_form.fa_gerber_group.ext_entry.get_value() - if new_ext == '': - return - - old_val = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().replace(' ', '').split(',') - if new_ext in old_val: - return - old_val.append(new_ext) - old_val.sort() - self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value(', '.join(old_val)) - if ext_type == 'keyword': - new_kw = self.ui.util_pref_form.kw_group.kw_entry.get_value() - if new_kw == '': - return - - old_val = self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') - if new_kw in old_val: - return - old_val.append(new_kw) - old_val.sort() - self.ui.util_pref_form.kw_group.kw_list_text.set_value(', '.join(old_val)) - - # update the self.myKeywords so the model is updated - self.autocomplete_kw_list = \ - self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') - self.myKeywords = self.tcl_commands_list + self.autocomplete_kw_list + self.tcl_keywords - self.shell.command_line().set_model_data(self.myKeywords) - - def del_extension(self, ext_type): - """ - Remove a file extension from the list for a specific object - - :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword - :return: - """ - if ext_type == 'excellon': - new_ext = self.ui.util_pref_form.fa_excellon_group.ext_entry.get_value() - if new_ext == '': - return - - old_val = self.ui.util_pref_form.fa_excellon_group.exc_list_text.get_value().replace(' ', '').split(',') - if new_ext not in old_val: - return - old_val.remove(new_ext) - old_val.sort() - self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value(', '.join(old_val)) - if ext_type == 'gcode': - new_ext = self.ui.util_pref_form.fa_gcode_group.ext_entry.get_value() - if new_ext == '': - return - - old_val = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().replace(' ', '').split(',') - if new_ext not in old_val: - return - old_val.remove(new_ext) - old_val.sort() - self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value(', '.join(old_val)) - if ext_type == 'gerber': - new_ext = self.ui.util_pref_form.fa_gerber_group.ext_entry.get_value() - if new_ext == '': - return - - old_val = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().replace(' ', '').split(',') - if new_ext not in old_val: - return - old_val.remove(new_ext) - old_val.sort() - self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value(', '.join(old_val)) - if ext_type == 'keyword': - new_kw = self.ui.util_pref_form.kw_group.kw_entry.get_value() - if new_kw == '': - return - - old_val = self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') - if new_kw not in old_val: - return - old_val.remove(new_kw) - old_val.sort() - self.ui.util_pref_form.kw_group.kw_list_text.set_value(', '.join(old_val)) - - # update the self.myKeywords so the model is updated - self.autocomplete_kw_list = \ - self.ui.util_pref_form.kw_group.kw_list_text.get_value().replace(' ', '').split(',') - self.myKeywords = self.tcl_commands_list + self.autocomplete_kw_list + self.tcl_keywords - self.shell.command_line().set_model_data(self.myKeywords) - - def restore_extensions(self, ext_type): - """ - Restore all file extensions associations with FlatCAM, for a specific object - - :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword - :return: - """ - - if ext_type == 'excellon': - # don't add 'txt' to the associations (too many files are .txt and not Excellon) but keep it in the list - # for the ability to open Excellon files with .txt extension - new_exc_list = deepcopy(self.exc_list) - - try: - new_exc_list.remove('txt') - except ValueError: - pass - self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value(', '.join(new_exc_list)) - if ext_type == 'gcode': - self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value(', '.join(self.gcode_list)) - if ext_type == 'gerber': - self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value(', '.join(self.grb_list)) - if ext_type == 'keyword': - self.ui.util_pref_form.kw_group.kw_list_text.set_value(', '.join(self.default_keywords)) - - # update the self.myKeywords so the model is updated - self.autocomplete_kw_list = self.default_keywords - self.myKeywords = self.tcl_commands_list + self.autocomplete_kw_list + self.tcl_keywords - self.shell.command_line().set_model_data(self.myKeywords) - - def delete_all_extensions(self, ext_type): - """ - Delete all file extensions associations with FlatCAM, for a specific object - - :param ext_type: type of FlatCAM object: excellon, gerber, geometry and then 'not FlatCAM object' keyword - :return: - """ - - if ext_type == 'excellon': - self.ui.util_pref_form.fa_excellon_group.exc_list_text.set_value('') - if ext_type == 'gcode': - self.ui.util_pref_form.fa_gcode_group.gco_list_text.set_value('') - if ext_type == 'gerber': - self.ui.util_pref_form.fa_gerber_group.grb_list_text.set_value('') - if ext_type == 'keyword': - self.ui.util_pref_form.kw_group.kw_list_text.set_value('') - - # update the self.myKeywords so the model is updated - self.myKeywords = self.tcl_commands_list + self.tcl_keywords - self.shell.command_line().set_model_data(self.myKeywords) - def on_edit_join(self, name=None): """ Callback for Edit->Join. Joins the selected geometry objects into @@ -4792,7 +4222,7 @@ class App(QtCore.QObject): return if self.ui.plot_tab_area.currentWidget().objectName() == "preferences_tab": - if factor != 1: # means we had a unit change in the rest of the app + if factor != 1: # means we had a unit change in the rest of the app if self.app_units != new_units: pref_factor = 25.4 if new_units == 'MM' else 1 / 25.4 self.scale_preferences(pref_factor, new_units) @@ -5971,8 +5401,8 @@ class App(QtCore.QObject): return if dia_box.reference == 'abs': - abs_x = location[0] - bounds[0] - abs_y = location[1] - bounds[1] + abs_x = location[0] - bounds[0] + abs_y = location[1] - bounds[1] location = (abs_x, abs_y) self.options['global_jump_ref'] = dia_box.reference except Exception: @@ -6334,7 +5764,7 @@ class App(QtCore.QObject): continue minx, miny, maxx, maxy = geo.bounds - new_dia = min([maxx-minx, maxy-miny]) + new_dia = min([maxx - minx, maxy - miny]) new_drill = geo.centroid new_drill_geo = new_drill.buffer(new_dia / 2.0) @@ -6658,7 +6088,7 @@ class App(QtCore.QObject): self.log.error("Could not access tools DB file. The file may be locked,\n" "not existing or doesn't have the read permissions.\n" "Check to see if exists, it should be here: %s\n" - "It may help to reboot the app, it will try to recreate it if it's missing." % + "It may help to reboot the app, it will try to recreate it if it's missing." % self.data_path) self.inform.emit('[ERROR] %s' % _("Could not load the file.")) return 'fail' @@ -6785,7 +6215,7 @@ class App(QtCore.QObject): return if obj.kind == 'geometry': - if tool['data']['tool_target'] not in [0, 1]: # General, Milling Type + if tool['data']['tool_target'] not in [0, 1]: # General, Milling Type # close the tab and delete it for idx in range(self.ui.plot_tab_area.count()): if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"): @@ -6806,7 +6236,7 @@ class App(QtCore.QObject): self.ui.plot_tab_area.removeTab(idx) self.inform.emit('[success] %s' % _("Tool from DB added in Tool Table.")) elif obj.kind == 'gerber': - if tool['data']['tool_target'] not in [0, 3]: # General, Isolation Type + if tool['data']['tool_target'] not in [0, 3]: # General, Isolation Type # close the tab and delete it for idx in range(self.ui.plot_tab_area.count()): if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"): @@ -6960,7 +6390,7 @@ class App(QtCore.QObject): self.ui.plugin_tab_layout.addWidget(self.ui.plugin_scroll_area) # def on_close_notebook_tab(self): - # self.tool_shapes.clear(update=True) + # self.tool_shapes.clear(update=True) def on_gui_coords_clicked(self): self.distance_tool.run(toggle=True) @@ -8395,6 +7825,7 @@ class App(QtCore.QObject): for plot_obj in obj_collection: if plot_obj.obj_options['plot'] is False: continue + def worker_task(obj): with self.proc_container.new("Plotting"): if obj.kind == 'cncjob': @@ -8774,10 +8205,10 @@ class App(QtCore.QObject): self.log.debug("Newer version available.") title = _("Newer Version Available") msg = '%s

>%s
%s' % ( - _("There is a newer version available for download:"), - str(data["name"]), - str(data["message"]) - ) + _("There is a newer version available for download:"), + str(data["name"]), + str(data["message"]) + ) self.message.emit(title, msg, "info") def on_plotcanvas_setup(self): @@ -9212,7 +8643,7 @@ class App(QtCore.QObject): item = sel_obj.item item_index = self.collection.index(item.row(), 0, group_index) idx = item_index.row() - new_c = (new_line_color, new_color, '%s_%d' % (_("Layer"), int(idx+1))) + new_c = (new_line_color, new_color, '%s_%d' % (_("Layer"), int(idx + 1))) try: self.options["gerber_color_list"][idx] = new_c except Exception as err_msg: @@ -9261,16 +8692,16 @@ class App(QtCore.QObject): item = sel_obj.item item_index = self.collection.index(item.row(), 0, group_gerber_index) idx = item_index.row() - new_c = (outline_color, fill_color, '%s_%d' % (_("Layer"), int(idx+1))) + new_c = (outline_color, fill_color, '%s_%d' % (_("Layer"), int(idx + 1))) try: self.options["gerber_color_list"][idx] = new_c except IndexError: for x in range(len(self.options["gerber_color_list"]), len(all_gerber_list)): self.options["gerber_color_list"].append( ( - self.options["gerber_plot_fill"], # content color - self.options["gerber_plot_line"], # outline color - '%s_%d' % (_("Layer"), int(idx+1))) # layer name + self.options["gerber_plot_fill"], # content color + self.options["gerber_plot_line"], # outline color + '%s_%d' % (_("Layer"), int(idx + 1))) # layer name ) self.options["gerber_color_list"][idx] = new_c elif sel_obj.kind == 'excellon': @@ -10748,7 +10179,7 @@ class MenuFileHandlers(QtCore.QObject): # make sure that the Excellon objeacts are drawn on top of everything excellon_objs = [obj for obj in obj_selection if obj.kind == 'excellon'] - cncjob_objs =[obj for obj in obj_selection if obj.kind == 'cncjob'] + cncjob_objs = [obj for obj in obj_selection if obj.kind == 'cncjob'] # reverse the object order such that the first selected is on top rest_objs = [obj for obj in obj_selection if obj.kind != 'excellon' and obj.kind != 'cncjob'][::-1] obj_selection = rest_objs + cncjob_objs + excellon_objs @@ -12266,8 +11697,8 @@ class MenuFileHandlers(QtCore.QObject): out1 = compressor_obj.compress(project_as_json) out2 = compressor_obj.flush() project_zipped = b"".join([out1, out2]) - except Exception as err: - self.log.error("Failed to save compressed file: %s because: %s" % (str(filename), str(err))) + except Exception as errrr: + self.log.error("Failed to save compressed file: %s because: %s" % (str(filename), str(errrr))) self.inform.emit('[ERROR_NOTCL] %s' % _("Failed.")) return @@ -12315,7 +11746,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s: %s %s' % (_("Failed to parse saved project file"), str(filename), - _("Retry to save it."))) + _("Retry to save it."))) # noqa f.close() return except Exception: @@ -12323,7 +11754,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s: %s %s' % (_("Failed to parse saved project file"), str(filename), - _("Retry to save it."))) + _("Retry to save it."))) # noqa f.close() return @@ -12336,7 +11767,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s: %s %s' % (_("Failed to parse saved project file"), str(filename), - _("Retry to save it."))) + _("Retry to save it."))) # noqa tb_settings = QSettings("Open Source", "FlatCAM") lock_state = self.app.ui.lock_action.isChecked() @@ -12372,7 +11803,7 @@ class MenuFileHandlers(QtCore.QObject): if file_string.getvalue() == '': msg = _("Save cancelled because source file is empty. Try to export the file.") - self.inform.emit('[ERROR_NOTCL] %s' % msg) + self.inform.emit('[ERROR_NOTCL] %s' % msg) # noqa return 'fail' try: @@ -12388,7 +11819,7 @@ class MenuFileHandlers(QtCore.QObject): except PermissionError: self.inform.emit('[WARNING] %s' % _("Permission denied, saving not possible.\n" - "Most likely another app is holding the file open and not accessible.")) + "Most likely another app is holding the file open and not accessible.")) # noqa return 'fail' def on_file_savedefaults(self): @@ -12401,5 +11832,4 @@ class MenuFileHandlers(QtCore.QObject): self.app.defaults.update(self.app.options) self.app.preferencesUiManager.save_defaults() - # end of file diff --git a/appObjects/AppObject.py b/appObjects/AppObject.py index 3ff1091b..10d43655 100644 --- a/appObjects/AppObject.py +++ b/appObjects/AppObject.py @@ -336,11 +336,6 @@ class AppObject(QtCore.QObject): except Exception as e: self.app.log.error("AppObject.new_object() -> setting colors error. %s" % str(e)) - # ############################################################################################################# - # update the SHELL auto-completer model with the name of the new object - # ############################################################################################################# - self.app.shell.command_line().set_model_data(self.app.myKeywords) - if auto_select or self.app.ui.notebook.currentWidget() is self.app.ui.properties_tab: # select the just opened object but deselect the previous ones self.app.collection.set_all_inactive() diff --git a/appObjects/AppObjectTemplate.py b/appObjects/AppObjectTemplate.py index cecf2fdd..c198302a 100644 --- a/appObjects/AppObjectTemplate.py +++ b/appObjects/AppObjectTemplate.py @@ -331,10 +331,9 @@ class FlatCAMObj(QtCore.QObject): if new_name != old_name: # update the SHELL auto-completer model data try: - self.app.myKeywords.remove(old_name) - self.app.myKeywords.append(new_name) - self.app.shell._edit.set_model_data(self.app.myKeywords) - self.app.ui.code_editor.set_model_data(self.app.myKeywords) + self.app.regFK.remove_keyword(old_name, update=False) + self.app.regFK.prepend_keyword(new_name) + self.app.ui.code_editor.set_model_data(self.app.regFK.myKeywords) except Exception: self.app.log.debug( "on_name_activate() --> Could not remove the old object name from auto-completer model list") diff --git a/appObjects/ObjectCollection.py b/appObjects/ObjectCollection.py index cb5db7df..51b44282 100644 --- a/appObjects/ObjectCollection.py +++ b/appObjects/ObjectCollection.py @@ -363,7 +363,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): self.view.setFont(font) # ## GUI Events - self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change) + self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change) # noqa # self.view.activated.connect(self.on_item_activated) self.view.keyPressed.connect(self.app.ui.keyPressEvent) self.view.mouseReleased.connect(self.on_list_click_release) @@ -556,8 +556,8 @@ class ObjectCollection(QtCore.QAbstractItemModel): # update the SHELL auto-completer model data try: - self.app.myKeywords.remove(old_name) - self.app.myKeywords.append(new_name) + self.app.regFK.remove_keyword(old_name, update=False) + self.app.regFK.prepend_keyword(new_name) self.app.shell._edit.set_model_data(self.app.myKeywords) except Exception as e: self.app.log.error( @@ -567,7 +567,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): msg = "%s: %s %s: %s" % (_("Object renamed from"), old_name, _("to"), new_name) self.app.inform.emit(msg) - self.dataChanged.emit(index, index) + self.dataChanged.emit(index, index) # noqa return True else: return False @@ -620,7 +620,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): # ############################################################################################################ # update the KeyWords list with the name of the file # ############################################################################################################ - self.app.myKeywords.append(name) + self.app.regFK.prepend_keyword(name) # ############################################################################################################ # ############################# Set the Object UI (Properties Tab) ########################################### @@ -737,15 +737,15 @@ class ObjectCollection(QtCore.QAbstractItemModel): # some objects add a Tab on creation, close it here for idx in range(self.app.ui.plot_tab_area.count()): widget_name = self.app.ui.plot_tab_area.widget(idx).objectName() - if widget_name == active.obj.obj_options['name'] or widget_name == (active.obj.obj_options['name'] + "_editor_tab"): + if widget_name == active.obj.obj_options['name'] or \ + widget_name == (active.obj.obj_options['name'] + "_editor_tab"): self.app.ui.plot_tab_area.removeTab(idx) break # update the SHELL auto-completer model data name = active.obj.obj_options['name'] try: - self.app.myKeywords.remove(name) - self.app.shell._edit.set_model_data(self.app.myKeywords) + self.app.regFK.remove_keyword(name) # this is not needed any more because now the code editor is created on demand # self.app.ui.code_editor.set_model_data(self.app.myKeywords) except Exception as e: @@ -791,15 +791,15 @@ class ObjectCollection(QtCore.QAbstractItemModel): # some objects add a Tab on creation, close it here for idx in range(self.app.ui.plot_tab_area.count()): wdg_name = self.app.ui.plot_tab_area.widget(idx).objectName() - if wdg_name == deleted.obj.obj_options['name'] or wdg_name == (deleted.obj.obj_options['name'] + "_editor_tab"): + if wdg_name == deleted.obj.obj_options['name'] or \ + wdg_name == (deleted.obj.obj_options['name'] + "_editor_tab"): self.app.ui.plot_tab_area.removeTab(idx) break # update the SHELL auto-completer model data name = deleted.obj.obj_options['name'] try: - self.app.myKeywords.remove(name) - self.app.shell._edit.set_model_data(self.app.myKeywords) + self.app.regFK.remove_keyword(name) # this is not needed any more because now the code editor is created on demand # self.app.ui.code_editor.set_model_data(self.app.myKeywords) except Exception as e: @@ -1080,7 +1080,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): return obj_list def update_view(self): - self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex()) + self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex()) # noqa def on_row_activated(self, index): if index.isValid(): diff --git a/appPlugins/ToolShell.py b/appPlugins/ToolShell.py index b472f619..2a9df2a8 100644 --- a/appPlugins/ToolShell.py +++ b/appPlugins/ToolShell.py @@ -312,8 +312,6 @@ class FCShell(TermWidget): self.init_tcl() - self._edit.set_model_data(self.app.myKeywords) - app_icon = QtGui.QIcon() app_icon.addFile(self.app.resource_location + '/app16.png', QtCore.QSize(16, 16)) app_icon.addFile(self.app.resource_location + '/app24.png', QtCore.QSize(24, 24))