How to fit url image size into eto WebView

Hi there!

I am using eto.forms.webview to display web images as a reference in my dialog. This works, but if the image is larger than the webview, I get scrollbars.
I am looking for a method to scale the content to the webview size, so you see the whole image fitted inside the webview with no scrollbars.

Can anyone help me out?


Hi @timcastelijn,

Maybe this gives you a few ideas:

import Eto
import Rhino
import System

def test_get_web_image(url):
        wc = System.Net.WebClient()
        bytes = wc.DownloadData(url)
        if bytes:
            ms = System.IO.MemoryStream(bytes)
            image = Eto.Drawing.Bitmap(ms)
            return image
        print("Unable to read web image.")
    return None
class test_dialog(Eto.Forms.Dialog[bool]):
    def __init__(self, image):
        self.Title = "Test"
        self.Padding = Eto.Drawing.Padding(5)
        self.Resizable = False
        image_view = Eto.Forms.ImageView()
        image_view.Image = image
        self.Content = image_view

def test_show_image(url):
    image = test_get_web_image(url)
    if not image:
        print("Unable to read web image.")
    dialog = test_dialog(image)
if( __name__ == "__main__" ):
    url = ""

– Dale

Hi @dale,

thanks! (again :grin:)