This Python script implements a graphical user interface (GUI) application using the Tkinter library. The application allows users to process Word/PDF files, view the processed content, and perform regular expression pattern matching.
The FileProcessorApp class manages the file processing functionality. It provides a GUI for users to drag and drop or select Word/PDF files. The processed content is displayed, and users can switch to the RegexApp for further pattern matching.
__init__(self, root): Initializes the FileProcessorApp with the main Tkinter root window.hide(self): Hides the current window.show(self): Shows the current window.switch_to_file_processor(self): Switches to the FileProcessorApp window.switch_to_regex_app(self): Switches to the RegexApp window.handle_drop(self, event): Handles the drop event when files are dragged and dropped.open_file_dialog(self): Opens a file dialog for users to select a file.enable_switch_button(self): Enables the switch button to the RegexApp after processing is complete.update_status(self, message): Updates the status bar with the given message.process_file(self, file_path): Processes the selected file, extracting text content and saving it to 'output.txt'.
The RegexApp class manages the regular expression pattern matching functionality. It displays metacharacters, special sequences, and sets. Users can enter a regex pattern to search for matches in the processed text.
__init__(self, root): Initializes the RegexApp with the main Tkinter root window.hide(self): Hides the current window.show(self): Shows the current window.switch_to_file_processor(self): Switches to the FileProcessorApp window.toggle_edit_mode(self): Toggles between view and edit modes for the search results.find_matches(self): Finds and displays matches for the entered regex pattern.display_dictionary(self, heading, desc, dictionary): Displays dictionaries of metacharacters, special sequences, and sets.
- Label for instructions
- Drag and drop functionality
- Button to select files
- Status bar
- Switch button to RegexApp
- Text widget for metacharacters, special sequences, and sets
- Entry widget for entering regex patterns
- Button to trigger search
- Labels for displaying total words, matched words, and most frequent words
- Edit button to toggle between view and edit modes
- Text widget for displaying search results
- User opens the application.
- In the FileProcessorApp:
- User drags and drops or selects Word/PDF files.
- The processed content is displayed.
- User can switch to the RegexApp for pattern matching.
- In the RegexApp:
- User views metacharacters, special sequences, and sets.
- User enters a regex pattern and clicks the search button.
- Search results, total words, matched words, and most frequent words are displayed.
- User can toggle between view and edit modes.
- User can switch back and forth between FileProcessorApp and RegexApp as needed.
- Run the script.
- Drag and drop or select Word/PDF files in the FileProcessorApp.
- View processed content and switch to the RegexApp for pattern matching.
- Enter regex patterns in the RegexApp to search for matches.
- Tkinter: Python's standard GUI library.
- tkinterdnd2: A Tkinter extension for drag-and-drop functionality.
- pdfplumber: A library for extracting text content from PDF files.
Follow these steps to run the File Processor and RegexApp:
-
Install dependencies using pip:
pip install -r requirements.txt
-
Run the main script:
python main.py
Ensure that you have Python installed on your machine.
- The processed content is saved to 'output.txt'.
- The application supports Word (.docx) and PDF (.pdf) file formats.
- Users can explore and understand regex patterns using the RegexApp.


