def __new_directory(self):
     """Allows the user to change the target image directory from
     the database.
     """
     if PY_VERSION == 2:
         self.__database_filepath = tkFileDialog.askdirectory()
     else:
         self.__database_filepath = filedialog.askdirectory()
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        self.path = filedialog.askdirectory()
        # open files

        self.players = None
        self.famcontact = None
        self.masterSUs = None
        self.teams = None
        self.unilist = None
        self.open_main_files()  # loads above
Ejemplo n.º 4
0
 def __opendir(self):
     '''打开文件夹的逻辑'''
     self.textbox.delete('1.0', tk.END) # 先删除所有
     self.dirname = filedialog.askdirectory() # 打开文件夹对话框
     self.entryvar.set(self.dirname) # 设置变量entryvar,等同于设置部件Entry
     if not self.dirname:
         messagebox.showwarning('警告', message='未选择文件夹!')  # 弹出消息提示框
     self.dirlist = os.listdir(self.entryvar.get())
     for eachdir in self.dirlist:
         self.textbox.insert(tk.END, eachdir+'\r\n')
     self.textbox.update()
Ejemplo n.º 5
0
    def afterinit(self):
        try:
            logging.info("mo.start gets called")
            try:
                logging.info("checking registry for past data")
                self.last_location = reg.get_reg("profiles_dir")
                print(self.last_location)
                self.last_master = int(reg.get_reg("last_master"))
                self.mods_dir = reg.get_reg("mods_dir")
                if len(self.last_location) < 3:
                    print("warum error?")
                    logging.info("last location empty?")
                    raise IOError
                logging.info("calling mo.start")
                logging.info(self.last_location)
                print("last location: " + str(self.last_location))
                mo.start(str(self.last_location))
                print("check 7")
            except:
                print("no reg data")
                logging.info("no registry data found / registry data has errors?")
                mo.start(filedialog.askdirectory(title="Open profiles directory"))
                self.last_master = 0
                self.mods_dir = ""

            self.importdir = ""
            self.profiledirsbak = mo.profiledirsbak
            self.activeprofiles = []
            self.activeprofiles2 = []
            for i in range(0, len(mo.moprofiles)):
                self.activeprofiles.append("disabled")
                self.activeprofiles2.append("disabled")
            print("check 4")
            mo.activeprofiles=self.activeprofiles
            mo.activeprofiles2=self.activeprofiles2
            logging.info("creating widgets")
            print("check widgets")
            self.createWidgets()
            print("check 5")
            logging.info("creating image")
            self.createImage()
            print("check 6")
        except:
            try:
                print("afterinit2")
                self.afterinit2()
            except:
                print("wtf")
                logging.warning("mo.start returned an error or there was a problem with the first afterinit") 
                self.exit()
Ejemplo n.º 6
0
 def afterinit2(self):
     logging.info("mo.start gets called")
     mo.start(filedialog.askdirectory(title="Open profiles directory"))
     self.importdir = ""
     self.last_master = 0
     self.profiledirsbak = mo.profiledirsbak
     self.activeprofiles = []
     self.activeprofiles2 = []
     for i in range(0, len(mo.moprofiles)):
         self.activeprofiles.append("disabled")
         self.activeprofiles2.append("disabled")
     mo.activeprofiles=self.activeprofiles
     mo.activeprofiles2=self.activeprofiles2
     self.refresh()
     self.createWidgets()
     self.createImage()
Ejemplo n.º 7
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"))
Ejemplo n.º 8
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"))
Ejemplo n.º 9
0
 def get_get_mods_dir(self):
     try:
         self.get_mods_dir(filedialog.askdirectory(title="Open mods directory", initialdir = self.mods_dir))
     except:
         self.get_mods_dir(filedialog.askdirectory(title="Open mods directory"))