Well, this will be a really noobish question. But hey i am a noob
I dont understand why the background turns to red before i click the button in the following code. Can anyone please explain.
import direct.directbase.DirectStart
#from pandac.PandaModules import Fog
from pandac.PandaModules import TextNode
from direct.gui.DirectGui import *
from direct.gui.OnscreenText import OnscreenText
from direct.showbase.DirectObject import DirectObject
#from direct.interval.MetaInterval import Sequence
#from direct.interval.LerpInterval import LerpFunc
#from direct.interval.FunctionInterval import Func
import sys
font = loader.loadFont("cmss12")
def genLabelText(text, i):
return OnscreenText(text = text,
pos = (-1.3, 0.95-0.05*i),
fg = (1,1,0,1),
align = TextNode.ALeft,
scale = .05,
font = font)
def guiButton(lbl, px, py, pz, cmd):
return DirectButton(text = (lbl),
pos = (px, py, pz),
scale = 0.1,
command = cmd)
class world(DirectObject):
def __init__(self):
base.setFrameRateMeter(True)
self.titleText = genLabelText("TEST PROGRAM", 0)
self.escapeText = genLabelText("ESC: Quit", 1)
self.keys = {"incR" : 0, "incG": 0, "incB": 0}
self.accept('escape', sys.exit)
self.accept('r', self.setKey, ["incR", 1])
self.accept('r-up', self.setKey, ["incR", 0])
self.accept('g', self.setKey, ["incG", 1])
self.accept('g-up', self.setKey, ["incG", 0])
self.accept('b', self.setKey, ["incB", 1])
self.accept('b-up', self.setKey, ["incB", 0])
#if self.keys["incR"]:
#r += .1
#base.setBackgroundColor(r, 0, 0)
guiButton("EXIT", -1.0, 0.0, 0.0, sys.exit)
guiButton("RED", -1.0, 0.0, 0.4, base.setBackgroundColor(1, 0, 0))
def setKey(self, key, val): self.keys[key] = val
w = world()
run()
Also, i am using PyPE and it gives me a warning as follows, could you also explain why Interval already exists and why it adjusts the clock: