Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable space..functions..tkinter

Status
Not open for further replies.

jakecvb

Programmer
Joined
Aug 4, 2006
Messages
1
Location
US
I've looked over this code too mutch, and even whent and read the main python tutorial again, and I can't understand why this code dosen't work.

The Python docs claim that declaring a variable at the beginning of a function, or class to a entrnal value or function is how you reference the external function, class, or value in that sector of variable space. Understanding that, and the rest of the tutorial I tryed to make reference to a external object/class only to find the script wouldn't even initialize.

Help will be greatly appreciated!

The code:
Code:
import Tkinter
from Tkconstants import *
from VideoCapture import Device

cam = Device()
cam.saveSnapshot('image.gif', timestamp=3, boldfont=1)

def snapper(canvas,tk,photo):
    p = cam
    p.saveSnapshot('image.gif', timestamp=3, boldfont=1)
    photo=Tkinter.PhotoImage(file='image.gif')
    canvas.create_image(200, 250, image=photo)
          
def window(tk):
    global photo
    frame=Tkinter.Frame(tk,background='#333333')
    frame.pack()
    canvas=Tkinter.Canvas(frame,width=400,height=400,background='black')
    canvas.pack()
    photo=Tkinter.PhotoImage(file='image.gif')
    canvas.create_image(200, 250, image=photo)
    button=Tkinter.Button(frame, text="Exit", width=10, height=1, command=tk.destroy)
    button.pack(side=LEFT,padx=5)
    button1=Tkinter.Button(frame, text="Connect", width=10, height=1, command=tk.destroy)
    button1.pack(side=LEFT,padx=5)
    button2=Tkinter.Button(frame, text="Disconnect", width=10, height=1, command=tk.destroy)
    button2.pack(side=LEFT,padx=5)
    button3=Tkinter.Button(frame, text="Refresh", width=10, height=1)
    button3.bind("<button-1>", snapper(canvas,tk,photo))
    button3.pack(side=LEFT,padx=5)



root = Tkinter.Tk()
window(root)
root.mainloop()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top