tuttle-dev/tuttle

UI: Display app icon and title instead of flet

clstaudt opened this issue ยท 16 comments

On starting the app from the command line, the custom app icon (app/assets/icon) should be used and the title of the app should be displayed. Currently this uses the flet defaults.

@flamesjames good first issue?

@clstaudt just want to confirm I'm understanding correctly - are you referring to the app icon/title of the window itself or in a particular spot?

@flamesjames Yes, of the application window.

@clstaudt This is taking longer than expected due to some issues with running the app before my changes. I believe I have followed the instructions in the readme doc, but when trying to run the app, I am getting some issue with the flet library:

Traceback (most recent call last):
  File "C:\Users\jmart\Documents\Coding\PythonProjects\OpenSource\Tuttle\tuttle\app\app.py", line 418, in <module>
    app(
  File "C:\Users\jmart\Documents\Coding\PythonProjects\OpenSource\Tuttle\tuttle\venv\Lib\site-packages\flet-0.4.0.dev1085-py3.11.egg\flet\flet.py", line 82, in app
    __app_sync(
  File "C:\Users\jmart\Documents\Coding\PythonProjects\OpenSource\Tuttle\tuttle\venv\Lib\site-packages\flet-0.4.0.dev1085-py3.11.egg\flet\flet.py", line 149, in __app_sync
    fvp, pid_file = open_flet_view(
                    ^^^^^^^^^^^^^^^
  File "C:\Users\jmart\Documents\Coding\PythonProjects\OpenSource\Tuttle\tuttle\venv\Lib\site-packages\flet-0.4.0.dev1085-py3.11.egg\flet\flet.py", line 490, in open_flet_view
    args, flet_env, pid_file = __locate_and_unpack_flet_view(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jmart\Documents\Coding\PythonProjects\OpenSource\Tuttle\tuttle\venv\Lib\site-packages\flet-0.4.0.dev1085-py3.11.egg\flet\flet.py", line 546, in __locate_and_unpack_flet_view
    zip_file = __download_flet_client("flet-windows.zip")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jmart\Documents\Coding\PythonProjects\OpenSource\Tuttle\tuttle\venv\Lib\site-packages\flet-0.4.0.dev1085-py3.11.egg\flet\flet.py", line 658, in __download_flet_client
    urllib.request.urlretrieve(flet_url, temp_arch)
  File "C:\Python311\Lib\urllib\request.py", line 241, in urlretrieve
               ^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\urllib\request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "C:\Python311\Lib\urllib\request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

I will continue investigating this as I familiarize myself with the app structure.. if you have any ideas, please shoot them my way! Thank you

Hi @flamesjames, this looks like an issue you should ask about at the flet project.

Try Python 3.10 instead of 3.11 and see if it still appears.

@clstaudt I finally got my environment up and running and able to run the app now. Thank you for your suggestion on trying Python 3.10. I have created a venv using this version and it seems to be running now -- the reason 3.11 also may not have worked is because I didn't allow flet to have access to my private network so some things were blocked.

Anyways, I will finally be able to make some progress on the assigned issues starting tomorrow. Apologies for the delay.

Hi @flamesjames, are you still on this? If yes, do you need support?

@clstaudt - yes, apologies. I have been sick this week and haven't gotten much time to work on open source the past few days. I will try and make progress tomorrow.

@flamesjames Don't worry, was just wondering if you needed any support.

@clstaudt haven't found too much of a straight answer on how to easily change app icon and title, however, it seems flet released a pack command that might give the flexibility to accomplish what needs done here? Would you agree, or do you know of an alternate solution?

Here are the resources for flet pack command:

@flamesjames There are probably two separate tasks here:

  1. bundle the app into an executable together with an icon, using flet pack
  2. set an icon when running the app from the Python package (without flet pack / pyinstaller involved)

The first one can probably be done with the instructions you found.

This works for me for setting the icon on a macOS .app bundle:

โ•ฐโ”€ flet pack app/app.py --name Tuttle --icon app/assets/icon/macos/AppIcon.icns --product-name Tuttle --product-version 1.0  

Screenshot 2023-02-06 at 20 32 18

I am more curious about the second problem.

@clstaudt - gotcha, so focus on #2.. I've spent some time on this and not finding much helpful documentation at all.

On Stack Overflow, I've read that "You can't add a custom icon to a plain Python script, but if you convert it to a Windows executable using py2exe, you can specify icon resources to use for it."

On a post on one of the flet discussion boards, I read that "a favicon.png in the assets/ folder will be used." However, I tried adding this using the icon file in the project but no luck.

Also went thru a doc where a maintainer commented a method/example but unsuccessful with this as well.

Nothing helpful on the flet discussion boards either.. I am stuck on this as of now..

Thanks @flamesjames - how about raising this as an issue in the flet project? Flet is by no means finished and completely documented and this kind of feedback is important for getting it there.

@clstaudt - sure thing Christian, I have done so just now per flet-dev/flet#991. Thank you for the guidance! I will work on the other assigned issues while we await an update.

Thanks @flamesjames , part 1 we know how to do and part 2 is a missing feature in flet.