np=NodePath(…)
btn=PGButton(‘my_btn’)
btn.setup(np,np,np,np) #just for test
I expect the identic appearence in all button states, but in ‘rollover’ state button looks shaded. How to switch off internal behaviour (i want to see clear texture)?
So are you saying the problem is now solved and you understand what went wrong before, or are you saying the problem is still unsolved and showing a bit of code to reproduce it? (I can’t actually run that code without your egg and bmp file.)
The problem is your egg file, which defines the advanced texture property saved-result. Any advanced texture properties compel Panda to construct a special TextureStage for this texture instead of the default TextureStage.
Then, when you do model.setTexture(tex), you are applying your new texture on the default TextureStage, which accumulates with the existing texture instead of replacing it. That’s why it appears darker.
If you want to replace it, you should either find the existing TextureStage first, with:
No. DirectButton is a higher-level wrapper around the PGButton class. Obviously PGButton is also exposed to Python (otherwise DirectButton couldn’t exist).
Not sure what you’re asking. The only function call there with any meat in it is getRelativePoint(); the rest of it is all fluff which you don’t necessarily need. Are you asking how to eliminate the fluff, or are you asking if there is some other method than getRelativePoint()?
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
if __name__=='__main__':
from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
app=ShowBase('test_app')
class guiEntry(PGEntry, DirectObject):
def __init__(self):
PGEntry.__init__(self, 'test_entry')
DirectObject.__init__(self)
np=aspect2d.attachNewNode(self)
np.setPos(0,0,0)
if __name__=='__main__':
en=guiEntry()
en.setup (0.3, 1)
en.setFrame(0.0,0.5,0.0,0.4)
en.setBlinkRate (1.5)
en.setActive (1)
en.setFocus (1)
en.setMaxChars (100)
en.setState(en.SFocus)
fs=en.getFrameStyle(0)
fs.setType(fs.TFlat)
fs.setColor(0.2,0.7,0.7,1)
fs.setWidth(0.05,0.05)
en.setFrameStyle(0, fs)
''' # way 1
pgi_txt=en.getTextNode()
pgi_txt.setTextColor(0.9,0,0,1)
pgi_txt.setGlyphScale(0.2)
pgi_txt.setText('start')
en.addChild(pgi_txt)
''' # way 2
text_def=en.getTextDef (en.SFocus)
text_def.setGlyphScale(0.2) # no effect
en.setText('ggoo')
text_def.setText('ggoo')
text_def.setTextColor(0.9,0,0,1) # no effect
#NodePath(text_def).setPos(-0.4,0,0.4)
#en.addChild(text_def)
#'''
cr=TextNode('cursor')
cr.setText('<')
cr=NodePath(cr.generate())
cr.setScale(0.2)
str_end=len(en.getPlainText())
en.setCursorPosition (str_end)
en.getCursorDef().node().removeAllChildren()
cr.reparentTo(en.getCursorDef())
app.run()
Сan not set text properties (color, scale) through TeхtNodе obtained by PGEntry.getTextDef(0)/way1/ and TextNode obtained by PGItem.getTextNode() /way2/ is not processed by method PGEntry.getPlainText() (for example), PGEntry.getProperties() returns const object. Not yet used the font. How to set entry-text color, scale …in general, how to control it?
not obvious (
I called PGItem.getTextNode() without pre-initialization, and everything seems all right, using PGEntry.getTextDef(0).setText(’…’) and it is displayed (hence the object exists).
What is the purpose of the PGEntry.getProperties()? Only for copy?
I agree it’s not obvious, but you are mucking around with the low-level objects here, instead of using the high-level DirectEntry. Since you’re using low-level objects, you have to expect the occasional nonobvious interface; these objects weren’t really intended for direct manipulation by end-users.
PGEntry.getProperties() is read-only, and is intended for querying the properties at a particular character position in the string. This might be useful if embedded property changes are present within the string (e.g. for RTF input).