Skip to content

Commit

Permalink
Add notification for unsupported formats and no data detected
Browse files Browse the repository at this point in the history
  • Loading branch information
receyuki committed Mar 31, 2023
1 parent 1fb01b3 commit 62c26bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions file_version_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(1, 0, 0, 0),
prodvers=(1, 0, 0, 0),
filevers=(1, 0, 1, 0),
prodvers=(1, 0, 1, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x17,
# Contains a bitmask that specifies the Boolean attributes of the file.
Expand All @@ -32,7 +32,7 @@ VSVersionInfo(
[StringStruct('CompanyName', ''),
StringStruct('LegalCopyright', 'Copyright © 2023 receyuki All rights reserved.'),
StringStruct('ProductName', 'SD Prompt Reader'),
StringStruct('ProductVersion', '1.0.0.0'),
StringStruct('ProductVersion', '1.0.1.0'),
StringStruct('FileDescription', 'SD Prompt Reader'),
StringStruct('InternalName', 'SD Prompt Reader'),
StringStruct('OriginalFilename', 'SD Prompt Reader.exe')])
Expand Down
21 changes: 14 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,27 @@ def image_data(file):


def image_info_format(text):
prompt_index = [text.index("\nNegative prompt:"),
text.index("\nSteps:")]
positive = text[:prompt_index[0]]
negative = text[prompt_index[0] + 1 + len("Negative prompt: "):prompt_index[1]]
setting = text[prompt_index[1] + 1:]
if text:
prompt_index = [text.index("\nNegative prompt:"),
text.index("\nSteps:")]
positive = text[:prompt_index[0]]
negative = text[prompt_index[0] + 1 + len("Negative prompt: "):prompt_index[1]]
setting = text[prompt_index[1] + 1:]
else:
positive = negative = setting = "No data detected or unsupported formats"
return positive, negative, setting, text


def display_info(event):
global image, image_tk, image_label, info, scaling
boxes = [positive_box, negative_box, setting_box]
file_path = event.data.replace("}", "").replace("{", "")
# clear text
for box in boxes:
box.configure(state=NORMAL)
box.delete("1.0", END)
if event.data.endswith(".png"):
with open(event.data, "rb") as f:
if file_path.lower().endswith(".png"):
with open(file_path, "rb") as f:
text_line, _ = image_data(f)
info = image_info_format(text_line)
# insert prompt
Expand All @@ -120,6 +124,9 @@ def display_info(event):
# display image
image_tk.configure()
image_label.configure(image=image_tk)
else:
for box in boxes:
box.insert(END, "Unsupported formats")


def resize_image(event):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'plist': {
'CFBundleName': 'SD Prompt Reader',
'CFBundleDisplayName': 'SD Prompt Reader',
'CFBundleVersion': '1.0.0',
'CFBundleVersion': '1.0.1',
'CFBundleIdentifier': 'com.receyuki.sd-prompt-reader',
'NSHumanReadableCopyright': 'Copyright © 2023 receyuki All rights reserved.',
},
Expand Down

0 comments on commit 62c26bd

Please sign in to comment.