Skip to content
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

Image View in Box #1923

Closed
KyucraftV2 opened this issue May 2, 2023 · 2 comments · Fixed by #1956
Closed

Image View in Box #1923

KyucraftV2 opened this issue May 2, 2023 · 2 comments · Fixed by #1956
Labels
bug A crash or error in behavior.

Comments

@KyucraftV2
Copy link

Describe the bug

When you create an image_view, put this in a Box and put this box in main_window. The image doesnt appear.
I have this code :

#Testing add image
self.box1 = toga.Box(style=Pack(direction=COLUMN))
image = toga.Image(r"resources\img.png")
image_view = toga.ImageView(id='view1', image=image)
self.box1.add(image_view)
self.mainBox.add(self.box1)

#Create the main window
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = self.mainBox
self.main_window.show()

But if on the line self.mainBox.add(self.box1), I have self.mainBox.add(image_view), the image appear

Steps to reproduce

  1. Use the code
  2. Run the app
  3. See the image doesnt appear

Expected behavior

Normally the image needs to appear when its in a box like if the image is not in box.

Screenshots

No response

Environment

  • Operating System: Windows
  • Python version: 3.8
  • Software versions:
    • Briefcase: 0.3.14
    • Toga: 0.3.1

Logs


Additional context

No response

@KyucraftV2 KyucraftV2 added the bug A crash or error in behavior. label May 2, 2023
@freakboy3742
Copy link
Member

Thanks for the report.

I'm fairly certain this will turn out to be a layout issue. Image is a weird widget at present in that it doesn't enforce a minimum size constraint, so I suspect what is happening here is that the Image is collapsing to 0 size. I think the immediate workaround will be to add a fixed height and width (or a flex=1) to the style definition for the image; the longer term fix will be to ensure that there's a default intrinsic size derived by the size of the image itself.

@KyucraftV2
Copy link
Author

Okey thanks a lot, when i fix the height and width it works, but with the flex=1 it doesnt work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants