# Using Classes in App module

**URL:** <https://forum.inductiveautomation.com/t/using-classes-in-app-module/7443>\
**Category:** Ignition\
**Created:** [October 21, 2013, 4:34pm UTC](https://forum.inductiveautomation.com/t/using-classes-in-app-module/7443 "2013-10-21T16:34:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RonInBako](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@RonInBako](https://forum.inductiveautomation.com/u/RonInBako)\
**Post date:** [October 21, 2013, 4:34pm UTC](https://forum.inductiveautomation.com/t/using-classes-in-app-module/7443/1 "2013-10-21T16:34:05Z")

</div>

I’m new to Ignition and Python. I’m using version 7.6.3 for x64 windows.  
I would like to understand the correct way to use class logic in scripting.

I created module app.logic with this code:

[code]class Angle():

angle = 88

def getAngle():  
import system,app  
return angle

def inst():  
import system,app  
instance = app.logic.Angle()  
return instance.getAngle()[/code]

I have a button with this ActionPerformed script:

`from app.logic import inst
from app.logic import Angle
angle = app.logic.inst()
event.source.parent.getComponent('Label 1').text = str(angle)
`

When I click the button I get the following error:

[code]Traceback (most recent call last):  
File “event:actionPerformed”, line 3, in   
File “module:app.logic”, line 12, in inst  
TypeError: getAngle() takes no arguments (1 given)

(stack trace removed)

Ignition v7.6.3 (b2013090513)  
Java: Sun Microsystems Inc. 1.6.0\_43  
[/code]

Not sure if I have imports in the right places, but hoping to get 88 to display on my label.  
Where have I gone wrong?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [October 21, 2013, 6:57pm UTC](https://forum.inductiveautomation.com/t/using-classes-in-app-module/7443/2 "2013-10-21T18:57:06Z")

</div>

Hi RonInBako,

Python methods take their object instance (usually named self) as their first argument.

Also, you have angle as a static variable, not an instance variable. Instance variables are create inside methods and static variables are created outside methods.

Try:

```auto
def getAngle(self):
    return Angle.angle
```

If you want the angle variable to be an instance variable then it is done like this:

[code]class Angle():  
def **init** (self):  
self.angle = 88   
def getAngle(self):  
return self.angle

def inst():  
import system,app  
instance = app.logic.Angle()  
return instance.getAngle()  
[/code]  
Nick

---

<div class="post-metadata">

**Author:** ![RonInBako](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@RonInBako](https://forum.inductiveautomation.com/u/RonInBako)\
**Post date:** [October 21, 2013, 11:22pm UTC](https://forum.inductiveautomation.com/t/using-classes-in-app-module/7443/3 "2013-10-21T23:22:27Z")

</div>

Thanks Nik, I needed to see Python Class rules in action.

Glad to know the distinction between a static and instance variable. I’m used to programming C++ and C#.
