Python 如何在Visual Studio 2013中调用类MyWindow(Window)内的函数?
我正在使用VS2013和PTVS,我想按下一个按钮来调用一个函数。但是我是python和WPF的初学者,所以我遇到了一些麻烦,所以我的函数类是:Python 如何在Visual Studio 2013中调用类MyWindow(Window)内的函数?,python,wpf,visual-studio-2013,ironpython,ptvs,Python,Wpf,Visual Studio 2013,Ironpython,Ptvs,我正在使用VS2013和PTVS,我想按下一个按钮来调用一个函数。但是我是python和WPF的初学者,所以我遇到了一些麻烦,所以我的函数类是: class VendasXML(object): def MakeXML(self) : offset = 0 url = 'https://api.mercadolibre.com/orders/search?seller=' + AutenticacaoML["user_id"] + '&access
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
和我的类MyWindow(窗口):
我在按钮标签中调用WPF中的函数:
<Button Click="AtualizarXML" x:Name="butao" Content="Button" Grid.Column="1" HorizontalAlignment="Left" Margin="519,79,-381,0" VerticalAlignment="Top" Width="371" Height="323"/>
但是,当我单击按钮调用函数时,会出现以下异常:
我必须做些什么来克服这个问题?我找到了解决方案:
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
以及:
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
def AtualizarXML(self, sender, e):
MakeXML(AutenticacaoML())