image over button?

hi I’m trying to put an image over a button so i can select images an not buttons with text.
I don’t know why the button its always over the image.
here is my code:

 
import Blender
from Blender.BGL import*
from Blender.Draw import*
li=[1]
img=Blender.Image.Get("image.jpg")
if not img :
 img=Blender.Image.Load("//myRenderdir/image.jpg")
def dibujar() :
 
 PushButton("",98,50,50,img.getSize()[0],img.getSize()[1]) 
def event(evt, val):
  if (evt == ESCKEY):
    Exit()
    return
 
def bevent(evt):
 Draw()
 
Register(dibujar,event,bevent)

I’m just trying to do an image menu, so other solutions can work too.
thanks

Is this the only draw code you have? Right now I don’t see any calls to functions that would draw images.

If it is the only code, then you should probably add that.

If you have something to draw images then:

1.) Try reordering the calls to drawing functions so that the image is drawn last.

2.) I’ve had issues in the past where calls to BGL functions are evaluated before calls to draw functions, i.e. buttons seem to be drawn after all the user GL function calls. It could be the case with images as well, where no matter what, the image is drawn before buttons are drawn. If thats the case, it might not be possible to have the image drawn over the button. However, I’d try #1 before going down the road of trying to figure this out.

thanks forTe yes i deleted the call by accident because i deleted other things so the problem was easier to understand.:o

 
import Blender
from Blender.BGL import*
from Blender.Draw import*

img=Blender.Image.Load("//myRenderdir/image.jpg")
def dibujar() :
     PushButton("",1,50,50,img.getSize()[0],img.getSize()[1]) 
     Image(img, 50, 50)
def event(evt, val):
  if (evt == ESCKEY):
    Exit()
    return
def bevent(evt):
Draw()
Register(dibujar,event,bevent)

its like you say that the buttons are the last thing to draw, then i should be looking for another solution. I try but i couldn’t draw with BGL maybe with that you could draw after the buttons, but probably not.

OK here i have a solution

 
import Blender
from Blender.BGL import*
from Blender.Draw import*
img=Blender.Image.Load("//myRenderdir/image.jpg")
def dibujar() :
 Image(img, 50, 50)
def event(evt, val):
  if (evt == ESCKEY):
    Exit()
    return
  if(evt == LEFTMOUSE and val):
 pos=Blender.Window.GetMouseCoords() #mouse position
 coord=Blender.Window.GetScreenInfo()[2] # coordinates of the script area
 if(coord['vertices'][0]+50<pos[0] and coord['vertices'][0]+50+img.getSize()[0]>pos[0] and coord['vertices'][1]+50<pos[1] and coord['vertices'][1]+50+img.getSize()[1]>pos[1]):  #ask if you are inside the image area 
  print "inside"
 else:
  print "outside"
def bevent(evt):
 Draw()
 
Register(dibujar,event,bevent)

the only problem its that I’m using the GetScreenInfo() to get the coordinates of the script area, if you don’t add or remove areas you don’t have a problem and you have to guess what area you are in my case was the 3(that’s why coord=Blender.Window.GetScreenInfo()[2] ).
so somebody knows how to access the coordinates of the current area?

thanks

import Blender
from Blender.BGL import*
from Blender.Draw import*

img=Blender.Image.Load("//myRenderdir/image.jpg")

def dibujar() :
    Image(img, 50, 50)

def event(evt, val):
    if (evt == ESCKEY):
        Exit()
        return
    if(evt == LEFTMOUSE and val):
        pos=Blender.Window.GetMouseCoords() #mouse position
        id = Blender.Window.GetAreaID()
        for area in Blender.Window.GetScreenInfo():
            if area['id'] == id:
                coord = area['vertices']
        if(coord[0]+50<pos[0] and coord[0]+50+img.getSize()[0]>pos[0] and coord[1]+50<pos[1] and coord[1]+50+img.getSize()[1]>pos[1]):  #ask if you are inside the image area 
            print "inside"
        else:
            print "outside"

def bevent(evt):
    Draw()
 
Register(dibujar,event,bevent)

thank Crouch, i think that should work fine