【问题标题】:Where is the .idlerc folder for Python IDLE on Mac?Mac 上 Python IDLE 的 .idlerc 文件夹在哪里?
【发布时间】:2016-02-03 01:31:39
【问题描述】:

我正在寻找 IDLE 的 .idlerc 文件夹。我的设置是 Python 2.7.9 + Mac OSX El Capitan。此文件夹包含“config-highlight.cfg”文件以应用新的自定义主题。

【问题讨论】:

    标签: macos python-2.7 themes customization python-idle


    【解决方案1】:

    .idlerc 应该在您的 HOME 目录中。目录中读写的代码在idlelib/configHandler.py中,在GetUserCfgDir'method'中。我在下面复制了它,删除了无用的self 参数,并添加了所需的导入。

    import os, sys
    
    def GetUserCfgDir():
        """Return a filesystem directory for storing user config files.
    
        Creates it if required.
        """
        cfgDir = '.idlerc'
        userDir = os.path.expanduser('~')
        if userDir != '~': # expanduser() found user home dir
            if not os.path.exists(userDir):
                warn = ('\n Warning: os.path.expanduser("~") points to\n ' +
                        userDir + ',\n but the path does not exist.')
                try:
                    print(warn, file=sys.stderr)
                except OSError:
                    pass
                userDir = '~'
        if userDir == "~": # still no path to home!
            # traditionally IDLE has defaulted to os.getcwd(), is this adequate?
            userDir = os.getcwd()
        userDir = os.path.join(userDir, cfgDir)
        if not os.path.exists(userDir):
            try:
                os.mkdir(userDir)
            except OSError:
                warn = ('\n Warning: unable to create user config directory\n' +
                        userDir + '\n Check path and permissions.\n Exiting!\n')
                print(warn, file=sys.stderr)
                raise SystemExit
        # TODO continue without userDIr instead of exit
        return userDir
    
    print(GetUserCfgDir())
    

    我会考虑将此信息添加到“首选项”对话框中。但我也注意到,可以通过在对话框中编辑现有主题来添加主题。对于 2.7.11、3.4.4 和 3.5.1,IDLE 有一个新的深色主题可供开始。为了使编辑更容易,我们计划添加一种简单的方法来更改所有使用它的项目的默认背景。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-26
      • 2014-08-29
      • 1970-01-01
      • 2014-08-28
      • 2014-08-21
      • 2022-10-23
      • 2013-03-08
      • 1970-01-01
      相关资源
      最近更新 更多