toga icon indicating copy to clipboard operation
toga copied to clipboard

Add an API to set a background image on toga.Box

Open QiShanZhang opened this issue 2 years ago • 9 comments

What is the problem or limitation you are having?

I can't add background behind the box ,can you help me , tell me some skii or function can do that

Describe the solution you'd like

i dont know

Describe alternatives you've considered

thank you

Additional context

thank you

QiShanZhang avatar Mar 01 '23 04:03 QiShanZhang

Thanks for the suggestion; as you've noticed, there's no current API for this on toga.Box.

You might be able to implement this on a per-platform basis by accessing box._impl.native, and using the native APIs for each platform.

If we were to add this feature to Toga, we'd need to be able to set an image, as well as the position, tiling and stretch properties. The background-size, background-position and background-repeat CSS properties for a model API for what we would need to support.

One decision to be made is whether this should be implemented as a new styling feature in Pack, or a specific API entry point on toga.Box.

freakboy3742 avatar Mar 01 '23 04:03 freakboy3742

Thank you for your patience Is there has some skill can put box on the images? I want make a APP that on one image have some box you can input and then make respond , now the difficult is the image can't put behind the box.

QiShanZhang avatar Mar 01 '23 04:03 QiShanZhang

I don't really understand your description, but as long as you don't need anything to overlap the image, you can display it using the Image and ImageView APIs.

mhsmith avatar Mar 01 '23 09:03 mhsmith

thank you very much, i want make a textinput box and a button overlap the image,

QiShanZhang avatar Mar 01 '23 09:03 QiShanZhang

I don't really understand your description, but as long as you don't need anything to overlap the image, you can display it using the Image and ImageView APIs.

thank you very much, i want make a textinput box and a button overlap the image,

QiShanZhang avatar Mar 01 '23 09:03 QiShanZhang

OK, in that case I don't have any other suggestions except what @freakboy3742 posted above.

mhsmith avatar Mar 01 '23 09:03 mhsmith

OK, in that case I don't have any other suggestions except what @freakboy3742 posted above. Do you know how to use the box._impl.native , i can't

QiShanZhang avatar Mar 01 '23 09:03 QiShanZhang

As you can see byprinting it, the native object will be whatever widget your platform uses to implement Toga's Box. Instructions for using that object can be found in the documentation for the underlying UI toolkit (GTK, Winforms, etc.). But this is outside of the scope of Toga's API, so unfortunately we don't have time to give detailed help.

mhsmith avatar Mar 01 '23 18:03 mhsmith

Just wanted to cast another vote for this.

Especially if also coming with the ability to have the image stretch when the window is resized. Would save a lot of headaches dealing with hacks to make this work now.

hyuri avatar Jan 04 '24 13:01 hyuri