Files
flatcam-wsl/tclCommands/TclCommandGetPath.py
Marius Stanciu eed7e3d620 - some minor changes in the Python version detection
- added a new Tcl Command named SetPath which will set a path to be used by the Tcl commands. Once set will serve as a fallback path in case that the files fail to be opened first time. It will be persistent, saved in preferences.
- added the GUI for the new Open Example in the FIle -> Scripting menu.
- I am modifying all the open ... handlers to add a parameter that will flag if the method was launched from Tcl Shell. This way if the method will fail to open the filename (which include the path) it will try to open from a set fallback path.
- fixed issue #406, bug introduced recently (leftover changes).
- modified the ImportSVG Tcl command name to OpenSVG (open_svg alias)
- added a new Tcl command named OpenDXF (open_dxf alias)
- fixed some errors in Scripting features
- added a new Tcl command named GetPath as a convenient way to get the current default path stored in App.defaults['global_tcl_path']
2020-04-28 14:37:34 +03:00

67 lines
1.9 KiB
Python

# ##########################################################
# FlatCAM: 2D Post-processing for Manufacturing #
# File Author: Marius Adrian Stanciu (c) #
# Date: 4/28/2020 #
# MIT Licence #
# ##########################################################
from tclCommands.TclCommand import TclCommand
import collections
import os
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
log = logging.getLogger('base')
class TclCommandGetPath(TclCommand):
"""
Tcl shell command to get the current default path set for Tcl.
example:
"""
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['get_path']
description = '%s %s' % ("--", "Get the default Tcl Shell folder path.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
])
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
option_types = collections.OrderedDict([
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
required = []
# structured help for current command, args needs to be ordered
help = {
'main': "Will get the folder path used as a fallback path for opening files.",
'args': collections.OrderedDict([
]),
'examples': ['get_path']
}
def execute(self, args, unnamed_args):
"""
:param args:
:param unnamed_args:
:return:
"""
self.app.shell.append_output("Current default Tcl Shell path is: ")
path = self.app.defaults["global_tcl_path"]
return path