python之GUI编程-tkinter学习
新手刚学习几天,勿喷!好多东西不会,没有相关文档全面学习,有资源的希望分享下!总的来说很难用。 一、源代码 1 import itchat 2 import requests 3 import tkinter 4 from tkinter import messagebox 5 6 7 def func(self): 8 cont = text2.get(1.0, 'end').replace('\n', '') 9 if len(cont) == 0: 10 messagebox.showinfo("错误", "不能发送空消息") 11 return 12 else: 13 try: 14 req = requests.get('http://i.itpk.cn/api.php', params={'question': cont}) 15 text1.config(state='normal') 16 text1.insert(tkinter.INSERT, '我: ' + cont + '\n') 17 text1.config(state='disabled') 18 text2.delete('1.0', 'end') 19 text1.config(state='normal') 20 text1.insert(tkinter.INSERT, '夏莉: ' + req