Recreate the Python Terminal in a tkinter interface

I’m a beginner in python and i need help with a personnal project.

As written in the title, I want to recreate the python terminal. let me explain:
When I create code, I prefer it to be visibly nice in the pycharm’s terminal, created a tkinter interface it’s sometimes boring…

example of one of my minimalist but pleasant to read code (yes, it’s in frensh

so i just want the same thing but in a simple tkinter interface.

I recreated the “print()” command
“DBoxComputer()” when it is the computer, a ‘print()’ (in white on the image above)
“DBoxUser()” when it’s me who enters an ‘input()’ (in green on the image above)

The problem, impossible for me to recreate the “input()” command
I can’t pause my code. Tell it to wait until I press “return” (there is a key bind) to move on, like in the classic terminal when it waits for an “input()” then “return”


import tkinter.font as font
import ttkbootstrap as ttk

#-PARAMETRES FENETRES-
root = ttk.Window(themename="darkly")
root.title("test")
root.geometry("800x500+50+50")

#-FONCTIONS
def DBoxComputer(entry):
    DBox.config(state="normal")
    DBox.insert("end-1c", entry + "n", "ComputerBasic")
    DBox.config(state="disabled")
    DBox.yview_moveto('1.0')

def DBoxUser(entry):
    DBox.config(state="normal")
    DBox.insert("end-1c", entry + "n", "UserBasic")
    DBox.config(state="disabled")
    myEntry.delete(0, ttk.END)

def Entry():
    x = ""
    while x != "Return":
        root.bind("<Key>", Raccourcies)

    user = myEntry.get()
    DBoxUser(user)
    return user

def Raccourcies(event):
    x = event.keysym
    print(x)
    if x == "Return":
        return x

def Start():

    DBoxComputer("Hello Patrick")
    DBoxComputer("Do you like biscuits ?")
    x = Entry()

    if x == "yes":
        DBoxComputer("Haaa me too, miam :p")
    elif x == "no":
        DBoxComputer("Non ?! Sad... you're missing a few things...")
    else:
        DBoxComputer("You don't know how to answer a simple question?")

#-Raccourcies-
root.bind("<Key>", Raccourcies)

#-WIDGETS-
marge = ttk.Label(root) #deco
DBox = ttk.Text(marge, font="georgia 10", state="disabled", width=80)
espace = ttk.Frame(marge) #deco
myEntry = ttk.Entry(marge, width=80)

#-FONT CUSTOMS-
DBox.tag_config("ComputerBasic", font=font.Font(family="System", size=20, weight="normal", slant="italic"))
DBox.tag_config("UserBasic", font=font.Font(family="Microsoft Sans Serif", size=20, weight="normal"))

#-PLACEMENTS-
marge.pack(padx=10, pady=10, expand=True)
DBox.pack(expand=True)
espace.pack(pady=5)
myEntry.pack()

Start()

#-BOUCLE-
root.mainloop()

if i delete these lines:

    x = Entry()

    if x == "yes":
        DBoxComputer("Haaa me too, miam :p")
    elif x == "no":
        DBoxComputer("Non ?! Sad... you're missing a few things...")
    else:
        DBoxComputer("You don't know how to answer a simple question?")

this appears:
.

I’m sure the problem comes from the fact that it waits for me to press “return” but the loop goes so fast that it isn’t even able to launch the program

Do you have a solution, whether in the structure of the code, or a method that I don’t know?
Thanks in advance

New contributor

Jack Panot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật