3
I have the following code :
#coding-utf-8
from Tkinter import Frame, Tk, BOTH, Text, Menu, END
import tkFileDialog
from tkinter import filedialog as fd
import dbf
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Conversor de Arquivo DBF.")
self.pack(fill=BOTH, expand=1)
menubar = Menu(self.parent)
self.parent.config(menu=menubar)
fileMenu = Menu(menubar)
fileMenu.add_command(label="Abrir", command=self.onOpen)
menubar.add_cascade(label="Arquivo", menu=fileMenu)
self.txt = Text(self)
self.txt.pack(fill=BOTH, expand=1)
def onOpen(self):
ftypes = [('All files', '*')]
dlg = tkFileDialog.Open(self, filetypes = ftypes)
fl = dlg.show()
if fl != '':
text = self.readFile(fl)
self.txt.insert(END, text)
def readFile(self, fl):
text = "Seu arquivo foi convertido corretamente e pronto para carregar no InCeres. O mesmo se encontra na" \
"mesma pasta que foi importado"
text2 = "Nao foram encontrados ocorrencia para serem corrigidas."
mudou = False
with dbf.Table(fl) as table:
for field in ('sampleid', '__sampleid','_sampleid', 'n__samplei'):
try:
table.rename_field(field, 'id')
mudou = True
except Exception as e:
print(e)
pass
if mudou:
return text
else:
return text2
def main():
root = Tk()
ex = Example(root)
root.geometry("300x250+300+300")
root.mainloop()
if __name__ == '__main__':
main()
I would like it to become an executable, I mean open the window that was made so that operations can be done, I tried to use the py2exe
, maybe wrongly...it only generates the . exe that opens a windows console
How can I generate it?
Try the pyinstaller (http://www.pyinstaller.org/)
– epx