Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_Module_Selector.py
- import tkinter as tk
- from tkinter import ttk
- import os
- CATEGORIES = {
- "Core Language / Syntax": {
- "abc":("Tools for defining Abstract Base Classes and enforcing interfaces.","d"),
- "ast":("Represents Python code as an Abstract Syntax Tree for analysis or transformation.","o"),
- "tokenize":("Converts Python source into tokens for parsing or analysis.","d"),
- "token":("Constants representing Python’s lexical tokens.","d"),
- "code":("Utilities for compiling and executing Python code dynamically.","d"),
- "codeop":("Helpers for compiling code conditionally, used by interactive interpreters.","d"),
- "dis":("Disassembles Python bytecode for inspection and debugging.","d"),
- "symtable":("Accesses the compiler’s symbol tables for introspection.","d"),
- "types":("Defines dynamic type objects and helpers used throughout Python.","o"),
- "typing":("Provides type hints and static typing support.","o")
- },
- "Data Structures & Algorithms": {
- "array":("Compact C-style arrays storing basic numeric types efficiently.","o"),
- "bisect":("Maintains sorted lists via binary search insertion.","o"),
- "collections":("High-performance container datatypes like deque, Counter, defaultdict.","k"),
- "heapq":("Implements a binary heap for priority queue operations.","o"),
- "itertools":("Fast, memory-efficient iterator building blocks.","k"),
- "operator":("Functional access to operators for cleaner functional-style code.","o"),
- "functools":("Higher-order functions like lru_cache, partial, reduce.","k"),
- "reprlib":("Generates abbreviated repr() output for large or recursive objects.","d")
- },
- "Math & Numbers": {
- "cmath":("Mathematical functions for complex numbers.","o"),
- "math":("Standard mathematical functions implemented in C for speed.","k"),
- "decimal":("Decimal floating-point arithmetic with exact precision.","o"),
- "fractions":("Implements rational numbers as Fraction objects.","o"),
- "statistics":("Statistical functions like mean, median, stdev.","k"),
- "random":("Pseudo-random number generators and utilities.","k"),
- "numbers":("Abstract base classes for numeric types.","d")
- },
- "File / OS / System": {
- "os":("Portable access to operating system functionality.","k"),
- "pathlib":("Object-oriented filesystem paths.","k"),
- "shutil":("High-level file operations like copy, move, archive.","k"),
- "glob":("Pattern-based file searching using wildcards.","k"),
- "tempfile":("Creates temporary files and directories securely.","k"),
- "stat":("Interprets file stat results and constants.","o"),
- "sys":("Access to interpreter internals and runtime environment.","k"),
- "sysconfig":("Access to Python’s build-time configuration.","d"),
- "platform":("Identifies the underlying platform and system details.","k"),
- "errno":("Standardized error codes from the OS.","o"),
- "signal":("Signal handling for asynchronous events.","d"),
- "atexit":("Registers functions to run at interpreter shutdown.","d"),
- "time":("Time-related functions including sleep and timestamps.","k"),
- "timeit":("Measures execution time of small code snippets.","o"),
- "mmap":("Memory-mapped file support for efficient file access.","d"),
- "posixpath":("POSIX-specific path manipulation helpers.","d"),
- "logging":("Flexible logging system for applications.","o")
- },
- "Text / Parsing / Encoding": {
- "re":("Regular expression engine for pattern matching.","k"),
- "string":("String constants and helper functions.","o"),
- "textwrap":("Wraps and formats text paragraphs.","o"),
- "base64":("Base64 encoding and decoding utilities.","o"),
- "binascii":("Low-level binary/ASCII conversions.","d"),
- "quopri":("Quoted-printable encoding used in email.","d"),
- "uu":("UUencode encoding/decoding.","d"),
- "codecs":("Registry and base classes for text encodings.","d"),
- "encodings":("Implementation of Python’s encoding system.","d"),
- "gettext":("Internationalization and localization support.","d"),
- "keyword":("Tests whether strings are Python keywords.","o"),
- "json":("JSON encoding and decoding.","k")
- },
- "Compression / Archiving": {
- "gzip":("Read and write gzip-compressed files.","o"),
- "bz2":("Bzip2 compression and decompression.","d"),
- "lzma":("LZMA compression and decompression.","d"),
- "zipfile":("Read and write ZIP archives.","o"),
- "zipimport":("Import modules from ZIP archives.","d"),
- "zipapp":("Create executable Python ZIP applications.","d"),
- "tarfile":("Read and write TAR archives.","d")
- },
- "Networking / Internet": {
- "socket":("Low-level networking interface.","o"),
- "socketserver":("Framework for network servers.","d"),
- "http":("HTTP client and server utilities.","o"),
- "urllib":("URL handling and HTTP requests.","o"),
- "ftplib":("FTP client protocol implementation.","d"),
- "imaplib":("IMAP email client.","d"),
- "poplib":("POP3 email client.","d"),
- "smtplib":("SMTP email sending client.","d"),
- "smtpd":("SMTP server implementation.","d"),
- "telnetlib":("Telnet client.","d"),
- "nntplib":("NNTP newsgroup client.","d"),
- "wsgiref":("WSGI utilities and reference server.","d"),
- "ipaddress":("Manipulate IPv4 and IPv6 addresses.","d")
- },
- "Concurrency / Async": {
- "threading":("High-level threading interface.","o"),
- "multiprocessing":("Process-based parallelism.","o"),
- "concurrent":("Futures for thread and process pools.","o"),
- "asyncio":("Asynchronous I/O framework.","o"),
- "asynchat":("Legacy async chat handler.","d"),
- "asyncore":("Legacy async socket handler.","d"),
- "queue":("Thread-safe FIFO queue.","o"),
- "selectors":("High-level I/O multiplexing.","d"),
- "select":("Low-level I/O multiplexing.","d"),
- "sched":("Event scheduler.","d"),
- "contextvars":("Context-local state for async tasks.","d")
- },
- "Debugging / Introspection": {
- "inspect":("Retrieves information about live objects.","o"),
- "traceback":("Extracts, formats, and prints stack traces.","o"),
- "trace":("Tracks program execution and generates coverage.","o"),
- "tracemalloc":("Tracks memory allocations.","d"),
- "pdb":("Interactive debugger.","o"),
- "bdb":("Debugger framework used by pdb.","d"),
- "profile":("Deterministic profiler.","d"),
- "cProfile":("C-optimized profiler.","d"),
- "pstats":("Profiler statistics manipulation.","d"),
- "faulthandler":("Prints tracebacks on fatal errors.","d"),
- "linecache":("Random access to lines of Python source.","o"),
- "runpy":("Run modules by name or path.","o"),
- "pyclbr":("Class browser support.","d"),
- "pydoc":("Generates Python documentation.","o"),
- "pydoc_data":("Data used by pydoc.","o")
- },
- "Databases / Storage": {
- "sqlite3":("Built-in SQLite database engine.","d"),
- "shelve":("Persistent dictionary-like objects.","d"),
- "dbm":("Simple key-value database interfaces.","d"),
- "plistlib":("Read/write Apple plist files.","d"),
- "mailbox":("Manipulate mailbox formats.","d")
- },
- "Email / MIME": {
- "email":("Construct, parse, and handle email messages.","d"),
- "mailcap":("Mailcap file handling.","d"),
- "imghdr":("Detect image file types.","d"),
- "mimetypes":("Guess MIME types based on filenames.","d")
- },
- "Audio": {
- "aifc":("Read/write AIFF audio files.","d"),
- "audioop":("Manipulate raw audio data.","o"),
- "chunk":("Read/write IFF chunked data.","o"),
- "sndhdr":("Identify sound file headers.","o"),
- "sunau":("Read/write Sun AU audio files.","d"),
- "wave":("Read/write WAV audio files.","o")
- },
- "GUI": {
- "tkinter":("Standard Python GUI toolkit.","o"),
- "turtle":("Simple drawing and teaching graphics.","o")
- },
- "XML / HTML": {
- "xml":("XML processing libraries.","d"),
- "xmlrpc":("XML-RPC client and server.","d"),
- "html":("HTML parsing and manipulation.","o")
- },
- "Security / Crypto": {
- "hashlib":("Secure hash and message digest algorithms.","d"),
- "hmac":("Keyed-hash message authentication.","d"),
- "secrets":("Generate cryptographically strong random numbers.","d"),
- "uuid":("Generate universally unique identifiers.","d")
- },
- "Miscellaneous": {
- "calendar":("Calendar-related functions.","o"),
- "argparse":("Command-line argument parsing.","o"),
- "getopt":("Legacy command-line parsing.","d"),
- "getpass":("Secure password input.","d"),
- "pprint":("Pretty-print Python objects.","d"),
- "site":("Site-specific configuration hooks.","d"),
- "ensurepip":("Bootstraps the pip installer.","d"),
- "venv":("Create virtual environments.","d"),
- "warnings":("Issue and control warning messages.","o"),
- "weakref":("Weak references to objects.","d"),
- "webbrowser":("Open URLs in a browser.","o"),
- "msilib":("Create and manipulate MSI installers.","d"),
- "msvcrt":("Windows-specific C runtime utilities.","o"),
- "winreg":("Windows registry access.","d"),
- "winsound":("Play sounds on Windows.","o"),
- "xdrlib":("Encode/decode XDR data.","d")
- }
- }
- vars_dict = {}
- desc_var = None
- def apply_mode(mods, mode):
- for module,(desc,flag) in mods.items():
- if mode=="k":
- vars_dict[module].set(flag=="k")
- elif mode=="o":
- vars_dict[module].set(flag in ("k","o"))
- elif mode=="d":
- vars_dict[module].set(flag!="d")
- def select_all():
- for v in vars_dict.values():
- v.set(True)
- def select_none():
- for v in vars_dict.values():
- v.set(False)
- def show_desc(module, category):
- desc, flag = CATEGORIES[category][module]
- desc_var.set(f"{module}: {desc}")
- def print_sel():
- os.system("cls")
- s=[m for m,v in vars_dict.items() if v.get()]
- print("\n".join(s))
- print("Total:",len(s))
- root=tk.Tk()
- root.title("Module Selector")
- root.geometry("+-10+0")
- desc_var=tk.StringVar()
- container=ttk.Frame(root)
- canvas=tk.Canvas(container,height=600,width=600)
- scroll=ttk.Scrollbar(container,orient="vertical",command=canvas.yview)
- frame=ttk.Frame(canvas)
- frame.bind("<Configure>",lambda e:canvas.configure(scrollregion=canvas.bbox("all")))
- canvas.create_window((0,0),window=frame,anchor="nw")
- canvas.configure(yscrollcommand=scroll.set)
- container.pack(fill="both",expand=True)
- canvas.pack(side="left",fill="both",expand=True)
- scroll.pack(side="right",fill="y")
- style = ttk.Style()
- style.configure("Bold.TCheckbutton", font=("TkDefaultFont", 10, "bold"))
- for category,mods in CATEGORIES.items():
- lf=ttk.LabelFrame(frame,text=category)
- lf.pack(fill="x",padx=10,pady=5)
- bf=ttk.Frame(lf)
- bf.pack(fill="x")
- ttk.Button(bf,text="KEEP",command=lambda m=mods:apply_mode(m,"k")).pack(side="left")
- ttk.Button(bf,text="OPTIONAL",command=lambda m=mods:apply_mode(m,"o")).pack(side="left")
- ttk.Button(bf,text="DROP",command=lambda m=mods:apply_mode(m,"d")).pack(side="left")
- ttk.Button(bf,text="ALL",command=lambda m=mods:[vars_dict[x].set(True) for x in m]).pack(side="left")
- ttk.Button(bf,text="NONE",command=lambda m=mods:[vars_dict[x].set(False) for x in m]).pack(side="left")
- for module,(desc,flag) in mods.items():
- v = tk.BooleanVar(value=(flag in "ok"))
- vars_dict[module] = v
- row = ttk.Frame(lf)
- row.pack(fill="x", anchor="w")
- ttk.Checkbutton(
- row,
- text=module,
- variable=v,
- command=lambda mod=module, cat=category: show_desc(mod, cat),
- style="Bold.TCheckbutton"
- ).grid(row=0, column=0, sticky="w")
- ttk.Label(
- row,
- foreground="red",
- text=desc
- ).grid(row=0, column=1, sticky="w", padx=(20,10))
- row.grid_columnconfigure(0, minsize=120)
- ttk.Button(root,text="PRINT",command=print_sel).pack(side="right")
- root.mainloop()
Add Comment
Please, Sign In to add comment