I have been working with code examples (from the good people on this site) and I have been learning quite a bit about Python and becoming more comfortable with.
The program I am working on is being done in pieces, the GUI being really the primary area of problems thus far as I am unfamiliar with this aspect of programming.
The submitted code below is a merge of two sets of code. Allow me to explain what I am trying to achieve with this code (** this code is really only a test which I shall expand upon greatly if\ when it works):
I present a button where a player chooses to "play"; in this simple example, the button will initiate a RNG, which in turn will return a random value 1-52 (in this example, I am just allowing a return of one number for testing-- I already know the RNG works. My issue is that everything seems to work (including the IF test statement) but the display of final result (a single image from my working folder named "king_emp.GIF") does not occur, the loading of this image onto the canvas.
from Tkinter import * from random import* import random #=======================================def(s) def show_image2(): canvas1.create_image(50, 320, image=photo2) def shuffle(x): # random.shuffle(x) would be simpler for i in xrange(len(x)-1, 0, -1): #pick an element in x[:i+1] with which to exchange x[i] j = int(random.random() * (i+1)) x[i], x[j] = x[j], x[i] #print x # test canvas1.config(text=x)#  acts to choose only 1 of 52 image2 = "king_emp.GIF" #=======================================canvas set-up canvas1 = Tk() canvas1.title('Heart Test1') canvas1 = Label(canvas1, fg='pink', bg='purple') canvas1.grid(row=1, column=0, columnspan=4) #=======================================image handling #photo2 = PhotoImage(file=image2) #=======================================var & list for RNG x =  #1 test card #=======================================button(s) rng_button = Button(canvas1, text='Play??', fg='white', bg='black', command=(lambda: shuffle(x)) ) rng_button.grid(row=0, column=2) #=======================================test 1 if x == : #photo2 = PhotoImage(file=image2) # commented out for below test print 'Test for RNG sucessful.' #=======================================run canvas1.mainloop()
I am stuck at a point where I feel I am missing something that allows for display of this particular image.
Any help or comments would be greatly appreciated
Thank-you in advance.