⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appdirs.py

📁 wxPython的基本示例程序
💻 PY
字号:
#----------------------------------------------------------------------------# Name:         appdirs.py# Purpose:      Utilities for retrieving special application dirs## Author:       Kevin Ollivier, Jeff Norton## Created:      8/27/05# CVS-ID:       $Id: appdirs.py,v 1.4 2006/04/20 06:25:51 RD Exp $# Copyright:    (c) 2004-2005 ActiveGrid, Inc.# License:      wxWindows License#----------------------------------------------------------------------------from activegrid.util.lang import *import sysimport osimport stringimport activegrid.util.sysutils as sysutilsdef _getSystemDir(kind):    if (kind == AG_LOGS_DIR):        return os.path.join(getSystemDir(AG_SYSTEM_DIR) , "logs")    elif (kind == AG_DEMOS_DIR):        return os.path.join(getSystemDir(AG_SYSTEM_DIR), "demos")    else:        path = ""        if (sysutils.isServer()):            path = os.getenv("ACTIVEGRID_SERVER_HOME")            if ((path is None) or (len(path) < 1)):                path = sysutils.mainModuleDir        else:            path = os.getenv("AG_DOCUMENTS_DIR")            if ((path is None) or (len(path) < 1)):                if sysutils.isWindows():                    ifDefPy()                    try:                        from win32com.shell import shell, shellcon                        path = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, None, 0)                    except:                        pass                    endIfDef()                    if ((path is None) or (len(path) < 1)):                        homedrive = asString(os.getenv("HOMEDRIVE"))                        homepath = os.getenv("HOMEPATH")##                        if ((homedrive is not None) and (len(homedrive) > 0) and (homepath is not None) and (len(homepath) > 0)):                        path = os.path.join(homedrive, homepath, "MYDOCU~1")                else:                    ifDefPy()                    if sys.platform == "darwin":                        try:                            import macfs                            import MACFS                            fsspec_disk, fsspec_desktop = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kDocumentsFolderType, 0)                            path = macfs.FSSpec((fsspec_disk, fsspec_desktop, '')).as_pathname()                        except:                            pass                    endIfDef()                                ifDefPy()                if ((path is None) or (len(path) < 1)):                    path = os.path.expanduser("~")                endIfDef()                if ((path is None) or (len(path) < 1)):                    path = "/"                path = os.path.join(path, "ActiveGrid")                    return path        AG_SYSTEM_DIR = 0AG_LOGS_DIR = 1AG_DEMOS_DIR = 2__systemDir = None__logsDir = None__demosDir = Nonedef getSystemDir(kind=0):    if (kind == AG_SYSTEM_DIR):        global __systemDir        if (__systemDir is None):            __systemDir = _getSystemDir(kind)        return __systemDir    elif (kind == AG_LOGS_DIR):        global __logsDir        if (__logsDir is None):            __logsDir = _getSystemDir(kind)        return __logsDir    elif (kind == AG_DEMOS_DIR):        global __demosDir        if (__demosDir is None):            __demosDir = _getSystemDir(kind)        return __demosDir    return None# NOTE: We don't set this at startup because wxStandardPaths needs a running# application object. This makes sure the wxApp will always be created when# we get the folder.ifDefPy()def getAppDataFolder():    try:        # NOTE: cannot import wx from the server        import wx        # wxStandardPaths requires a running app        if wx.GetApp() and wx.Platform != "__WXGTK__":            data_folder = wx.StandardPaths.Get().GetUserDataDir()            if not os.path.exists(data_folder):                os.mkdir(data_folder)            return data_folder    except:        pass    # wxBug: on *nix, it wants to point to ~/.appname, but    # so does wxConfig... For now, redirect this to ~/.appbuilder    # when this is fixed, we'll migrate settings to the correct place    return os.path.join(os.path.expanduser("~"), ".appbuilder")endIfDef()ifDefPy()def createSystemDirs():    if (not os.path.exists(getSystemDir())):        os.mkdir(getSystemDir())    if (not os.path.exists(getSystemDir(AG_LOGS_DIR))):        os.mkdir(getSystemDir(AG_LOGS_DIR))    if (not os.path.exists(getSystemDir(AG_DEMOS_DIR))):        os.mkdir(getSystemDir(AG_DEMOS_DIR))endIfDef()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -