-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDnD_Dice_Roller
More file actions
30 lines (24 loc) · 813 Bytes
/
DnD_Dice_Roller
File metadata and controls
30 lines (24 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# A simple DND dice roller application using a GUI framework
import tkinter as tk
import random
# Define main application function
def main_app():
# Create main window
window = tk.Tk()
window.title("DND Dice Roller")
result_label = tk.Label(window, text="")
result_label.pack(pady=10)
def roll_dice():
dice_types = [4, 6, 8, 10, 12, 20, 100]
results = []
for die in dice_types:
result = random.randint(1, die)
results.append(f"d{die}: {result}")
result_label.config(text="\n".join(results))
# Create a button that triggers dice roll
roll_button = tk.Button(window, text="Roll Dice", command=roll_dice)
roll_button.pack(pady=10)
# Start the main event loop
window.mainloop()
# Run the app
main_app()