The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Python
 slider in Origin
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cts18488

United Kingdom
83 Posts

Posted - 03/15/2023 :  4:53:38 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 2021b and Service Release (Select Help-->About Origin):
Operating System: Win 100 Ent

Is it possible to add a slider in Origin with Python coding? For example I have a 4x4 subplots and I want to control the background colour with the slider. If the slider is on 0 all the subplots to have transparent background. As the position of the slider moves, the corresponding subplot to change its background colour (to yellow for example)

Thank you.

cts18488

United Kingdom
83 Posts

Posted - 03/21/2023 :  4:08:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Can anyone tell me if this is achievable? Thank you!
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 03/21/2023 :  9:48:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This can be done if can call LT from Python which in turn call an Origin C function. See

https://my.originlab.com/forum/topic.asp?TOPIC_ID=46189


We currently don't have built-in GUI support in originpro package.

CP


Go to Top of Page

cts18488

United Kingdom
83 Posts

Posted - 03/27/2023 :  04:18:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Would it be possible to show me how to do this in Python? How to call LT and do the background modification using the slider?
quote:
Originally posted by cpyang

This can be done if can call LT from Python which in turn call an Origin C function. See

https://my.originlab.com/forum/topic.asp?TOPIC_ID=46189


We currently don't have built-in GUI support in originpro package.

CP




Go to Top of Page

YimingChen

1618 Posts

Posted - 03/27/2023 :  11:26:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You could install the Python package tinker to create the slider.
https://www.originlab.com/doc/python/Python-Packages#Using_the_Python_Packages_Tool

Try the sample script below:

from tkinter import *
import originpro as op

def update(event):
    gl = op.find_graph()[0]
    gl.set_int("TRANSPARENCY", event)   

parent = Tk()
parent.geometry("520x80")
sli1 = Scale(parent, from_=0, to=100, tickinterval=25, length= 500, orient=HORIZONTAL, command=update)
sli1.pack()
mainloop()




James

Edited by - YimingChen on 03/27/2023 11:42:54 AM
Go to Top of Page

YimingChen

1618 Posts

Posted - 03/30/2023 :  1:04:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is the example code to change the layer background through a slider.

from tkinter import *
import originpro as op

def update(event):
    global prev
    gl = op.find_graph()[prev]
    gl.set_int("TRANSPARENCY", 100) 
    
    cur = int(event) - 1
    gl = op.find_graph()[cur]
    gl.set_int("TRANSPARENCY", 0)   
    prev = cur
    
prev = 0
parent = Tk()
parent.geometry("520x80")
sli1 = Scale(parent, from_=0, to=16, tickinterval=4, length= 500, orient=HORIZONTAL, command=update)
sli1.pack()
mainloop()



https://my.originlab.com/ftp/forum_and_kbase/Images/changeBackground.opju

James

Edited by - YimingChen on 03/30/2023 1:05:14 PM
Go to Top of Page

YimingChen

1618 Posts

Posted - 03/30/2023 :  2:16:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is another example to adjust the contour colormap transparency. To try the script, please install the 2023b beta version.


from tkinter import *
import originpro as op

def update1(event):
    gl = op.find_graph()[0]
    gl.set_int("cmap.transparency", event)
    
def update2(event):
    gl = op.find_graph()[1]
    gl.set_int("cmap.transparency", event)
    
parent = Tk()
parent.geometry("220x120")
sli1 = Scale(parent, from_=0, to=100, tickinterval=20, length= 200, orient=HORIZONTAL, command=update1)
sli2 = Scale(parent, from_=0, to=100, tickinterval=20, length= 200, orient=HORIZONTAL, command=update2)

sli1.pack()
sli2.pack()
mainloop()




https://my.originlab.com/ftp/forum_and_kbase/Images/transparentContour.oggu

James
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000