【发布时间】:2019-12-15 08:48:41
【问题描述】:
我正在尝试集成 kivy 中包含的文件选择器模块,以允许用户通过 FileChooserListView 获取输入文件的文件字符串,但是当通过 pyinstaller 构建应用程序时,应用程序无法打开。有人碰巧知道问题是什么吗?这是一个示例代码:在 pycharm 中运行良好,但在 pyinstaller 构建时无法打开。
from os.path import exists
from threading import Thread
from sys import exit
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.lang import Builder
from os.path import sep, expanduser, dirname, splitext
from kivy.uix.filechooser import FileChooserListView
KV = '''
<MetaLevel>:
rows: 2
cols: 1
Label:
text: 'test text'
Button:
text: 'test button'
on_press: root.popup()
<file_popup>:
file_chooser: file_chooser
GridLayout:
rows:1
cols:1
FileChooserListView:
id: file_chooser
path: r'C:\\Users'
on_submit: root.printer()
'''
Builder.load_string(KV)
class MetaLevel(GridLayout):
def popup(self):
App.get_running_app().file_popup.open()
class file_popup(Popup):
def printer(self):
print(self.file_chooser.path)
App.get_running_app().file_popup.dismiss()
class Cruncher(App):
def build(self):
self.file_popup = file_popup()
return MetaLevel()
if __name__ == "__main__":
Cruncher().run()
【问题讨论】:
-
什么版本的pyinstaller?你的 pyinstaller 命令是什么样的?
-
pyinstaller --version = 3.5,我已经尝试了几乎所有可能的输入,包括基本的“pyinstaller”C:\Users\...“”虽然理想情况下我会使用“pyinstaller --name 名称 --onedir --windowed "C:\Users\..." "
-
检查 build\(script-name) 文件夹中的 warn-(script-name).txt 文件,我相信你会看到各种各样的错误。
标签: python kivy pyinstaller filechooser