here2share

# tk_Module_Selector.py

Mar 11th, 2026 (edited)
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.35 KB | None | 0 0
  1. # tk_Module_Selector.py
  2.  
  3. import tkinter as tk
  4. from tkinter import ttk
  5. import os
  6.  
  7. CATEGORIES = {
  8.     "Core Language / Syntax": {
  9.         "abc":("Tools for defining Abstract Base Classes and enforcing interfaces.","d"),
  10.         "ast":("Represents Python code as an Abstract Syntax Tree for analysis or transformation.","o"),
  11.         "tokenize":("Converts Python source into tokens for parsing or analysis.","d"),
  12.         "token":("Constants representing Python’s lexical tokens.","d"),
  13.         "code":("Utilities for compiling and executing Python code dynamically.","d"),
  14.         "codeop":("Helpers for compiling code conditionally, used by interactive interpreters.","d"),
  15.         "dis":("Disassembles Python bytecode for inspection and debugging.","d"),
  16.         "symtable":("Accesses the compiler’s symbol tables for introspection.","d"),
  17.         "types":("Defines dynamic type objects and helpers used throughout Python.","o"),
  18.         "typing":("Provides type hints and static typing support.","o")
  19.     },
  20.  
  21.     "Data Structures & Algorithms": {
  22.         "array":("Compact C-style arrays storing basic numeric types efficiently.","o"),
  23.         "bisect":("Maintains sorted lists via binary search insertion.","o"),
  24.         "collections":("High-performance container datatypes like deque, Counter, defaultdict.","k"),
  25.         "heapq":("Implements a binary heap for priority queue operations.","o"),
  26.         "itertools":("Fast, memory-efficient iterator building blocks.","k"),
  27.         "operator":("Functional access to operators for cleaner functional-style code.","o"),
  28.         "functools":("Higher-order functions like lru_cache, partial, reduce.","k"),
  29.         "reprlib":("Generates abbreviated repr() output for large or recursive objects.","d")
  30.     },
  31.  
  32.     "Math & Numbers": {
  33.         "cmath":("Mathematical functions for complex numbers.","o"),
  34.         "math":("Standard mathematical functions implemented in C for speed.","k"),
  35.         "decimal":("Decimal floating-point arithmetic with exact precision.","o"),
  36.         "fractions":("Implements rational numbers as Fraction objects.","o"),
  37.         "statistics":("Statistical functions like mean, median, stdev.","k"),
  38.         "random":("Pseudo-random number generators and utilities.","k"),
  39.         "numbers":("Abstract base classes for numeric types.","d")
  40.     },
  41.  
  42.     "File / OS / System": {
  43.         "os":("Portable access to operating system functionality.","k"),
  44.         "pathlib":("Object-oriented filesystem paths.","k"),
  45.         "shutil":("High-level file operations like copy, move, archive.","k"),
  46.         "glob":("Pattern-based file searching using wildcards.","k"),
  47.         "tempfile":("Creates temporary files and directories securely.","k"),
  48.         "stat":("Interprets file stat results and constants.","o"),
  49.         "sys":("Access to interpreter internals and runtime environment.","k"),
  50.         "sysconfig":("Access to Python’s build-time configuration.","d"),
  51.         "platform":("Identifies the underlying platform and system details.","k"),
  52.         "errno":("Standardized error codes from the OS.","o"),
  53.         "signal":("Signal handling for asynchronous events.","d"),
  54.         "atexit":("Registers functions to run at interpreter shutdown.","d"),
  55.         "time":("Time-related functions including sleep and timestamps.","k"),
  56.         "timeit":("Measures execution time of small code snippets.","o"),
  57.         "mmap":("Memory-mapped file support for efficient file access.","d"),
  58.         "posixpath":("POSIX-specific path manipulation helpers.","d"),
  59.         "logging":("Flexible logging system for applications.","o")
  60.     },
  61.  
  62.     "Text / Parsing / Encoding": {
  63.         "re":("Regular expression engine for pattern matching.","k"),
  64.         "string":("String constants and helper functions.","o"),
  65.         "textwrap":("Wraps and formats text paragraphs.","o"),
  66.         "base64":("Base64 encoding and decoding utilities.","o"),
  67.         "binascii":("Low-level binary/ASCII conversions.","d"),
  68.         "quopri":("Quoted-printable encoding used in email.","d"),
  69.         "uu":("UUencode encoding/decoding.","d"),
  70.         "codecs":("Registry and base classes for text encodings.","d"),
  71.         "encodings":("Implementation of Python’s encoding system.","d"),
  72.         "gettext":("Internationalization and localization support.","d"),
  73.         "keyword":("Tests whether strings are Python keywords.","o"),
  74.         "json":("JSON encoding and decoding.","k")
  75.     },
  76.  
  77.     "Compression / Archiving": {
  78.         "gzip":("Read and write gzip-compressed files.","o"),
  79.         "bz2":("Bzip2 compression and decompression.","d"),
  80.         "lzma":("LZMA compression and decompression.","d"),
  81.         "zipfile":("Read and write ZIP archives.","o"),
  82.         "zipimport":("Import modules from ZIP archives.","d"),
  83.         "zipapp":("Create executable Python ZIP applications.","d"),
  84.         "tarfile":("Read and write TAR archives.","d")
  85.     },
  86.  
  87.     "Networking / Internet": {
  88.         "socket":("Low-level networking interface.","o"),
  89.         "socketserver":("Framework for network servers.","d"),
  90.         "http":("HTTP client and server utilities.","o"),
  91.         "urllib":("URL handling and HTTP requests.","o"),
  92.         "ftplib":("FTP client protocol implementation.","d"),
  93.         "imaplib":("IMAP email client.","d"),
  94.         "poplib":("POP3 email client.","d"),
  95.         "smtplib":("SMTP email sending client.","d"),
  96.         "smtpd":("SMTP server implementation.","d"),
  97.         "telnetlib":("Telnet client.","d"),
  98.         "nntplib":("NNTP newsgroup client.","d"),
  99.         "wsgiref":("WSGI utilities and reference server.","d"),
  100.         "ipaddress":("Manipulate IPv4 and IPv6 addresses.","d")
  101.     },
  102.  
  103.     "Concurrency / Async": {
  104.         "threading":("High-level threading interface.","o"),
  105.         "multiprocessing":("Process-based parallelism.","o"),
  106.         "concurrent":("Futures for thread and process pools.","o"),
  107.         "asyncio":("Asynchronous I/O framework.","o"),
  108.         "asynchat":("Legacy async chat handler.","d"),
  109.         "asyncore":("Legacy async socket handler.","d"),
  110.         "queue":("Thread-safe FIFO queue.","o"),
  111.         "selectors":("High-level I/O multiplexing.","d"),
  112.         "select":("Low-level I/O multiplexing.","d"),
  113.         "sched":("Event scheduler.","d"),
  114.         "contextvars":("Context-local state for async tasks.","d")
  115.     },
  116.  
  117.     "Debugging / Introspection": {
  118.         "inspect":("Retrieves information about live objects.","o"),
  119.         "traceback":("Extracts, formats, and prints stack traces.","o"),
  120.         "trace":("Tracks program execution and generates coverage.","o"),
  121.         "tracemalloc":("Tracks memory allocations.","d"),
  122.         "pdb":("Interactive debugger.","o"),
  123.         "bdb":("Debugger framework used by pdb.","d"),
  124.         "profile":("Deterministic profiler.","d"),
  125.         "cProfile":("C-optimized profiler.","d"),
  126.         "pstats":("Profiler statistics manipulation.","d"),
  127.         "faulthandler":("Prints tracebacks on fatal errors.","d"),
  128.         "linecache":("Random access to lines of Python source.","o"),
  129.         "runpy":("Run modules by name or path.","o"),
  130.         "pyclbr":("Class browser support.","d"),
  131.         "pydoc":("Generates Python documentation.","o"),
  132.         "pydoc_data":("Data used by pydoc.","o")
  133.     },
  134.  
  135.     "Databases / Storage": {
  136.         "sqlite3":("Built-in SQLite database engine.","d"),
  137.         "shelve":("Persistent dictionary-like objects.","d"),
  138.         "dbm":("Simple key-value database interfaces.","d"),
  139.         "plistlib":("Read/write Apple plist files.","d"),
  140.         "mailbox":("Manipulate mailbox formats.","d")
  141.     },
  142.  
  143.     "Email / MIME": {
  144.         "email":("Construct, parse, and handle email messages.","d"),
  145.         "mailcap":("Mailcap file handling.","d"),
  146.         "imghdr":("Detect image file types.","d"),
  147.         "mimetypes":("Guess MIME types based on filenames.","d")
  148.     },
  149.  
  150.     "Audio": {
  151.         "aifc":("Read/write AIFF audio files.","d"),
  152.         "audioop":("Manipulate raw audio data.","o"),
  153.         "chunk":("Read/write IFF chunked data.","o"),
  154.         "sndhdr":("Identify sound file headers.","o"),
  155.         "sunau":("Read/write Sun AU audio files.","d"),
  156.         "wave":("Read/write WAV audio files.","o")
  157.     },
  158.  
  159.     "GUI": {
  160.         "tkinter":("Standard Python GUI toolkit.","o"),
  161.         "turtle":("Simple drawing and teaching graphics.","o")
  162.     },
  163.  
  164.     "XML / HTML": {
  165.         "xml":("XML processing libraries.","d"),
  166.         "xmlrpc":("XML-RPC client and server.","d"),
  167.         "html":("HTML parsing and manipulation.","o")
  168.     },
  169.  
  170.     "Security / Crypto": {
  171.         "hashlib":("Secure hash and message digest algorithms.","d"),
  172.         "hmac":("Keyed-hash message authentication.","d"),
  173.         "secrets":("Generate cryptographically strong random numbers.","d"),
  174.         "uuid":("Generate universally unique identifiers.","d")
  175.     },
  176.  
  177.     "Miscellaneous": {
  178.         "calendar":("Calendar-related functions.","o"),
  179.         "argparse":("Command-line argument parsing.","o"),
  180.         "getopt":("Legacy command-line parsing.","d"),
  181.         "getpass":("Secure password input.","d"),
  182.         "pprint":("Pretty-print Python objects.","d"),
  183.         "site":("Site-specific configuration hooks.","d"),
  184.         "ensurepip":("Bootstraps the pip installer.","d"),
  185.         "venv":("Create virtual environments.","d"),
  186.         "warnings":("Issue and control warning messages.","o"),
  187.         "weakref":("Weak references to objects.","d"),
  188.         "webbrowser":("Open URLs in a browser.","o"),
  189.         "msilib":("Create and manipulate MSI installers.","d"),
  190.         "msvcrt":("Windows-specific C runtime utilities.","o"),
  191.         "winreg":("Windows registry access.","d"),
  192.         "winsound":("Play sounds on Windows.","o"),
  193.         "xdrlib":("Encode/decode XDR data.","d")
  194.     }
  195. }
  196.  
  197. vars_dict = {}
  198. desc_var = None
  199.  
  200. def apply_mode(mods, mode):
  201.     for module,(desc,flag) in mods.items():
  202.         if mode=="k":
  203.             vars_dict[module].set(flag=="k")
  204.         elif mode=="o":
  205.             vars_dict[module].set(flag in ("k","o"))
  206.         elif mode=="d":
  207.             vars_dict[module].set(flag!="d")
  208.  
  209. def select_all():
  210.     for v in vars_dict.values():
  211.         v.set(True)
  212.  
  213. def select_none():
  214.     for v in vars_dict.values():
  215.         v.set(False)
  216.  
  217. def show_desc(module, category):
  218.     desc, flag = CATEGORIES[category][module]
  219.     desc_var.set(f"{module}: {desc}")
  220.  
  221. def print_sel():
  222.     os.system("cls")
  223.     s=[m for m,v in vars_dict.items() if v.get()]
  224.     print("\n".join(s))
  225.     print("Total:",len(s))
  226.  
  227. root=tk.Tk()
  228. root.title("Module Selector")
  229. root.geometry("+-10+0")
  230.  
  231. desc_var=tk.StringVar()
  232.  
  233. container=ttk.Frame(root)
  234. canvas=tk.Canvas(container,height=600,width=600)
  235. scroll=ttk.Scrollbar(container,orient="vertical",command=canvas.yview)
  236. frame=ttk.Frame(canvas)
  237.  
  238. frame.bind("<Configure>",lambda e:canvas.configure(scrollregion=canvas.bbox("all")))
  239. canvas.create_window((0,0),window=frame,anchor="nw")
  240. canvas.configure(yscrollcommand=scroll.set)
  241.  
  242. container.pack(fill="both",expand=True)
  243. canvas.pack(side="left",fill="both",expand=True)
  244. scroll.pack(side="right",fill="y")
  245.  
  246. style = ttk.Style()
  247. style.configure("Bold.TCheckbutton", font=("TkDefaultFont", 10, "bold"))
  248.  
  249. for category,mods in CATEGORIES.items():
  250.     lf=ttk.LabelFrame(frame,text=category)
  251.     lf.pack(fill="x",padx=10,pady=5)
  252.  
  253.     bf=ttk.Frame(lf)
  254.     bf.pack(fill="x")
  255.  
  256.     ttk.Button(bf,text="KEEP",command=lambda m=mods:apply_mode(m,"k")).pack(side="left")
  257.     ttk.Button(bf,text="OPTIONAL",command=lambda m=mods:apply_mode(m,"o")).pack(side="left")
  258.     ttk.Button(bf,text="DROP",command=lambda m=mods:apply_mode(m,"d")).pack(side="left")
  259.     ttk.Button(bf,text="ALL",command=lambda m=mods:[vars_dict[x].set(True) for x in m]).pack(side="left")
  260.     ttk.Button(bf,text="NONE",command=lambda m=mods:[vars_dict[x].set(False) for x in m]).pack(side="left")
  261.  
  262.     for module,(desc,flag) in mods.items():
  263.         v = tk.BooleanVar(value=(flag in "ok"))
  264.         vars_dict[module] = v
  265.  
  266.         row = ttk.Frame(lf)
  267.         row.pack(fill="x", anchor="w")
  268.  
  269.         ttk.Checkbutton(
  270.             row,
  271.             text=module,
  272.             variable=v,
  273.             command=lambda mod=module, cat=category: show_desc(mod, cat),
  274.             style="Bold.TCheckbutton"
  275.         ).grid(row=0, column=0, sticky="w")
  276.  
  277.         ttk.Label(
  278.             row,
  279.             foreground="red",
  280.             text=desc
  281.         ).grid(row=0, column=1, sticky="w", padx=(20,10))
  282.  
  283.         row.grid_columnconfigure(0, minsize=120)
  284.  
  285. ttk.Button(root,text="PRINT",command=print_sel).pack(side="right")
  286.  
  287. root.mainloop()
Add Comment
Please, Sign In to add comment