Eto ImageView help

Hello I have some problem in a simple Eto dynamic layout…

I want to add a picture stored in my computer in a Row and I make a mistake somewhere to retrieve and store the file using forms.ImageView…need help

Here is the part of the DynamicLayout:

# Create layout
        layout = forms.DynamicLayout()
        layout.Padding = drawing.Padding(5)
        layout.Spacing = drawing.Size(5, 5)
        layout.AddRow(self.ImageLogo())
        self.Content = layout

def ImageLogo()
        self.ImageLogo = forms.ImageView()
        self.ImageLogo.Size = drawing.Size(400, 200)
        self.ImageLogo.Image = drawing.Bitmap("C:\Users\Antoine\LOGO.png")

But I do not understand where to place or write the path to store it as ImageLogo…
PNG is maybe the problem?..

Thanks for your help

Hi,
The problem is the incorrect image path format.

def ImageLogo(self):
    self.ImageLogo = forms.ImageView()
    self.ImageLogo.Size = drawing.Size(400, 200)

    try:
        image_path = r"C:\Users\Antoine\LOGO.png"  # Using raw string for path
        self.ImageLogo.Image = drawing.Bitmap(image_path)
    except Exception as e:
        print(f"Error loading image: {e}")

    return self.ImageLogo

Hope that helps !

Farouk

@farouk.serragedine

Thank you for your quick help it works now with the path, I also forgot to return.self.Imagelogo to store the value… lol

But My window opens, there is space for my picture… but nothing is visible… I changed with a .JPG image and it is still blank… but no code error…

Any idea?

Hi @antoine ,
Pay close attention to the filepath string

from Eto.Forms import Application, Form, ImageView, DynamicLayout
from Eto.Drawing import Bitmap, Padding, Size

class MyForm(Form):
    def __init__(self):
        self.initializeComponents()

    def initializeComponents(self):
        # Create layout
        layout = DynamicLayout()
        layout.Padding = Padding(5)
        layout.Spacing = Size(5, 5)
        layout.AddRow(self.createImageLogo())
        self.Content = layout

    def createImageLogo(self):
        imageLogo = ImageView()
        imageLogo.Size = Size(400, 200)
        # Use a raw string for the file path or replace \ with \\
        imageLogo.Image = Bitmap(r"C:\Users\admin\Pictures\auto\1.jpg")
        return imageLogo

def main():
    form = MyForm()
    form.Show()


if __name__ == '__main__':
    main()

This works just fine, make sure you use the correct filepath format.

Farouk

Another simple example:

import Eto
import Rhino

dialog = Rhino.UI.Forms.CommandDialog()
dialog.Size = Eto.Drawing.Size(800,600)
imageView = Eto.Forms.ImageView()
imageView.Image = Eto.Drawing.Bitmap(r"C:\Windows\System32\FeatureToastBulldogImg.png")
dialog.Content = imageView
dialog.ShowHelpButton = False
dialog.Resizable = True
dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)

– Dale

@farouk.serragedine @dale

Thank you for your help, one of my mistake was also to use both Pc and Mac and the \ / is the opposite on Mac for a path :slight_smile:

Maybe I have an other question, because I will use a simple form to fill user text on a project, but my was was to let this window active when working on rhino , I understand that the way is to pass ShowModal, to ShowSemiModal, to permit the window staying on top, but the way it works is complicated for me to understand, do you have maybe an example of a window working in SemiModal mode?

If I have any question on semimetal I will after create a new topic of course

Thanks a lot for your help