MyreMylar / pygame_gui

A GUI system for pygame.
MIT License
698 stars 83 forks source link

Pyinstaller not getting the hook file? #236

Closed fregapple closed 2 years ago

fregapple commented 2 years ago

Hi there,

I am trying to package with pyinstaller. If I add the data like this: ('C:/Users/user/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/site-packages/pygame_gui/data', 'pygame_gui/data'),

Then pyinstaller picks up the data files EG default theme and fonts. but if I use:

a.datas += Tree('data', prefix='data')

Then I get the error: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'data'. I think pyinstaller is not recognising the hook file.. Or am I meant to put the hook file into the pyinstaller directory?

MyreMylar commented 2 years ago

data there is your apps data directory, not pygame_gui's.

If you don't have one, don't add it.

On Tue, 18 Jan 2022, 07:22 fregapple, @.***> wrote:

Hi there,

I am trying to package with pyinstaller. If I add the data like this: ('C:/Users/user/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/site-packages/pygame_gui/data', 'pygame_gui/data'),

Then pyinstaller picks up the data files EG default theme and fonts. but if I use:

a.datas += Tree('data', prefix='data')

Then I get the error: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'data'. I think pyinstaller is not recognising the hook file.. Or am I meant to put the hook file into the pyinstaller directory?

— Reply to this email directly, view it on GitHub https://github.com/MyreMylar/pygame_gui/issues/236, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDGGUBI2AR5HJNWEX3YB3UWUIMVANCNFSM5MGMVYNQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

fregapple commented 2 years ago

if I remove the line a.datas etc then I still can't package with pyinstaller. I get default.json not available.

image This solution works and I can package fine. However you stated below his solution that you have now included a hook. But it doesn't seem to grab it. For me at least.

MyreMylar commented 2 years ago

At work this week so can't debug it for you.

Pretty sure it worked with the example pyinstaller project in pygame_gui_examples, so I'd start there and see if that works for you. If you link up a GitHub page at the weekend I might be able to take a look.

On Tue, 18 Jan 2022, 08:00 fregapple, @.***> wrote:

if I remove the line a.datas etc then I still can't package with pyinstaller. I get default.json not available.

[image: image] https://user-images.githubusercontent.com/82219216/149894831-9b76a8d8-c54e-458b-986e-33d41866f4b4.png This solution works and I can package fine. However you stated below his solution that you have now included a hook. But it doesn't seem to grab it. For me at least.

— Reply to this email directly, view it on GitHub https://github.com/MyreMylar/pygame_gui/issues/236#issuecomment-1015155381, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDGGRFUQE2FZDHAGWCKVTUWUMYJANCNFSM5MGMVYNQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

fregapple commented 2 years ago

Thanks, if you feel up to it: https://github.com/fregapple/py_retro-Frontend - this is what I am working on currently follow the readME to get all the code together before trying to run the install.py. You'll have to remove: image from the spec file as that links the gui folder manually.

MyreMylar commented 2 years ago

I found the bug and released 0.6.1 to fix it. Upgrade to 0.6.1 and it should now work again 👍

a line was out of place in setup.cfg :)

fregapple commented 2 years ago

I'll give it a shot right now!

fregapple commented 2 years ago

I have tried again and it runs into the same issue. I will try it on a different python version.

I run into: image here is my addition: image

MyreMylar commented 2 years ago

I assume this is a pyinstaller building error?

As I mentioned above for that line in your spec file to work you need a data directory in the root of your project. If you don't have any custom data (your own fonts, images or sounds) then you shouldn't need it.

The hook files with data (e.g. pygame, pygame_gui) all have their own version of this line that should be added automatically.

If it all builds correct in no-one file mode you will see subdirectories in your dist/project name directory for pygame and pygame_gui with their respective data files inside.

On Thu, 20 Jan 2022, 07:15 fregapple, @.***> wrote:

I have tried again and it runs into the same issue. I will try it on a different python version.

I run into: [image: image] https://user-images.githubusercontent.com/82219216/150291027-cfb4e2f5-a139-4b84-b5f4-b93602cc76c5.png here is my addition: [image: image] https://user-images.githubusercontent.com/82219216/150291050-6e8744f8-80bf-44f4-bca3-eb9bce787ef1.png

— Reply to this email directly, view it on GitHub https://github.com/MyreMylar/pygame_gui/issues/236#issuecomment-1017183179, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDGGT5ESGCMX3E5STNINLUW6ZBZANCNFSM5MGMVYNQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

fregapple commented 2 years ago

Thankyou.

Separate question. I am looking at putting images onto my buttons, but would like it to take the entire button and then scale with the button.

adding "sub_surface_rect": "0,0,0,0" in the theme file for the hovered image, has it blow up past the buttons dimensions at it's original size, which is quite big. Can it scale depending on the button size? or is this not implemented yet?

fregapple commented 2 years ago

Hey! I know your busy, and this is just a very beginner question. Just want to know if possible, otherwise I’ll just use my own button class!

And close this issue

MyreMylar commented 2 years ago

Oh hello, sorry I missed this.

Currently there is no theming controls for images (so no scaling or positioning) they are just always centred at their original scale. These controls will come in some future update (there are several issues about images on UIElements)

fregapple commented 2 years ago

No stress! I see, is there perhaps a way the manager can read a theme from within the script, rather than a json file. That way I could make one that takes variables of images that I can convert to proper sizings based on screen resolution

MyreMylar commented 2 years ago

The easiest way to change/scale the images on the buttons yourself during the program would be to set the button.normal_image attribute (and the other button image state attributes - check the code in ui_button.py) to your rescaled image then call button.rebuild().

Minor hack and it won't let you reposition the image but should let you alter the surface data.

On Mon, 24 Jan 2022, 01:23 fregapple, @.***> wrote:

No stress! I see, is there perhaps a way the manager can read a theme from within the script, rather than a json file. That way I could make one that takes variables of images that I can convert to proper sizings based on screen resolution

— Reply to this email directly, view it on GitHub https://github.com/MyreMylar/pygame_gui/issues/236#issuecomment-1019628788, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDGGWJ4LVIGBJX3L4GSBDUXSS2DANCNFSM5MGMVYNQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

fregapple commented 2 years ago

No problems, I'll keep checking it out!

Thanks and will no doubt chat to you again!