An essential idea of object-oriented programming (and of programming in general) is that you need to keep references to objects you want to do things with.
For example, in your GameApp.build
method, you're creating an AnchorLayout
object, assign it to the root
local variable, and then add widgets to it through that local variable.
Your question seems to be, "how do I keep issuing commands to that object after the build
method has finished running?" I'm noticing an attempt to call root.clear_widgets()
in the clearWidgets
method, which of course doesn't work because root
is a local variable -- it has no existence outside of the method it's used in.
This is where object attributes come in. See, an object is a chunk of state that you can pass around in your program. You can add more state to any object you create. For example, in your launchScreenBtn
class's __init__
method, you're setting the anchor_x
, anchor_y
and size_hint
attributes of the instance being created. As long as you have a reference to a launchScreenBtn
instance, you can access those attributes (with e.g. my_lsbtn.anchor_x
), regardless of whether you're in a function/method.
So what you want to do is make use of that mechanism more. In your GameApp.build
method, you don't want to make root
a local variable: you want to make it an attribute instead (self.root = AnchorLayout()
). That way, in your clearwidgets
method, you can access it, calling self.root.clear_widgets()
.
Apply similar principles through the rest of your application: whenever you have something you'd like to keep manipulating after you've exited the method it's defined in, it's a sign you want to make it an attribute.
While you're at it, you should read a few tutorials on object-oriented programming, because it looks like your grasp of it is shaky. Start with the Python tutorial's section on classes: http://docs.python.org/2/tutorial/classes.html