from hidden_skills import *
import tkinter as tk
from tkinter import ttk, LEFT
class App(tk.Tk):
def __init__(self):
super().__init__()
self.title('the LivinGrimoire')
self.geometry('600x200')
self.resizable(width=False, height=False)
self.style = ttk.Style(self)
self.configure(background='black')
# animation
self.rnd: DrawRnd = DrawRnd()
self._photos: list[tk.PhotoImage] = []
i = -1
# happy
i = i +1
self._photos.insert(i, tk.PhotoImage(file="images/happy/happy1-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/happy/happy2-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/happy/happy3-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/happy/happy4-0000.png").subsample(10, 10))
# mad
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/mad/mad1-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/mad/mad2-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/mad/mad3-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/mad/mad4-0000.png").subsample(10, 10))
# neutral
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/neutral/neutral1-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/neutral/neutral2-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/neutral/neutral3-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/neutral/neutral4-0000.png").subsample(10, 10))
# sad
self._photos.insert(i, tk.PhotoImage(file="images/sad/sad1-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/sad/sad2-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/sad/sad3-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/sad/sad4-0000.png").subsample(10, 10))
# shy
self._photos.insert(i, tk.PhotoImage(file="images/shy/shy1-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/shy/shy1-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/shy/shy1-0000.png").subsample(10, 10))
i = i + 1
self._photos.insert(i, tk.PhotoImage(file="images/shy/shy1-0000.png").subsample(10, 10))
# btn
self.btn = tk.Button(text="click me", image=self._photos[0], command=self.clickEvent)
self.btn.configure(background='black')
self.btn.pack(side=LEFT)
# entry
self.entry = tk.Entry(width=60)
self.entry.config(fg="#03A062", bg="black")
self.entry.config(font=("helvetica", 14, "bold"))
self.entry.bind("<Return>", self.onReturn)
self.entry.pack(ipadx=30, ipady=10)
# lbl
self.lbl = tk.Label(self)
self.lbl.config(fg="#03A062", bg="black")
self.lbl.config(font=("helvetica", 14))
self.lbl["text"] = "output"
self.lbl.pack()
self.regexUtil: RegexUtil = RegexUtil()
self.chobit: Chobits = Chobits()
self.tickEvent()
def tickEvent(self):
result = self.chobit.think("", "", "")
if len(result) != 0:
self.lbl["text"] = result
self.after(3000, lambda: self.tickEvent()) # no concern for stack overflow, uses queue
# print(self.chobit.getSoulEmotion())
def clickEvent(self):
result = self.chobit.think(self.entry.get(), "", "")
if len(result) == 0:
self.lbl["text"] = "output field"
else:
self.lbl["text"] = result
self.entry.delete(0, tk.END)
def onReturn(self, event):
result = self.chobit.think(self.entry.get(), "", "")
if len(result) == 0:
self.lbl["text"] = "output field"
else:
self.lbl["text"] = result
self.btn.config(image=self._photos[self.rnd.getSimpleRNDNum(len(self._photos)-1)])
self.entry.delete(0, tk.END)
# print(self.chobit.getSoulEmotion())
return 'break'