👨‍💻 dev TKInter cs

development

fukurou

the supreme coder
ADMIN
*********
*imports*
*********
from tkinter import *
from tkinter import scrolledtext
from tkinter import messagebox
from tkinter.ttk import Progressbar
from tkinter import filedialog
from tkinter import Menu

******
*stem*
******
import tkinter
window = tkinter.Tk()
# rest of the code goes here
window.mainloop()
# this code runs after the window closes
*******
*title*
*******
window.title("livingrimoire")
*************
*window size*
*************
window.geometry('500x500') # set size
# set minimum size:
window.wm_minsize(width=500,height=300)
##########################################
*******
*label*
*******
lbl = tkinter.Label(window, text="Hello", font=("Arial Bold", 20))
lbl.grid(column=0, row=0) # place label
lbl.pack() # other label placement method
 

fukurou

the supreme coder
ADMIN
Python:
    # tkinter stuff
    window = tkinter.Tk()
    window.title("livingrimoire")
    window.wm_minsize(width=500, height=100)


    # # label
    # lbl = tkinter.Label(window, text="Hello", font=("Arial Bold", 20))
    # lbl.pack()

    def clicked1():
        text.delete('1.0', END)
        window.geometry('600x400')


    photo = PhotoImage(file="imgt.png").subsample(7, 5)
    btn = tkinter.Button(text="click me", image=photo, command=clicked1)
    btn.pack(side=LEFT)
    # entry = Entry()
    # entry.insert(index=0, string=">")
    # entry.pack()
    text = Text(window)
    text.config(fg="#03A062", bg="black")
    text.config(font=("helvetica", 14))
    text.insert("end", ">")
    text.pack()
    window.geometry('600x400')
    window.mainloop()
 

fukurou

the supreme coder
ADMIN
Python:
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')

        self.photo = tk.PhotoImage(file="imgt.png").subsample(10, 10)
        self.btn = tk.Button(text="click me", image=self.photo, 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()

    def tickEvent(self):
        print("tick event engaged")
        self.after(3000, lambda: self.tickEvent())

    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.entry.delete(0, tk.END)
        return 'break'
 

fukurou

the supreme coder
ADMIN
Python:
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')
        # btn
        self.photo = tk.PhotoImage(file="images/imgt.png").subsample(10, 10)
        self.btn = tk.Button(text="click me", image=self.photo, 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.entry.delete(0, tk.END)
        # print(self.chobit.getSoulEmotion())
        return 'break'
 

fukurou

the supreme coder
ADMIN
Python:
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'
 
Top