-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add theme options to place button images on button surface relative to button #145
Comments
OK, that's not the right way to add an image to a button. There are two approaches:
https://pygame-gui.readthedocs.io/en/latest/theme_reference/theme_button.html#images
I think that should work for most cases, but if you redraw the button for any reason you'll have to reset the dynamic image on it and it takes a few frames to load all the button states into memory so you might want have to handle that. Likely the easier approach is to stick to static images for most scenarios and just switch the button out to an identical one with the image on it if you want to add an image to it dynamically. Currently there is no extra support for more than one image on a button, aligning images on a button or any sort of animated series of images on a button. It's possible they might be added in the future but are not planned for the immediate future. |
Got this error |
here is my theme.json: { |
Usually we use relative paths from the working directory, so if
|
How to specifical image postion on a UIButton, if image rect is smaller than button's. |
Right now there is no way to set the position in the theming data, images are just always centred. It's something I would like to change eventually, along with support for multiple images on elements. The easiest approach right now, assuming the button is statically sized, would just be to pad the image itself with transparent pixels so it appears where you want in the final button. |
I am using icon for uidropdown in this way, and have to care for all states like expaned/closed/selected/normal... |
Describe the bug
I'm trying to draw a image on a button with .image or .set_image attributes but they neither works, with .image i have TypeError:
TypeError: 'pygame.Surface' object is not callable
To Reproduce
Steps to reproduce the behaviour:
Platform and software (please complete the following information):
Additional context
Code:
self.draw = pygame_gui.elements.UIButton(pygame.Rect((self.x, self.y), (150, 40)), self.text, self.manager,
None, self.text_tip)
self.draw.set_image(screen,'LVLUP.bmp')
or:
self.draw = pygame_gui.elements.UIButton(pygame.Rect((self.x, self.y), (150, 40)), self.text, self.manager,
None, self.text_tip)
self.draw.image(screen,'LVLUP.bmp')
The text was updated successfully, but these errors were encountered: