- Posts: 85
- Thank you received: 0
show image in pyvcp widget
3 years 6 months ago #268156
by fery15sty
show image in pyvcp widget was created by fery15sty
Hello can help me..
Can anyone show the .xml code to display images on pyvcp_widget? In pyvcp_widget like this:
class pyvcp_image(_pyvcp_dummy):
all_images = {}
def __init__(self, master, pycomp, name, **kw):
self.all_images[name] = PhotoImage(name, kw, master)
class _pyvcp_image(Label):
def __init__(self, master, pycomp, images, halpin=None, **kw):
Label.__init__(self, master, **kw)
if isinstance(images, str): images = images.split()
self.images = images
if halpin == None:
halpin = "number."+str(pyvcp_number.n)
pyvcp_number.n += 1
self.halpin = halpin
self.value = 0
self.last = None
pycomp.newpin(halpin, self.pintype, HAL_IN)
def update(self, pycomp):
l = pycomp[self.halpin]
if l != self.last:
try:
self.configure(image=self.images[l])
except (IndexError, KeyError):
print("Unknown image #%d on %s" % (l, self.halpin), file=sys.stderr)
self.last = l
class pyvcp_image_bit(_pyvcp_image):
pintype = HAL_BIT
class pyvcp_image_u32(_pyvcp_image):
pintype = HAL_U32
I tried this but it didn't work
########
<image>
<images></images>
</image>
#######
Can anyone show the .xml code to display images on pyvcp_widget? In pyvcp_widget like this:
class pyvcp_image(_pyvcp_dummy):
all_images = {}
def __init__(self, master, pycomp, name, **kw):
self.all_images[name] = PhotoImage(name, kw, master)
class _pyvcp_image(Label):
def __init__(self, master, pycomp, images, halpin=None, **kw):
Label.__init__(self, master, **kw)
if isinstance(images, str): images = images.split()
self.images = images
if halpin == None:
halpin = "number."+str(pyvcp_number.n)
pyvcp_number.n += 1
self.halpin = halpin
self.value = 0
self.last = None
pycomp.newpin(halpin, self.pintype, HAL_IN)
def update(self, pycomp):
l = pycomp[self.halpin]
if l != self.last:
try:
self.configure(image=self.images[l])
except (IndexError, KeyError):
print("Unknown image #%d on %s" % (l, self.halpin), file=sys.stderr)
self.last = l
class pyvcp_image_bit(_pyvcp_image):
pintype = HAL_BIT
class pyvcp_image_u32(_pyvcp_image):
pintype = HAL_U32
I tried this but it didn't work
########
<image>
<images></images>
</image>
#######
Please Log in to join the conversation.
3 years 6 months ago #268158
by MaHa
Replied by MaHa on topic show image in pyvcp widget
Thats from my panel, toggle between 2 gifs, controlled by selectimag0
Code:
<image name="sof" file="sof.gif"/>
<image name="son" file="son.gif"/>
<image_u32 halpin="selectimag0" images="sof son"/>
Please Log in to join the conversation.
3 years 6 months ago #268202
by fery15sty
Replied by fery15sty on topic show image in pyvcp widget
its work in basic (classic) pyvcp panel, but not working in pyvcp widget panel.. I think in pyvcp widget panel use different syntax .xml code.
Please Log in to join the conversation.
Time to create page: 0.132 seconds
