コード例 #1
0
 def get_mods_dir(self, filedialogoutput):
     if filedialogoutput.endswith("/"):
         self.mods_dir = filedialogoutput
     else:
         self.mods_dir = filedialogoutput + "/"
     self.mods_dir_bak = reg.get_reg("mods_dir_bak")
     if self.mods_dir.endswith("ods/"):
         reg.set_reg("mods_dir_bak", self.mods_dir)
         reg.set_reg("mods_dir", self.mods_dir)
     elif self.mods_dir[0].isalpha():
         self.get_mods_dir(filedialog.askdirectory(title="Open mods directory"))
     elif self.mods_dir == "/":
         if self.mods_dir_bak == "/":
             self.get_mods_dir(filedialog.askdirectory(title="Open mods directory"))
         else:
             self.mods_dir = reg.get_reg("mods_dir_bak")
     print(self.mods_dir)
コード例 #2
0
def start(filedialogoutput):
    #print("--start--")
    #print(filedialogoutput)
    #print("end")
    logging.info("mo.start called sucessfully")
    logging.info("importing global variables")
    global moprofilesdir
    global moprofilesdirbak
    global moprofiles
    global profiledirs
    global profiledirsbak
    global profiledirsdis
    global tries
    try:
        reg.set_reg("profiles_dir_bak", moprofilesdir)
    except:
        a=0
    print("check 1")
    #print(filedialogoutput)
    logging.info("importing global variables done") 
    s = list(filedialogoutput)
    #file_loc = open("location.txt", "w", encoding="utf8")
    #file_loc.write(filedialogoutput)
    #file_loc.close()
    #logging.info(s)
    for i in range(0, len(s)):
        if s[i] == "\\":
            s[i]= "/"
    filedialogoutput = "".join(s)
    #moprofilesdirbak = moprofilesdir
    if filedialogoutput.endswith("/"):
        moprofilesdir = filedialogoutput
    else:
        moprofilesdir = filedialogoutput + "/"
    reg.set_reg("profiles_dir", moprofilesdir)
    try:
        if reg.get_reg("profiles_dir_bak") == None:
            reg.set_reg("profiles_dir_bak", moprofilesdir)

        elif reg.get_reg("profiles_dir_bak") == "":
            reg.set_reg("profiles_dir_bak", moprofilesdir)
    except:
        a=9
    logging.info("moprofilesdir: " + moprofilesdir)
    #print(moprofilesdir)
    moprofiles = []
    print("check 2")
    profiles_string = "profiles/"
    if moprofilesdir.endswith("rofiles/") or moprofilesdir.endswith("rofiles\\"):
        logging.info("--if statement went through")
        for entry in os.scandir(moprofilesdir):
            logging.info("----for statement went through")
            if not entry.name.startswith(".") and entry.is_dir():
                logging.info("------if not statement went through")
                moprofiles.append(entry.name)
                logging.info("--------moprofiles appended")
            else:
                logging.warning("------if not statement did not go through, maybe not a folder?")
        profiledirs = []
        #profiledirsbak = []

        for i in range(0,len(moprofiles)):
            profiledirs.append(moprofilesdir + moprofiles[i] + "/")

        logging.info("------profiledirs------")
        logging.info(profiledirs)
        logging.info("-----------------------")
        print("check 3")
        

    else:
        cache = tries
        tries = cache + 1
        if tries > 1:
            tries = 0
            if len(reg.get_reg("profiles_dir_bak")) < 8:
                start(reg.get_reg("profiles_dir_bak"))
            else:
                try:
                    start(filedialog.askdirectory(title="Open profiles directory - JUST DO IT", initialdir = last_location))
                except:
                    start(filedialog.askdirectory(title="Open profiles directory - JUST DO IT"))
        else:
            try:
                try:
                    start(reg.get_reg("profiles_dir_bak"))
                except:
                    start(filedialog.askdirectory(title="Open profiles directory - JUST DO IT", initialdir = last_location))
            except:
                start(filedialog.askdirectory(title="Open profiles directory - JUST DO IT"))
コード例 #3
0
def start(filedialogoutput):
    #print("--start--")
    #print(filedialogoutput)
    #print("end")
    logging.info("mo.start called sucessfully")
    logging.info("importing global variables")
    global moprofilesdir
    global moprofilesdirbak
    global moprofiles
    global profiledirs
    global profiledirsbak
    global profiledirsdis
    global tries
    try:
        reg.set_reg("profiles_dir_bak", moprofilesdir)
    except:
        a = 0
    print("check 1")
    #print(filedialogoutput)
    logging.info("importing global variables done")
    s = list(filedialogoutput)
    #file_loc = open("location.txt", "w", encoding="utf8")
    #file_loc.write(filedialogoutput)
    #file_loc.close()
    #logging.info(s)
    for i in range(0, len(s)):
        if s[i] == "\\":
            s[i] = "/"
    filedialogoutput = "".join(s)
    #moprofilesdirbak = moprofilesdir
    if filedialogoutput.endswith("/"):
        moprofilesdir = filedialogoutput
    else:
        moprofilesdir = filedialogoutput + "/"
    reg.set_reg("profiles_dir", moprofilesdir)
    try:
        if reg.get_reg("profiles_dir_bak") == None:
            reg.set_reg("profiles_dir_bak", moprofilesdir)

        elif reg.get_reg("profiles_dir_bak") == "":
            reg.set_reg("profiles_dir_bak", moprofilesdir)
    except:
        a = 9
    logging.info("moprofilesdir: " + moprofilesdir)
    #print(moprofilesdir)
    moprofiles = []
    print("check 2")
    profiles_string = "profiles/"
    if moprofilesdir.endswith("rofiles/") or moprofilesdir.endswith(
            "rofiles\\"):
        logging.info("--if statement went through")
        for entry in os.scandir(moprofilesdir):
            logging.info("----for statement went through")
            if not entry.name.startswith(".") and entry.is_dir():
                logging.info("------if not statement went through")
                moprofiles.append(entry.name)
                logging.info("--------moprofiles appended")
            else:
                logging.warning(
                    "------if not statement did not go through, maybe not a folder?"
                )
        profiledirs = []
        #profiledirsbak = []

        for i in range(0, len(moprofiles)):
            profiledirs.append(moprofilesdir + moprofiles[i] + "/")

        logging.info("------profiledirs------")
        logging.info(profiledirs)
        logging.info("-----------------------")
        print("check 3")

    else:
        cache = tries
        tries = cache + 1
        if tries > 1:
            tries = 0
            if len(reg.get_reg("profiles_dir_bak")) < 8:
                start(reg.get_reg("profiles_dir_bak"))
            else:
                try:
                    start(
                        filedialog.askdirectory(
                            title="Open profiles directory - JUST DO IT",
                            initialdir=last_location))
                except:
                    start(
                        filedialog.askdirectory(
                            title="Open profiles directory - JUST DO IT"))
        else:
            try:
                try:
                    start(reg.get_reg("profiles_dir_bak"))
                except:
                    start(
                        filedialog.askdirectory(
                            title="Open profiles directory - JUST DO IT",
                            initialdir=last_location))
            except:
                start(
                    filedialog.askdirectory(
                        title="Open profiles directory - JUST DO IT"))
コード例 #4
0
 def radiocom(self, button):
     self.disablecb(button)
     self.importdir= mo.profiledirs[button]
     mo.radiovar= self.radiovar.get()
     reg.set_reg("last_master", str(button))
コード例 #5
0
    def createWidgets(self):

        #tab 1

        if int(self.last_master) >= len(mo.moprofiles):
            self.last_master = 0
            reg.set_reg("last_master", "0")
        
        self.radiovar = tk.IntVar()
        self.radiovar.set(0)
        
        self.checkbuttons = []
        self.checkbuttonvars = []
        self.radiobuttons = []


        
        for i in range(0, len(mo.moprofiles)):
            self.checkbuttonvars.append(tk.StringVar())
            self.checkbuttonvars[i].set("disabled")
            self.checkbuttons.append(tk.Checkbutton(self.textframe, text=mo.moprofiles[i], onvalue = "enabled", offvalue = "disabled", variable = self.checkbuttonvars[i], command = lambda i=i: self.modifyprofiles(i)))
            self.checkbuttons[i].grid(column=2, row=i+1, sticky="W")
        self.checkbuttons[int(self.last_master)].config(state=tk.DISABLED)
        
        for i in range(0, len(mo.moprofiles)):
            self.radiobuttons.append(tk.Radiobutton(self.textframe, variable=self.radiovar, value = i, command= lambda i=i: self.radiocom(i)))
            self.radiobuttons[i].grid(column=1, row=i+1)
        self.radiobuttons[int(self.last_master)].select()
        
        self.importlabel=tk.Label(self.textframe, text="Master \n Order")
        self.importlabel.grid(column=1, row = 0, sticky = "W")
        self.exportlabel=tk.Label(self.textframe, text="Orders to override")
        self.exportlabel.grid(column=2, row = 0, sticky = "W")

        self.startbutton=tk.Button(self.textframe, text="Start", command=lambda: self.startmo())
        self.startbutton.grid(column=3, row=1, sticky = "N" + "W" + "S" + "E")

        self.filevar = tk.StringVar()
        self.filebutton=tk.Button(self.textframe, text="Choose profiles directory", command=lambda: self.afterinit2())
        self.filebutton.grid(column=3, row=2, sticky = "N" + "W" + "S" + "E")

        self.quitbutton = tk.Button(self.textframe, text="Quit", command=lambda: self.savelog())
        self.quitbutton.grid(column=3, row=3, sticky = "N" + "W" + "S" + "E")

        self.backupvar = tk.IntVar()
        self.backupbutton = tk.Checkbutton(self.textframe, text="Backup modlist.txt?", variable = self.backupvar, command= self.backup)
        self.backupbutton.grid(column=3, row=4, sticky = "N" + "W" + "S")
        self.backupbutton.invoke()

        self.logvar = tk.IntVar()
        self.logbutton = tk.Checkbutton(self.textframe, text="DEBUG", variable = self.logvar)
        self.logbutton.grid(column=3, row=5, sticky = "N" + "W" + "S")

        #tab 2

        #self.radiovar2 = tk.IntVar()
        #self.radiovar2.set(0)

        self.checkbuttons2 = []
        self.checkbuttonvars2 = []

        for i in range(0, len(mo.moprofiles)):
            self.checkbuttonvars2.append(tk.StringVar())
            self.checkbuttonvars2[i].set("disabled")
            self.checkbuttons2.append(tk.Checkbutton(self.textframe2, text=mo.moprofiles[i], onvalue = "enabled",
                                                     offvalue = "disabled", variable = self.checkbuttonvars2[i], command = lambda i=i: self.modifyprofiles2(i)))
            self.checkbuttons2[i].grid(column=2, row=i+1, sticky="W")
            
        #self.checkbuttons2[int(self.last_master)-1].config(state=tk.DISABLED)

        self.importlabel2=tk.Label(self.textframe2, text=" \n ")
        self.importlabel2.grid(column=1, row = 0, sticky = "W")

        self.exportlabel2=tk.Label(self.textframe2, text="Profiles to sort")
        self.exportlabel2.grid(column=2, row = 0, sticky = "W")

        self.startbutton2=tk.Button(self.textframe2, text="Start", command=lambda: self.startps())
        self.startbutton2.grid(column=3, row=1, sticky = "N" + "W" + "S" + "E")

        self.filevar2 = tk.StringVar()
        self.filebutton2=tk.Button(self.textframe2, text="  Choose mods directory  ",
                                   command=lambda : self.get_get_mods_dir())
        self.filebutton2.grid(column=3, row=2, sticky = "N" + "W" + "S" + "E")

        self.quitbutton2 = tk.Button(self.textframe2, text="Quit", command=lambda: self.savelog())
        self.quitbutton2.grid(column=3, row=3, sticky = "N" + "W" + "S" + "E")

        self.backupbutton2 = tk.Checkbutton(self.textframe2, text="Backup modlist.txt?", variable = self.backupvar, command= self.backup())
        self.backupbutton2.grid(column=3, row=4, sticky = "N" + "W" + "S")

        self.logbutton2 = tk.Checkbutton(self.textframe2, text="DEBUG", variable = self.logvar)
        self.logbutton2.grid(column=3, row=5, sticky = "N" + "W" + "S")