show image in pyvcp widget
- fery15sty
- Offline
- Senior Member
Less
More
- Posts: 79
- Thank you received: 9
03 Apr 2023 09:08 - 03 Apr 2023 09:11 #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>
#######
Last edit: 03 Apr 2023 09:11 by fery15sty.
Please Log in or Create an account to join the conversation.
- MaHa
- Offline
- Platinum Member
Less
More
- Posts: 394
- Thank you received: 156
03 Apr 2023 10:16 #268158
by MaHa
Replied by MaHa on topic show image in pyvcp widget
Thats from my panel, toggle between 2 gifs, controlled by selectimag0
<image name="sof" file="sof.gif"/>
<image name="son" file="son.gif"/>
<image_u32 halpin="selectimag0" images="sof son"/>
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- fery15sty
- Offline
- Senior Member
Less
More
- Posts: 79
- Thank you received: 9
03 Apr 2023 21:26 #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 or Create an account to join the conversation.
- fery15sty
- Offline
- Senior Member
Less
More
- Posts: 79
- Thank you received: 9
04 Apr 2023 01:31 #268220
by fery15sty
Replied by fery15sty on topic show image in pyvcp widget
I've tried and error like this
Please Log in or Create an account to join the conversation.
Time to create page: 0.054 seconds