When testing the code in the console it runs normally and all the functions work properly and after pyInstaller the problem comes. When I press the Minimize button, instead of appearing in the system tray, the icon disappears and in general the program is not in a window, but it works in the background? If anyone can help 🙂
I only tried with update pyInstaller and pystray, have no Idea what to do..
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['web_search.py'],
pathex=[],
binaries=[],
datas=[('ImotSearch_MIcon.png', '.'), ('sent_ads.json', 'web')],
hiddenimports=['requests', 'pystray'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=True,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[('v', None, 'OPTION')],
name='web_search',
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['ImotSearch_MIcon.png'],
)`
button:
def quit_window(icon, item):
icon.stop()
root.destroy()
def show_window(icon, item):
icon.stop()
root.after(0, root.deiconify)
def hide_window():
root.withdraw()
image = Image.open(r"ImotSearch_MIcon.png")
menu = (item('Exit', quit_window), item('Open', show_window))
icon = pystray.Icon("name", image, "web search", menu)
icon.run()
minimize_button = tk.Button(root, text="Minimize", command=hide_window)
minimize_button.pack(pady=5)````
New contributor
user26115200 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.