# -*- coding:utf-8 -*-
import tkinter as tk
from chatgpt import ChatGPT

# 初始化
chatgpt = ChatGPT()

# 创建图形化窗口
root = tk.Tk()
root.title('chatgpt小助手')

# 创建输入框
input_text = tk.StringVar()
entry_input = tk.Entry(root, textvariable=input_text)
entry_input.pack()

# 创建输出框
output_text = tk.StringVar()
label_output = tk.Label(root, textvariable=output_text, bg='white', width=50)
label_output.pack()

# 定义方法
def get_answer():
    # 读取输入框内容
    input_str = input_text.get()
    # 调用chatgpt接口
    answer = chatgpt.get_answer(input_str)
    # 更新输出框内容
    output_text.set(answer)

# 创建按钮
button_get_answer = tk.Button(root, text='获取答案', command=get_answer)
button_get_answer.pack()

# 进入消息循环
root.mainloop()
Python ChatGPT 图形化脚本工具:便捷问答助手

原文地址: https://www.cveoy.top/t/topic/lmtm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录