1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| class FileDownload: def __init__(self, master): self.file_path = StringVar() self.file_path.set('请输入下载文件地址:') self.src_dir = '' self.urls = [] open_btn = Button(master, text="链接ftp服务", width=15, height=3, borderwidth=2, command=self.connect_ftp_service) download_btn = Button(master, text="开始下载文件", width=15, height=3, borderwidth=2, command=self.file_download) open_btn.grid(row=0, column=0, ipadx=5, ipady=3, padx=10, pady=3) download_btn.grid(row=1, column=0, ipadx=5, ipady=3, padx=10, pady=3) self.file_label = Entry(master, textvariable=self.file_path, fg='green', bg='white') self.file_label.grid(row=0, column=1, rowspan=2, ipadx=200, ipady=15, padx=10, pady=2) self.text = Text(master, width=200, height=50, bg='white', fg='blue') self.text.grid(row=2, columnspan=2, ipadx=10, ipady=10)
def server_msg_input(self): """
:return: ip port username psd """ child = tkinter.Tk() child.title('服务器账户信息输入') child['height'] = 260 child['width'] = 320 child.resizable(0, 0) ip_label = tkinter.Label(child, text='IP:', font=('黑体', 12)) ip_label.place(x=25, y=20) ip_str = tkinter.StringVar() ip_entry = tkinter.Entry(child, font=('黑体', 12), textvariable=ip_str) ip_entry.place(x=100, y=20)
port_label = tkinter.Label(child, text='port:', font=('黑体', 12)) port_label.place(x=25, y=60) port_str = tkinter.StringVar() port_entry = tkinter.Entry(child, font=('黑体', 12), textvariable=port_str) port_entry.place(x=100, y=60)
user_name_label = tkinter.Label(child, text='UserName:', font=('黑体', 12)) user_name_label.place(x=25, y=100) user_name_str = tkinter.StringVar() user_name_entry = tkinter.Entry(child, font=('黑体', 12), textvariable=user_name_str) user_name_entry.place(x=100, y=100)
psd_label = tkinter.Label(child, text='PassWord:', font=('黑体', 12)) psd_label.place(x=25, y=140) psd_str = tkinter.StringVar() psd_entry = tkinter.Entry(child, font=('黑体', 12), textvariable=psd_str) psd_entry.place(x=100, y=140)
def Get_key(): global key, edt_ip, edt_port, edt_user_name, edt_pass_word key = ip_entry.get() edt_ip = ip_entry.get() edt_port = port_entry.get() edt_user_name = user_name_entry.get() edt_pass_word = psd_entry.get() if edt_ip != "" and ip_identify(edt_ip) and edt_port != "" and edt_user_name != "" and edt_pass_word != "": logger.debug( " user input server msg , ip : " + edt_ip + ",port:" + edt_port + ".user name :" + edt_user_name + ", psd : " + edt_pass_word) connect_ftp_server(self, edt_ip, edt_port, edt_user_name, edt_pass_word) else: logger.error(" you input msg is error , please re input!") showerror(title='错误!', message='您输入信息有误,请重新输入!') child.destroy()
child.bind('<Return>', Get_key) btn_OK = tkinter.Button(child, text='确认', font=('黑体', 12), height=2, command=Get_key) btn_OK.place(x=150, y=200)
|