Bitte unter Linux ausprobieren. Dieses Beispiel wird wahrscheinlich so nicht unter Windows funktionieren. Aber wenn es unter Linux funktioniert, dann sehe ich eine Lösung:
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# Achte auf das Coding. Das muss mit dem wirklichen Dateicoding zusammenpassen.
import sys
import encodings
import encodings.ascii
import encodings.utf_8
import encodings.iso8859_1
import encodings.iso8859_15
import encodings.mbcs
import encodings.cp850
import codecs
# Encodings
out_enc = "iso-8859-1"
err_enc = "iso-8859-1"
in_enc = "iso-8859-1"
# StdOut und StdErr umleiten -> Streamwriter mit korrektem Encoding
sys.stdout = codecs.getwriter(out_enc)(sys.__stdout__)
sys.stderr = codecs.getwriter(out_enc)(sys.__stderr__)
sys.stdin = codecs.getreader(in_enc)(sys.__stdin__)
def Generate(self, event):
"""Verkleinert die eigentlichen Bilder"""
if not resize.isEmpty(self.txtFolder.GetValue()) and not ( resize.isEmpty(self.txtHeight.GetValue()) and resize.isEmpty(self.txtWidth.GetValue()) and not resize.isEmpty(self.txtDestination.GetValue()) ):
self.Enable(False)
maximum = count(self.txtFolder.GetValue(), self)
progress = wx.ProgressDialog("Status", u"Dateien werden gezählt", maximum,parent = self, style = wx.PD_AUTO_HIDE | wx.PD_CAN_ABORT | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME)
#self.Status.Destroy()
progress.Update(0, "Dateien werde umgeformt")
wildcard = (".jpg", ".png", ".jpeg", ".gif", ".bmp")
if resize.isEmpty(self.txtHeight.GetValue()):
height = 0
width = int(self.txtWidth.GetValue())
elif resize.isEmpty(self.txtWidth.GetValue()):
width = 0
height = int(self.txtHeight.GetValue())
else:
height = int(self.txtHeight.GetValue())
width = int(self.txtWidth.GetValue())
lCounter = 0
exit = True
for dir, dirs, files in os.walk(self.txtFolder.GetValue()):
subdir = string.split(dir, self.txtFolder.GetValue())[-1]
for file in files:
...
...
...
Gerold
Edit: Ich habe STDIN vergessen. (ungetestet)