关于如何将数据文件添加到python应用程序中,我一直在结合Stack Overflow和web上的其他部分:
import Tkinter
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
--- Everything Fine Here ---
self.B = Tkinter.Button(self, text = 'Create Document', command = self.OnButtonClick)
self.B.grid(column = 0, row = 6)
def OnButtonClick(self):
createDoc()
if __name__ == "__main__":
app = simpleapp_tk(None)
app.title('Receipt Form')
app.iconbitmap(os.getcwd() + '/M.ico')
app.mainloop()
我尝试过使用.spec文件,但没有成功
Onedir工作正常,但是当我试图编译成一个可执行文件时,它会给出一个错误,即文件'M.ico'没有被定义。在
如果有人能够将数据文件与pyinstaller绑定到一个文件中。请帮忙。谢谢。在
我在一台运行python2.7和pyinstaller3.2的windows10计算机上
您必须指定要添加到pyinstaller.spec文件中的每个数据文件,或者通过命令行选项(.spec更容易。)下面是我的.spec文件,其中有一个“datas”部分:
在此之后,如果您试图访问在.spec文件中指定的任何数据文件,则必须使用Pyinstaller的\u MEIPASS文件夹来引用文件。下面是我如何使用名为数据数据库公司名称:
^{pr2}$上述方法取代了这一单独的陈述:
当我经历同样的事情时,这个链接对我帮助很大: https://irwinkwan.com/2013/04/29/python-executables-pyinstaller-and-a-48-hour-game-design-compo/
希望这有帮助!在
相关问题 更多 >
编程相关推荐