Example #1
0
 def refreshImgList(self, **kwargs):
     self.catalogue.getCatalogue()
     self.tkImgDict = {}
     self.tkGifDict = {}
     self.imgListBox = frontend.FancyListbox(self, selectmode=tk.SINGLE)
     for img in self.catalogue.images:
         PIL_img = Image.open(io.BytesIO(img.data))
         print(img.name, PIL_img.size, end=" ")
         PIL_img = PIL_img.resize(shrinkImg(PIL_img.size), Image.ANTIALIAS)
         print(PIL_img.size)
         CurrentTkImg = ImageTk.PhotoImage(PIL_img)
         self.tkImgDict[img.name] = CurrentTkImg
         self.imgListBox.insert(tk.END, img.name)
     for gif in self.catalogue.gifs:
         self.imgListBox.insert(tk.END, gif.name)
         self.tkGifDict[gif.name] = gif.frames
     self.imgListBox.config(highlightbackground=self.baseColor)
     self.imgListBox.grid(row=2, column=2, sticky="ew")
     self.imgListBox.pack_propagate(0)
     self.imgLabel = tk.Label(width=440, height=340, bg=self.baseColor)
     self.imgLabel.configure(highlightbackground=self.baseColor)
     self.imgLabel.grid(row=2, column=0)
     self.imgListBox.bind('<ButtonRelease-1>', self.showChosen)
     ImgName = kwargs.get("ImgName")
     if ImgName == None:
         ImgName = list(self.tkImgDict)[0]
     if ImgName in self.tkImgDict:
         self.imgLabel.config(image=self.tkImgDict[ImgName])
     elif ImgName in self.tkGifDict:
         self.gifDisplay = frontend.GIF(self.root, self.imgLabel, ImgName,
                                        self.tkGifDict[ImgName])
         self.gifDisplay.start()
Example #2
0
 def showChosen(self, *ignore):
     ImgName = self.imgListbox.get(self.imgListbox.curselection()[0])
     if ImgName in self.tkImgDict:
         self.imgLabel.config(image=self.tkImgDict[ImgName])
     elif ImgName in self.tkGifDict:
         self.gifDisplay = frontend.GIF(self.root, self.imgLabel, ImgName,
                                        self.tkGifDict[ImgName])
         self.gifDisplay.start()
Example #3
0
 def refreshImgList(self, **kwargs):
     self.tkImgDict = {}
     self.imgListBox = frontend.FancyListbox(self, selectmode=tk.SINGLE)
     try:
         MyImages = self.catalogue.getCatalogue()
     except:
         MyImages = []
         tk.Label(
             frame1,
             text=
             'Looks like you dont have any images yet.\n Maybe try adding some.',
             font='Helvetica 18 bold').pack()
     self.root.update()
     print("Root window: ", self.root.winfo_width(),
           self.root.winfo_height())
     for MyImage in MyImages:
         if type(MyImage) is backend.Catalogue.GIF:
             continue
         PIL_img = Image.open(io.BytesIO(MyImage.data))
         print(MyImage.name, PIL_img.size, end=" ")
         PIL_img = PIL_img.resize(shrinkImg(PIL_img.size), Image.ANTIALIAS)
         print(PIL_img.size)
         CurrentTkImg = ImageTk.PhotoImage(PIL_img)
         self.tkImgDict[MyImage.name] = CurrentTkImg
         self.imgListBox.insert(tk.END, MyImage.name)
     self.imgListBox.config(highlightbackground=self.baseColor)
     self.imgListBox.grid(row=2, column=2, sticky="ew")
     self.imgListBox.pack_propagate(0)
     self.imgLabel = tk.Label(width=440, height=340, bg=self.baseColor)
     self.imgLabel.configure(highlightbackground=self.baseColor)
     self.imgLabel.grid(row=2, column=0)
     self.imgListBox.bind('<ButtonRelease-1>', self.showChosen)
     ImgName = kwargs.get("ImgName")
     if ImgName == None:
         ImgName = list(self.tkImgDict)[0]
     if ImgName in self.tkImgDict:
         self.imgLabel.config(image=self.tkImgDict[ImgName])
     elif ImgName in self.tkGifDict:
         self.gifDisplay = frontend.GIF(self.root, self.imgLabel, ImgName,
                                        self.tkGifDict[ImgName])
         self.gifDisplay.start()
Example #4
0
 def refresh(self, **kwargs):
     #get list of gifs and images
     self.tkImgDict = {}
     self.tkGifDict = {}
     items = self.catalogue.getCatalogue()
     #self.imgListbox.delete(1.0, tk.END)
     for img in self.catalogue.images:
         self.imgListbox.insert(tk.END, img.name)
         PIL_img = Image.open(io.BytesIO(img.data))
         self.tkImgDict[img.name] = ImageTk.PhotoImage(
             (PIL_img).resize(shrinkImg(PIL_img.size), Image.ANTIALIAS))
     for gif in self.catalogue.gifs:
         self.imgListbox.insert(tk.END, img.name)
         self.tkGifDict[gif.name] = gif.frames
     #set imgLabel
     current = kwargs.get("current")
     if current == None:
         current = list(self.tkImgDict)[0]
     if current in self.tkImgDict:
         self.imgLabel.config(image=self.tkImgDict[current])
     elif current in self.tkGifDict:
         self.gifDisplay = frontend.GIF(self.root, self.imgLabel, current,
                                        self.tkGifDict[current])
         self.gifDisplay.start()