Adding PNG image to a canvas in a window

More
17 Jan 2021 00:25 #195608 by Vmax549
Does anyone know how to add an PNG image to a canvas in a window ?? I have looked and tried everything I could find and no luck sp far. So I turn to the experts for help. I am working on creating Wizards for PathPilot and I need to be able to add an image to teh window as a reference of the process yo u will be working with.


(;-) TP
Attachments:

Please Log in or Create an account to join the conversation.

More
17 Jan 2021 01:16 #195615 by smgvbest
I have not done it but i would think it would be same as they do in PP for the conversational screens.

Have you looked at that code for an example?

Sandra

Please Log in or Create an account to join the conversation.

More
17 Jan 2021 01:49 #195621 by Vmax549
yes I have they do not use python windows to display their images. I am using Python Widows to display teh process and I wish to add an image to teh window through a canvas or through a large button, it doesnot matter which as long as it displays teh image.

I cannot get PP to respond to any code sample I have found on teh web. One should be able to add an gif image directly to a canvas as teh gif format is supported directly. Other formats suh as png or jpg have to be imported in from another program that you would have to install and import from.

Just tryng to keep it simple. (;-) TP

Please Log in or Create an account to join the conversation.

More
17 Jan 2021 22:38 #195715 by Vmax549
This is the code I am using to create teh Frame and canvas. When it gets to teh line to create the image it crashes. PP does not have a python editor so I do not know what the error message may be.

def createWidgets(self):
self.PreviewFrame = Frame(self,bd=5)
self.PreviewFrame.grid(row=0, column=0)
self.PreviewCanvas = Canvas(self.PreviewFrame,width=300, height=300, bg='black')
self.PreviewCanvas.grid(sticky=N+S+E+W)
self.img = PhotoImage(file='~/home/operator/tmc/configs/tormach_mill/nc_subs/cncporting.gif')
#self.PreviewCanvas.create_image(250,250, image=img)

Please Log in or Create an account to join the conversation.

More
17 Jan 2021 23:09 #195719 by Vmax549
OK I just remembered that I shouod be getting an error message in PP logfile and yes it was there. It said cannot open file,path or file not found.

I am sure it is there and I have tried many variants to the path. So back to work.

(;-) TP

Please Log in or Create an account to join the conversation.

More
18 Jan 2021 00:33 #195732 by crowloy
thinking that ~ in the path might be an issue. ~/home/operator doesn't make sense. ~/tmc would or just removing the ~

Please Log in or Create an account to join the conversation.

More
18 Jan 2021 01:51 #195740 by Vmax549
You are correct on teh pathing. I just had the app open when the email signaled me. I tried it your way and it now works. I guess I need to work on understanding linux pathing (;-)

Everything Wizard is looking better now. Just working on getting the datetime from python and displaying it in teh gcode

ThankYou very much, (;-) TP

Please Log in or Create an account to join the conversation.

More
19 Jan 2021 01:44 - 19 Jan 2021 01:47 #195855 by smgvbest
This line is in error
self.img = PhotoImage(file='~/home/operator/tmc/configs/tormach_mill/nc_subs/cncporting.gif')

what that is saying is you image in in
/home/operator/home/operator/tmc/configs/tormach_mill/nc_subs/cncporting.gif
That's because ~ is your home directory

so it should be
self.img = PhotoImage(file='~/tmc/configs/tormach_mill/nc_subs/cncporting.gif')

a few more path entries are

. (a single period) is the current directory
.. (two periods) is one direct up from where you are
~, $HOME both refer to your home directory
Last edit: 19 Jan 2021 01:47 by smgvbest.

Please Log in or Create an account to join the conversation.

Moderators: cncbasher
Time to create page: 0.091 seconds
Powered by Kunena Forum