Dice Roller Using Tkinter














































Dice Roller Using Tkinter



DICE ROLL GAME USING PYTHON 

This is a friendly beginner-level Python project. In this project we will be taking the script to another level and create a GUI(Graphical User Interface) using tkinter.

Tkinter is the most commonly used library for converting any script to Graphical User Interface (GUI).

-Dice unicode characters dictionary Dice= { 0 : '๐ŸŽฒ', 1 : 'โš€', 2 : 'โš', 3 : 'โš‚', 4 : 'โšƒ', 5 : 'โš„', 6 : 'โš…' }

-This is a Python game to roll a dice and show random numbers between(1-6).

-Run the python program to play the game.



PREQUISITES

install tkinter using

pip install tkinter


CODE-



# Python Dice Rolling Game using Tkinter
# - Rishaw Kumar from tkinter import * App = Tk() App.title("Dice Roller") # Dice unicode characters dictionary Dice = { 0 : '๐ŸŽฒ', 1 : 'โš€', 2 : 'โš', 3 : 'โš‚', 4 : 'โšƒ', 5 : 'โš„', 6 : 'โš…' } # First dice character to show when the app starts lbl = Label(App, text=Dice[0], font=('Times', 100)) lbl.grid(row=0, column=0, padx=40) # Choose number from 1 - 6 randomly and display it def roll(): from random import randint dice_choice = randint(1, 6) dice_lbl = Label(App, text=Dice[dice_choice], font=('Times', 100), width=2) dice_lbl.grid(row=0, column=0, padx=40) # Roll button roll_button = Button(App, text='Roll', command=roll) roll_button.grid() App.mainloop()




OUTPUT-








Comments