如何在visualstudio2013中调用MyWindow(Window)类中的函数?

2024-09-27 21:33:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我用的是vs2013和PTVS,我想按一个按钮来调用一个函数。但我是python和WPF的初学者,所以遇到了一些麻烦,所以我的函数类是:

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

窗口和我的类:

^{pr2}$

我在WPF的button标记中调用函数:

^{3}$

当我点击这个按钮时,我调用了这个函数: enter image description here

我该怎么做才能克服这个问题?在


Tags: 函数tokenurlaccessresponse按钮offsetint
1条回答
网友
1楼 · 发布于 2024-09-27 21:33:58

我找到了解决办法:

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

以及:

^{pr2}$

相关问题 更多 >

    热门问题