コード例 #1
0
ファイル: hylte.py プロジェクト: d98mp/digitalasagor
def main():
    """Load the inifile and start the player or the editor"""
    runhylte = True
    #Debug?
    fontsize = 12
    
    #Workaround for unicode in exefiles
    if hasattr(sys,"setdefaultencoding"):
        sys.setdefaultencoding("utf-8")
        print("setdefaultencoding")

    inidir = os.path.dirname(sys.argv[0])
    inifile = os.path.join(inidir, _ininame)
    
    if(os.path.exists(inifile)):
        parser = getConfigParser(inifile)
        #ConfigParser.ConfigParser()
        #parser.read(inifile)
        
        try:
            datadir = parser.get(ini.general, ini.datadir)
            width = parser.getint(ini.moviescreen, ini.width)
            height = parser.getint(ini.moviescreen, ini.height)
            playsize = (width, height)
            width = parser.getint(ini.preview, ini.width)
            height = parser.getint(ini.preview, ini.height)
            prevsize = (width, height)

        except NoOptionError as exc:
            print('Could not read ini file:', exc)
            return
        else:
            if(not os.path.isabs(datadir)):
                datadir = os.path.normpath(os.path.join(inidir, datadir))
    else:
        print('Inifile does not exist')
        return
            
            
    if(len(argv) > 1):
        runhylte = (argv[1].upper() != 'ADMIN')

    datamodel = DataModel(datadir, prevsize, playsize, True)

    try:
        wdir = tempfile.mkdtemp()
        root = Tk()

        if(runhylte):
            gui = PlayerGui(root, datamodel, parser)
        else:
            spmanager.load(os.path.normpath(os.path.join(inidir, _searchpathfilename)))
            gui = AdminGui(root, datamodel, wdir, parser)

        root.mainloop()
    
    finally:
        shutil.rmtree(wdir)
コード例 #2
0
ファイル: admin.py プロジェクト: d98mp/digitalaskyltar
        root = tki.Tk()
        self.root = root
        
        root.protocol("WM_DELETE_WINDOW", self._ehQuit)
        root.title(lang[lng.txtEditorTitle])
        root.rowconfigure(0, weight = 1)
        root.columnconfigure(0, weight = 1)

        nb = ttk.Notebook(root)
        self._nb = nb
        nb.grid(row = 0, column = 0, sticky = 'wnes')
        nt = selector.SelectorTab(nb)
        nb.add(nt, text = lang[lng.txtSelectFile])
        nb.select(0)
        

    def _ehQuit(self):
        """Terminate the application."""
        spmanager.save()
        self.root.destroy()
    
if __name__ == "__main__":
    #Workaround for unicode in exefiles
    if hasattr(sys,"setdefaultencoding"):
        sys.setdefaultencoding("utf-8")

    inidir = os.path.dirname(sys.argv[0])
    spmanager.load(os.path.normpath(os.path.join(inidir, _searchpathfilename)))
    ag = AdminGui()
    ag.root.mainloop()