You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用PyInstaller打包KivyMD项目后MDFloatingActionButton禁用失效

PyInstaller打包KivyMD项目后MDFloatingActionButton禁用功能失效

将KivyMD项目通过PyInstaller打包为exe文件后,出现MDFloatingActionButton禁用功能失效的问题,但在未打包的Python环境中该功能可正常运行。

用于实现点击后禁用按钮的代码片段:

for btn in self.ids.values():  # Loop through all widgets in self.ids
    if isinstance(btn, MDFloatingActionButton) and btn != button_instance:
        btn.disabled = True

当前使用的环境版本:

  • Python 3.9.0
  • KivyMD 1.0.1
  • PyInstaller 6.0.0

打包配置代码:

block_cipher = None
from kivy_deps import sdl2, glew
from kivymd import hooks_path as kivymd_hooks_path

a = Analysis(
    ['Main.py'],
    pathex=[],
    binaries=[],
    datas=[('login.kv', '.')],
    hiddenimports=['kivymd.icon_definitions.icon_definitions', 'kivymd.uix.button', 'kivy.properties'],
    hookspath=[kivymd_hooks_path],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    cipher=block_cipher,
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
    name='Main',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,   
)

内容的提问来源于stack exchange,提问作者Shah Shah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 13:46:09