Oh Snap!

Please turnoff your ad blocking mode for viewing your site content

Hit enter after type your search item

Python 3 Random Facts Generator GUI Desktop App Using Randfacts Library Full Project For Beginners

/
/
/
46 Views

 

Welcome folks today in this blog post we will be generating random facts using randfacts library in python. All the full source code of application is given below.

 

 

Get Started

 

 

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

 

pip install randfacts

 

After installing the library you need to make an app.py file and copy paste the following code

 

app.py

 

# import required modules 
import tkinter as tk 
from tkinter import *
import randfacts 
import time 



# function to add facts 
def move(): 
    facts = randfacts.getFact(True) 
    c = "*)"
    label = Label(root, text=c+facts) 
    label.pack() 

    
    
# function to close window 
def destroy(): 
    root.destroy() 


    
# driver code 
root = tk.Tk() 

# adjust window 
root.config(bg="red") 
root.geometry("400x400") 

# add buttons 
button = tk.Button(root, text="Click here for Facts", command=move) 
button2 = tk.Button(root, text="Clear and quit", command=destroy) 
button.pack() 
button2.pack() 

root.mainloop()

 

READ  Python 3 Tkinter Script to Build Length Unit Converter (Centimeter + meter + Inches) GUI Desktop App Full Project For Beginners

 

Now if you execute the python script by typing the below command as shown below

 

python app.py

 

 

As you can see when you click the button to generate random facts then the random facts is generated in the desktop app.

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar
Coding Shiksha 2020. All Rights Reserved.
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :