Change position of an image from a client timer scrip

Hi, i need yours help.

I’m new using this amazing software.

I want to change the position of an image from a client timer scrip… i can change from a boton with this example:

component = event.source.parent.getComponent('Image')
origX = component.x
origY = component.y
 
system.gui.transform(
    component,
    0, 0,
    duration=1000,
    callback=lambda: system.gui.transform(
        component,
        origX, origY,
        duration=1000,
        acceleration=system.gui.ACCL_FAST_TO_SLOW
    )
)

I understand what each means, but when I tried the same code in a scrip, It didn´t work.
Ignition show me
"SyntaxError: (“mismatched input “expecting DEDENT”, (”,22,1, ´/tsystem.gui.transform(/n´))

i want to assing then new position with a int var like:

system.gui.transform(
    component,
    int var x_1, int var_y_1
)

I can´t see the property position on “Vision property editor”. It´s easy do it with a Symbol factory but i Want with a image.

Sorry for my English.

Thanks for your help.

Use triple backticks to format your code in this forum

```

def example():
   pass

```

Like this to make it more readable. You have a syntax error so its really important for us to see your code as it actually is if we want a chance of being able to solve it.

Do It!! Thanks

I see the code you copied from documentation, where is your actual code?

I will say this - int var x_1, int var_y_1 will not work. You don’t declare types in python. You would have

x_1 = 0
y_1 = 0

system.gui.transform(
    component,
    x_1, y_1,
    ....
)

I have this:

newx = system.tag.readBlocking(["M_1"]).value
newy = system.tag.readBlocking(["M_2"]).value


    window = system.gui.getWindow("prueba")
    text_1 = window.rootContainer.getComponent("Image")

system.gui.transform(
    text_1,
   newx, newy,
    )

Try

system.gui.transform(
    text_1,
   newx, newy
    )

You don’t want a trailing comma if you are not going to feed an additional argument. If you do this do you get an error?

newx = system.tag.readBlocking(["M_1"]).value
newy = system.tag.readBlocking(["M_2"]).value

    window = system.gui.getWindow("prueba")
    text_1 = window.rootContainer.getComponent("Image")

system.gui.transform(
    text_1,
   newx, newy
    )

The same error continues:

"SyntaxError: (“mismatched input “expecting DEDENT”, (”,22,1, ´/tsystem.gui.transform(/n´))

Your code is indented exaclty like it is in this forum? Do this

newx = system.tag.readBlocking(["M_1"]).value
newy = system.tag.readBlocking(["M_2"]).value

window = system.gui.getWindow("prueba")
text_1 = window.rootContainer.getComponent("Image")

system.gui.transform(
    text_1,
   newx, newy
    )

Unlike other languages like Java which use { } to denote code blocks, python uses white spaces, so an indent is only used underneath control operators like an if statement.

if someCondition:
    print "I am indented and only run if someConditon is met"

print "I always run!"

Yes, it´s the same code.

the code is working in a push botton… but i need that the image will be in continuosly movement, so i copied the code to the client timer scrips, din´t work on the scrips

Maybe Do you know how Can I change the position´s image with the vision properties edit? why I can´t see the image´s position option?

Is something updating your M_1 M_2 tags? If they’re static, seems like the component will just be moved to that position once, and then just keep being placed to the same position. Can you post your entire code from your client script?

I don´t have other code line… it´s just that…

M_1 and M_2 are variables from a OPC server, in the tag Browser they are correctly, i can chance de value from the PLC or manually.

the Scrip didn´t compile

Ohh one other thing I should have caught.

newx = system.tag.readBlocking(["M_1"]).value
newy = system.tag.readBlocking(["M_2"]).value

Should be

newx = system.tag.readBlocking(["M_1"])[0].value
newy = system.tag.readBlocking(["M_2"])[0].value

because you get a list of values back.

1 Like

It´s woooorkiiiiiiiiiiiiiiiiing!!! it´s woooooorkin!!!

Thanks a lot… and I´m sorry for your time…

I´m learning use the Ignition so will be soon for the forum.

1 Like

No problem, and don’t worry, if I am posting on here, it is because I have the time lol.