Пример #1
0
def prepare_app():
    # first initialize the app to prevent errors in Windows,
    # which is checking some wx runtime variables beforehand.
    app = wx.App(False)

    ## initialise language settings:
    try:
        langIni = codecs.open(findfile("language.ini"), 'r', 'utf-8')
    except IOError:
        language = u'en'  #defaults to english
    else:
        language = langIni.read().strip()

    locales = {
        u'en': (wx.LANGUAGE_ENGLISH, u'en_US.UTF-8'),
        u'de': (wx.LANGUAGE_GERMAN, u'de_DE.UTF-8'),
    }
    mylocale = wx.Locale(locales[language][0], wx.LOCALE_LOAD_DEFAULT)
    langdir = findfile("locale")

    Lang = gettext.translation(u'lang',
                               langdir,
                               languages=[mylocale.GetCanonicalName()],
                               fallback=True)

    Lang.install(unicode=1)
    if platform.system() == 'Linux':
        try:
            # to get some language settings to display properly:
            os.environ['LANG'] = locales[language][1]

        except (ValueError, KeyError):
            pass

    # get version
    try:
        from ._version import version
    except:
        warnings.warn(_("Could not determine ShapeOut version."))
        version = None

    # get session file
    sessionfile = None
    for arg in sys.argv:
        if arg.endswith(".zmso"):
            print("\nLoading Session " + arg)
            sessionfile = arg
        else:
            print("Ignoring command line parameter: " + arg)

    app.frame = frontend.Frame(version, sessionfile=sessionfile)

    return app
Пример #2
0
def prepare_app():
    # first initialize the app to prevent errors in Windows,
    # which is checking some wx runtime variables beforehand.
    app = wx.App(False)
   
    ## initialise language settings:
    try:
        langIni = codecs.open(findfile("language.ini"), 'r', 'utf-8')
    except IOError:
        language = u'en' #defaults to english
    else:
        language = langIni.read().strip()

    locales = {
        u'en' : (wx.LANGUAGE_ENGLISH, u'en_US.UTF-8'),
        u'de' : (wx.LANGUAGE_GERMAN, u'de_DE.UTF-8'),
        }
    mylocale = wx.Locale(locales[language][0], wx.LOCALE_LOAD_DEFAULT)
    langdir = findfile("locale")
    
    
    Lang = gettext.translation(u'lang', langdir,
                 languages=[mylocale.GetCanonicalName()], fallback=True)
                 
    Lang.install(unicode=1)
    if platform.system() == 'Linux':
        try:
            # to get some language settings to display properly:
            os.environ['LANG'] = locales[language][1]

        except (ValueError, KeyError):
            pass

    # get version
    try:
        from ._version import version
    except:
        warnings.warn(_("Could not determine ShapeOut version."))
        version = None
    
    # get session file
    sessionfile = None
    for arg in sys.argv:
        if arg.endswith(".zmso"):
            print("\nLoading Session "+arg)
            sessionfile=arg
        else:
            print("Ignoring command line parameter: "+arg)

    app.frame = frontend.Frame(version, sessionfile = sessionfile)
    
    return app
Пример #3
0
    def SetWorkingDirectory(self, wd, name="Main"):
        if os.path.exists(wd):
            self.working_directory = wd
            cfgso = self.cfgfile
            path=findfile(cfgso)
            if path == "":
                warnings.warn("Could not find configuration file {}.".
                              format(cfgso))
            fop = codecs.open(path, 'r', "utf-8")
            fc = fop.readlines()
            fop.close()
            wdirin = False
            for i in range(len(fc)):
                if fc[i].startswith("Working Directory "+name):
                    fc[i] = u"Working Directory {} = {}".format(name, wd)
                    wdirin = True
            if not wdirin:
                fc.append(u"Working Directory {} = {}".format(name, wd))
            fop = codecs.open(path, 'w', "utf-8")
            
            for i in range(len(fc)):
                fc[i] = fc[i].strip()+"\n"

            fop.writelines(fc)
            fop.close()
Пример #4
0
def autogit_add(filter_func):
    for filepath in util.findfile(
        filter_func = lambda path : (
            ".git" not in path and
            ".bak" not in path
            )
        ):
        print(filepath)
Пример #5
0
def splash_show():
    app = wx.App(False)
    # Show the splash screen as early as possible
    img = wx.Image(findfile('logo.png'))
    img.ConvertAlphaToMask()
    bitmap = wx.BitmapFromImage(img)
    frame = wx.Frame(None, -1, "AdvancedSplash Test")
    AS.AdvancedSplash(frame, bitmap=bitmap, 
                agwStyle=AS.AS_NOTIMEOUT|AS.AS_CENTER_ON_SCREEN)
    app.MainLoop()
Пример #6
0
def splash_show():
    app = wx.App(False)
    # Show the splash screen as early as possible
    img = wx.Image(findfile('logo.png'))
    img.ConvertAlphaToMask()
    bitmap = wx.BitmapFromImage(img)
    frame = wx.Frame(None, -1, "AdvancedSplash Test")
    AS.AdvancedSplash(frame,
                      bitmap=bitmap,
                      agwStyle=AS.AS_NOTIMEOUT | AS.AS_CENTER_ON_SCREEN)
    app.MainLoop()
Пример #7
0
def splash_show():
    # bypass "iCCP: known incorrect sRGB profile":
    wx.Log.SetLogLevel(0)
    # setup splash app
    app = wx.App(False)
    # Show the splash screen as early as possible
    img = wx.Image(findfile('zm_logo_small.png'))
    # alpha mask is only binary - don't use it, looks ugly.
    #img.ConvertAlphaToMask()
    bitmap = wx.BitmapFromImage(img)
    frame = wx.Frame(None, -1, "AdvancedSplash Test")
    AS.AdvancedSplash(frame, bitmap=bitmap, 
                agwStyle=AS.AS_NOTIMEOUT|AS.AS_CENTER_ON_SCREEN)
    app.MainLoop()
Пример #8
0
def splash_show():
    # bypass "iCCP: known incorrect sRGB profile":
    wx.Log.SetLogLevel(0)
    # setup splash app
    app = wx.App(False)
    # Show the splash screen as early as possible
    img = wx.Image(findfile('zm_logo_small.png'))
    # alpha mask is only binary - don't use it, looks ugly.
    #img.ConvertAlphaToMask()
    bitmap = wx.BitmapFromImage(img)
    frame = wx.Frame(None, -1, "AdvancedSplash Test")
    AS.AdvancedSplash(frame,
                      bitmap=bitmap,
                      agwStyle=AS.AS_NOTIMEOUT | AS.AS_CENTER_ON_SCREEN)
    app.MainLoop()
Пример #9
0
 def GetWorkingDirectory(self, name="Main"):
     """ Returns the current working directory """
     wd = default = "./"
     cfgso = self.cfgfile
     path=findfile(cfgso)
     if path == "":
         wd = default
     else:
         fop = codecs.open(path, 'r', "utf-8")
         fc = fop.readlines()
         fop.close()
         for line in fc:
             if line.startswith(("Working Directory "+name).strip()):
                 wd = line.partition("=")[2].strip()
                 if not os.path.exists(wd):
                     wd = default
     self.working_directory = wd
     return wd
Пример #10
0
    def __init__(self):
        # get default path of configuration
        shcfg = "shapeout.cfg"
        fname = findfile(shcfg)
        if not os.path.exists(fname):
            # Create the file
            if hasattr(sys, 'frozen'):
                d = os.path.realpath(os.path.join(sys._MEIPASS,  # @UndefinedVariable
                                                       "shapeout-data"))
                self.cfgfile = os.path.join(d, shcfg)
            else:
                self.cfgfile = os.path.join(os.path.dirname(__file__),
                                                                  shcfg)
            fop = codecs.open(self.cfgfile, 'wb', "utf-8")
            fop.writelines(DefaultConfig)
            fop.close()
        else:
            self.cfgfile = fname

        self.working_directories = {}
        self.GetWorkingDirectory()
Пример #11
0
        arv.append(sys.argv[i])
#  m.findfiler(path) :return all files in path
#  m.findfile(parh):  return files in path
#  m.findtype(files,type='.txt'):    return type file in files
#
# --------------------------
# mypath=os.getcwd()
# the jobs list
s = []
if len(arv) > 0:
    if '-r' in opt:
        for i in arv:
            s += m.findfiler(i)
    else:
        for i in arv:
            s += m.findfile(i)
else:
    if '-r' in opt:
        s = m.findfiler('.')
    else:
        s = m.findfile('.')
list.sort(s)
if "-help" in opt or "--help" in opt:
    print _USAGE
    exit(0)
if len(opt) == 0:
    jobcol = m.findtype(s, '.txt')
    hep.Sub(jobcol)
if '-txt' in opt:
    jobcol = m.findtype(s, '.txt')
    hep.Sub(jobcol)
Пример #12
0
def autogit_add(filter_func):
    for filepath in util.findfile(filter_func=lambda path:
                                  (".git" not in path and ".bak" not in path)):
        print(filepath)
Пример #13
0
            rx = orderlist.index(x)
        else:
            rx = len(orderlist) + 1
        if y in orderlist:
            ry = orderlist.index(y)
        else:
            ry = len(orderlist) + 1
        if rx == ry:
            if x<y:
                ry += 1
            else:
                rx += 1
        return rx-ry

    return sorted(cfgkeys, cmp=compare)




## Overwrite the tlab configuration with our own.
cfg_file = findfile("dclab.cfg")
cfg = dfn.LoadConfiguration(cfg_file, dfn.cfg)
cfg_ordered_list = GetConfigurationKeys(cfg_file)

thispath = os.path.dirname(os.path.realpath(__file__))
isoeldir = findfile("isoelastics")
isoelastics = LoadIsoelastics(os.path.join(thispath, isoeldir))

# Axes that should not be displayed  by Shape Out
IGNORE_AXES = ["AreaPix", "Frame"]