Skip to content

Commit

Permalink
Merge v1.96_dev with main branch (#36)
Browse files Browse the repository at this point in the history
* Initial v1.96 commit

  - New:
    - New feature `Thumbnail Panel`: Displayed below the current image.
    - Added `Copy` command to the right-click textbox context menu.

  - Fixed:
    - Fixed issue where the `Delete Pair` tool would overwrite the next index with the deleted text.
    - Fixed an issue that was degrading the quality of the displayed image and not respecting the `Image Display Quality` setting.
    - Fixed a memory leak that could occur whenever the primary image is displayed.
    - Fixed Next/Previous button not properly displaying their relief when clicked.
    - Fixed an issue where landscape images were improperly scaled, leading to an incorrect aspect ratio.
    - Fixed `Open Text Directory...` not respecting the actual filepath if set by `Set Text File Path...`.
    - Fixed issue where the file lists were not updated when using the internal function "jump_to_image()".
    - Fixed the following tools not respecting the `Loading Order > Descending` setting, causing them to jump to the wrong index.
      - `Image Grid`, `Upscale Image`, `Resize Image`
    - Potential fix for the `Stats > PPI` calculation returning "0.00".
    - Small improvements to the directory entry logic that make it more robust and less annoying.

  - Other changes:
    - Using `Open Current Directory...` will now automatically select the current image in the file explorer.
      - The `Open` button will also select the current image if the path being opened is the same as the image path.
    - The Image info (the stats displayed above the image) is now cached for quicker access.
    - `Zip Dataset...` Now only zips images and text files in the selected directory, omitting subfolders.
    - The `Options`, and `Tools` menus have been reorganized.
    - The color mode is now displayed in the image info panel.
    - You can now close the `Crop Image` window with the `Escape` key.

  - Project Changes:
    - `Upscale`: v1.05:
      - FIXED: Prevent the app from hanging while upscaling a GIF.
    - `Batch Resize`: v1.07:
      - NEW: A timer is now displayed in the bottom row.
      - FIXED: The following resize modes not working/causing an error: `Longer Side`, and `Height`
    - `TkToolTip`: v1.06:
      - NEW: Added `justify` parameter to allow defining/configuring text justification in the tooltip.
      - FIXED: Issue where the underlying widget would be impossible to interact with after hiding the tooltip.
      - CHANGE: Now uses `TkDefaultFont` instead of Tahoma as the default font for the tooltip text.

* Update TkToolTip.py

Revise Usage formatting.

* v1.96_dev update

* Update save_image_edit()

Use the `with` file manager to automatically close the image after saving.

* v1.96_dev - Additional features

    - New feature `Edit Image Panel`: Enabled from the options/image menu, this section allows you to edit the `Brightness`, `Contrast`, `Saturation`, `Sharpness`, `Highlights`, and `Shadows` of the current image.
    - New feature `Edit Image...`: Open the current image in an external editor, the default is MS Paint.
    - New feature `Open With`: Trigger the _Open With_ dialog to pick and choose a specific application to open the image with.
    - A quick guided setup will run on the app's first launch, or if the settings file is deleted.
      - This will set the preferred autocomplete dictionaries and matching settings.

* Reset index entry on ValueError

* Added "Boost" setting to sharpness adjustment

Minor refactor to the way the window is created.

* Create: BatchTagEdit & TagEditor

TagEditor is a tool for analyzing and editing tags across many text files. It creates a dictionary of tags and their file/text position so they can be easily addressed later.

BatchTagEdit is the replacement for batch_tag_delete. BTE has an improved and more versatile UI, along with being able to not only delete tags, but edit them.

BatchTagEdit is a more optimized and efficient version of batch_tag_delete.

* Update README.md

* Update README.md

* BatchTagEdit, edit_panel, and TkToolTip updates

* Update TkToolTip.py

Fix issue when the _fade() function is called and the tip_window no longer exists

* Update img-txt_viewer.pyw

Add additional commands to thumbnail context menu.

Handle RGBA images in in the "edit_panel". (disable adjustment)

Remove "Open With..." command as it no longer works in Windows 11.

open_image_in_editor(), and delete_pair() now support a specific index to act upon.

* cleanup

* Preliminary update to ttk widgets

+ Some very minor cleanup/organizing.

* Convert "font_size_var" to an IntVar()

* Update "edit_image_panel" layout

* Update img-txt_viewer.pyw

* Update README.md

* Create Start.bat

Used for creating and activating the virtual environment, along with installing  requirements, and starting the app.

* Update release information, update README

* Revise "#region - Changelog" formatting

* Batch Resize Images now uses ttk widgets

* Update TkToolTips: New default background color

+ Minor organization

* Minor organization

* upscale_image.py - Organize imports

* Organize import statements

* find_dupe_file now uses TkToolTips

* Move to TkToolTip git package

* Move 'batch_tag_edit' to it's own script

* Update batch_tag_edit.py

Trying to set the stage for a more homogonous set of variable names for these tools, along with a more logical ordering of arguments.

* batch_resize_images is not built-in

Move batch_resize_images.py to "scripts", and refactor it to be displayed inside the main UI.

* Update internal notes

* Update README.md

* Update README.md

* Update img-txt_viewer.pyw

* Update img-txt_viewer.pyw

Fix "big_save_button" not being reset to "True"

Increase width of Save/Revert button to better accommodate when the "Revert" button text is "Restore".

* Update README.md

* Update img-txt_viewer.pyw

Disable 'Open With' dialog.

I could only get this working with file paths without spaces, all the usual fixes didn't work.

* Refactor 'find_dupe_files' into a built-in tool

* Alt tool setup, and UI state setup

Alt tools are now initialized directly inside the ImgTxtViewer init for better reusability.

The UI state can now be tracked when switching tools. I'd like this to be more flexible (for the user) but it's fine how it is.

* Update img-txt_viewer.pyw

Update some tool popup positions

* Refactor settings logic and other initial code

* Refactor main 'About Window' to separate script

* Update internal Todo list

* Organizing

* misc

Disable some menus on startup, check directory on "index_goto_next_empty()", rename some variables in "_save_file()"

* Update Start.bat

* Update img-txt_viewer.pyw

* Replace 'message_label'; update suggestion logic

Replace the 'message_label' with a visual indicator in the title.

Suggestions can now be clicked to insert them.

The comma from the last suggestion is stripped away.

* Update batch_resize_images.py

* Update find_dupe_file.py

* restructure 'upscale' files

* upload new models

 - Added two additional upscale models: `AnimeSharp-4x` and `UltraSharp-4x`.

* remove unneeded models

A scale of '4' is always used, so these models aren't needed.

* Create models folder

Additional NCNN models will be loaded from here.

* update upscale_image.py

 - Added two additional upscale models: `AnimeSharp-4x` and `UltraSharp-4x`.

- Additional NCNN upscale models can now be loaded by placing them in the `models` directory.

* Update about_img_txt_viewer.py

* Update img-txt_viewer.pyw

* Restructure 'edit_panel'

Move 'edit_panel' into a new class 'EditPanel' outside of 'ImgTxtViewer'

* Update dictionary.csv

Updated the top 1700 words with new/better "aliases" for improved autocomplete suggestions.

Some issues occurred, but they shouldn't be a big deal. Primarily, there are some duplicates, and some aliases may also be the true-name.

* Update 'Autocomplete' class

* Update 'Autocomplete' Class

Pre-cache single letter suggestions for the loaded dictionary.

Cache all suggestions for quicker retrieval.

Some organization.

* Update img-txt_viewer.pyw

* Improve precache handling

* misc changes

* Create .gitignore

* Highlight suggestions on mouse hover

* All highlights now use 'pastel_colors'

- Custom and duplicate highlights now use a range of pastel colors.

* misc changes

* Fix _extract_tags splitting tags with special characters

Treat only commas as delimiters to avoid turning "close-up" into "close" and "up" as well as "^_^" into "_" etc. 

Also removes empty and white-space only strings.

walrus :=

* Fix delete_tag_under_mouse

If the text contained two tags where the second tag is a substring of the first (e.g., "military uniform, uniform"), line_text.find(tag) would find "uniform" in "military uniform" when analyzing the "uniform" tag which would set the indices incorrectly and end up throwing an error because clicked_tag was never defined.

* Refactor delete_tag_under_mouse()

Refactored the delete_tag_under_mouse() method by breaking it down into smaller, reusable functions: set_text_highlight() for configuring and adding text highlight tags, delete_tag() for deleting the selected tag and cleaning up the text, get_cursor_and_line_text() for retrieving cursor and line text information, and find_clicked_tag() for identifying the tag under the cursor.

* Update TagEditor.py

* Update changelog

* Fix incorrect object lookup+

Fix incorrectly looking for "self" instead of "self.parent" object.

Fixed issue where the font settings weren't being set after reading them.

* Fix 'delete_tag_under_mouse()` (#39)

* Original issue by @UrzasLegacy (#39)

---------

Track delete_tag job and cancel old job if a new job occurs.

Fix clipboard issue.

---------

Co-authored-by: Nenotriple <[email protected]>

* Update README.md

* Update changelog, about, remove F5 refresh bind

Sync "about" with GitHub README.

Commented out the refresh bind "F5" because it was overlapping with the "Batch Tag Edit" bind. Some other button combo could be used, maybe "Shift+F5", but it's not something I used often.

* Update variable names and consolidate after() IDs

* Update img-txt_viewer.pyw

Run sync_title_with_content() after deleting a tag. This is done to check if the file is different from the text_box.

* ONNX tool (#41)

* Add ONNX tagging prototype

* Generalize and integrate with img-txt_viewer

* .gitkeep onnx_models folder

* Refactor OnnxTagger

Here's where I'm at with the refactoring:

1) I constructed a class for `OnnxTagger`
2) All settings and variables for `OnnxTagger` are contained inside its own class, making initialization and access easier.
3) Using the class is simple to execute:
   - `onnx_tagger= OnnxTagger()`
   - `onnx_tagger.tag_image("image_path")`
 4) The `tag_image()` function now returns the results, so they only need to be formatted once.
 5) I don't think we'll be using a pop-up window for the results, so I removed that.
 6) For now I disabled the `SettingsManager` logic, just temporary.

The function to tag an image can now be called as simple as this *(From ImgTxtViewer)*:

    def infer_tags(self):
        csv_result, confidence_result = self.onnx_tagger.tag_image(self.image_files[self.current_index])
        print(csv_result, confidence_result)

* Add batch inference benchmarking

* Update img-txt_viewer.pyw

Remove test code

* Update OnnxTagger.py

Remove test code

---------

Co-authored-by: Nenotriple <[email protected]>

* v1.96_dev Bug Fixes (#44)

* Handle clipboard empty or non-text data

* Fix bug ttk.Button doesn't have "Height" param

* Fix manually closing about window

* Fix restore_backup success messagebox showing for every image restored

* Fix image_index_entry refresh issue on successful filter. Minor UX improvements

* Fix save_button padding reset issue

* Fix attribute initialization issues in edit_panel

* Set initial directory for file dialog in choose_working_directory.
- Use last saved directory from config if 'self.image_dir' is invalid.
- Default to script directory if no valid path is found.

* Update edit_panel.py

"edit_is_reverted_var" and "current_image" are a variable of ImgTxtViewer, so it should be accessed from EditPanel using "parent".

* Update about_img_txt_viewer.py

* Update about_img_txt_viewer.py

Keep index when clearing the filter. This prevents the index from resetting to 1 if the filter is invalid.

* Revert last commit

* Update img-txt_viewer.pyw

Keep index when clearing the filter. This prevents the index from resetting to 1 if the filter is invalid.

---------

Co-authored-by: Nenotriple <[email protected]>

* Merge OnnxTagger with v1.96_dev (#42)

* Add ONNX tagging prototype

* Generalize and integrate with img-txt_viewer

* .gitkeep onnx_models folder

* Refactor OnnxTagger

Here's where I'm at with the refactoring:

1) I constructed a class for `OnnxTagger`
2) All settings and variables for `OnnxTagger` are contained inside its own class, making initialization and access easier.
3) Using the class is simple to execute:
   - `onnx_tagger= OnnxTagger()`
   - `onnx_tagger.tag_image("image_path")`
 4) The `tag_image()` function now returns the results, so they only need to be formatted once.
 5) I don't think we'll be using a pop-up window for the results, so I removed that.
 6) For now I disabled the `SettingsManager` logic, just temporary.

The function to tag an image can now be called as simple as this *(From ImgTxtViewer)*:

    def infer_tags(self):
        csv_result, confidence_result = self.onnx_tagger.tag_image(self.image_files[self.current_index])
        print(csv_result, confidence_result)

* initial

* Rename ONNXTagger.py to OnnxTagger.py

* Return 'confidence_result' as a dictionary

confidence_result is now a dictionary where keys are tags and items are tag confidence scores.

This makes handling the data much easier.

* Further UI setup

Initial implementation of inserting tags into the UI.

* Update OnnxTagger.py

Add docstring

* Update OnnxTagger.py

Initialize replace_underscore as a BooleanVar to make it easier to interact with from ImgTxtViewer

* Update OnnxTagger.py

OnnxTagger is no longer responsible for getting the model_path.

The model_path must now be sent along with "tag_image()".

* update create_auto_tag_widgets_tab4()

ImgTxtViewer now scans a "onnx_models" folder and creates a dictionary (self.onnx_model_dict) where keys are model folder basenames, and items are .onnx model filepaths.

* Update img-txt_viewer.pyw

* Update OnnxTagger.py

* Update OnnxTagger.py

Update "_read_csv_tags()" so it never replaces the kaomoji that include underscores.

* Update img-txt_viewer.pyw

* Update OnnxTagger.py

_format_results() now returns tag_list, and tag_dictionary

tag_dictionary now contains the specific tag category.

* Update img-txt_viewer.pyw

Update "parse_interrogation_result()" to handle the new "tag_dictionary" setup.

* Update OnnxTagger.py

Rename, etc.

* Update img-txt_viewer.pyw

Rename and cleanup "parse_interrogation_result()"

* Update img-txt_viewer.pyw

`exportselection=False` prevents the Listbox selection from being cleared when the widget loses focus.

Rename `get_model_list()` to `get_onnx_model_list()`

* Update img-txt_viewer.pyw

- Auto insert generated tags

- Insert selection prefix/append/replace

- Display total/selected tags in UI

* Add Entry widgets cluster

* Update img-txt_viewer.pyw

Pad the selected tags to the same length as the total tags to prevent the label width from changing during selection.

(prevent the label from jumping around as it updates from 1s to 10s for example)

Collapse `create_auto_tag_widgets_tab4()`

* Update OnnxTagger.py

Use a Tkinter messagebox for dispalying errors

* Implement tagger Listbox context menu

* Update img-txt_viewer.pyw

Rename "Auto-Tag" to "AutoTag"

Rename "My Tags" to "MyTags"

* Update OnnxTagger.py

Rename "replace_underscore" to "keep_underscore"

Introduce new variable (unused) "keep_escape_character = BooleanVar(value=False)"

* Update img-txt_viewer.pyw

Add "Keep (\)" checkbutton. (unused)

Organize both checkbuttons in a frame.

* Update OnnxTagger.py

Implement: "keep_tags = []" logic. All tags in the list will always be inserted in the returned tags.

Implement: "replace_tag_dict = {}" logic. "replace_tag_dict " is a dictionary where keys are tag strings, and items are tags that will replace their key.

* Color "keep" tags red

* Update img-txt_viewer.pyw

Implement logic that sets the "exclude_tags", "keep_tags", and "replace_tag_dict" OnnxTagger variables from ImgTxtViewer.

* Update OnnxTagger.py

* Update OnnxTagger.py

Organize and refactor some logic.

tag_list is now returned as a list instead of a string.

* Convert tag_list items to a single string

* Update img-txt_viewer.pyw

Implement "max_tags" logic.

Count tags while adding them to the Listbox, if count exceeds "max_tags", stop inserting tags into the Listbox.

* Organize 'text_notebook'

Ensure only the necessary variables are initialized in the ImgTxtViewer class.

* Create .gitattributes

* Update .gitignore

* Delete .gitattributes

* Update img-txt_viewer.pyw

Condense the text_widget_frame printout to a lambda function.

* Simplify entry binds

* Update img-txt_viewer.pyw

* Move "max_tag" logic to "interrogate_image_tags()"

* Add Spinbox validation

* Update OnnxTagger.py

Only reload model if the model_path has changed since the last run.

Only reload the model_tags if the model_path, or options have changed.

Move `keep_underscore` logic from `_read_csv_tags()` to `_format_results`

* Update img-txt_viewer.pyw

* Update `tag_image()` docstring

* Adjust _preprocess_image (#45)

* Adjust _preprocess_image

Avoid stretching image and use Lanczos for a huge improvement in recognition


* Use average image color as background fill 

_get_avg_color() takes a pixel border from around the original image, averages the pixel colors, and returns a tuple of integers, each representing the average value of the red, green, and blue components of the border pixels.

---------

Co-authored-by: Nenotriple <[email protected]>

* Update OnnxTagger.py

* Update img-txt_viewer.pyw

Add `auto_exclude_tags_checkbutton` and logic.

* Update img-txt_viewer.pyw

Replace `auto_insert_checkbutton` with `auto_insert_menubutton`.

Tags can now be auto-inserted with the following options: Prefix, Append, Replace

`auto_insert_tags()` handles this new insert logic.

* Update img-txt_viewer.pyw

* Update img-txt_viewer.pyw

* Add help button/info

* Update img-txt_viewer.pyw

---------

Co-authored-by: Alistor <[email protected]>

* Update ONNXTagger.py

* Update changelog and show_auto_tag_help() message

* Fix broken assignments

* Update img-txt_viewer.pyw

Improve `show_auto_tag_help()` message.

Ask to open `show_auto_tag_help()` if no model is selected and the user tries to interrogate an image.

* Update .gitignore

* Fix initialdir fallback error (#47)

* Merge CropUI with v1.96_dev branch (#48)

* Create CropUI.py

* Bring changes from pr#47 to CropUI branch

* Update CropUI.py

Add `.webp` support.

Add error message if no images are found in the selected director.

* Update CropUI.py

* Update CropUI.py

Further organize Handle logic into the CropSelHandles class.

Fix `self.pos_x_spinbox.set()` and  `self.pos_y_spinbox.set()` being set incorrectly.

* Update CropUI.py

Organize and refactor

* Update CropUI.py

* Update CropUI.py

Potential fix for:

- Image scale dictates crop selection accuracy.
  - Separate image coords from canvas coords.

Widget values are now updates more selectively.

crop_image() now builds the image coords by the widget values, so no scaling is needed.

* Update CropUI.py

Implement "expand_from_center" while using handles to resize the selection.

* Update CropUI.py

Initial implementation of "fixed selection" handling.

* Disable width/height widgets by mode

* Update CropUI.py

Still need to implement "fixed selection" logic for handles.

* Update CropUI.py

* Hide handles based on selected mode.

* Update CropUI.py

Implement logic that maintains aspect ratio of the rectangle when resizing using a handle during "Aspect Ratio" mode.

* Update CropUI.py

Lock width/height initial selection to center if expand_from_center_var is True

Normalize UI widget sizes.

* Fix error if `center_x - center_y` were not defined

* Initial "Auto Aspect" mode UI implementation

* Initial implementation of Auto Aspect mode

* Remove test bind

* Update CropUI.py

* Move CropUI.py

* Delete crop_image.py

* Replace `crop_image` with `CropUI`

Rough initial implementation into ImgTxtViewer.

* Further integrate CropUI into ImgTxtViewer

* Fix typo

* Implement CropUI ui_state

* Update img-txt_viewer.pyw

Refactor "ui_state" to simply be a string.

Refactor the "toggle_alt_ui_menus()" logic to be more modular.

* Update changelog

* Update changelog

* Update CropUI.py

Set path and current image when loading CropUI

* Send `ImgTxtViewer.image_files` to CropUI

* Add `After Crop` menu

This menu will dictate the behavior of the app after cropping.

* Add context menu to Entry and Spinbox widgets

* Update CropUI.py

Prevent selection overrun in "Width", and "Height" modes.

Allow resizing the selection by moving the mouse vertically/horizontally in "Aspect Ratio" mode.

Prevent "crop_info_label" jumping around when the character count changes by adding a fixed width.

* Update CropUI.py

Ad Index Spinbox, and total image label.

Keep selection when resizing the window.

Fix issues with Aspect Ratio mode and Expand from center.

Organize and refactor some code.

* Add `Toggle overlay` logic

* Add Double-Click to create a selection

Double-Click to quickly create a selection that's centered and half-size.

* Fix "Aspect Ratio" mode overrunning image bounds

* Update CropUI.py

Add transform controls, Rotate, Flip_x, Flip_y

Organize interface

* Initial `After Crop` logic implementation

* Auto-select AutoTag tab when running interrogator

* Implement `Adjust selection with mousewheel` logic

* Update widgets during mousewheel resize

* Update CropUI.py

CropInterface now initializes variables during class construction so settings are persistent when opening/closing CropUI.

Organize and rename some variables.

* Add `Open dir` logic to the `open_button`

* Update CropUI.py

Prevent aspect ratio from breaking during "Aspect Ratio" mode wile expanding with the mouse wheel.

* Rename `models` folder to `ncnn_models`

* Rename `models` folder to `nccn_models`

* Streamline startup script

* Rename img-txt_viewer.pyw to img-txt_viewer.py

* Update img-txt_viewer.py

Fix `validate_spinbox_value()` not working correctly for the `auto_tag_max_tags_spinbox` widget, preventing the value from being adjustable.

* Update edit_panel.py

Initialize `edit_is_reverted_var ` inside `edit_panel.py`

* Add PyTrominoes `Easter Egg` game

* Update img-txt_viewer.py

* Update PyTrominos.py

Add ghost piece.

Better handling of key repeat and delay when holding a button.

Score is now also multiplied by level, max x3

* Update PyTrominos.py

Add a way to quickly start the game without ImgTxtViewer

* Add selection guidelines

* Add onnxruntime version

* Re-focus game window after closing help

* Add batch image interrogation

* Organize shapes, reposition I, J, and L shapes

* Update Start.bat

Add option to install requirements.txt if it exists.

* Update img-txt_viewer.py

Allow Batch interrogation to properly utilize "auto_exclude_tags_var" by checking the txt file instead of the text_box.

* Fix thumbnail_panel event error

Replace lambda with named function for Button-3 binding to handle event argument correctly.

* Used to filter CSV dictionaries using a blacklist.

* Create danbooru_safe.csv

The majority of NSFW tags are removed (using `filter_csv.py`).

All artist tags are removed.

43,167 rows removed. This makes it a great dictionary to load alongside the English dictionary!

* Add `danbooru_safe`

* Update internal changelog

* Enable `Crop...` imageContext command for GIFs

* Update CropUI.py

Add thumbnail_panel for GIF frames, allowing you to select individual frames for cropping.

Added button "Extract GIF", used to extract the GIF frames and save them to the disk.

* Update CropUI.py

Add highlight to selected thumbnail.

* Update CropUI.py

Fix aspect ratio breaking when selection expands against both top and bottom boundary.

* Update CropUI.py

Fix issue where Aspect Ratio wasn't fixed when dragging from right-to-left.

* Update CropUI.py

Fix issue where the overlay would only properly update when going from disabled to enabled. Using `ImgCanvas.refresh_image()` is a better approach.

* Update CropUI.py

* Update img-txt_viewer.py

Add option to refresh the thumbnails.

Fixed error when attempting to get image info from images that don't exist.

* Update img-txt_viewer.py

* Update find_dupe_file.py

- New Feature: Added "Move Captions" option.
  - Moves text pairs when found. Only works in "Images" scanning mode.

* Reload last directory; enhancements and fixes

Prevent unnecessary image refreshes when reloading the last directory.

Add "Courier New" as default font_var as this is the fallback in the settings_manager.

Allow the settings_manager to actually restore the settings even when not reloading the last directory.

* Update img-txt_viewer.py

Saving using the `CTRL + S` hotkey will now highlight the save button for a brief moment.

* Update img-txt_viewer.py

Calling `show_pair()` after restoring the ImgTxtViewer UI fixes most cases of the image not reloading.

* Cleanup

* Preliminary Autocomplete refactoring

* Update Autocomplete.py

* Update img-txt_viewer.py

Add menu buttons:
- View: Change image settings.
- ☰: Change autocomplete suggestion settings.

Prevent Paned Window sash from being interactable before selection a directory.

* Update img-txt_viewer.py

Cleanup "xxxContext_menu" object names to "xxx_context_menu".

Better handling of the suggestion_menubutton by using a command instead of a bind. This prevents the "Pressed" state from sticking after clicking the button.

* Fix typo

Fix typo "nccn", instead of "ncnn".

* Organize imports

* Organize

replace all "piece" with "shape"

* Fix `my_tags.csv` missing error

Fixed an error when loading the app and `my_tags.csv` didn't exist.

* Properly build model list

Fix error where the model list wasn't being correctly constructed when the "ncnn_models" folder didn't exist.

* Create Build_Instructions.md

* Set default browse dir to the user home dir

* Remove unnecessary variable

* Update img-txt_viewer.py

* Update CropUI.py

Add black dashed lines to the guidelines.

Refactor guideline logic.

Use a StringVar for `guidelines_var` instead of using the combobox. This lets the variable persists through multiple calls to open CropUI.

* Update requirements.txt

* Update CropUI.py

Use progressively higher quality scaling for smaller images.

Add a `thumbnail_timeline_slider` than can be used to quickly cycle through and the GIF frames.

Ensure GIF frames are always converted to RGBA mode to ensure the highest quality.

* Use text_dir instead of image_dir for text_file_path

Should be fine...

* Update img-txt_viewer.py

Refactor the MyTags tab to use a Listbox.

Including options: Insert into the text box (prefix/append), edit/remove the selected tags, and move up/down.

* Update .gitignore

* Revert "Update .gitignore"

This reverts commit 467de8b.

* Update .gitignore

* Allow adding tags to MyTags from AutoTag

* Update img-txt_viewer.py

Move `prompt_first_time_setup()` into settings_manager.py

Update `prompt_first_time_setup()` so it uses Checkbutton widgets, and allows the selection of multiple dictionaries.

Properly check `quite` to prevent annoying popups.

* Update settings_manager.py

Move `prompt_first_time_setup()` into settings_manager.py

Update `prompt_first_time_setup()` so it uses Checkbutton widgets, and allows the selection of multiple dictionaries.

Small Organizing.

* Get edit_panel dynamically from parent

* Create Changelog.md

* Update Changelog.md

Fix formatting issue

* Remove internal changelog

* General cleanup, first pass

* General cleanup, second pass

* Prevent focus relief when clicking a thumbnail

* Disable print

* Add AutoTag settings to `reset_settings()`

* Fix typo

* Add Thumbnail and Edit panel settings

* Pad timeline slider

* Add context menu to MyTags Listbox

* Fix MyTags not loading properly

* Update Changelog.md

* Set default CSV var state

All CSV vars are now set to False on startup/fallback. From here on out we'll rely on the startup-prompt to handle these kinds of options.

* Update about_img_txt_viewer.py

* Update PyTrominos.py

* Update info text

* Refactor `CalculateFileStats` into it's own class

Now calculates "avg_caption_length" (in words)

* Refactor constant `VERSION` as a cls variable of ImgTxtViewer

* Rename `master` to `root`

* Refactor UI creation

* Update documentation

* Refactor Autocomplete SuggestionHandler logic

* Update Autocomplete.py

* Add / Update docstrings

* Refactor edit_panel attributes

* Refactor `text_controller` logic

* Update text_controller.py

* Update .gitignore

* Fix filter issue

Fix issue with incorrect `ImgTxtViewer.total_images_label`, `ImgTxtViewer.image_files`, `ImgTxtViewer.text_files` when a filter was active.

* Update img-txt_viewer.py

In `open_image_in_editor()` and `set_external_image_editor_path(), validate the provided path to ensure the external editor exists and is accessible.

* Move function

* Update img-txt_viewer.py

* Create User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Triple hash for MyTag comments is now depreciated

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update settings_manager.py

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update Autocomplete.py

* Update User_Guide.md

* Update User_Guide.md

Displaying colored text in markdown is obnoxiously difficult.

* Update suggestion_textbox ToolTip

* Update User_Guide.md

* Update User_Guide.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

Markdown sucks

* Update Changelog.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Update User_Guide.md

* Enforce utf-8 encoding when opening text files

* Update filter

* Fix issue from refactoring

* Update README.md

* Update README.md

* Update Changelog.md

* Update README.md

* Update README.md

---------

Co-authored-by: UrzasLegacy <[email protected]>
  • Loading branch information
Nenotriple and UrzasLegacy authored Nov 29, 2024
1 parent 651a97d commit 867ba75
Show file tree
Hide file tree
Showing 57 changed files with 74,077 additions and 7,629 deletions.
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Virtual Environment
venv/


# Visual Studio Code workspace settings
/.vscode


# pycache
__pycache__/


# Dictionary Pre-Cache
main/dict/cache/


# PyInstaller
dist/
build/
*.spec


# App Settings file
settings.cfg


# MyTags file
my_tags.csv


# ONNX Models
onnx_models/*
!onnx_models/ONNX vision models go here

# Misc
docs/Workpad.md
366 changes: 154 additions & 212 deletions README.md

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions Start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
@echo off
setlocal enabledelayedexpansion


REM Set up a Python virtual environment and run a specified Python script.


REM Variables
set "PYTHON_SCRIPT=img-txt_viewer.py"
set "VENV_DIR=venv"
set "SCRIPT_DIR=%~dp0"


REM Navigate to the script directory
cd /d "%SCRIPT_DIR%" || (
echo Failed to set current directory.
pause
exit /b 1
)
echo Set current directory... OK


REM Check if Python is installed
python --version >nul 2>&1 || (
echo Python is not installed or not found in PATH.
pause
exit /b 1
)


REM Check if the virtual environment already exists
if not exist "%VENV_DIR%\Scripts\activate.bat" (
echo Creating a Python virtual environment: "%SCRIPT_DIR%\%VENV_DIR%"
python -m venv "%VENV_DIR%" || (
echo An error occurred while creating the virtual environment.
pause
exit /b 1
)
echo Virtual environment created.
) else (
echo Virtual environment already exists: "%SCRIPT_DIR%\%VENV_DIR%"
)


REM Activate the virtual environment
call "%VENV_DIR%\Scripts\activate.bat" || (
echo Activating the virtual environment... FAIL
pause
exit /b 1
)
echo Virtual environment activated.


REM Upgrade pip
python -m pip install --upgrade pip


REM Install requirements if requirements.txt exists
if exist "requirements.txt" (
set /p INSTALL_REQ="requirements.txt found. Do you want to install the requirements? (Y/N): "
if /i "!INSTALL_REQ!"=="Y" (
echo Installing requirements...
pip install -r requirements.txt || (
echo Failed to install requirements.
pause
exit /b 1
)
) else (
echo Skipping requirements installation.
)
)


REM Launch the user-defined Python script
if "%PYTHON_SCRIPT%"=="" (
echo Auto-Launch: Skipping
) else (
echo Launching: %PYTHON_SCRIPT%
python "%PYTHON_SCRIPT%" || (
echo Launching... FAIL
pause
exit /b 1
)
)


echo.
call cmd /k


endlocal
30 changes: 30 additions & 0 deletions docs/Build_Instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Build Instructions for img-txt Viewer

## Steps to Build the Executable:

1. Activate the Project Virtual Environment
2. Upgrade PyInstaller
```
pip install --upgrade pyinstaller
```
3. Run PyInstaller
```
pyinstaller img-txt_viewer.py --onefile --windowed --icon=icon.ico --add-data="icon.ico;." --add-data="main;main"
```

## Breakdown of the PyInstaller Command:

1. Main command to run PyInstaller.
- `pyinstaller`
2. The Python script to convert into an executable.
- `img-txt_viewer.py`
3. Bundle everything into a single executable file.
- `--onefile`
4. Run the executable without opening a console window.
- `--windowed`
5. Path to the icon file for the executable.
- `--icon=icon.ico`
6. Include the icon file in the root directory of the bundled application.
- `--add-data="icon.ico;."`
7. Include the `main` directory in the bundled application.
- `--add-data="main;main"`
Loading

0 comments on commit 867ba75

Please sign in to comment.