예제 #1
0
    def __init__(__, boss, mode=True, name=K.path_map + "save.wf"):
        """Fenetre 'exploreur' pour sauvegarder et charger les maps . mode = 1 (save) ou 0 (load)"""
        tk.Tk.__init__(__)
        text_mode = "Sauvegarder" * bool(mode) + "Charger" * bool(not mode)
        __.title(text_mode)
        __.mode = mode
        __.boss = boss
        __.old_ind = 0

        __.Struct = tk.Frame(__)
        __.Struct2 = tk.Frame(__)

        __.Entry = Entry256(__.Struct2, width=30)
        if mode:
            __.Entry.insert(0, get_name(try_file(name)))
        else:
            __.Entry.insert(0, get_name(name))

        __.Scroll = tk.Scrollbar(__.Struct, width=20)
        __.List = tk.Listbox(__.Struct, width=50, height=30)
        __.refresh()
        __.Scroll.config(command=__.List.yview)
        __.List.config(yscrollcommand=__.Scroll.set)

        __.Erreur = tk.Label(__.Struct2, fg="red")

        __.Struct.pack(side=tk.LEFT)
        __.Struct2.pack(side=tk.RIGHT)
        __.List.pack(side=tk.RIGHT, fill=tk.Y)
        __.Scroll.pack(side=tk.LEFT, fill=tk.Y)
        __.Entry.pack()
        tk.Button(__.Struct2, text=text_mode,
                  command=__.valider).pack(fill=tk.X)
        tk.Button(__.Struct2, text="Supprimer",
                  command=__.suppr).pack(fill=tk.X)
        tk.Button(__.Struct2, text="Renommer",
                  command=__.renommer).pack(fill=tk.X)
        __.Erreur.pack(fill=tk.X)

        __.List.bind('<ButtonRelease-1>', lambda ev: __.clic(True))
        __.bind("<Destroy>", lambda ev: __.quit())
        __.mainloop()
예제 #2
0
	def valider(__):
		try:
			if __.mode:#mode sauveagarder
				name = __.Entry.get()
				if name:
					save = True
					if get_ext(name) != "wf": name += ".wf"
					temp = K.path_map + name
					if temp != try_file(temp):
						if not Question("Remplacer",
									"Le fichier '%s' existe déjà .\nVoulez-vous l'écraser ?"%(name)).choix:
							save = False
					if save:
						__.boss.filename = K.path_map + name
						__.destroy()
			else:#mode charger
				name = __.clic()
				if name:
					__.boss.filename = K.path_map + name
					__.destroy()
		except Exception, err: __.Erreur.configure(text=err[-1])
예제 #3
0
	def __init__(__,boss,mode=True,name=K.path_map + "save.wf"):
		"""Fenetre 'exploreur' pour sauvegarder et charger les maps . mode = 1 (save) ou 0 (load)"""
		tk.Tk.__init__(__)
		text_mode = "Sauvegarder" * bool(mode) + "Charger" * bool(not mode)
		__.title(text_mode)
		__.mode = mode
		__.boss = boss
		__.old_ind = 0

		__.Struct = tk.Frame(__)
		__.Struct2 = tk.Frame(__)

		__.Entry = Entry256(__.Struct2,width=30)
		if mode:
			__.Entry.insert(0, get_name(try_file(name)))
		else:
			__.Entry.insert(0, get_name(name))

		__.Scroll = tk.Scrollbar(__.Struct, width=20)
		__.List = tk.Listbox(__.Struct, width=50,height=30)
		__.refresh()
		__.Scroll.config(command = __.List.yview)
		__.List.config(yscrollcommand = __.Scroll.set)

		__.Erreur = tk.Label(__.Struct2, fg="red")

		__.Struct.pack(side=tk.LEFT)
		__.Struct2.pack(side=tk.RIGHT)
		__.List.pack(side = tk.RIGHT, fill = tk.Y)
		__.Scroll.pack(side = tk.LEFT, fill = tk.Y)
		__.Entry.pack()
		tk.Button(__.Struct2, text=text_mode, command=__.valider).pack(fill=tk.X)
		tk.Button(__.Struct2, text="Supprimer", command=__.suppr).pack(fill=tk.X)
		tk.Button(__.Struct2,text="Renommer" , command=__.renommer).pack(fill=tk.X)
		__.Erreur.pack(fill=tk.X)

		__.List.bind('<ButtonRelease-1>',lambda ev : __.clic(True))
		__.bind("<Destroy>",lambda ev: __.quit())
		__.mainloop()
예제 #4
0
 def valider(__):
     try:
         if __.mode:  #mode sauveagarder
             name = __.Entry.get()
             if name:
                 save = True
                 if get_ext(name) != "wf": name += ".wf"
                 temp = K.path_map + name
                 if temp != try_file(temp):
                     if not Question(
                             "Remplacer",
                             "Le fichier '%s' existe déjà .\nVoulez-vous l'écraser ?"
                             % (name)).choix:
                         save = False
                 if save:
                     __.boss.filename = K.path_map + name
                     __.destroy()
         else:  #mode charger
             name = __.clic()
             if name:
                 __.boss.filename = K.path_map + name
                 __.destroy()
     except Exception, err:
         __.Erreur.configure(text=err[-1])