Button texture

Hi, I’m new in panda and I want to make good looking buttons for my GUI. But unfortunately, the texture i’d like to apply to them is scaled according to the scaling factor of the button. Additionally, the button is scaled according to the size of my panda3D Window. Hence, the pictures, which I add as texture doesn’t look good any more.

This leads me to two questions:
Can I give the button a fixed size, which will never change?
Can scale the button according the the texture which I applied? (Like: scale: 130x130 pixel)

I hope you can help me.

greets

There is also an other question I’d like to ask. How can a specify a function that gets called when the mouse rolls over a button, and leafs it again? I need this for turning specific flags on and off, just by rolling over the button.

greets

this is for your mouseover/out functions:

button.accept(button.guiItem.getEnterEvent(), yourFunctionMouseOver)
button.accept(button.guiItem.getExitEvent(),yourFunctionMouseOut)

set the frameSize:

b = DirectButton(text="bla")
b["frameSize"]=(-.2, .2, -.2, .2)

or just give the button an image of your desired size, then call

b.resetFrameSize()

and remove the image afterwards

b["image"]=None

to calculate the scale of the button for your desired pixelsize i used this:
(substitute 768.0 with your screenheight)

def calcImgScale(pixel):
     imgScale = pixel/768.0
     return imgScale
b["scale"] = calcImgScale(130,130)

you maybe have to resetFrameSize(), i am not sure

greets, kampfgnu