copyCode prototypes: 15 versions towards ThuOneCopy
Across October and November 2024 I iterated a file-picker-to-clipboard tool through 15 versions, adding filtering and a packaged build before it became ThuOneCopy.
- Period
- Oct 2024 – Nov 2024
- Technologies
- 2
- Diagrams
- 1
- Reading time
- 2 min
Purpose
Select multiple files from a project tree and copy their contents as one block (for pasting into ChatGPT), with filtering and light code cleanup.
Version History
| Version | Date | Lines | Key functions / change |
|---|---|---|---|
copyCode.py |
10-21 | 267 | First full UI: initUI, recursive checkboxes (add_checkbox_recursive), tree click → open_file_tab, selected list, filters (create_filters, update_filter), copy_code, process_file, extract_class_names, open_folder |
copyCode2.py |
10-21 | 111 | Side experiment: pyperclip copy + cleanup (remove_multiline_comments, remove_single_line_comments, remove_imports, order_with_numbers, show_copied_code) |
copyCode3.py |
10-21 | 254 | Back to the tree UI; adds close_tab |
copyCode4.py |
10-21 | 262 | Refinements |
copyCode5.py |
10-21 | 288 | select_files_in_folder (folder select) |
copyCode6.py |
10-21 | 282 | toggle_selection_in_folder (toggle instead of select) |
copyCode7.py |
10-21 | 352 | Custom checkable model (flags, data, setData, get_checked_files, clear_checked) + two-way sync (update_selected_files, on_selected_list_item_changed) |
copyCode8.py |
11-18 | 366 | Adds eventFilter (keyboard / mouse handling) |
copyCode_8_1.py |
11-18 | 380 | 8.x branch tweaks |
copyCode_8_2.py |
11-18 | 383 | 8.x tweaks |
copyCode_8_3.py |
11-18 | 403 | Most complete 8.x |
copyCode9.py |
11-18 | 355 | Alternative without eventFilter |
copyCode10.py |
11-18 | 354 | Variant of 9 |
exe/ThuOneCopy_v1.py |
11-18 | 403 | Release candidate (= the 8_3 feature set) + setup.py for packaging → first exe |
Best / latest: exe/ThuOneCopy_v1.py (equivalent to copyCode_8_3.py). copyCode5.txt is a text copy of v5; note.txt / note0.txt hold the prompts. |
How it works
Diagram as text
flowchart TD
O[Open folder] --> T[QTreeView + checkable model]
T -->|check folder| R[recursive select / toggle files]
T -->|click file| TAB[open in tab]
R --> L[selected-files list ⇄ tree sync]
L --> F{filters: extensions / names}
F --> C[copy_code: read files, process_file, headers, class names]
C --> CB[(clipboard)]Techniques
Qt model / view with custom flags / setData check states; recursive tree traversal; regex comment / import stripping; event filters; iterative prototyping with LLM assistance.
Related projects
HAR and Copy-as-fetch to API documentation formatter
A Tkinter and browser tool that turns HAR files and Copy-as-fetch strings into clean API documentation, with key masking for safe sharing.
PythonDesktop GUI (Tk / Qt)JavaScriptPDF Agent: PDF split and shuffle tool (4 versions)
A small Tkinter desktop tool that splits PDFs several ways for visa-document preparation, refined through four versions in one week.
PythonPDF & document generationDesktop GUI (Tk / Qt)Redwings PDF Tools: desktop PDF compressor and toolkit
A desktop PDF compressor with a binary search for the sharpest result under a size limit.
PythonPDF & document generationDesktop GUI (Tk / Qt)SQLiteWant to discuss this project?
Happy to walk through the architecture, trade-offs or the code.