为什么我不能运行我的.exe转换的wxPython文件? AttributeError的

时间:2011-10-12 19:38:13

标签: python wxpython executable attributeerror

这是我得到的输出:

Traceback (most recent call last):
    File "ConvertImagesWithInterface.py", line 1, in (module)
    File "wx\__init__.pyc", line 45, in (module)
    File "wx\_core.pyc", line 5, in (module)
    File "new.pyc", line 3, in (module)
AttributeError: 'module' object has no attribute 'Frame'

我尝试将__init__个文件和new.pyc文件复制到与(模块)位置相关的不同目录中,尝试重命名模块内部的内容,并查看其他人有的20个不同问题,但我找不到如何解决这个问题的答案。有人有什么想法吗?

提前致谢。

import wx as wxPython
import os

try:
# Python2
import Tkinter as tk
import tkFileDialog as tkfd

except ImportError:
# Python3
import tkinter as tk
import tkinter.filedialog as tkfd

newFileName = "" 
newFolderName = "new folder/"
newDirectory = "" 
path = ""
jpgType = ".jpg"
pngType = ".png"
filesConverted = ""
numberOfFiles = 0

class greg(wxPython.Frame):

def __init__(self, parent, id):
    wxPython.Frame.__init__(self, parent, id, 'Convert Images', size = (160, 110))
    panel = wxPython.Panel(self)

    button = wxPython.Button(panel, label = "exit", pos = (10, 10), size = (60, 60))
    self.Bind(wxPython.EVT_BUTTON, self.closebutton, button)
    self.Bind(wxPython.EVT_CLOSE, self.closewindow)

    button = wxPython.Button(panel, label = "convert", pos = (80, 10), size = (60, 60))
    self.Bind(wxPython.EVT_BUTTON, self.file_open, button)



def closebutton(self, event):
    self.Close(True)

def closewindow(self, event):
    self.Destroy()

def file_open(self, event):
    root = tk.Tk()
    root.withdraw() 
    path = tkfd.askdirectory(parent=root,initialdir="/",title='Please select a directory') + "/"

    directoryFiles = os.listdir(path)
    newDirectory = path + newFolderName
    convert(newDirectory, directoryFiles, path);

    temp = wxPython.MessageDialog( self, filesConverted, "About Sample Editor", wxPython.OK | wxPython.CENTRE)
    temp.ShowModal()
    quit()


def convert(newDir, dirFiles, filePath):
if not os.path.exists(newDir):
    os.makedirs(newDir)
for x in range(0, len(dirFiles)):
    fileName = dirFiles[x]
    fileType = fileName[(len(fileName)-10):-6]
    if jpgType == fileType or pngType == fileType:
        fileNametoReadFrom = filePath + fileName
        file = open(fileNametoReadFrom, 'rb')
        text = file.read()
        file.close()
        newFileName = filePath + newFolderName + "new " + fileName[:-6]
        file = open(newFileName, 'wb')
        file.write(text[4:-13])
        file.close()
        global filesConverted
        filesConverted = filesConverted + str(numberOfFiles) + ": Converted: " + fileNametoReadFrom + "\n"
        global numberOfFiles
        numberOfFiles = numberOfFiles + 1
filesConverted = filesConverted + "\n" + str(numberOfFiles) + " files have been placed in " + filePath + newFolderName


if __name__ == '__main__':
app = wxPython.PySimpleApp()
frame = greg(parent = None, id = -1)
frame.Show()
app.MainLoop()

0 个答案:

没有答案