2

So I had it working, not sure what I changed but maybe someone else can take a peek and see where the error is.

here is the code the image is made and set to display in

def app_openfile(self, w, o, s):
    io_file = filedialog.askopenfilename()
    self.hex_data=Util.openFile(io_file)
    self.all_bin_data = Util.convertToBinary(self.hex_data)
    self.bin_data = self.all_bin_data
    ##infor bar call goes here
    self.bit_image = Util.makeImage(self.bin_data, w, o, s)
    print(self.bit_image.size)
    print(self.bit_image)
    self.photo = ImageTk.BitmapImage(self.bit_image, background='white')
    print(self.photo)
    self.binViewBox.create_image((0,0), image=self.photo, anchor=N)
    self.binViewBox.config(xscrollincrement=self.Scale,
                           yscrollincrement=self.Scale,
                           scrollregion=(0,
                                         0,
                                         math.ceil((int(w) * int(self.Scale))),
                                         math.ceil(len(self.binData)/int(w)* int(self.Scale))))

Now in the Util.makeimage bit, I have it set to show before it returns to verify it makes an image, and it does. But for some reason I haven't figured out yet, is why its now throwing this error.

_tkinter.TclError: image "pyimage11" doesn't exist

this is the return of the print statement before the exception is thrown

making image 1000 0 1

(1000, 96)

"PIL.Image.Image image mode=1 size=1000x96 at 0xE1ADD30"

pyimage11

EDIT:

this is an example what it should produce, but isn't pushed to the tkinter canvas

enter image description here

Update as of 08/14/2018

def app_openfile():
    io_file = filedialog.askopenfilename()
    h_data=Util.openFile(io_file)
    all_b_data = b_data = Util.convertToBinary(h_data)
    all_b_data = b_data = Util.convertToBinary(h_data)
    viewtest = Canvas(root, width=500, height=500,bd=0)
    bimage = Util.makeImage(b_data, 800, 0, 5)
    bimage = ImageTk.BitmapImage(bimage)
    viewtest.create_image((0,0), image=bimage)
app_openfile()
root = Tk()
root.wm_title('PyDMT')
root.resizable(width=True, height=True)
root.mainloop()

Took out the class stuff to see if that was the issue, but still throws error.

CaptObvious
  • 31
  • 1
  • 5
  • You should use PhotoImage instance as an image value. rather then using BitmapImage Also, you need to keep the reference of your image. im = Image.open(pathToImage) self.photo = ImageTk.PhotoImage(im) – jits_on_moon Jul 14 '18 at 12:10
  • Using BitmapImage because its type '1', this is to help with loading the size of the image, since many are quite large, and a normal Photoimage takes a long time for it to be created. The self.image, self.photo is used to keep reference. The image is made only from memory, there isn't a photo. The program pulls from files. – CaptObvious Jul 14 '18 at 12:20
  • I think this might be useful. https://stackoverflow.com/questions/20251161/tkinter-tclerror-image-pyimage3-doesnt-exist/20259317 – jits_on_moon Jul 14 '18 at 12:21
  • I am finding it seems to be with the .create_image bit. Thanks for the suggestions Mr J. – CaptObvious Jul 14 '18 at 12:41
  • I had also tried it with PhotoImage, pushes the same error. – CaptObvious Aug 13 '18 at 15:19

0 Answers0