sticker-convert 2.8.12__py3-none-any.whl → 2.17.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. sticker_convert/__main__.py +24 -24
  2. sticker_convert/auth/__init__.py +0 -0
  3. sticker_convert/auth/auth_base.py +19 -0
  4. sticker_convert/auth/auth_discord.py +149 -0
  5. sticker_convert/{utils/auth/get_kakao_auth.py → auth/auth_kakao_android_login.py} +331 -300
  6. sticker_convert/auth/auth_kakao_desktop_login.py +327 -0
  7. sticker_convert/auth/auth_kakao_desktop_memdump.py +281 -0
  8. sticker_convert/{utils/auth/get_line_auth.py → auth/auth_line.py} +98 -80
  9. sticker_convert/auth/auth_signal.py +139 -0
  10. sticker_convert/auth/auth_telethon.py +161 -0
  11. sticker_convert/auth/auth_viber.py +250 -0
  12. sticker_convert/auth/telegram_api.py +736 -0
  13. sticker_convert/cli.py +623 -509
  14. sticker_convert/converter.py +1093 -962
  15. sticker_convert/definitions.py +11 -0
  16. sticker_convert/downloaders/download_band.py +111 -0
  17. sticker_convert/downloaders/download_base.py +171 -130
  18. sticker_convert/downloaders/download_discord.py +92 -0
  19. sticker_convert/downloaders/download_kakao.py +417 -255
  20. sticker_convert/downloaders/download_line.py +484 -472
  21. sticker_convert/downloaders/download_ogq.py +80 -0
  22. sticker_convert/downloaders/download_signal.py +108 -92
  23. sticker_convert/downloaders/download_telegram.py +56 -130
  24. sticker_convert/downloaders/download_viber.py +121 -95
  25. sticker_convert/gui.py +788 -795
  26. sticker_convert/gui_components/frames/comp_frame.py +180 -165
  27. sticker_convert/gui_components/frames/config_frame.py +156 -113
  28. sticker_convert/gui_components/frames/control_frame.py +32 -30
  29. sticker_convert/gui_components/frames/cred_frame.py +232 -162
  30. sticker_convert/gui_components/frames/input_frame.py +139 -137
  31. sticker_convert/gui_components/frames/output_frame.py +112 -110
  32. sticker_convert/gui_components/frames/right_clicker.py +25 -23
  33. sticker_convert/gui_components/windows/advanced_compression_window.py +757 -715
  34. sticker_convert/gui_components/windows/base_window.py +7 -2
  35. sticker_convert/gui_components/windows/discord_get_auth_window.py +79 -0
  36. sticker_convert/gui_components/windows/kakao_get_auth_window.py +511 -186
  37. sticker_convert/gui_components/windows/line_get_auth_window.py +94 -102
  38. sticker_convert/gui_components/windows/signal_get_auth_window.py +84 -135
  39. sticker_convert/gui_components/windows/viber_get_auth_window.py +168 -0
  40. sticker_convert/ios-message-stickers-template/.github/FUNDING.yml +3 -3
  41. sticker_convert/ios-message-stickers-template/.gitignore +0 -0
  42. sticker_convert/ios-message-stickers-template/README.md +10 -10
  43. sticker_convert/ios-message-stickers-template/stickers/Info.plist +43 -43
  44. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Info.plist +31 -31
  45. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Contents.json +6 -6
  46. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Contents.json +20 -20
  47. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Contents.json +9 -9
  48. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 1.sticker/Sticker 1.png +0 -0
  49. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Contents.json +9 -9
  50. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 2.sticker/Sticker 2.png +0 -0
  51. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Contents.json +9 -9
  52. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/Sticker Pack.stickerpack/Sticker 3.sticker/Sticker 3.png +0 -0
  53. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/App-Store-1024x1024pt.png +0 -0
  54. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Contents.json +91 -91
  55. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-App-Store-1024x768pt.png +0 -0
  56. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPad-67x50pt@2x.png +0 -0
  57. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPad-Pro-74x55pt@2x.png +0 -0
  58. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPhone-60x45pt@2x.png +0 -0
  59. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages-iPhone-60x45pt@3x.png +0 -0
  60. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages27x20pt@2x.png +0 -0
  61. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages27x20pt@3x.png +0 -0
  62. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages32x24pt@2x.png +0 -0
  63. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/Messages32x24pt@3x.png +0 -0
  64. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPad-Settings-29pt@2x.png +0 -0
  65. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPhone-Settings-29pt@3x.png +0 -0
  66. sticker_convert/ios-message-stickers-template/stickers StickerPackExtension/Stickers.xcstickers/iMessage App Icon.stickersiconset/iPhone-settings-29pt@2x.png +0 -0
  67. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.pbxproj +364 -364
  68. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
  69. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -8
  70. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/project.xcworkspace/xcuserdata/niklaspeterson.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  71. sticker_convert/ios-message-stickers-template/stickers.xcodeproj/xcuserdata/niklaspeterson.xcuserdatad/xcschemes/xcschememanagement.plist +14 -14
  72. sticker_convert/job.py +279 -179
  73. sticker_convert/job_option.py +15 -2
  74. sticker_convert/locales/en_US/LC_MESSAGES/base.mo +0 -0
  75. sticker_convert/locales/ja_JP/LC_MESSAGES/base.mo +0 -0
  76. sticker_convert/locales/zh_CN/LC_MESSAGES/base.mo +0 -0
  77. sticker_convert/locales/zh_TW/LC_MESSAGES/base.mo +0 -0
  78. sticker_convert/py.typed +0 -0
  79. sticker_convert/resources/NotoColorEmoji.ttf +0 -0
  80. sticker_convert/resources/compression.json +220 -16
  81. sticker_convert/resources/emoji.json +527 -77
  82. sticker_convert/resources/help.ja_JP.json +88 -0
  83. sticker_convert/resources/help.json +24 -10
  84. sticker_convert/resources/help.zh_CN.json +88 -0
  85. sticker_convert/resources/help.zh_TW.json +88 -0
  86. sticker_convert/resources/input.ja_JP.json +74 -0
  87. sticker_convert/resources/input.json +121 -71
  88. sticker_convert/resources/input.zh_CN.json +74 -0
  89. sticker_convert/resources/input.zh_TW.json +74 -0
  90. sticker_convert/resources/memdump_linux.sh +25 -0
  91. sticker_convert/resources/memdump_windows.ps1 +8 -0
  92. sticker_convert/resources/output.ja_JP.json +38 -0
  93. sticker_convert/resources/output.json +24 -0
  94. sticker_convert/resources/output.zh_CN.json +38 -0
  95. sticker_convert/resources/output.zh_TW.json +38 -0
  96. sticker_convert/uploaders/compress_wastickers.py +186 -156
  97. sticker_convert/uploaders/upload_base.py +44 -35
  98. sticker_convert/uploaders/upload_signal.py +218 -173
  99. sticker_convert/uploaders/upload_telegram.py +353 -388
  100. sticker_convert/uploaders/upload_viber.py +178 -0
  101. sticker_convert/uploaders/xcode_imessage.py +295 -285
  102. sticker_convert/utils/callback.py +238 -6
  103. sticker_convert/utils/chrome_remotedebug.py +219 -0
  104. sticker_convert/utils/chromiums/linux.py +52 -0
  105. sticker_convert/utils/chromiums/osx.py +68 -0
  106. sticker_convert/utils/chromiums/windows.py +45 -0
  107. sticker_convert/utils/emoji.py +28 -0
  108. sticker_convert/utils/files/json_resources_loader.py +24 -19
  109. sticker_convert/utils/files/metadata_handler.py +8 -7
  110. sticker_convert/utils/files/run_bin.py +1 -1
  111. sticker_convert/utils/media/codec_info.py +99 -67
  112. sticker_convert/utils/media/format_verify.py +33 -20
  113. sticker_convert/utils/process.py +231 -0
  114. sticker_convert/utils/translate.py +108 -0
  115. sticker_convert/utils/url_detect.py +40 -33
  116. sticker_convert/version.py +1 -1
  117. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/METADATA +189 -96
  118. sticker_convert-2.17.0.0.dist-info/RECORD +138 -0
  119. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/WHEEL +1 -1
  120. sticker_convert/utils/auth/get_signal_auth.py +0 -129
  121. sticker_convert-2.8.12.dist-info/RECORD +0 -101
  122. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/entry_points.txt +0 -0
  123. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info/licenses}/LICENSE +0 -0
  124. {sticker_convert-2.8.12.dist-info → sticker_convert-2.17.0.0.dist-info}/top_level.txt +0 -0
@@ -1,137 +1,139 @@
1
- #!/usr/bin/env python3
2
- from pathlib import Path
3
- from tkinter import filedialog
4
- from typing import TYPE_CHECKING, Any
5
-
6
- from ttkbootstrap import Button, Entry, Label, LabelFrame, OptionMenu # type: ignore
7
-
8
- from sticker_convert.definitions import DEFAULT_DIR
9
- from sticker_convert.gui_components.frames.right_clicker import RightClicker
10
- from sticker_convert.utils.url_detect import UrlDetect
11
-
12
- if TYPE_CHECKING:
13
- from sticker_convert.gui import GUI # type: ignore
14
-
15
-
16
- class InputFrame(LabelFrame):
17
- def __init__(self, gui: "GUI", *args: Any, **kwargs: Any) -> None:
18
- self.gui = gui
19
- super().__init__(*args, **kwargs)
20
-
21
- self.input_option_lbl = Label(
22
- self, text="Input source", width=15, justify="left", anchor="w"
23
- )
24
- input_full_names = [i["full_name"] for i in self.gui.input_presets.values()]
25
- default_input_full_name = self.gui.input_presets[self.gui.default_input_mode][
26
- "full_name"
27
- ]
28
- self.input_option_opt = OptionMenu(
29
- self,
30
- self.gui.input_option_display_var,
31
- default_input_full_name,
32
- *input_full_names,
33
- command=self.cb_input_option,
34
- bootstyle="secondary", # type: ignore
35
- )
36
- self.input_option_opt.config(width=32)
37
-
38
- self.input_setdir_lbl = Label(
39
- self, text="Input directory", width=35, justify="left", anchor="w"
40
- )
41
- self.input_setdir_entry = Entry(
42
- self,
43
- textvariable=self.gui.input_setdir_var,
44
- width=60,
45
- validatecommand=self.gui.highlight_fields,
46
- )
47
- self.input_setdir_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
48
- self.setdir_btn = Button(
49
- self,
50
- text="Choose directory",
51
- command=self.cb_set_indir,
52
- width=16,
53
- bootstyle="secondary", # type: ignore
54
- )
55
-
56
- self.address_lbl = Label(
57
- self,
58
- text=self.gui.input_presets[self.gui.default_input_mode]["address_lbls"],
59
- width=18,
60
- justify="left",
61
- anchor="w",
62
- )
63
- self.address_entry = Entry(
64
- self,
65
- textvariable=self.gui.input_address_var,
66
- width=80,
67
- validate="focusout",
68
- validatecommand=self.cb_input_option,
69
- )
70
- self.address_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
71
- self.address_tip = Label(
72
- self,
73
- text=self.gui.input_presets[self.gui.default_input_mode]["example"],
74
- justify="left",
75
- anchor="w",
76
- )
77
-
78
- self.input_option_lbl.grid(column=0, row=0, sticky="w", padx=3, pady=3)
79
- self.input_option_opt.grid(
80
- column=1, row=0, columnspan=2, sticky="w", padx=3, pady=3
81
- )
82
- self.input_setdir_lbl.grid(
83
- column=0, row=1, columnspan=2, sticky="w", padx=3, pady=3
84
- )
85
- self.input_setdir_entry.grid(column=1, row=1, sticky="w", padx=3, pady=3)
86
- self.setdir_btn.grid(column=2, row=1, sticky="e", padx=3, pady=3)
87
- self.address_lbl.grid(column=0, row=2, sticky="w", padx=3, pady=3)
88
- self.address_entry.grid(
89
- column=1, row=2, columnspan=2, sticky="w", padx=3, pady=3
90
- )
91
- self.address_tip.grid(column=0, row=3, columnspan=3, sticky="w", padx=3, pady=3)
92
-
93
- preset = [
94
- k
95
- for k, v in self.gui.input_presets.items()
96
- if v["full_name"] == self.gui.input_option_display_var.get()
97
- ][0]
98
- if preset == "local":
99
- self.address_entry.config(state="disabled")
100
- else:
101
- self.address_entry.config(state="normal")
102
-
103
- def cb_set_indir(self, *_args: Any) -> None:
104
- orig_input_dir = self.gui.input_setdir_var.get()
105
- if not Path(orig_input_dir).is_dir():
106
- orig_input_dir = DEFAULT_DIR
107
- input_dir = filedialog.askdirectory(initialdir=orig_input_dir)
108
- if input_dir:
109
- self.gui.input_setdir_var.set(input_dir)
110
-
111
- def cb_input_option(self, *_: Any) -> bool:
112
- input_option_display = self.gui.get_input_display_name()
113
-
114
- if input_option_display == "auto":
115
- url = self.gui.input_address_var.get()
116
- download_option = UrlDetect.detect(url)
117
-
118
- if download_option is None:
119
- self.gui.input_option_true_var.set(
120
- self.gui.input_presets["auto"]["full_name"]
121
- )
122
- else:
123
- self.gui.input_option_true_var.set(
124
- self.gui.input_presets[download_option]["full_name"]
125
- )
126
- else:
127
- self.gui.input_option_true_var.set(self.gui.input_option_display_var.get())
128
-
129
- self.gui.highlight_fields()
130
-
131
- return True
132
-
133
- def set_states(self, state: str) -> None:
134
- self.input_option_opt.config(state=state)
135
- self.address_entry.config(state=state)
136
- self.input_setdir_entry.config(state=state)
137
- self.setdir_btn.config(state=state)
1
+ #!/usr/bin/env python3
2
+ from pathlib import Path
3
+ from tkinter import filedialog
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ from ttkbootstrap import Button, Entry, Label, LabelFrame, OptionMenu # type: ignore
7
+
8
+ from sticker_convert.definitions import DEFAULT_DIR
9
+ from sticker_convert.gui_components.frames.right_clicker import RightClicker
10
+ from sticker_convert.utils.translate import I
11
+ from sticker_convert.utils.url_detect import UrlDetect
12
+
13
+ if TYPE_CHECKING:
14
+ from sticker_convert.gui import GUI # type: ignore
15
+
16
+
17
+ class InputFrame(LabelFrame):
18
+ def __init__(self, gui: "GUI", *args: Any, **kwargs: Any) -> None:
19
+ self.gui = gui
20
+ super().__init__(*args, **kwargs)
21
+
22
+ self.input_option_lbl = Label(
23
+ self, text=I("Input source"), width=15, justify="left", anchor="w"
24
+ )
25
+ input_full_names = [i["full_name"] for i in self.gui.input_presets.values()]
26
+ default_input_full_name = self.gui.input_presets[self.gui.default_input_mode][
27
+ "full_name"
28
+ ]
29
+ self.input_option_opt = OptionMenu(
30
+ self,
31
+ self.gui.input_option_display_var,
32
+ default_input_full_name,
33
+ *input_full_names,
34
+ command=self.cb_input_option,
35
+ bootstyle="secondary", # type: ignore
36
+ )
37
+ self.input_option_opt.config(width=32)
38
+
39
+ self.input_setdir_lbl = Label(
40
+ self, text=I("Input directory"), width=35, justify="left", anchor="w"
41
+ )
42
+ self.input_setdir_entry = Entry(
43
+ self,
44
+ textvariable=self.gui.input_setdir_var,
45
+ width=60,
46
+ validatecommand=self.gui.highlight_fields,
47
+ )
48
+ self.input_setdir_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
49
+ self.setdir_btn = Button(
50
+ self,
51
+ text=I("Choose directory"),
52
+ command=self.cb_set_indir,
53
+ width=16,
54
+ bootstyle="secondary", # type: ignore
55
+ )
56
+
57
+ self.address_lbl = Label(
58
+ self,
59
+ text=self.gui.input_presets[self.gui.default_input_mode]["address_lbls"],
60
+ width=18,
61
+ justify="left",
62
+ anchor="w",
63
+ )
64
+ self.address_entry = Entry(
65
+ self,
66
+ textvariable=self.gui.input_address_var,
67
+ width=80,
68
+ validate="focusout",
69
+ validatecommand=self.cb_input_option,
70
+ )
71
+ self.address_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
72
+ self.address_tip = Label(
73
+ self,
74
+ text=self.gui.input_presets[self.gui.default_input_mode]["example"],
75
+ justify="left",
76
+ anchor="w",
77
+ )
78
+
79
+ self.input_option_lbl.grid(column=0, row=0, sticky="w", padx=3, pady=3)
80
+ self.input_option_opt.grid(
81
+ column=1, row=0, columnspan=2, sticky="w", padx=3, pady=3
82
+ )
83
+ self.input_setdir_lbl.grid(
84
+ column=0, row=1, columnspan=2, sticky="w", padx=3, pady=3
85
+ )
86
+ self.input_setdir_entry.grid(column=1, row=1, sticky="w", padx=3, pady=3)
87
+ self.setdir_btn.grid(column=2, row=1, sticky="e", padx=3, pady=3)
88
+ self.address_lbl.grid(column=0, row=2, sticky="w", padx=3, pady=3)
89
+ self.address_entry.grid(
90
+ column=1, row=2, columnspan=2, sticky="w", padx=3, pady=3
91
+ )
92
+ self.address_tip.grid(column=0, row=3, columnspan=3, sticky="w", padx=3, pady=3)
93
+
94
+ preset = [
95
+ k
96
+ for k, v in self.gui.input_presets.items()
97
+ if v["full_name"] == self.gui.input_option_display_var.get()
98
+ ][0]
99
+ if preset == "local":
100
+ self.address_entry.config(state="disabled")
101
+ else:
102
+ self.address_entry.config(state="normal")
103
+
104
+ def cb_set_indir(self, *_args: Any) -> None:
105
+ orig_input_dir = self.gui.input_setdir_var.get()
106
+ if not Path(orig_input_dir).is_dir():
107
+ orig_input_dir = DEFAULT_DIR
108
+ input_dir = filedialog.askdirectory(initialdir=orig_input_dir)
109
+ if input_dir:
110
+ self.gui.input_setdir_var.set(input_dir)
111
+
112
+ def cb_input_option(self, *_: Any) -> bool:
113
+ input_option_display = self.gui.get_input_display_name()
114
+
115
+ if input_option_display == "auto":
116
+ url = self.gui.input_address_var.get()
117
+ download_option = UrlDetect.detect(url)
118
+
119
+ if download_option is None:
120
+ self.gui.input_option_true_var.set(
121
+ self.gui.input_presets["auto"]["full_name"]
122
+ )
123
+ else:
124
+ self.gui.input_option_true_var.set(
125
+ self.gui.input_presets[download_option]["full_name"]
126
+ )
127
+ else:
128
+ self.gui.input_option_true_var.set(self.gui.input_option_display_var.get())
129
+
130
+ self.gui.highlight_fields()
131
+ self.gui.comp_frame.cb_no_compress_toggle()
132
+
133
+ return True
134
+
135
+ def set_states(self, state: str) -> None:
136
+ self.input_option_opt.config(state=state)
137
+ self.address_entry.config(state=state)
138
+ self.input_setdir_entry.config(state=state)
139
+ self.setdir_btn.config(state=state)
@@ -1,110 +1,112 @@
1
- #!/usr/bin/env python3
2
- from pathlib import Path
3
- from tkinter import filedialog
4
- from typing import TYPE_CHECKING, Any
5
-
6
- from ttkbootstrap import Button, Entry, Label, LabelFrame, OptionMenu # type: ignore
7
-
8
- from sticker_convert.definitions import DEFAULT_DIR
9
- from sticker_convert.gui_components.frames.right_clicker import RightClicker
10
-
11
- if TYPE_CHECKING:
12
- from sticker_convert.gui import GUI # type: ignore
13
-
14
-
15
- class OutputFrame(LabelFrame):
16
- def __init__(self, gui: "GUI", *args: Any, **kwargs: Any) -> None:
17
- self.gui = gui
18
- super().__init__(*args, **kwargs)
19
-
20
- self.output_option_lbl = Label(
21
- self, text="Output options", width=18, justify="left", anchor="w"
22
- )
23
- output_full_names = [i["full_name"] for i in self.gui.output_presets.values()]
24
- defult_output_full_name = self.gui.output_presets[self.gui.default_output_mode][
25
- "full_name"
26
- ]
27
- self.output_option_opt = OptionMenu(
28
- self,
29
- self.gui.output_option_display_var,
30
- defult_output_full_name,
31
- *output_full_names,
32
- command=self.cb_output_option,
33
- bootstyle="secondary", # type: ignore
34
- )
35
- self.output_option_opt.config(width=32)
36
-
37
- self.output_setdir_lbl = Label(
38
- self, text="Output directory", justify="left", anchor="w"
39
- )
40
- self.output_setdir_entry = Entry(
41
- self,
42
- textvariable=self.gui.output_setdir_var,
43
- width=60,
44
- validatecommand=self.gui.highlight_fields,
45
- )
46
- self.output_setdir_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
47
-
48
- self.output_setdir_btn = Button(
49
- self,
50
- text="Choose directory",
51
- command=self.cb_set_outdir,
52
- width=16,
53
- bootstyle="secondary", # type: ignore
54
- )
55
-
56
- self.title_lbl = Label(self, text="Title")
57
- self.title_entry = Entry(
58
- self,
59
- textvariable=self.gui.title_var,
60
- width=80,
61
- validate="focusout",
62
- validatecommand=self.gui.highlight_fields,
63
- )
64
- self.title_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
65
-
66
- self.author_lbl = Label(self, text="Author")
67
- self.author_entry = Entry(
68
- self,
69
- textvariable=self.gui.author_var,
70
- width=80,
71
- validate="focusout",
72
- validatecommand=self.gui.highlight_fields,
73
- )
74
- self.author_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
75
-
76
- self.output_option_lbl.grid(column=0, row=0, sticky="w", padx=3, pady=3)
77
- self.output_option_opt.grid(
78
- column=1, row=0, columnspan=2, sticky="w", padx=3, pady=3
79
- )
80
- self.output_setdir_lbl.grid(
81
- column=0, row=1, columnspan=2, sticky="w", padx=3, pady=3
82
- )
83
- self.output_setdir_entry.grid(column=1, row=1, sticky="w", padx=3, pady=3)
84
- self.output_setdir_btn.grid(column=2, row=1, sticky="e", padx=3, pady=3)
85
- self.title_lbl.grid(column=0, row=2, sticky="w", padx=3, pady=3)
86
- self.title_entry.grid(column=1, columnspan=2, row=2, sticky="w", padx=3, pady=3)
87
- self.author_lbl.grid(column=0, row=3, sticky="w", padx=3, pady=3)
88
- self.author_entry.grid(
89
- column=1, columnspan=2, row=3, sticky="w", padx=3, pady=3
90
- )
91
-
92
- def cb_set_outdir(self, *_args: Any) -> None:
93
- orig_output_dir = self.gui.output_setdir_var.get()
94
- if not Path(orig_output_dir).is_dir():
95
- orig_output_dir = DEFAULT_DIR
96
- output_dir = filedialog.askdirectory(initialdir=orig_output_dir)
97
- if output_dir:
98
- self.gui.output_setdir_var.set(output_dir)
99
-
100
- def cb_output_option(self, *_: Any) -> None:
101
- self.gui.output_option_true_var.set(self.gui.output_option_display_var.get())
102
- self.gui.comp_frame.cb_comp_apply_preset()
103
- self.gui.highlight_fields()
104
-
105
- def set_states(self, state: str) -> None:
106
- self.title_entry.config(state=state)
107
- self.author_entry.config(state=state)
108
- self.output_option_opt.config(state=state)
109
- self.output_setdir_entry.config(state=state)
110
- self.output_setdir_btn.config(state=state)
1
+ #!/usr/bin/env python3
2
+ from pathlib import Path
3
+ from tkinter import filedialog
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ from ttkbootstrap import Button, Entry, Label, LabelFrame, OptionMenu # type: ignore
7
+
8
+ from sticker_convert.definitions import DEFAULT_DIR
9
+ from sticker_convert.gui_components.frames.right_clicker import RightClicker
10
+ from sticker_convert.utils.translate import I
11
+
12
+ if TYPE_CHECKING:
13
+ from sticker_convert.gui import GUI # type: ignore
14
+
15
+
16
+ class OutputFrame(LabelFrame):
17
+ def __init__(self, gui: "GUI", *args: Any, **kwargs: Any) -> None:
18
+ self.gui = gui
19
+ super().__init__(*args, **kwargs)
20
+
21
+ self.output_option_lbl = Label(
22
+ self, text=I("Output options"), width=18, justify="left", anchor="w"
23
+ )
24
+ output_full_names = [i["full_name"] for i in self.gui.output_presets.values()]
25
+ defult_output_full_name = self.gui.output_presets[self.gui.default_output_mode][
26
+ "full_name"
27
+ ]
28
+ self.output_option_opt = OptionMenu(
29
+ self,
30
+ self.gui.output_option_display_var,
31
+ defult_output_full_name,
32
+ *output_full_names,
33
+ command=self.cb_output_option,
34
+ bootstyle="secondary", # type: ignore
35
+ )
36
+ self.output_option_opt.config(width=32)
37
+
38
+ self.output_setdir_lbl = Label(
39
+ self, text=I("Output directory"), justify="left", anchor="w"
40
+ )
41
+ self.output_setdir_entry = Entry(
42
+ self,
43
+ textvariable=self.gui.output_setdir_var,
44
+ width=60,
45
+ validatecommand=self.gui.highlight_fields,
46
+ )
47
+ self.output_setdir_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
48
+
49
+ self.output_setdir_btn = Button(
50
+ self,
51
+ text=I("Choose directory"),
52
+ command=self.cb_set_outdir,
53
+ width=16,
54
+ bootstyle="secondary", # type: ignore
55
+ )
56
+
57
+ self.title_lbl = Label(self, text=I("Title"))
58
+ self.title_entry = Entry(
59
+ self,
60
+ textvariable=self.gui.title_var,
61
+ width=80,
62
+ validate="focusout",
63
+ validatecommand=self.gui.highlight_fields,
64
+ )
65
+ self.title_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
66
+
67
+ self.author_lbl = Label(self, text=I("Author"))
68
+ self.author_entry = Entry(
69
+ self,
70
+ textvariable=self.gui.author_var,
71
+ width=80,
72
+ validate="focusout",
73
+ validatecommand=self.gui.highlight_fields,
74
+ )
75
+ self.author_entry.bind("<Button-3><ButtonRelease-3>", RightClicker)
76
+
77
+ self.output_option_lbl.grid(column=0, row=0, sticky="w", padx=3, pady=3)
78
+ self.output_option_opt.grid(
79
+ column=1, row=0, columnspan=2, sticky="w", padx=3, pady=3
80
+ )
81
+ self.output_setdir_lbl.grid(
82
+ column=0, row=1, columnspan=2, sticky="w", padx=3, pady=3
83
+ )
84
+ self.output_setdir_entry.grid(column=1, row=1, sticky="w", padx=3, pady=3)
85
+ self.output_setdir_btn.grid(column=2, row=1, sticky="e", padx=3, pady=3)
86
+ self.title_lbl.grid(column=0, row=2, sticky="w", padx=3, pady=3)
87
+ self.title_entry.grid(column=1, columnspan=2, row=2, sticky="w", padx=3, pady=3)
88
+ self.author_lbl.grid(column=0, row=3, sticky="w", padx=3, pady=3)
89
+ self.author_entry.grid(
90
+ column=1, columnspan=2, row=3, sticky="w", padx=3, pady=3
91
+ )
92
+
93
+ def cb_set_outdir(self, *_args: Any) -> None:
94
+ orig_output_dir = self.gui.output_setdir_var.get()
95
+ if not Path(orig_output_dir).is_dir():
96
+ orig_output_dir = DEFAULT_DIR
97
+ output_dir = filedialog.askdirectory(initialdir=orig_output_dir)
98
+ if output_dir:
99
+ self.gui.output_setdir_var.set(output_dir)
100
+
101
+ def cb_output_option(self, *_: Any) -> None:
102
+ self.gui.output_option_true_var.set(self.gui.output_option_display_var.get())
103
+ self.gui.comp_frame.cb_comp_apply_preset()
104
+ self.gui.highlight_fields()
105
+ self.gui.comp_frame.cb_no_compress_toggle()
106
+
107
+ def set_states(self, state: str) -> None:
108
+ self.title_entry.config(state=state)
109
+ self.author_entry.config(state=state)
110
+ self.output_option_opt.config(state=state)
111
+ self.output_setdir_entry.config(state=state)
112
+ self.output_setdir_btn.config(state=state)
@@ -1,23 +1,25 @@
1
- #!/usr/bin/env python3
2
- from typing import Any
3
-
4
- from ttkbootstrap import Menu # type: ignore
5
-
6
-
7
- # Reference: https://stackoverflow.com/a/57704013
8
- class RightClicker:
9
- def __init__(self, event: Any) -> None:
10
- right_click_menu = Menu(None, tearoff=0, takefocus=0)
11
-
12
- for txt in ["Cut", "Copy", "Paste"]:
13
- right_click_menu.add_command(
14
- label=txt,
15
- command=lambda event=event, text=txt: self.right_click_command(
16
- event, text
17
- ),
18
- )
19
-
20
- right_click_menu.tk_popup(event.x_root, event.y_root, entry="0")
21
-
22
- def right_click_command(self, event: Any, cmd: str) -> None:
23
- event.widget.event_generate(f"<<{cmd}>>")
1
+ #!/usr/bin/env python3
2
+ from typing import Any
3
+
4
+ from ttkbootstrap import Menu # type: ignore
5
+
6
+ from sticker_convert.utils.translate import I
7
+
8
+
9
+ # Reference: https://stackoverflow.com/a/57704013
10
+ class RightClicker:
11
+ def __init__(self, event: Any) -> None:
12
+ right_click_menu = Menu(None, tearoff=0, takefocus=0)
13
+
14
+ for txt in [I("Cut"), I("Copy"), I("Paste")]:
15
+ right_click_menu.add_command(
16
+ label=txt,
17
+ command=lambda event=event, text=txt: self.right_click_command(
18
+ event, text
19
+ ),
20
+ )
21
+
22
+ right_click_menu.tk_popup(event.x_root, event.y_root, entry="0")
23
+
24
+ def right_click_command(self, event: Any, cmd: str) -> None:
25
+ event.widget.event_generate(f"<<{cmd}>>")