|
import tkinter as tk |
|
from tkinter import scrolledtext |
|
|
|
|
|
def generate_response(user_input): |
|
|
|
|
|
|
|
return "Chatbot: This is where your Hugging Face chatbot response goes." |
|
|
|
class ChatbotUI: |
|
def __init__(self, root): |
|
self.root = root |
|
self.root.title("Chatbot Interface") |
|
|
|
|
|
self.chat_history = scrolledtext.ScrolledText(root, wrap=tk.WORD, width=50, height=20) |
|
self.chat_history.grid(row=0, column=0, padx=10, pady=10, columnspan=2) |
|
|
|
|
|
self.user_input = tk.Entry(root, width=40) |
|
self.user_input.grid(row=1, column=0, padx=10, pady=10) |
|
|
|
|
|
self.submit_button = tk.Button(root, text="Submit", command=self.process_input) |
|
self.submit_button.grid(row=1, column=1, padx=10, pady=10) |
|
|
|
|
|
self.chat_history.insert(tk.END, "Chatbot: Hello! How can I help you today?\n") |
|
|
|
def process_input(self): |
|
user_message = self.user_input.get() |
|
self.chat_history.insert(tk.END, f"You: {user_message}\n") |
|
|
|
|
|
chatbot_response = generate_response(user_message) |
|
|
|
self.chat_history.insert(tk.END, chatbot_response + "\n") |
|
|
|
self.user_input.delete(0, tk.END) |
|
|
|
def run_chat_ui(): |
|
try: |
|
root = tk.Tk() |
|
chatbot_ui = ChatbotUI(root) |
|
root.mainloop() |
|
except tk.TclError: |
|
print("No graphical display found. Running in non-GUI mode.") |
|
|
|
if __name__ == "__main__": |
|
run_chat_ui() |