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?
Thanks!
https://www.technischeunie.nl/images/artikel/4765186.gif ’
dale
(Dale Fugier)
July 27, 2022, 11:34pm
2
Hi @timcastelijn ,
Maybe this gives you a few ideas:
import Eto
import Rhino
import System
def test_get_web_image(url):
try:
wc = System.Net.WebClient()
bytes = wc.DownloadData(url)
if bytes:
ms = System.IO.MemoryStream(bytes)
image = Eto.Drawing.Bitmap(ms)
return image
except:
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.")
return
dialog = test_dialog(image)
dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
if( __name__ == "__main__" ):
url = "https://www.technischeunie.nl/images/artikel/4765186.gif"
test_show_image(url)
– Dale