Hello ,
the problem i'm facing is how to insert a cliquable image in a frame , i show the code :

def InterfaceDeps():

    global interf0   
    interf0 = Toplevel()
    interf0.geometry("500x400")
    interf0.title('             Test Data')

    f1 = Frame(interf0, bg="blue",  width=500, height=500)
    f1.pack( fill=X, expand=0)
#######  Image  #############
    imageinfo = Image.open("C:/Documents and Settings/Administrateur/Bureau/Python_tests/nvprojet/Info1.jpg") 
    imageinfo=imageinfo.resize((60,60),Image.BICUBIC)
    photoinfo = ImageTk.PhotoImage(imageinfo) 

    canvas = tk.Canvas(interf0 , width = imageinfo.size[0], height = imageinfo.size[1]) 
    canvas.create_image(0,0, anchor = tk.NW, image=photoinfo)
    canvas.place(x=180 , y= 180 )

#############################

    afficher = Button(interf0, text = "Afficher" )#, command = afficher)
    afficher.place( x=315, y=80 )

    inserer = Button(interf0, text = "Inserer" )#, command = insere)
    inserer.place( x=315, y=110 )

    modifier = Button(interf0, text = "Modifier" ) #, command = modif)
    modifier.place( x=315, y=140 )

    supprimer = Button(interf0, text = "Supprimer" )#, command = afficheselected)
    supprimer.place( x=315, y=170 )

    Quitter = Button(interf0, text = "Quitter" , command = fquitter)
    Quitter.place( x=200, y=350 )

    interf0.after(0,center,interf0) 
    fenetre.withdraw()

Recommended Answers

All 6 Replies

The best you can do AFAIK is to bind the canvas to a button click and get the coordinates. You then check to see if the click was within the boundaries of the image. If you bind the Canvas object to a button click that calls the function clicked, the following will print the x,y coordinates. Also, the obvious, you can also attach an image to a button Click Here or a label. You can also get the coords() for the image and the bounding box Click Here

def clicked(event):
    print "image clicked", event.x, event.y

Hello woooee ,

Since yesterday i'm trying to execute my python scripts from the IDLE , it show :

IDLE's subprocess didn't make connection . Either IDLE can't start a subprocess or personal firewall software is blocking the connection

That means that you saved in your python folder (when using the ide) a file which is named tkinter.py or a file which name is the same with some original python file. Try looking into your python folder (i.e. C:\\Python273 or C:\\Python3.3) and find that file, and change its name.

Thank you for your answer Lucaci , but i don't understand what do you mean , and where to find the file tkinter.py ?

I'm saying that you might have saved a file in your Python folder called tkinger.py or a name which is of a file from Python. Your IDLE actually is a program wrote in Python throughout the tkinter api, so, if you do have a file called tkinter.py in your Python folder, the IDLE will try to load that file (for its subprocesses) thus trowing errors saying it's not the right file... It might by that, because I used to have the same trouble until I figured that out (had a file of my own called tkinter.py which IDLE loaded at each startup).

Hello again ,

The priority in my work actualy is about database and python , i used postgresql , and i want use mysql , this where i'm blocked .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.