我正在寻找IDLE的.idlerc文件夹。我的设置是Python 2.7.9 + Mac OSX El Capitan。此文件夹包含" config-highlight.cfg"文件以应用新的自定义主题。
答案 0 :(得分:0)
.idlerc
应位于您的HOME目录中。在目录中读取和写入的代码位于GetUserCfgDir“方法”中的idlelib / configHandler.py中。我在下面复制了它,删除了无用的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有一个新的黑暗主题开始。为了使编辑更容易,我们计划添加一种简单的方法来更改使用它的所有项目的默认背景。