skinning directcheckbutton

Im having a problem skinning a directCheckButton.

import direct.directbase.DirectStart
from direct.gui.DirectGui import *
from pandac.PandaModules import *

geom = loader.loadModel('box')
indicator_geom = loader.loadModel('indicator')

button = DirectCheckButton(
	relief = None,
	boxRelief = None,
	geom = geom,
	indicator_geom = indicator_geom,
	parent = aspect2d,
	scale=0.4,
	command = None)

run()

This is what I get:

here are the files:
filedropper.com/directcheckbutton

EDIT: another not related question:
How do you set a command for a button AFTER its creation? I thought the method

commandFunc

was for that, but its not it.

here is how you change basically any (and all) configuration options specified at creation time:

button = DirectButton(command=myfirstFunc)
button['command'] = mysecondFunc

as you can see any options passed as parameters to directGui objects can be changed at run time

~powerpup118

Great, i forgot about it.

Any ideas about the skinning problem?

Okay, add DirectOptionMenu to my problem.

I cant skin that too.
If I pass a texture-card i made to the ‘geom’ parameter, then it will look as expected, but the clickable area is different and a lot bigger. Shouldn’t geom be responsible for that as well? And… what parameter do you use for skinning the options? They cover half of the screen now.

It looks to me like your geom and your indicator_geom aren’t matching up. It’s your responsibility to create these objects so that they match up together.

David

the archive I posted has the egg files, which were created with egg-texture-cards. I havent done anything special, “egg-texture-cards -o button.egg button.png”

I can’t download your archive from the link.

David

Thats the last time im using that hosting service.

FastFreeFileHosting.com/file/500 … n-zip.html

Sry for offtopic, but for sharing files, Dropbox and spideroak are excellent.
If you want to share files for other to see, spideroak is best, you can setup a folder, and application will sync and you get link which point to web mirror of that folder.

With dropbox, you have public folder, and there is python script that will make html page with links to everything else in public folder.

In both cases, other people get data from cloud.

if dropbox is so good why did it delete my file in less than a week? Even if its very rare thing its still enough for me to not use it again.
THe one i use now seems to work and its all i really need.

lets get back on topic.

Guys?

Ive uploaded it here after that: fastfreefilehosting.com/file/500 … n-zip.html

Add these :

button.indicator['text'] = '' # change the default asterisk text
button.indicator.guiItem.getStateDef(0).removeNode() # remove the indicator geom of the 0 state
# base.mouseWatcherNode.showRegions(render2d,'gui-popup',0)

About the incorrect Z pos, that’s because the default asterisk text’s bounds is added. To prevent it, pass indicator_text = ‘’ to the constructor, or just button.indicator.setZ(0) afterward.

What z pos? EDIT: Ok
The problem is this:

The line “button.indicator.guiItem.getStateDef(0).removeNode()” makes the custom indicator geom appear only in the correct state. I dont really get what it did, but at least thats fixed.
But the indicator still appears on the left from the button, as you see…

you’d see it clearly by doing :

geom.showTightBounds()
indicator.showTightBounds()

Right, the geom should cover the indicator too.

bb = button.bounds # LRBT
for i in range(4):
    bgc = button.stateNodePath[i].getChild(0)
    bgc.setSx(bb[1]-bb[0])
    bgc.setX(-.5*button.indicator['geom_scale'][0]-button['borderWidth'][0])

I dont think we understand each other :confused:
I dont want the geom to cover the indicator too, I want the indicator to be in the same place as the button, exactly like when it is not skinned:

I dont understand why i need to set this myself.

The space on the right is for the text.
If it’s not skinned, the button covers the indicator and text, so I did exactly that.

If you only want the geom to behave as the boxRelief instead :

for i in range(4):
    bgc = button.stateNodePath[i].getChild(0)
    bgc.setX(button.indicator.getX())

Yeah, but in my opinion if there is no text then it should look the same way as not skinned is.

Then it’s like this :

if button['text']:
   bb = button.bounds # LRBT
   sx = bb[1]-bb[0]
   px = -.5*button.indicator['geom_scale'][0]-button['borderWidth'][0]
   for i in range(4):
       bgc = button.stateNodePath[i].getChild(0)
       bgc.setSx(sx)
       bgc.setX(px)
else:
   button.indicator.setPos(0)
   button.bounds = Vec4(button.guiItem.getFrame())
   button.bounds.setX(button.indicator.bounds[0]-button.indicator['borderWidth'][0])
   button.guiItem.setFrame(button.bounds)

For changing text :

def newText(self,newText):
    self['text'] = newText
    for i in range(4):
        bgc = self.stateNodePath[i].getChild(0)
        bgc.clearTransform()
    self.resetFrameSize()
    if self['text']:
       bb = self.bounds # LRBT
       sx = bb[1]-bb[0]
       px = -.5*self.indicator['geom_scale'][0]-self['borderWidth'][0]
       for i in range(4):
           bgc = self.stateNodePath[i].getChild(0)
           bgc.setSx(sx)
           bgc.setX(px)
    else:
       self.indicator.setPos(0)
       self.bounds = Vec4(self.guiItem.getFrame())
       self.bounds.setX(self.indicator.bounds[0]-self.indicator['borderWidth'][0])
       self.guiItem.setFrame(self.bounds)
DirectCheckButton.newText = newText

Test code :

button.newText('text')

texts = ['', 'df3 9e9u', 'f0-k3e e-0k', 'fjsd9fd98']
def cycleButtonText(t):
    texts.insert(0,texts.pop())
    button.newText(texts[0])
    return t.again
taskMgr.doMethodLater(2,cycleButtonText,'cycle')

thats more like it.

import direct.directbase.DirectStart
from direct.gui.DirectGui import *
from pandac.PandaModules import *

geom = loader.loadModel('button')
indicator = loader.loadModel('indicator')

button = DirectCheckButton(
	relief = None,
	boxRelief = None,
	geom = geom,
	indicator_geom = indicator)

button.indicator.setPos(0)
button.bounds = Vec4(button.guiItem.getFrame())

button.indicator['text'] = '' # change the default asterisk text
button.indicator.guiItem.getStateDef(0).removeNode() # remove the indicator geom of the 0 state

run()

How this little stuff of checkbutton work confuse me a bit. Can I ask for this to be a feature request so panda does this automatically?