-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubset Generator.py
More file actions
40 lines (28 loc) · 1.07 KB
/
Subset Generator.py
File metadata and controls
40 lines (28 loc) · 1.07 KB
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
31
32
33
34
35
36
37
38
39
40
import tkinter as tk
from tkinter import messagebox
from itertools import combinations
def generate_subsets():
input_data = entry_set.get().strip()
if not input_data:
messagebox.showerror("Error", "Please enter set elements.")
return
elements = [x.strip() for x in input_data.split(",") if x.strip()]
result_box.delete("1.0", tk.END)
result_box.insert(tk.END, "Subsets:\n\n")
count = 0
for r in range(len(elements) + 1):
for subset in combinations(elements, r):
result_box.insert(tk.END, f"{set(subset)}\n")
count += 1
result_box.insert(tk.END, f"\nTotal Subsets: {count}")
# GUI Setup
root = tk.Tk()
root.title("Subset Generator")
root.geometry("500x450")
tk.Label(root, text="Enter Set Elements (comma-separated):").pack(pady=5)
entry_set = tk.Entry(root, width=50)
entry_set.pack(pady=5)
tk.Button(root, text="Generate Subsets", command=generate_subsets).pack(pady=10)
result_box = tk.Text(root, height=18, width=55)
result_box.pack(pady=5)
root.mainloop()