Exemple #1
0
    def optionsCallback(self, selection, text):
        self.overlay = None

        if (text == "add"):
            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Add new emulator",{"textColor":(55,55,55), "backgroundColor":(221,221,221), "useSidebar":True}, \
                                        self.getEmptyData() ,self.configOptions ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)
            self.subComponent.setConfigCallback(self.configCallback)
        if (text == "edit"):
            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Edit emulator",{"textColor":(55,55,55), "backgroundColor":(221,221,221)}, \
                                        self.currentSelection ,self.configOptions ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)
            self.subComponent.setConfigCallback(self.configCallback)
        if (text == "remove"):
            self.overlay = ConfirmOverlay.ConfirmOverlay(
                "really delete?", [("theme/b_button.png", "back"),
                                   ("theme/a_button.png", "delete")],
                self.deleteCallback)
            RenderControl.setDirty()
Exemple #2
0
    def optionsCallback(self, selection, text):
        self.overlay = None

        if (not Configuration.isRS97()):
            self.configOptions = self.configOptions + json.load(
                open('config/legacy.json'))

        if (selection == 0):
            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Add new link",{"textColor":(55,55,55), "backgroundColor":(221,221,221), "useSidebar":True}, \
                                        self.getEmptyData() ,self.configOptions ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)
            self.subComponent.setConfigCallback(self.configCallback)
        if (selection == 1):
            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Edit link",{"textColor":(55,55,55), "backgroundColor":(221,221,221)}, \
                                        self.currentSelection ,self.configOptions ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)
            self.subComponent.setConfigCallback(self.configCallback)
        if (selection == 2):
            self.overlay = ConfirmOverlay.ConfirmOverlay(
                "really delete?", (255, 255, 255),
                [("theme/b_button.png", "back"),
                 ("theme/a_button.png", "delete")], self.deleteCallback)
            RenderControl.setDirty()
Exemple #3
0
    def optionsCallback(self, selection, text):
        self.overlay = None

        opt = Theme.getConfigOptions()

        if (text == "add"):
            opt["useSidebar"] = True
            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Add new link",opt, \
                                        self.getEmptyData() ,self.configOptions ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   opt["footerFontColor"], opt["footerColor"])
            self.subComponent.setFooter(footer)
            self.subComponent.setConfigCallback(self.configCallback)
        if (text == "edit"):
            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Edit link",opt, \
                                        self.currentSelection ,self.configOptions ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   opt["footerFontColor"], opt["footerColor"])
            self.subComponent.setFooter(footer)
            self.subComponent.setConfigCallback(self.configCallback)
        if (text == "remove"):
            self.overlay = ConfirmOverlay.ConfirmOverlay(
                "really delete?", [("theme/b_button.png", "back"),
                                   ("theme/a_button.png", "delete")],
                self.deleteCallback)
            RenderControl.setDirty()
def train_all_model():
    Holistic.train_holistic_model()
    Header.train_header_model()
    Footer.train_footer_model()
    LeftBody.train_leftbody_model()
    RightBody.train_rightbody_model()
    train_meta_model()
Exemple #5
0
    def openSelection(self, current):
        print("Opening selection")
        ResumeHandler.setLastUsedMain(current, self.currentIndex)

        if (current["type"] == "emulator"):
            print("Opening emulator file selection")
            options = {}
            options["textColor"] = (55, 55, 55)
            options["background"] = current["background"]
            options["useSidebar"] = True

            if ("description" in current):
                options["description"] = current["description"]

            if ("folderIcon" in current):
                options["folderIcon"] = current["folderIcon"]

            if ("previews" in current):
                options["previews"] = current["previews"]

            if ("fileFilter" in current):
                options["fileFilter"] = current["fileFilter"]

            self.subComponent = FileChooser.FileChooser(
                self.screen, current["name"], current["selectionPath"], False,
                options, self.emulatorCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "select")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)

        if (current["type"] == "native"):
            print("Opening native selection")
            options = {}
            options["background"] = current["background"]
            options["useSidebar"] = True
            self.subComponent = NativeAppList.NativeAppList(
                self.screen, current["name"], current["data"], options,
                self.nativeCallback)
            if ("allowEdit" in self.config["options"]
                    and self.config["options"]["allowEdit"]):
                footer = Footer.Footer(
                    [("theme/direction.png", "select")],
                    [("theme/b_button.png", "back"),
                     ("theme/a_button.png", "select"),
                     ("theme/select_button.png", "options")], (255, 255, 255))
            else:
                footer = Footer.Footer([("theme/direction.png", "select")],
                                       [("theme/b_button.png", "back"),
                                        ("theme/a_button.png", "select")],
                                       (255, 255, 255))
            self.subComponent.setFooter(footer)
Exemple #6
0
    def installIPK(self):

        print("Opening ipk file selection")
        options = {}
        options["textColor"] = (55, 55, 55)

        options["useSidebar"] = False
        options["useGamelist"] = False
        options["fileFilter"] = [".ipk", ".IPK"]
        options["useFileFilter"] = True
        options["limitSelection"] = False
        options["hideFolders"] = False
        options["selectionPath"] = "/home/retrofw"

        self.subComponent = FileChooser.FileChooser(self.screen,
                                                    "IPK Selection",
                                                    "/home/retrofw", False,
                                                    options,
                                                    self.installIPKCallback)
        footer = Footer.Footer([("theme/direction.png", "select")],
                               [("theme/b_button.png", "back"),
                                ("theme/a_button.png", "select")],
                               (255, 255, 255))
        self.subComponent.setFooter(footer)
        RenderControl.setDirty()
Exemple #7
0
    def optionsCallback(self, optionID, text):
        print("Options came back with: ", optionID)
        self.overlay = None
        if (optionID == 0):
            self.overlay = SelectionMenu.SelectionMenu(self.screen,
                                                       ["Emulator", "Native"],
                                                       self.typeAddCallback)
        if (optionID == 1):
            conf = None
            if (self.config["mainMenu"][self.currentIndex]["type"] ==
                    "emulator"):
                conf = json.load(open('config/entry.json'))
                if (not Configuration.isRS97()):
                    conf = conf + json.load(open('config/pap.json'))
            else:
                conf = json.load(open('config/native.json'))

            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Edit menu entry",{"textColor":(55,55,55), "backgroundColor":(221,221,221)}, \
                                        self.config["mainMenu"][self.currentIndex] ,conf ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)
        if (optionID == 2):
            self.overlay = ConfirmOverlay.ConfirmOverlay(
                "really delete?", (255, 255, 255),
                [("theme/b_button.png", "back"),
                 ("theme/a_button.png", "delete")], self.deleteCallback)
            RenderControl.setDirty()
Exemple #8
0
    def openSelection(self):
        options = Theme.getSelectionOptions()
        options["textColor"] = (55, 55, 55)
        options["background"] = self.options["background"]
        options["useSidebar"] = False

        if ("selectDescription"
                in self.entryList[self.currentIndex]["options"]):
            options["description"] = self.entryList[
                self.currentIndex]["options"]["selectDescription"]

        if ("folderIcon" in self.options):
            options["folderIcon"] = self.options["folderIcon"]

        if ("fileFilter" in self.entryList[self.currentIndex]["options"]):
            options["fileFilter"] = self.entryList[
                self.currentIndex]["options"]["fileFilter"]

        if ("selectionPath" in self.entryList[self.currentIndex]["options"]):
            selectionPath = self.entryList[
                self.currentIndex]["options"]["selectionPath"]
        else:
            selectionPath = "/"

        self.subComponent = FileChooser.FileChooser(
            self.screen, self.entryList[self.currentIndex]["options"]["name"],
            selectionPath, False, options, self.selectionCallback)
        footer = Footer.Footer([("theme/direction.png", "select")],
                               [("theme/b_button.png", "back"),
                                ("theme/a_button.png", "select")],
                               (255, 255, 255))
        self.subComponent.setFooter(footer)
Exemple #9
0
    def __init__(self, screen, titel, options):
        self.screen = screen           
       
        self.title = titel
        self.options = options
        self.setFooter(Footer.Footer([],[],(255,255,255)))

            

        if("textColor" in self.options):
            self.textColor = options["textColor"]
        else:
            self.textColor = (0,0,0)
        
        if("backgroundColor" in self.options):
            self.backgroundColor = options["backgroundColor"]
        else:
            self.backgroundColor = (221,221,221, 160)
               
        self.toggleSidebar("useSidebar" in options and options["useSidebar"])


        self.initSelection()

        TaskHandler.addAnimation(self.config["screenHeight"] - self.footer.getHeight(), self.config["screenHeight"], 600, self.updateFooterPos, 2500) 
Exemple #10
0
    def openSettings(self):
        options = json.load(open('config/options.json'))
        theme = None
        for opt in options:
            if opt["id"] == "themeName":
                theme = opt

        if (theme != None):
            theme["values"] = []
            theme["names"] = []

            itemlist = os.listdir("theme/themes")
            for item in itemlist:
                if (item.endswith(".json")):
                    theme["values"].append(item.replace(".json", ""))
                    theme["names"].append(item.replace(".json", ""))


        self.subComponent = ConfigMenu.ConfigMenu(self.screen, "General Settings (PyMenu v" + str(self.config["version"]) + ")",{"textColor":(255,255,255), "backgroundColor":(0,0,0)}, \
                                        Configuration.getPathData("options"), options ,self.configCallback)
        footer = Footer.Footer([("theme/direction.png", "select")],
                               [("theme/b_button.png", "back"),
                                ("theme/a_button.png", "change"),
                                ("theme/start_button.png", "save")],
                               (255, 255, 255))
        self.subComponent.setFooter(footer)
        RenderControl.setDirty()
Exemple #11
0
 def __init__(self, screen, initialText, callback):
     self.screen = screen
     self.initialText = initialText
     self.currentText = str(initialText)
     self.callback = callback
     self.initBackground()
     self.setFooter(Footer.Footer([],[],(255,255,255)))
     TaskHandler.addAnimation(self.config["screenHeight"] - self.footer.getHeight(), self.config["screenHeight"], 600, self.updateFooterPos, 1000) 
Exemple #12
0
 def openSettings(self):
     self.subComponent = ConfigMenu.ConfigMenu(self.screen, "General Settings",{"textColor":(255,255,255), "backgroundColor":(0,0,0)}, \
                                     Configuration.getPathData("options"), json.load(open('config/options.json')) ,self.configCallback)
     footer = Footer.Footer([("theme/direction.png", "select")],
                            [("theme/b_button.png", "back"),
                             ("theme/a_button.png", "change"),
                             ("theme/start_button.png", "save")],
                            (255, 255, 255))
     self.subComponent.setFooter(footer)
     RenderControl.setDirty()
Exemple #13
0
    def onSelect(self):        
        if(self.entryList[self.currentIndex]["type"] == "string"):
            self.subComponent = TextInput.TextInput(self.screen, self.entryList[self.currentIndex]["value"], self.textCallback)
            footer = Footer.Footer([("theme/direction.png","select")], [("theme/b_button.png", "back"), ("theme/a_button.png", "add"), ("theme/start_button.png", "save")], (255,255,255)) 
            self.subComponent.setFooter(footer)          
        if(self.entryList[self.currentIndex]["type"] == "boolean"):
           self.overlay = SelectionMenu.SelectionMenu(self.screen, ["True", "False"], self.booleanCallback)
        if(self.entryList[self.currentIndex]["type"] == "folder"):
            options = {}   
            options["preview"] = False        
            self.subComponent = FileChooser.FileChooser(self.screen, self.entryList[self.currentIndex]["name"] ,self.entryList[self.currentIndex]["value"], True, options, self.fileFolderCallback)
            footer = Footer.Footer([("theme/direction.png","select")], [("theme/b_button.png", "back"), ("theme/a_button.png", "enter"), ("theme/start_button.png", "save")], (255,255,255)) 
            self.subComponent.setFooter(footer)       
        if(self.entryList[self.currentIndex]["type"] == "file"):
            options = {}   
            options["preview"] = False  

            if("filter" in self.entryList[self.currentIndex]["options"]):
                options["fileFilter"] = self.entryList[self.currentIndex]["options"]["filter"]

            self.subComponent = FileChooser.FileChooser(self.screen, self.entryList[self.currentIndex]["name"] ,self.entryList[self.currentIndex]["value"], False, options, self.fileFolderCallback)
            footer = Footer.Footer([("theme/direction.png","select")], [("theme/b_button.png", "back"), ("theme/a_button.png", "select")], (255,255,255)) 
            self.subComponent.setFooter(footer) 
        if(self.entryList[self.currentIndex]["type"] == "image"):
            options = {}   
            options["preview"] = True
            options["useSidebar"] = True
            options["directPreview"] = True 
            options["fileFilter"] = [".png", ".jpg"] 
            options["textColor"] = self.textColor
            options["backgroundColor"] = self.backgroundColor
            self.subComponent = FileChooser.FileChooser(self.screen, self.entryList[self.currentIndex]["name"] ,self.entryList[self.currentIndex]["value"], False, options, self.fileFolderCallback)
            footer = Footer.Footer([("theme/direction.png","select")], [("theme/b_button.png", "back"), ("theme/a_button.png", "select")], (255,255,255)) 
            self.subComponent.setFooter(footer)
        if(self.entryList[self.currentIndex]["type"] == "list"):   
            if("names" in self.entryList[self.currentIndex]["options"]):
                self.overlay = SelectionMenu.SelectionMenu(self.screen, self.entryList[self.currentIndex]["options"]["names"], self.listCallback)
            else:
                self.overlay = SelectionMenu.SelectionMenu(self.screen, self.entryList[self.currentIndex]["options"]["values"], self.listCallback)
Exemple #14
0
    def contextMenuCallback(self, selection, text):
        self.overlay = None

        if (text == "Mount USB"):
            print("Mounting USB")
            Common.mountUSB()
            self.suspend.disableSuspend()
            self.overlay = InfoOverlay.InfoOverlay("theme/usb.png",
                                                   self.usbMountCallback)

        if (text == "Poweroff"):
            if (platform.processor() == ""):
                subprocess.Popen(["sync"])
                subprocess.Popen(["poweroff"])
            else:
                print("Poweroff")

        if (text == "Reboot"):
            if (platform.processor() == ""):
                subprocess.Popen(["sync"])
                subprocess.Popen(["reboot"])
            else:
                print("reboot")

        if (text == "Run Gmenu2x"):
            print("Running gmenu 2x")
            if (Configuration.isOpenDinguX()):
                try:
                    fileName = "run"
                    file = open("/tmp/" + fileName, "w")
                    file.write("#!/bin/sh\n")
                    file.write("exec /usr/bin/gmenu2x")
                    file.close()
                    sys.exit()

                except Exception as ex:
                    print("mount exception " + str(ex))
            else:
                Common.gmenu2x()

        if (text == "Start Network"):
            Common.startNetwork()

        if (text == "IPK Manager"):
            self.subComponent = IPKManager.IPKManager(self.screen,
                                                      self.ipkCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/select_button.png", "options")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)
Exemple #15
0
    def __init__(self, screen, titel, options):
        self.screen = screen

        self.title = titel
        self.options = options
        self.setFooter(Footer.Footer([], [], (255, 255, 255)))

        if ("textColor" in self.options):
            self.textColor = options["textColor"]
        else:
            self.textColor = (0, 0, 0)

        if ("backgroundColor" in self.options):
            self.backgroundColor = options["backgroundColor"]
        else:
            self.backgroundColor = (221, 221, 221, 160)

        if ("sideColor" not in self.options):
            self.options["sideColor"] = (57, 58, 59, 255)

        if ("headerColor" not in self.options):
            self.options["headerColor"] = (57, 58, 59, 255)

        if ("headerFontColor" not in self.options):
            self.options["headerFontColor"] = (255, 255, 255)

        if ("selectionColor" not in self.options):
            self.options["selectionColor"] = (55, 55, 55, 120)

        if ("descriptionFontColor" not in self.options):
            self.options["descriptionFontColor"] = (255, 255, 255)

        if ("scrollbarColor" not in self.options):
            self.options["scrollbarColor"] = (0, 105, 105)

        self.toggleSidebar("useSidebar" in options and options["useSidebar"])

        self.initSelection()

        TaskHandler.addAnimation(
            self.config["screenHeight"] - self.footer.getHeight(),
            self.config["screenHeight"], 600, self.updateFooterPos, 2500)
Exemple #16
0
    def openSettings(self):
        options = json.load(open('config/options.json'))
        theme = None
        for opt in options:
            if opt["id"] == "themeName":
                theme = opt

        #append dynamic theme selection
        if (theme != None):
            theme["values"] = []
            theme["names"] = []

            itemlist = os.listdir("theme/themes")
            for item in itemlist:
                if (item.endswith(".json")):
                    theme["values"].append(item.replace(".json", ""))
                    theme["names"].append(item.replace(".json", ""))

        #filter options to show only the relevant ones
        if (Configuration.isOpenDinguX()):
            options = Common.removeOptionsEntries(options, [
                "displayTimeout", "suspendTimeout", "volumeControl",
                "defaultVolume"
            ])

        if (self.config["type"] != "K3P"):
            options = Common.removeOptionsEntries(options, ["volumeControl"])

        opt = Theme.getConfigOptions()


        self.subComponent = ConfigMenu.ConfigMenu(self.screen, "General Settings (PyMenu v" + str(self.config["version"]) + ")", opt , \
                                        Configuration.getPathData("options"), options ,self.configCallback)

        footer = Footer.Footer([("theme/direction.png", "select")],
                               [("theme/b_button.png", "back"),
                                ("theme/a_button.png", "change"),
                                ("theme/start_button.png", "save")],
                               opt["footerFontColor"], opt["footerColor"])
        self.subComponent.setFooter(footer)
        RenderControl.setDirty()
Exemple #17
0
    def optionsCallback(self, optionID, text):
        print("Options came back with: ", optionID)
        self.overlay = None
        if (optionID == 0):
            self.overlay = SelectionMenu.SelectionMenu(self.screen,
                                                       ["Emulator", "Native"],
                                                       self.typeAddCallback)
        if (optionID == 1):
            conf = None
            if (self.config["mainMenu"][self.currentIndex]["type"] ==
                    "emulator"):
                conf = json.load(open('config/entry.json'))
            elif (self.config["mainMenu"][self.currentIndex]["type"] ==
                  "lastPlayed"):
                conf = json.load(open('config/optionsLastPlayed.json'))
            else:
                conf = json.load(open('config/native.json'))

            #rg350 does not support individual overclocking, remove option
            if (Configuration.isOpenDinguX()):
                for opt in conf:
                    if (opt["id"] == "overclock"):
                        conf.remove(opt)
                        break

            opt = Theme.getConfigOptions()

            self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Edit menu entry",opt, \
                                        self.config["mainMenu"][self.currentIndex] ,conf ,self.addEditCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   opt["footerFontColor"], opt["footerColor"])
            self.subComponent.setFooter(footer)
        if (optionID == 2):
            self.overlay = ConfirmOverlay.ConfirmOverlay(
                "really delete?", [("theme/b_button.png", "back"),
                                   ("theme/a_button.png", "delete")],
                self.deleteCallback)
            RenderControl.setDirty()
Exemple #18
0
    def typeAddCallback(self, t, text):
        self.overlay = None

        data = None
        conf = None
        if (t == 0):
            data = self.getEmptyEmulatorData()
            conf = json.load(open('config/entry.json'))

        else:
            data = self.getEmptyNativeData()
            conf = json.load(open('config/native.json'))

        self.subComponent = ConfigMenu.ConfigMenu(self.screen, "Add new menu entry",{"textColor":(255,255,255), "backgroundColor":(0,0,0)}, \
                                   data ,conf ,self.addEditCallback)
        footer = Footer.Footer([("theme/direction.png", "select")],
                               [("theme/b_button.png", "back"),
                                ("theme/a_button.png", "change"),
                                ("theme/start_button.png", "save")],
                               (255, 255, 255))
        self.subComponent.setFooter(footer)
Exemple #19
0
    def openSelection(self, current):
        print("Opening selection")
        ResumeHandler.setLastUsedMain(current, self.currentIndex)

        options = Theme.getSelectionOptions()

        if (current["type"] == "emulator"):

            if ("useSelection" in current
                    and current["useSelection"] == False):
                print("Running emulator directly")
                self.emulatorCallback("", Keys.DINGOO_BUTTON_A, False)
                return

            print("Opening emulator file selection")

            options["entry"] = self.config["mainMenu"][self.currentIndex]
            options["background"] = current["background"]
            options["useSidebar"] = True
            options["useGamelist"] = current[
                "useGamelist"] if "useGamelist" in current else False

            options["backgroundColor"] = Theme.getColor(
                "selection/backgroundColor", (255, 255, 255, 160))

            if ("description" in current):
                options["description"] = current["description"]

            if ("folderIcon" in current):
                options["folderIcon"] = current["folderIcon"]

            if ("previews" in current):
                options["previews"] = current["previews"]

            if ("fileFilter" in current):
                options["fileFilter"] = current["fileFilter"]

            if ("useFileFilter" in current):
                options["useFileFilter"] = current["useFileFilter"]

            if ("limitSelection" in current):
                options["limitSelection"] = current["limitSelection"]

            if ("hideFolders" in current):
                options["hideFolders"] = current["hideFolders"]

            options["selectionPath"] = current["selectionPath"]

            self.subComponent = FileChooser.FileChooser(
                self.screen, current["name"], current["selectionPath"], False,
                options, self.emulatorCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/start_button.png", "Open with"),
                                    ("theme/a_button.png", "select")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)

        if (current["type"] == "native"):
            print("Opening native selection")

            options["background"] = current["background"]
            options["useSidebar"] = True

            if ("linkPath" in current):
                options["linkPath"] = current["linkPath"]

            self.subComponent = NativeAppList.NativeAppList(
                self.screen, current["name"], current["data"], options,
                self.nativeCallback)
            if ("allowEdit" in self.config["options"]
                    and self.config["options"]["allowEdit"]):
                footer = Footer.Footer(
                    [("theme/direction.png", "select")],
                    [("theme/b_button.png", "back"),
                     ("theme/a_button.png", "select"),
                     ("theme/select_button.png", "options")],
                    options["footerFontColor"], options["footerColor"])
            else:
                footer = Footer.Footer([("theme/direction.png", "select")],
                                       [("theme/b_button.png", "back"),
                                        ("theme/a_button.png", "select")],
                                       options["footerFontColor"],
                                       options["footerFontColor"])
            self.subComponent.setFooter(footer)

        if (current["type"] == "lastPlayed"
                or current["type"] == "favourites"):
            print("Opening customList selection")

            options["background"] = current["background"]
            options["useSidebar"] = True
            options["type"] = current["type"]

            options["backgroundColor"] = Theme.getColor(
                "selection/backgroundColor", (255, 255, 255, 160))

            self.subComponent = NativeAppList.NativeAppList(
                self.screen, current["name"], current["data"], options,
                self.customListCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "select")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)
Exemple #20
0
import Problem
import Header
import Footer
import os
from random import shuffle
import subprocess




foot = Footer.Footer()

files = os.listdir("p")
shuffle(files)
student_list = ['Chantel', 'Angel', 'Jaxon', 'Waylon', 'Lindsay',
				'Elli', 'Christian', 'Madison', 'Jake', 'Cooper']
for student in student_list:
	head = Header.Header(student)
	tex_file = student + 'out.tex'
	f = open(tex_file, 'w')
	f.write(str(head))
	i = 0
	for file in files:
		l = []
		fi = open("p/" + file, 'r')
		# read in the random variables and create them

		# then read in the string and create it
		prob = Problem.Problem(i, fi.readlines(), [])
		# then create a problem object and print/write it
		f.write(str(prob))
Exemple #21
0
    def onSelect(self):
        if (self.entryList[self.currentIndex]["type"] == "string"):
            self.subComponent = TextInput.TextInput(
                self.screen, self.entryList[self.currentIndex]["value"],
                self.textCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "add"),
                                    ("theme/start_button.png", "save")],
                                   Theme.getColor("settings/footer/fontColor",
                                                  (255, 255, 255)),
                                   Theme.getColor("settings/footer/color",
                                                  (57, 58, 59)))
            self.subComponent.setFooter(footer)
        if (self.entryList[self.currentIndex]["type"] == "boolean"):
            self.overlay = SelectionMenu.SelectionMenu(self.screen,
                                                       ["True", "False"],
                                                       self.booleanCallback)
        if (self.entryList[self.currentIndex]["type"] == "folder"):
            options = Theme.getConfigOptions()
            options["preview"] = False
            self.subComponent = FileChooser.FileChooser(
                self.screen, self.entryList[self.currentIndex]["name"],
                self.entryList[self.currentIndex]["value"], True, options,
                self.fileFolderCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "enter"),
                                    ("theme/start_button.png", "save")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)
        if (self.entryList[self.currentIndex]["type"] == "file"):
            options = Theme.getConfigOptions()
            options["preview"] = False

            if ("filter" in self.entryList[self.currentIndex]["options"]):
                options["fileFilter"] = self.entryList[
                    self.currentIndex]["options"]["filter"]

            self.subComponent = FileChooser.FileChooser(
                self.screen, self.entryList[self.currentIndex]["name"],
                self.entryList[self.currentIndex]["value"], False, options,
                self.fileFolderCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "select")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)
        if (self.entryList[self.currentIndex]["type"] == "image"):
            options = Theme.getConfigOptions()
            options["preview"] = True
            options["useSidebar"] = True
            options["directPreview"] = True
            options["fileFilter"] = [".png", ".jpg"]

            self.subComponent = FileChooser.FileChooser(
                self.screen, self.entryList[self.currentIndex]["name"],
                self.entryList[self.currentIndex]["value"], False, options,
                self.fileFolderCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "select")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)
        if (self.entryList[self.currentIndex]["type"] == "list"):
            if ("names" in self.entryList[self.currentIndex]["options"]):
                self.overlay = SelectionMenu.SelectionMenu(
                    self.screen,
                    self.entryList[self.currentIndex]["options"]["names"],
                    self.listCallback)
            else:
                self.overlay = SelectionMenu.SelectionMenu(
                    self.screen,
                    self.entryList[self.currentIndex]["options"]["values"],
                    self.listCallback)
        if (self.entryList[self.currentIndex]["type"] == "emu"):
            options = Theme.getConfigOptions()
            options["useSidebar"] = False

            data = copy.deepcopy(self.entryList[self.currentIndex]["value"])
            ##inject default if non found
            if (data == None or len(data) == 0):
                data = []
                default = {}
                default["cmd"] = self.optionTarget[
                    "cmd"] if "cmd" in self.optionTarget else "."
                default["workingDir"] = self.optionTarget[
                    "workingDir"] if "workingDir" in self.optionTarget else "."
                default["name"] = "default"
                data.append(default)

            self.subComponent = EmulatorList.EmulatorList(
                self.screen, "Emulators", data, options, self.emuListCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/select_button.png", "options"),
                                    ("theme/start_button.png", "save")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)

        if (self.entryList[self.currentIndex]["type"] == "selection"):
            options = Theme.getConfigOptions()
            options["useSidebar"] = False
            options["names"] = self.entryList[
                self.currentIndex]["options"]["names"]
            options["options"] = self.entryList[
                self.currentIndex]["options"]["options"]

            data = copy.deepcopy(self.entryList[self.currentIndex]["value"])
            ##inject default if non found
            if (data == None):
                data = []

            print(self.entryList[self.currentIndex]["options"])

            self.subComponent = SelectionList.SelectionList(
                self.screen, "Select", data, options,
                self.selectionListCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "change"),
                                    ("theme/start_button.png", "save")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)
def train_meta_model():
    # # 解决:Function call stack:
    # # distributed_function
    # gpu = tf.config.experimental.list_physical_devices(device_type='GPU')
    # tf.config.experimental.set_memory_growth(gpu[0], True)

    # 训练设置
    TRAIN_NUM = 320000  # 训练集数量
    VAL_NUM = 40000  # 验证集数量
    TEST_NUM = 40000  # 测试集数量
    BATCH_SIZE = get_datasets.BATCH_SIZE  # 批处理大小
    EPOCH_SIZE = 10  # 时期数
    LOG_FILE_PATH = './train_info.txt'  # 训练记录文件

    # 优化器设置
    LEARNING_RATE = 0.001
    DECAY_STEPS = TRAIN_NUM // BATCH_SIZE
    DECAY_RATE = 0.96

    print(
        '===============================================  数据集准备  ==============================================='
    )
    TRAIN_META_DATA_PATH = r'.\datasets\all\rvl_cdip_train.tfrecords'
    TEST_META_DATA_PATH = r'.\datasets\all\rvl_cdip_test.tfrecords'
    VAL_META_DATA_PATH = r'.\datasets\all\rvl_cdip_val.tfrecords'

    train_data = get_datasets.get_dataset_by_tfrecords(TRAIN_META_DATA_PATH)
    val_data = get_datasets.get_dataset_by_tfrecords(VAL_META_DATA_PATH)
    test_data = get_datasets.get_dataset_by_tfrecords(TEST_META_DATA_PATH)

    print(
        '===============================================  加载模型  ================================================='
    )
    log_file = open(LOG_FILE_PATH, 'a', encoding='utf-8')
    info = '========================================================================================================\n'\
           + str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) + '\n'
    log_file.write(info)

    holistic = Holistic.holistic(sub_holistic.sub_holistic())
    checkpoint_path = r"./model/Holistic-model/Holistic.ckpt"
    my_tools.save_and_load_models(checkpoint_path, log_file, holistic,
                                  'holistic')

    header = Header.header(holistic)
    checkpoint_path = r"./model/Header-model/Header.ckpt"
    my_tools.save_and_load_models(checkpoint_path, log_file, header, 'header')

    footer = Footer.footer(holistic)
    checkpoint_path = r"./model/Footer-model/Footer.ckpt"
    my_tools.save_and_load_models(checkpoint_path, log_file, footer, 'footer')

    leftbody = LeftBody.leftbody(holistic)
    checkpoint_path = r"./model/LeftBody-model/LeftBody.ckpt"
    my_tools.save_and_load_models(checkpoint_path, log_file, leftbody,
                                  'leftbody')

    rightbody = RightBody.rightbody(holistic)
    checkpoint_path = r"./model/RightBody-model/RightBody.ckpt"
    my_tools.save_and_load_models(checkpoint_path, log_file, rightbody,
                                  'rightbody')

    model = meta(holistic, header, footer, leftbody, rightbody)
    checkpoint_save_path = r"./model/Meta-model/Meta.ckpt"
    my_tools.save_and_load_models(checkpoint_save_path, log_file, model,
                                  'meta')

    info = '当前模型(.ckpt)保存位置:' + checkpoint_save_path + '\n'
    log_file.write(info)

    print(
        '=============================================  配置训练指标  ==============================================='
    )
    # 编译模型
    my_tools.compile_categorical_models(LEARNING_RATE, DECAY_STEPS, DECAY_RATE,
                                        model)

    info = '采用衰减学习率,各参数为(初始学习率、衰减步数和衰减率):' + str(LEARNING_RATE) + ' ' + str(DECAY_STEPS) + ' ' \
           + str(DECAY_RATE) + "\n"
    log_file.write(info)

    cp_callback = my_tools.save_model_checkpoint(checkpoint_save_path)

    # 可视化
    tensorBoard_callback = my_tools.vision_by_tensorboard()
    # tensorboard --logdir=.\logs

    print(
        '================================================  训练模型  ================================================'
    )
    # initial_epoch 整数,开始训练的时期(用于恢复以前的训练运行)。1是初始状态,但是不能对tensorboard续线
    history = model.fit(train_data,
                        epochs=EPOCH_SIZE,
                        steps_per_epoch=TRAIN_NUM // BATCH_SIZE,
                        validation_data=val_data,
                        validation_steps=VAL_NUM // BATCH_SIZE,
                        callbacks=[cp_callback, tensorBoard_callback])

    # # 保存模型,与cp_callback二选一即可
    # model.save_weights(checkpoint_save_path)

    def add_log(d):
        print(d, file=log_file)

    model.summary(print_fn=add_log)

    info = '模型训练参数为(批次大小、训练轮数):' + str(BATCH_SIZE) + ' ' + str(
        EPOCH_SIZE) + '\n'
    log_file.write(info)

    print(
        '===============================================  可视化模型  ==============================================='
    )
    loss__and_acc_img_path = r'./meta_loss_and_acc_model.jpg'
    # 可视化并保存图片
    my_tools.vision_by_plt(history, loss__and_acc_img_path)

    info = '训练准确率和损失曲线保存于:' + loss__and_acc_img_path + "\n"
    log_file.write(info)

    print(
        '================================================  测试模型  ================================================'
    )
    res = model.evaluate(test_data, verbose=2,
                         steps=TEST_NUM // BATCH_SIZE)  # steps 样本批次(非批次大小)

    info = '测试集结果(loss and acc):' + str(res) + "\n"
    log_file.write(info)
    info = '\n=====================================================================================================\n\n'
    log_file.write(info)
    log_file.close()