LUDO DICE ROLLER

LUDO DICE ROLLER USING PYTHON

Source Code:- 

 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# LUDO DICE ROLLER USING TKINTER AND PIL
 
from tkinter import *
from PIL import Image, ImageTk
import random
 
root = Tk()
root.geometry("550x580+100+10")
root.config(bg = "lightpink")
 
dice = ["dice 1.png", "dice 2.png", "dice 3.png", "dice 4.png", "dice 5.png", "dice 6.png"]
 
def Ludo_Dice():
    color = ["yellow", "lightgreen", "khaki2", "orange", "lightblue"]
    change_bg = random.choice(color)
    Frame(root, width = 280, height = 280, bg = change_bg, relief = GROOVE, bd = 7).place(x = 130, y = 80)
     
    dice_roll = random.choice(dice)
    img = Image.open(dice_roll)
    img = img.resize((230, 230))   
    photo = ImageTk.PhotoImage(img)
    L = Label(root, image = photo)
    L.image = photo
    L.place(x = 153, y = 102)   
 
Label(root, text = "LUDO DICE ROLLER", font = ("None 30 bold"), bg = "springgreen").place(x = 70, y = 10)
 
Frame(root, width = 280, height = 280, bg = "khaki2", relief = GROOVE, bd = 7).place(x = 130, y = 80)
 
Button(root, text = "Roll the Dice", font = ("None 25 bold"), command = Ludo_Dice, bg = "orange",
                                        bd = 5, activebackground = "orange").place(x = 155, y = 380)
 
Button(root, text = "Exit", font = ("None 25 bold"), command = exit, bg = "indianred1",
                                        bd = 5, activebackground = "indianred1").place(x = 220, y = 470)
 
root.mainloop()
 
# Follow me on Instagram:- @python_with_shubham
 
 
# LUDO DICE ROLLER USING TKINTER AND PIL

from tkinter import *
from PIL import Image, ImageTk
import random

root = Tk()
root.geometry("550x580+100+10")
root.config(bg = "lightpink")

dice = ["dice 1.png", "dice 2.png", "dice 3.png", "dice 4.png", "dice 5.png", "dice 6.png"]

def Ludo_Dice():
    color = ["yellow", "lightgreen", "khaki2", "orange", "lightblue"]
    change_bg = random.choice(color)
    Frame(root, width = 280, height = 280, bg = change_bg, relief = GROOVE, bd = 7).place(x = 130, y = 80)
    
    dice_roll = random.choice(dice)
    img = Image.open(dice_roll)
    img = img.resize((230, 230))    
    photo = ImageTk.PhotoImage(img)
    L = Label(root, image = photo)
    L.image = photo
    L.place(x = 153, y = 102)    

Label(root, text = "LUDO DICE ROLLER", font = ("None 30 bold"), bg = "springgreen").place(x = 70, y = 10)

Frame(root, width = 280, height = 280, bg = "khaki2", relief = GROOVE, bd = 7).place(x = 130, y = 80)

Button(root, text = "Roll the Dice", font = ("None 25 bold"), command = Ludo_Dice, bg = "orange", 
                                        bd = 5, activebackground = "orange").place(x = 155, y = 380)

Button(root, text = "Exit", font = ("None 25 bold"), command = exit, bg = "indianred1", 
                                        bd = 5, activebackground = "indianred1").place(x = 220, y = 470)

root.mainloop()

# Follow me on Instagram:- @python_with_shubham

Output:- 


Dice Images:-









Follow me on Instagram:- Python_with_Shubham




 

0 Comments