python Button问题
#_*_coding:utf-8_*_fromTkinterimport*importtkFileDialogimporturllibimportredefxiazai(...
#_*_coding:utf-8_*_
from Tkinter import *
import tkFileDialog
import urllib
import re
def xiazai():
html = E1.get()
openqw = urllib.urlopen(html)
html = openqw.read()
reg = r'src="(.+?\.jpg)"'
img = re.compile(reg)
#print img
imglist = re.findall(img,html)
#print imglist
x = 0
for imgr in imglist:
urllib.urlretrieve(imgr,yang,'%s.jpg' % x)
x+=1
def Zhujing():
yang = tkFileDialog.askdirectory()
return yang
root = Tk()
L1= Label(root,text = '网址')
E1 = Entry(root)
L2 = Label(root, text = '保存位置')
E2 = Entry(root)
B1 =Button(root,text = '......',command = Zhujing)
#B1.bind('<Button -1>',Zhujing)
B2 =Button(root,text = '下载',command = xiazai)
L1.grid(row = 0 , column =0)
E1.grid(row = 0 , column = 1)
L2.grid(row = 1 , column = 0)
E2.grid(row = 1 , column = 1)
B1.grid(row = 1 , column = 2)
B2.grid(row = 2 , column =2)
root.mainloop()
我想在点击B2后调用Zhujing()获取文件存储位置“然后将结果显示在E2中,最后在xiazai()中下载内容文件保存位置调Zhujing()的结果” 。“”中是我求各位大神的问题前面的我已经解决。谢谢 展开
from Tkinter import *
import tkFileDialog
import urllib
import re
def xiazai():
html = E1.get()
openqw = urllib.urlopen(html)
html = openqw.read()
reg = r'src="(.+?\.jpg)"'
img = re.compile(reg)
#print img
imglist = re.findall(img,html)
#print imglist
x = 0
for imgr in imglist:
urllib.urlretrieve(imgr,yang,'%s.jpg' % x)
x+=1
def Zhujing():
yang = tkFileDialog.askdirectory()
return yang
root = Tk()
L1= Label(root,text = '网址')
E1 = Entry(root)
L2 = Label(root, text = '保存位置')
E2 = Entry(root)
B1 =Button(root,text = '......',command = Zhujing)
#B1.bind('<Button -1>',Zhujing)
B2 =Button(root,text = '下载',command = xiazai)
L1.grid(row = 0 , column =0)
E1.grid(row = 0 , column = 1)
L2.grid(row = 1 , column = 0)
E2.grid(row = 1 , column = 1)
B1.grid(row = 1 , column = 2)
B2.grid(row = 2 , column =2)
root.mainloop()
我想在点击B2后调用Zhujing()获取文件存储位置“然后将结果显示在E2中,最后在xiazai()中下载内容文件保存位置调Zhujing()的结果” 。“”中是我求各位大神的问题前面的我已经解决。谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询