Python Tkinter ASCII Art Generator From Text or String and Downloads it as Image GUI Desktop App Full Project For Beginners

Python Tkinter ASCII Art Generator From Text or String and Downloads it as Image GUI Desktop App Full Project For Beginners

 

Welcome folks today in this blog post we will be generating ascii art from string or text in tkinter. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the following library using the pip command as shown below

 

pip install tkinter

 

After installing this library make an app.py file and copy paste the following code

 

app.py

 

#By Dx55
import tkinter as tk
import requests

#Generating window
window = tk.Tk()
window.geometry("750x500")
window.title("ASCII ART")
window.grid_columnconfigure(0, weight=1)

#Download function
def download_ascii():
    if text_input.get():
        user_input = text_input.get()
        payload = {"text": user_input}
        response = requests.get("http://artii.herokuapp.com/make",
                                params=payload)
        text_response = response.text
    else:
        text_response = "Write Up"

#Text widget
    textwidget = tk.Text()
    textwidget.insert(tk.END, text_response)
    textwidget.grid(row=3, column=0, sticky="WE", padx=10, pady=10)


#Credits label
credits_label = tk.Label(window, text="Ascii Art By artii.herokuapp.com")
credits_label.grid(row=4, column=0, sticky="S", pady=10)
        

#Welcome label
welcome_label = tk.Label(window, 
                         text="Welcome! Write something",
                         font=("Helvetica",15))
welcome_label.grid(row=0, column=0, sticky="N", padx=20, pady=10)

#Text input
text_input = tk.Entry()
text_input.grid(row=1, column=0, sticky="WE", padx=10)

#Download button
download_button = tk.Button(text="DOWNLOAD YOUR ART", command=download_ascii)
download_button.grid(row=2, column=0, sticky="WE", padx=10, pady=10)



#Main loop
if __name__ == "__main__":
    window.mainloop()

 

See also  Python 3 PyGame Ping Pong Game with AI Computer Using Numpy Script GUI Desktop App Full Project For Beginners

 

And now if you execute the above script with the command which is shown below

 

python app.py

 

Leave a Reply