python:systray
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| python:systray [2023/01/30 12:12] – Wulf Rajek | python:systray [2023/05/29 11:55] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 41: | Line 41: | ||
| pass | pass | ||
| + | icon.visible = False | ||
| python = sys.executable | python = sys.executable | ||
| os.execl(python, | os.execl(python, | ||
| # | # | ||
| - | def action_exit(): | + | def action_quit(): | 
| - |  | + |  | 
| + | print(" | ||
| + | os._exit(0) | ||
| def launch(): | def launch(): | ||
| Line 55: | Line 58: | ||
| pass | pass | ||
| - | image = Image.open(" | + | def resource_path(relative_path): | 
| + | try: | ||
| + | base_path = sys._MEIPASS | ||
| + | except Exception: | ||
| + | base_path = os.path.abspath(" | ||
| + | |||
| + | return os.path.join(base_path, | ||
| + | |||
| + | image = Image.open(resource_path("systrayicon.png")) | ||
| #icon = pystray.Icon(name ="just text", icon =image, title =" | #icon = pystray.Icon(name ="just text", icon =image, title =" | ||
| - | menu = (item(' | + | menu = (item(' | 
| icon = icon(" | icon = icon(" | ||
| Line 66: | Line 77: | ||
| icon.run(run_call) | icon.run(run_call) | ||
| + | </ | ||
| + | |||
| + | Create version file using: | ||
| + | < | ||
| + | pip install pyinstaller_versionfile | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | import pyinstaller_versionfile | ||
| + | |||
| + | pyinstaller_versionfile.create_versionfile( | ||
| + | output_file=" | ||
| + | version=" | ||
| + | company_name=" | ||
| + | file_description=" | ||
| + | internal_name=" | ||
| + | legal_copyright=" | ||
| + | original_filename=" | ||
| + | product_name=" | ||
| + | ) | ||
| + | </ | ||
| + | |||
| + | To build as single file with additional data like images, the resource_path function needs to be included and pyinstaller needs to use the --add-data option. On Windows a semicolon is required, on linux a colon works. | ||
| + | < | ||
| + | wine pyinstaller.exe --onefile --icon=systrayicon.ico --add-data " | ||
| + | </ | ||
| + | |||
| + | Pyinstaller options: | ||
| + | < | ||
| + | --onefile: Creates a single file. Synonyms: -F | ||
| + | --windowed: Ensures that no console is opened during execution. Synonyms: -w and --noconsole | ||
| + | --add-data: adds data to the file using " | ||
| + | --version: adds exe file version information | ||
| + | --icon: adds windows application icon file | ||
| </ | </ | ||
python/systray.1675080736.txt.gz · Last modified:  (external edit)
                
                