I have created a function that reads certain strings from a list.

The function should be displayed (or rather called) inside a frame created with tkinter.

My idea was to create the function as a method of the frame class (or maybe as a method of a label) and to call the method with a new instance. The result was, that the content is displayed in the console.

my code so far:

```
from Tkinter import *
root = Tk()

a = 1
b = -6
c = -5

def calc_x(y):
    x = 0
    if y == c:
        for i in range(1,len(data)):
            x = x + int(data[i][y])
            t = x/(len(data)-1)
        print str(t)+"%"
    else:
        for i in range(1,len(data)):
            x = x + int(data[i][y])
        print x 

class Fram(Frame):

    def __init__(self,tk,width,height):
        Frame.__init__(self,tk)
        self.config(width=width)
        self.config(height=height)
        self.config(bd=1)
        self.config(relief="solid")

square_frame = Fram(root,500,40).grid(row=0,column=0,padx=3,pady=3)

mainloop()

```

EDIT:

ok, thank you very much so far.
I added the "data" list as well as the souce URL.

How can I call the function with either of the variables (self.a/b/c) ?
When I create a instance of "Fram" it doesn't display the string.

```
from Tkinter import *
from urllib2 import *
import csv

root = Tk()

class Fram(Frame):

def __init__(self,tk,width,height):
    Frame.__init__(self,tk)
    self.config(width=width)
    self.config(height=height)
    self.config(bd=1)
    self.config(relief="solid")
    self.url = "http://data.nottinghamtravelwise.org.uk/parking.csv?noLocation=true?t=635509084580321642"
    self.webpage = urlopen(self.url)
    self.datareader = csv.reader(self.webpage.read().decode('utf-8').splitlines())
    self.data = list(self.datareader)
    self.a = 1
    self.b = -6
    self.c = -5
    self.value = self.calc_x(self.a)
    self.label = Label(self, text=self.value)
    self.label.pack()

def calc_x(self, y):
    x = 0
    if y == self.c:
        for i in range(1,len(data)):
            x = x + int(data[i][y])
            t = x/(len(data)-1)
        return str(t)+'%'
    else:
        for i in range(1,len(data)):
            x = x + int(data[i][y])
        return str(x)

```