Skip to content

Commit 1ea6d03

Browse files
authored
Create Random-Lottery-Generator-US-Standard.py
1 parent 1762985 commit 1ea6d03

1 file changed

Lines changed: 219 additions & 0 deletions

File tree

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
import sys
2+
import os
3+
import random
4+
import tkinter as tk
5+
from tkinter import messagebox
6+
7+
# =========================
8+
# THEME
9+
# =========================
10+
APP_BG = "#121212"
11+
PANEL_BG = "#1F1F1F"
12+
BTN_BG = "#2C2C2C"
13+
ACCENT = "#FF6F61"
14+
TEXT_CLR = "#E0E0E0"
15+
SUBTEXT_CLR = "#AAAAAA"
16+
BALL_BG = "#333333"
17+
BALL_FG = "#FFFFFF"
18+
19+
FONT = ("Segoe UI", 11)
20+
21+
# =========================
22+
# LOTTERY CONFIG
23+
# =========================
24+
LOTTERY_PRESETS = {
25+
"Powerball": {"main_numbers": (1, 69), "main_count": 5, "special_numbers": (1, 26), "special_count": 1},
26+
"Mega Millions": {"main_numbers": (1, 70), "main_count": 5, "special_numbers": (1, 25), "special_count": 1},
27+
}
28+
29+
# =========================
30+
# APP
31+
# =========================
32+
class LotteryGeneratorApp:
33+
def __init__(self, root):
34+
self.root = root
35+
root.title("MateTools – Lottery Number Generator")
36+
root.geometry("1000x520")
37+
root.configure(bg=APP_BG)
38+
root.resizable(False, False)
39+
40+
# =========================
41+
# LEFT PANEL
42+
# =========================
43+
left = tk.Frame(root, bg=PANEL_BG, width=420)
44+
left.pack(side="left", fill="y")
45+
46+
header = tk.Frame(left, bg=PANEL_BG)
47+
header.pack(fill="x", padx=16, pady=(18, 10))
48+
49+
tk.Label(
50+
header,
51+
text="MateTools",
52+
bg=PANEL_BG,
53+
fg=ACCENT,
54+
font=("Segoe UI", 20, "bold")
55+
).pack(side="left")
56+
57+
tk.Frame(left, bg=ACCENT, height=2).pack(fill="x", padx=16, pady=(0, 14))
58+
59+
tk.Label(
60+
left,
61+
text="Lottery Number Generator",
62+
bg=PANEL_BG,
63+
fg=TEXT_CLR,
64+
font=("Segoe UI", 14, "bold")
65+
).pack(anchor="w", padx=16, pady=(0, 2))
66+
67+
tk.Label(
68+
left,
69+
text="Generate random numbers for Powerball / Mega Millions",
70+
bg=PANEL_BG,
71+
fg=SUBTEXT_CLR,
72+
font=("Segoe UI", 10)
73+
).pack(anchor="w", padx=16, pady=(0, 16))
74+
75+
tk.Frame(left, bg=BTN_BG, height=1).pack(fill="x", padx=16, pady=(0, 16))
76+
77+
# =========================
78+
# LOTTERY SELECT BUTTONS
79+
# =========================
80+
tk.Label(
81+
left,
82+
text="Select Lottery",
83+
bg=PANEL_BG,
84+
fg=TEXT_CLR,
85+
font=("Segoe UI", 12, "bold")
86+
).pack(anchor="w", padx=16, pady=(0, 6))
87+
88+
self.lottery_var = tk.StringVar(value="Powerball")
89+
self.lottery_buttons = {}
90+
btn_frame = tk.Frame(left, bg=PANEL_BG)
91+
btn_frame.pack(fill="x", padx=16, pady=(0, 16))
92+
93+
for lottery in LOTTERY_PRESETS.keys():
94+
btn = tk.Button(
95+
btn_frame,
96+
text=lottery,
97+
command=lambda l=lottery: self.select_lottery(l),
98+
bg=BTN_BG if lottery != "Powerball" else ACCENT,
99+
fg="white" if lottery == "Powerball" else TEXT_CLR,
100+
font=FONT,
101+
relief="flat",
102+
height=2,
103+
width=18
104+
)
105+
btn.pack(side="left", expand=True, padx=4)
106+
self.lottery_buttons[lottery] = btn
107+
108+
# =========================
109+
# BUTTONS
110+
# =========================
111+
btn_frame2 = tk.Frame(left, bg=PANEL_BG)
112+
btn_frame2.pack(fill="x", padx=16, pady=16)
113+
114+
def make_btn(text, cmd, color=BTN_BG):
115+
return tk.Button(
116+
btn_frame2,
117+
text=text,
118+
command=cmd,
119+
bg=color,
120+
fg="white",
121+
font=("Segoe UI", 11, "bold"),
122+
relief="flat",
123+
height=2,
124+
width=18
125+
)
126+
127+
make_btn("Generate Numbers", self.generate_numbers).pack(side="left", expand=True, padx=4)
128+
make_btn("About", self.show_about, ACCENT).pack(side="left", expand=True, padx=4)
129+
130+
# =========================
131+
# RIGHT PANEL
132+
# =========================
133+
right = tk.Frame(root, bg=APP_BG)
134+
right.pack(side="right", fill="both", expand=True)
135+
136+
self.stats_card = tk.Frame(right, bg=PANEL_BG)
137+
self.stats_card.pack(padx=30, pady=40, fill="both", expand=True)
138+
139+
tk.Label(
140+
self.stats_card,
141+
text="Generated Numbers",
142+
bg=PANEL_BG,
143+
fg=TEXT_CLR,
144+
font=("Segoe UI", 14, "bold")
145+
).pack(pady=(20, 10))
146+
147+
self.numbers_frame = tk.Frame(self.stats_card, bg=PANEL_BG)
148+
self.numbers_frame.pack(pady=20)
149+
150+
# =========================
151+
# METHODS
152+
# =========================
153+
def select_lottery(self, lottery):
154+
self.lottery_var.set(lottery)
155+
for name, btn in self.lottery_buttons.items():
156+
if name == lottery:
157+
btn.config(bg=ACCENT, fg="white")
158+
else:
159+
btn.config(bg=BTN_BG, fg=TEXT_CLR)
160+
161+
def generate_numbers(self):
162+
# Clear previous numbers
163+
for widget in self.numbers_frame.winfo_children():
164+
widget.destroy()
165+
166+
lottery = self.lottery_var.get()
167+
preset = LOTTERY_PRESETS[lottery]
168+
169+
main = random.sample(range(preset["main_numbers"][0], preset["main_numbers"][1] + 1), preset["main_count"])
170+
special = random.sample(range(preset["special_numbers"][0], preset["special_numbers"][1] + 1), preset["special_count"])
171+
172+
main.sort()
173+
174+
# Display main numbers as balls
175+
for num in main:
176+
ball = tk.Label(
177+
self.numbers_frame,
178+
text=str(num),
179+
bg="#1E90FF",
180+
fg="white",
181+
font=("Segoe UI", 16, "bold"),
182+
width=4,
183+
height=2,
184+
relief="raised",
185+
bd=2
186+
)
187+
ball.pack(side="left", padx=5)
188+
189+
# Display special numbers
190+
for num in special:
191+
ball = tk.Label(
192+
self.numbers_frame,
193+
text=str(num),
194+
bg="#FF4500",
195+
fg="white",
196+
font=("Segoe UI", 16, "bold"),
197+
width=4,
198+
height=2,
199+
relief="raised",
200+
bd=2
201+
)
202+
ball.pack(side="left", padx=5)
203+
204+
def show_about(self):
205+
messagebox.showinfo(
206+
"About",
207+
"MateTools – Lottery Number Generator\n\n"
208+
"• Random number generation\n"
209+
"• Presets for Powerball and Mega Millions\n\n"
210+
"Built by MateTools"
211+
)
212+
213+
# =========================
214+
# RUN
215+
# =========================
216+
if __name__ == "__main__":
217+
root = tk.Tk()
218+
LotteryGeneratorApp(root)
219+
root.mainloop()

0 commit comments

Comments
 (0)