0

I'm using VS 2013 with PTVS an i want to press a button to call a function. But I'm beginner for python and WPF so I'm getting some trouble, so my class with my function is:

class VendasXML(object):
    def MakeXML(self) :
        offset = 0
        url = 'https://api.mercadolibre.com/orders/search?seller=' + AutenticacaoML["user_id"] + '&access_token=' + AutenticacaoML["access_token"] + '&offset=' + str(offset)
        response = urllib2.urlopen(url)
        b = response.read()

        bjson = json.loads(b)
        total = str(bjson['paging']['total'])
        limit = str(bjson['paging']['limit'])
        total = int(total)
        limit = int(limit)
        i = 0
        TotalRec = 0
        Totalt = 0

And my class MyWindow(Window):

class MyWindow(Window):
def __init__(self):
    wpf.LoadComponent(self, 'Metal_Goat_Manager.xaml')

def AtualizarXML(self, sender, e):
    Vendas = VendasXML()
    Vendas.MakeXML()

And i call the function in the WPF in the button tag:

<Button Click="AtualizarXML" x:Name="butao" Content="Button" Grid.Column="1" HorizontalAlignment="Left" Margin="519,79,-381,0" VerticalAlignment="Top" Width="371" Height="323"/>

But when I click the button to call the function i get this exception: enter image description here

What I must do to overcome this problem?

1 Answers1

0

I've find the solution:

def MakeXML(user) :
    offset = 0
    url = 'https://api.mercadolibre.com/orders/search?seller=' + user["user_id"] + '&access_token=' + user["access_token"] + '&offset=' + str(offset)
    print(url)
    response = urllib2.urlopen(url)
    b = response.read()
    print(b)

    bjson = json.loads(b)
    total = str(bjson['paging']['total'])
    limit = str(bjson['paging']['limit'])
    total = int(total)
    limit = int(limit)
    i = 0
    TotalRec = 0
    Totalt = 0

and:

def AtualizarXML(self, sender, e):
    MakeXML(AutenticacaoML())