DirectCheckButton error - need help

I’m creating a menu for an app that I am making. Currently I have one checkbutton and one regular button in it. The issue is, if I do not physically click on the checkbutton then I get this error: Traceback (most recent call last):
File “C:\Panda3D-1.8.1\direct\showbase\EventManager.py”, line 61, in eventLoopTask
self.doEvents()
File “C:\Panda3D-1.8.1\direct\showbase\EventManager.py”, line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File “C:\Panda3D-1.8.1\direct\showbase\EventManager.py”, line 122, in processEvent
messenger.send(eventName, paramList)
File “C:\Panda3D-1.8.1\direct\showbase\Messenger.py”, line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File “C:\Panda3D-1.8.1\direct\showbase\Messenger.py”, line 482, in __dispatch
method ((extraArgs + sentArgs))
File “C:\Panda3D-1.8.1\direct\gui\DirectButton.py”, line 103, in commandFunc
apply(self[‘command’], self[‘extraArgs’])
File “SeC1.py”, line 47, in killMenu
if self.loadWOFscreen == True:
AttributeError: myapp instance has no attribute ‘loadWOFscreen’
:task(error): Exception occurred in PythonTask eventManager
Traceback (most recent call last):
File “SeC1.py”, line 72, in
app.run()
File “C:\Panda3D-1.8.1\direct\showbase\ShowBase.py”, line 2921, in run
self.taskMgr.run()
File “C:\Panda3D-1.8.1\direct\task\Task.py”, line 502, in run
self.step()
File “C:\Panda3D-1.8.1\direct\task\Task.py”, line 460, in step
self.mgr.poll()
File “C:\Panda3D-1.8.1\direct\showbase\EventManager.py”, line 61, in eventLoopTask
self.doEvents()
File “C:\Panda3D-1.8.1\direct\showbase\EventManager.py”, line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File “C:\Panda3D-1.8.1\direct\showbase\EventManager.py”, line 122, in processEvent
messenger.send(eventName, paramList)
File “C:\Panda3D-1.8.1\direct\showbase\Messenger.py”, line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File “C:\Panda3D-1.8.1\direct\showbase\Messenger.py”, line 482, in __dispatch
method (
(extraArgs + sentArgs))
File “C:\Panda3D-1.8.1\direct\gui\DirectButton.py”, line 103, in commandFunc
apply(self[‘command’], self[‘extraArgs’])
File “SeC1.py”, line 47, in killMenu
if self.loadWOFscreen == True:
AttributeError: myapp instance has no attribute ‘loadWOFscreen’

Exit code: 1

If I do click on it, everything works like I think it should. I have even tried enabling an indicatorValue for it, thinking that would give the checkbutton focus, but it didn’t. I’ll put my code in the next post.

from direct.gui.DirectGui import *
from direct.showbase.ShowBase import ShowBase
from direct.gui.OnscreenText import OnscreenText 
from panda3d.core import *
from direct.interval.LerpInterval import LerpPosInterval


text1 =""

class myapp(ShowBase):     
    def __init__(self):
	ShowBase.__init__(self)         
	self.frame = DirectFrame(image = 'cmclogo.png', parent=render2d)
	self.quitButton = DirectButton(text="OK", scale=0.1, pos=(0.85,0,-0.95), command=self.killMenu)
        self.checkbutton = DirectCheckButton(text = "CheckButton" ,pos=(0.6,0,-0.95), scale=.05,command=self.setText, indicatorValue = 1)
	
 
	# Callback function to set  text 
    def setText(self, status):
	
		
	if(status):
		self.loadWOFscreen = True
				
	else:
		self.loadWOFscreen = False
	
	
	#self.textObject =  OnscreenText(text=str(text1), style=1, fg=(0,0,0,1),
                       #pos=(1,-0.75), align=TextNode.ARight, scale = .07)
	

    def killMenu(self):
	
	self.frame.destroy()
	self.quitButton.destroy()
	self.checkbutton.destroy()
	
	
	if self.loadWOFscreen == True:
		self.loadscreen()
	
	else:
		self.startApp()
	
    def loadscreen (self):
	#sets a background image.  parent=render2d makes the image the same size as the window
	self.background = OnscreenImage(image = 'tex/WheelofSafety.png', parent=render2d)
	
    def startApp(self):
	
	
	self.footBall = loader.loadModel('models/football')  #load the object
	self.footBall.setPos(0,5,0)    				#set the position
	self.footBall.setHpr(0,90,0)				#set rotation
	self.footBall.setScale(2,2,2)				#set scale
	self.footBall.reparentTo(render)                      #reparent to render
	
	LerpPosInterval(base.camera, 5, Point3(0, -10, 2)).start()
		


     
app = myapp()
app.run()

Thanks for any help

It looks like you simply forgot to initialize self.loadWOFscreen in myapp.init.

The way it is now, it is initialized in setText when you click the checkbutton for the first time.
That’s why you get that error when killMenu is called (by clicking the quit button) before clicking the checkbutton at least once.

Wow. That was a simple mistake. Thanks for the help. Still learning Python and Panda.