PIL/tkinter - updating label image with button images

Discussion created by chilcone on Jan 15, 2014
Latest reply on Jan 16, 2014 by chilcone
I'm trying to implement my simple image viewer, where I have one main label and menubutton with three choices. Each of them creates different numbers of buttons with pictures inside them. I would like create one main label and then update its image with images on the buttons. So when I click on the first button with image, that image will appear on the label, then click second button and that second image will appear and so on. I've tried to create two functions one for creating label and updating its image and the second for getting current image on the button, but I wasn't able to do the second one correctly. If u don't understand anything just write me.
Appreciate your help. Here's the code:

    import Tkinter as tk
except ImportError:
    import tkinter as tk 

from functools import partial
from PIL import Image, ImageTk

class Halabala():
    def __init__(self):
        self.master = tk.Tk()
        self.master.geometry("1100x700") = ["pavuk1.gif", "pavuk2.gif", "pavuk3.gif"]
        self.pictures2 = ["cukor1.gif", "cukor2.gif", "cukor3.gif", "cukor4.gif", "cukor5.gif"]

        self.lists_images = []
        self.lists_images2 = []


        self.lists_labels = []

        #self.main_label = tk.Label(self.master, image = None).grid(row = 0, column = 0) 
        #image with original size 

        self.rbutton = tk.Menubutton(self.master, text = "Choose picture")
        self.picks2 = tk.Menu(self.rbutton)
        self.picks2.add_command(label = "Spider", command = partial(self.create_labels,3))
        self.picks2.add_command(label = "Sugar", command = partial(self.create_labels,5))
        self.rbutton.config(width = 30, bg = "white", bd = 5, relief = tk.RAISED) = 900, y = 30)

    def init_image_list(self):
        for i in
                picture =
                picture.thumbnail((130, 130))

        for i in self.pictures2:
                picture =
                picture.thumbnail((130, 130))

    def create_labels(self, num):

        for label in self.lists_labels:

        for i in range(num):
            if num == 3:
                but = tk.Button(self.master, image = self.lists_images[i]) #command = self.get_command
                but.grid(row = 2, column = i + 1) #label will be in the first row
                but = tk.Button(self.master, image = self.lists_images2[i])
                but.grid(row = 2, column = i + 1)

    #def get_command(self):
        #self.main_label = tk.Label(self.master, image = self.get_image).grid(row = 0, column = 0)

    #def get_image(self):
    # don't know how to get current image from button

myapp = Halabala()