Hello everyone. Sorry in advance for the long post. I am fairly new to Panda, some friends and I have just started learning it. My goal right now is to try and figure out part of the GUI functions, and make a menu.
So far I have a multi-level menu structure, and haven’t run into any real issues. What I was wanting to know though is if it’s possible to have dynamic text as part of a DirectLabel. I already have this working with OnscreenText. However, I was hoping to get it working with DirectLabel because I prefer the visual options available through it, and also just want to know if it’s possible.
What I am trying to do is simply display the value of a slider next to it.
Here is a snippet from my menu with the working OnscreenText:
self.psRedValue = OnscreenText(parent = self.psmRedSlider,
font = self.menuFont,
fg = (0, 0, 0, 1),
bg = (1, 1, 0.4, 1),
scale = 0.18,
pos = (1.3, 0, 0),
mayChange = True)
taskMgr.add(self.PSSliderValueTask, 'PSSliderValueTask')
def PSSliderValueTask(self, task):
self.psRedValue.setText(str(int(self.psmRedSlider['value'] * 100)))
return task.cont
And here is the snippet of my attempt with DirectLabel (I also tried using text_mayChange = True):
self.psRedValue = DirectLabel(parent = self.psmRedSlider,
text_font = self.menuFont,
text_fg = (0, 0, 0, 1),
frameSize = (-0.7, 0.7, -0.5, 0.7),
frameColor = (1, 1, 0.4, 1),
scale = 0.18,
pos = (self.psmRedSlider, 1.3, 0, 0),
textMayChange = 1)
taskMgr.add(self.PSSliderValueTask, 'PSSliderValueTask')
def PSSliderValueTask(self, task):
self.psRedValue(text = (str(int(self.psmRedSlider['value'] * 100))))
return task.cont
The error I am getting is:
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
Type "help", "copyright", "credits" or "license" for more information.
>>> [evaluate Menu.py]
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
:task(error): Exception occurred in PythonTask PSSliderValueTask
Traceback (most recent call last):
File "<wingdb_compile>", line 148, in PSSliderValueTask
TypeError: 'DirectLabel' object is not callable
TypeError: 'DirectLabel' object is not callable
>>>
I also tried using DirectLabel with the setText command and recieved this error instead.
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
Type "help", "copyright", "credits" or "license" for more information.
>>> [evaluate Menu.py]
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
:task(error): Exception occurred in PythonTask PSSliderValueTask
Traceback (most recent call last):
File "<wingdb_compile>", line 148, in PSSliderValueTask
TypeError: setText() takes exactly 1 argument (2 given)
TypeError: setText() takes exactly 1 argument (2 given)
>>>
I tried searcing on the forums but couldn’t find anything related to this. So I’m not sure if I’m stuck using OnscreenText or if someone can point out a way to get this working with DirectLabel.
I only have some basic scripting experience from making some very simple game mods, so any help would be appreciated.