tuttle-dev / tuttle

🪰 Tuttle - time and money management for freelancers
GNU General Public License v3.0
62 stars 12 forks source link

UI: Display app icon and title instead of flet #168

Closed clstaudt closed 1 year ago

clstaudt commented 1 year ago

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.

clstaudt commented 1 year ago

@flamesjames good first issue?

flamesjames commented 1 year ago

@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?

clstaudt commented 1 year ago

@flamesjames Yes, of the application window.

flamesjames commented 1 year ago

@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

clstaudt commented 1 year ago

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.

flamesjames commented 1 year ago

@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.

clstaudt commented 1 year ago

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

flamesjames commented 1 year ago

@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.

clstaudt commented 1 year ago

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

flamesjames commented 1 year ago

@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:

clstaudt commented 1 year ago

@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.

clstaudt commented 1 year ago

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.

flamesjames commented 1 year ago

@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..

clstaudt commented 1 year ago

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.

flamesjames commented 1 year ago

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

clstaudt commented 1 year ago

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