|
import tkinter as tk |
|
from tkinter import scrolledtext, messagebox |
|
|
|
class CodetteApp(tk.Tk): |
|
def __init__(self): |
|
super().__init__() |
|
self.title("Codette Universal Reasoning Assistant") |
|
self.geometry("600x400") |
|
self.configure(bg="#eef6f9") |
|
|
|
|
|
title = tk.Label(self, text="Ask Codette", font=("Helvetica", 18, "bold"), bg="#eef6f9") |
|
title.pack(pady=10) |
|
|
|
|
|
self.input_field = tk.Entry(self, font=("Calibri", 14), width=60) |
|
self.input_field.pack(pady=5) |
|
self.input_field.focus() |
|
|
|
|
|
ask_btn = tk.Button(self, text="Ask", font=("Calibri", 12), command=self.handle_ask) |
|
ask_btn.pack(pady=5) |
|
|
|
|
|
output_label = tk.Label(self, text="Codette's Answer:", bg="#eef6f9") |
|
output_label.pack() |
|
|
|
self.output_box = scrolledtext.ScrolledText(self, font=("Consolas", 12), height=10, width=70) |
|
self.output_box.pack(pady=4) |
|
|
|
|
|
clear_btn = tk.Button(self, text="Clear", command=self.clear_all) |
|
clear_btn.pack(pady=3) |
|
|
|
def handle_ask(self): |
|
user_query = self.input_field.get().strip() |
|
if not user_query: |
|
messagebox.showwarning("Input Required", "Please enter your question.") |
|
return |
|
|
|
|
|
codette_reply = f"[Pretend answer] You asked: '{user_query}'" |
|
|
|
self.output_box.insert(tk.END, f"User: {user_query}\nCodette: {codette_reply}\n\n") |
|
self.out_box_yview_bottom() |
|
|
|
def out_box_yview_bottom(self): |
|
''' Scroll output box to bottom ''' |
|
self.output_box.yview_moveto(1.0) |
|
|
|
def clear_all(self): |
|
self.input_field.delete(0, tk.END) |
|
self.output_box.delete('1.0', tk.END) |
|
|
|
if __name__ == "__main__": |
|
app = CodetteApp() |
|
app.mainloop() |
|
|