Skip to content

Add "on_resize" to MainWindow #2304

Open
@hyuri

Description

@hyuri

What is the problem or limitation you are having?

I currently don't know when the window is getting resized, so I can't make adaptive decisions about how the content is being displayed unless I keep a background task continually "manually" checking. Example:

async def update_background_image(self, app, **kwargs):
	while True:
		if self.main_window.size[0] != self.background_image.width:
			new_image_size = (self.main_window.size[0], self.background_image.height)
			scaled_image = self.background_image.resize(new_image_size)
			self.background_image_view.image = scaled_image

		await asyncio.sleep(1)

Describe the solution you'd like

An on_change method in MainWindow.

This way, I can specify a function to be called only when the window has changed.

Describe alternatives you've considered

  1. Keep doing it manually;
  2. For the exemplified use case, it would be better if I was able to tell the image to adopt the window's width (or its box's width), so I wouldn't have to do any resizing.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions