Dictionaries speichern
Leider nicht: Ich benutze GUI und das tkFileDialog modul
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
Und was is' daran anders oO''... Am Ende kommt'n String heraus, den du überprüfen musst.Brafil hat geschrieben:Leider nicht: Ich benutze GUI und das tkFileDialog modul
-
- Python-Forum Veteran
- Beiträge: 16025
- Registriert: Freitag 20. Juni 2003, 16:30
- Kontaktdaten:
Warum? ``import Tkinter as tk`` und dann einfach alle Tkinter-namen mit ``tk.`` prefixen. So ist auch sofort ersichtlich woher die kommen und wozu die gehören.Brafil hat geschrieben:Import is jetzt geregelt, außer Tkinter, das ist immer noch mit *
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
Und ein Prog das daraus ein Runtime macht wäre auch nicht schlecht(Aber die meisten verstehe ich nicht)
PS: Ich brauche einen geeigneten Layoutmanager
PS: Ich brauche einen geeigneten Layoutmanager
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
-
- Python-Forum Veteran
- Beiträge: 16025
- Registriert: Freitag 20. Juni 2003, 16:30
- Kontaktdaten:
py2exe, cxFreeze, PyInstaller. Aber das ist eine Gelegenheit einen neuen Thread zu starten, ja?Brafil hat geschrieben:Und ein Prog das daraus ein Runtime macht wäre auch nicht schlecht(Aber die meisten verstehe ich nicht)
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
Ich habe jetzt grid benutzt. Ist auch nicht so anders, und es zeigt die liste jetzt in einem Text-widget an, nicht in einem PopUp menü
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
Jetzt habe ich wieder ein Problem...
Wie kriege ich es ohne global hin, dass mydict leer wird?
Wie kriege ich es ohne global hin, dass mydict leer wird?
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
Now I have a problem again... It doesn't save or load any files...
Code: Alles auswählen
def Loadfile():
"""Loads a file"""
namefile = tkFileDialog.askopenfilename(defaultextension='*.dat')
#Tries to open the file
try:
fopen = open(namefile)
mydict = pickle.load(fopen)
fopen.close()
#Display a message
tkMessageBox.showinfo("Load File", "File has been loaded successfully")
#If it can't
except:
#Show error message
tkMessageBox.showerror("Error", "Couldn't open file")
return mydict
def Savefile():
"""Saves the file"""
#Choose the place where to save to
savefiled = tkFileDialog.asksaveasfilename(defaultextension="*.dat")
#If the name doesn't end with '.dat', add it
if not savefiled.lower().endswith(".dat"):
savefiled = savefiled + ".dat"
fsave = open(savefiled, "w")
pickle.dump(mydict, fsave)
#Display a message
tkMessageBox.showinfo("Save File", "File has
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
Das Prog ist fast fertig , nur das runtime/exe erzeugen krieg ich net hin...
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
-
- Python-Forum Veteran
- Beiträge: 16025
- Registriert: Freitag 20. Juni 2003, 16:30
- Kontaktdaten:
Mit der Forumssuche bekommst du eine Menge Threads zu dem Thema.Brafil hat geschrieben:nur das runtime/exe erzeugen krieg ich net hin...
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
- gerold
- Python-Forum Veteran
- Beiträge: 5555
- Registriert: Samstag 28. Februar 2004, 22:04
- Wohnort: Oberhofen im Inntal (Tirol)
- Kontaktdaten:
Hallo Brafil!Brafil hat geschrieben:nur das runtime/exe erzeugen krieg ich net hin...
Für ein Tkinter-Programm: Nimm py2exe http://www.py2exe.org/ und lass dir von http://xoomer.alice.it/infinity77/main/GUI2Exe.html helfen.
Für ein wxPython-Programm: Dafür kenne ich nur cx_freeze http://python.net/crew/atuining/cx_Freeze/. Mit py2exe habe ich das noch nicht versucht.
mfg
Gerold
http://halvar.at | Kleiner Bascom AVR Kurs
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
Der List@editor ist da! Nur speichern und laden klappt immer noch nicht, obwohl ich den code 10-mal durchgelesen habe
List@editor v1.0
List@editor v1.0
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
Speichern klappt. Laden hat keinen (dauerhaften) Effekt. In der Funktion wird der lokale Name `mydict` an die geladenen Daten gebunden. Das hat natürlich keine Auswirkungen auf das Objekt, das an `mydict` auf Modulebene gebunden ist. Das müsste man leeren und mit den geladenen Daten füllen. Stichworte `clear()` und `update()`.
ENDLICH!!! Ich habe ein App daraus gemacht.. Ohne Fehlermeldung!
Na ja... fast...
Na ja... fast...
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
Ich hab die gespeicherte datei test.txt angeguckt, die ich gerade überschrieben hatte, aber da stehen immer noch die Werte von vorgestern. Stimmt hier was nicht?
Ich weiß, das try-except ist falsch, aber ohne das war es genauso. Und loadfile ist auch net mehr:
PS: Ich benutze
und nicht
oder so ähnlich...
Code: Alles auswählen
#Choose the place where to save to
try:
savefiled = tkFileDialog.asksaveasfilename(defaultextension="*.txt") #Später "*.dat"
#If the name doesn't end with '.dat', add it
if not savefiled.lower().endswith(".dat"):
savefiled = savefiled + ".dat"
fsave = open(savefiled, "w")
pickle.dump(mydict, fsave)
#Display a message
tkMessageBox.showinfo("Save File", "File has been saved successfully")
except:
tkMessageBox.showerror("Error", "Couldn't save file")
Code: Alles auswählen
def Loadfile():
"""Loads a file"""
namefile = tkFileDialog.askopenfilename(defaultextension='*.txt')
#Tries to open the file
try:
fopen = open(namefile)
mydict = pickle.load(fopen)
fopen.close()
#Display a message
tkMessageBox.showinfo("Load File", "File has been loaded successfully")
#If it can't
except:
#Show error message
tkMessageBox.showerror("Error", "Couldn't open file")
return mydict
Code: Alles auswählen
import pickle
Code: Alles auswählen
from pickle import *
oder import pickle as pckl
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
Es geht immer noch nicht...
[b][color=blue]Python[/color] + [color=orange]Blender[/color][/b] = [i]Super[/i]
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)
[i]"Le Python mangera Tout"[/i]
The Python is gonna eat everything
(Except for Java, there are too many fans)