sticker-convert 2.14.0.0__py3-none-any.whl → 2.15.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 (37) hide show
  1. sticker_convert/auth/__init__.py +0 -0
  2. sticker_convert/auth/auth_base.py +19 -0
  3. sticker_convert/{utils/auth/get_discord_auth.py → auth/auth_discord.py} +40 -13
  4. sticker_convert/{utils/auth/get_kakao_auth_android_login.py → auth/auth_kakao_android_login.py} +80 -84
  5. sticker_convert/{utils/auth/get_kakao_auth_desktop_login.py → auth/auth_kakao_desktop_login.py} +69 -28
  6. sticker_convert/{utils/auth/get_kakao_auth_desktop_memdump.py → auth/auth_kakao_desktop_memdump.py} +31 -24
  7. sticker_convert/{utils/auth/get_line_auth.py → auth/auth_line.py} +21 -6
  8. sticker_convert/{utils/auth/get_signal_auth.py → auth/auth_signal.py} +18 -20
  9. sticker_convert/auth/auth_telethon.py +151 -0
  10. sticker_convert/{utils/auth/get_viber_auth.py → auth/auth_viber.py} +19 -11
  11. sticker_convert/{utils/auth → auth}/telegram_api.py +4 -13
  12. sticker_convert/cli.py +44 -70
  13. sticker_convert/downloaders/download_line.py +2 -2
  14. sticker_convert/downloaders/download_telegram.py +1 -1
  15. sticker_convert/gui.py +15 -100
  16. sticker_convert/gui_components/frames/comp_frame.py +12 -4
  17. sticker_convert/gui_components/frames/config_frame.py +14 -6
  18. sticker_convert/gui_components/frames/control_frame.py +1 -1
  19. sticker_convert/gui_components/frames/cred_frame.py +6 -8
  20. sticker_convert/gui_components/windows/advanced_compression_window.py +3 -4
  21. sticker_convert/gui_components/windows/base_window.py +7 -2
  22. sticker_convert/gui_components/windows/discord_get_auth_window.py +3 -7
  23. sticker_convert/gui_components/windows/kakao_get_auth_window.py +79 -51
  24. sticker_convert/gui_components/windows/line_get_auth_window.py +5 -14
  25. sticker_convert/gui_components/windows/signal_get_auth_window.py +4 -12
  26. sticker_convert/gui_components/windows/viber_get_auth_window.py +8 -11
  27. sticker_convert/job.py +16 -32
  28. sticker_convert/uploaders/upload_telegram.py +1 -1
  29. sticker_convert/utils/callback.py +238 -6
  30. sticker_convert/version.py +1 -1
  31. {sticker_convert-2.14.0.0.dist-info → sticker_convert-2.15.0.0.dist-info}/METADATA +5 -5
  32. {sticker_convert-2.14.0.0.dist-info → sticker_convert-2.15.0.0.dist-info}/RECORD +36 -34
  33. sticker_convert/utils/auth/telethon_setup.py +0 -97
  34. {sticker_convert-2.14.0.0.dist-info → sticker_convert-2.15.0.0.dist-info}/WHEEL +0 -0
  35. {sticker_convert-2.14.0.0.dist-info → sticker_convert-2.15.0.0.dist-info}/entry_points.txt +0 -0
  36. {sticker_convert-2.14.0.0.dist-info → sticker_convert-2.15.0.0.dist-info}/licenses/LICENSE +0 -0
  37. {sticker_convert-2.14.0.0.dist-info → sticker_convert-2.15.0.0.dist-info}/top_level.txt +0 -0
sticker_convert/cli.py CHANGED
@@ -11,18 +11,18 @@ from typing import Any, Dict
11
11
 
12
12
  from mergedeep import merge # type: ignore
13
13
 
14
+ from sticker_convert.auth.auth_discord import AuthDiscord
15
+ from sticker_convert.auth.auth_kakao_android_login import AuthKakaoAndroidLogin
16
+ from sticker_convert.auth.auth_kakao_desktop_login import AuthKakaoDesktopLogin
17
+ from sticker_convert.auth.auth_kakao_desktop_memdump import AuthKakaoDesktopMemdump
18
+ from sticker_convert.auth.auth_line import AuthLine
19
+ from sticker_convert.auth.auth_signal import AuthSignal
20
+ from sticker_convert.auth.auth_telethon import AuthTelethon
21
+ from sticker_convert.auth.auth_viber import AuthViber
14
22
  from sticker_convert.definitions import CONFIG_DIR, DEFAULT_DIR
15
23
  from sticker_convert.job import Job
16
24
  from sticker_convert.job_option import CompOption, CredOption, InputOption, OutputOption
17
- from sticker_convert.utils.auth.get_discord_auth import GetDiscordAuth
18
- from sticker_convert.utils.auth.get_kakao_auth_android_login import GetKakaoAuthAndroidLogin
19
- from sticker_convert.utils.auth.get_kakao_auth_desktop_login import GetKakaoAuthDesktopLogin
20
- from sticker_convert.utils.auth.get_kakao_auth_desktop_memdump import GetKakaoAuthDesktopMemdump
21
- from sticker_convert.utils.auth.get_line_auth import GetLineAuth
22
- from sticker_convert.utils.auth.get_signal_auth import GetSignalAuth
23
- from sticker_convert.utils.auth.get_viber_auth import GetViberAuth
24
- from sticker_convert.utils.auth.telethon_setup import TelethonSetup
25
- from sticker_convert.utils.callback import Callback
25
+ from sticker_convert.utils.callback import CallbackCli
26
26
  from sticker_convert.utils.files.json_manager import JsonManager
27
27
  from sticker_convert.utils.url_detect import UrlDetect
28
28
  from sticker_convert.version import __version__
@@ -30,13 +30,13 @@ from sticker_convert.version import __version__
30
30
 
31
31
  class CLI:
32
32
  def __init__(self) -> None:
33
- self.cb = Callback()
33
+ self.cb = CallbackCli()
34
34
 
35
35
  def cli(self) -> None:
36
36
  try:
37
37
  from sticker_convert.utils.files.json_resources_loader import COMPRESSION_JSON, EMOJI_JSON, HELP_JSON, INPUT_JSON, OUTPUT_JSON
38
38
  except RuntimeError as e:
39
- self.cb.msg(str(e))
39
+ self.cb.put(str(e))
40
40
  return
41
41
 
42
42
  self.help = HELP_JSON
@@ -216,15 +216,7 @@ class CLI:
216
216
  self.opt_cred = self.get_opt_cred(args)
217
217
 
218
218
  job = Job(
219
- self.opt_input,
220
- self.opt_comp,
221
- self.opt_output,
222
- self.opt_cred,
223
- self.cb.msg,
224
- self.cb.msg_block,
225
- self.cb.bar,
226
- self.cb.ask_bool,
227
- self.cb.ask_str,
219
+ self.opt_input, self.opt_comp, self.opt_output, self.opt_cred, self.cb
228
220
  )
229
221
 
230
222
  signal.signal(signal.SIGINT, job.cancel)
@@ -258,9 +250,9 @@ class CLI:
258
250
  detected_download_option = UrlDetect.detect(url)
259
251
  if detected_download_option:
260
252
  download_option = detected_download_option
261
- self.cb.msg(f"Detected URL input source: {download_option}")
253
+ self.cb.put(f"Detected URL input source: {download_option}")
262
254
  else:
263
- self.cb.msg(f"Error: Unrecognied URL input source for url: {url}")
255
+ self.cb.put(f"Error: Unrecognied URL input source for url: {url}")
264
256
  sys.exit()
265
257
 
266
258
  opt_input = InputOption(
@@ -343,21 +335,21 @@ class CLI:
343
335
  if output_option == "local":
344
336
  preset = "custom"
345
337
  args.no_compress = True
346
- self.cb.msg(
338
+ self.cb.put(
347
339
  "Auto compression option set to no_compress (Reason: Export to local directory only)"
348
340
  )
349
341
  elif "telegram_emoji" in output_option:
350
342
  preset = "telegram_emoji"
351
- self.cb.msg(f"Auto compression option set to {preset}")
343
+ self.cb.put(f"Auto compression option set to {preset}")
352
344
  elif "telegram" in output_option:
353
345
  preset = "telegram"
354
- self.cb.msg(f"Auto compression option set to {preset}")
346
+ self.cb.put(f"Auto compression option set to {preset}")
355
347
  elif output_option == "imessage":
356
348
  preset = "imessage_small"
357
- self.cb.msg(f"Auto compression option set to {preset}")
349
+ self.cb.put(f"Auto compression option set to {preset}")
358
350
  else:
359
351
  preset = output_option
360
- self.cb.msg(f"Auto compression option set to {preset}")
352
+ self.cb.put(f"Auto compression option set to {preset}")
361
353
 
362
354
  opt_comp = CompOption(
363
355
  preset=preset,
@@ -464,13 +456,13 @@ class CLI:
464
456
  try:
465
457
  creds = JsonManager.load_json(creds_path)
466
458
  except JSONDecodeError:
467
- self.cb.msg("Warning: creds.json content is corrupted")
459
+ self.cb.put("Warning: creds.json content is corrupted")
468
460
  creds = {}
469
461
  else:
470
462
  creds = {}
471
463
 
472
464
  if creds:
473
- self.cb.msg("Loaded credentials from creds.json")
465
+ self.cb.put("Loaded credentials from creds.json")
474
466
 
475
467
  opt_cred = CredOption(
476
468
  signal_uuid=args.signal_uuid
@@ -514,23 +506,16 @@ class CLI:
514
506
  )
515
507
 
516
508
  if args.kakao_get_auth_android_login:
517
- get_kakao_auth_android_login = GetKakaoAuthAndroidLogin(
518
- opt_cred=opt_cred,
519
- cb_msg=self.cb.msg,
520
- cb_msg_block=self.cb.msg_block,
521
- cb_ask_str=self.cb.ask_str,
522
- )
523
- auth_token = get_kakao_auth_android_login.get_cred()
509
+ get_kakao_auth_android_login = AuthKakaoAndroidLogin(opt_cred, self.cb)
510
+ auth_token, msg = get_kakao_auth_android_login.get_cred()
524
511
 
525
512
  if auth_token:
526
513
  opt_cred.kakao_auth_token = auth_token
527
514
 
528
- self.cb.msg(f"Got auth_token successfully: {auth_token}")
515
+ self.cb.put(msg)
529
516
 
530
517
  if args.kakao_get_auth_desktop_memdump:
531
- get_kakao_auth_desktop_memdump = GetKakaoAuthDesktopMemdump(
532
- cb_ask_str=self.cb.ask_str,
533
- )
518
+ get_kakao_auth_desktop_memdump = AuthKakaoDesktopMemdump(opt_cred, self.cb)
534
519
  kakao_bin_path = None
535
520
  if args.kakao_bin_path:
536
521
  kakao_bin_path = args.kakao_bin_path
@@ -539,62 +524,51 @@ class CLI:
539
524
  if auth_token:
540
525
  opt_cred.kakao_auth_token = auth_token
541
526
 
542
- self.cb.msg(msg)
527
+ self.cb.put(msg)
543
528
 
544
529
  if args.kakao_get_auth_desktop_login:
545
- get_kakao_auth_desktop_login = GetKakaoAuthDesktopLogin(
546
- opt_cred=opt_cred,
547
- cb_msg=self.cb.msg,
548
- cb_msg_block=self.cb.msg_block,
549
- cb_ask_str=self.cb.ask_str,
550
- )
530
+ get_kakao_auth_desktop_login = AuthKakaoDesktopLogin(opt_cred, self.cb)
551
531
  auth_token, msg = get_kakao_auth_desktop_login.get_cred()
552
532
 
553
533
  if auth_token:
554
534
  opt_cred.kakao_auth_token = auth_token
555
535
 
556
- self.cb.msg(msg)
536
+ self.cb.put(msg)
557
537
 
558
538
  if args.signal_get_auth:
559
- m = GetSignalAuth(cb_msg=self.cb.msg, cb_ask_str=self.cb.ask_str)
539
+ m = AuthSignal(opt_cred, self.cb)
560
540
 
561
- uuid, password = m.get_cred()
541
+ uuid, password, msg = m.get_cred()
562
542
  if uuid and password:
563
543
  opt_cred.signal_uuid = uuid
564
544
  opt_cred.signal_password = password
565
545
 
566
- self.cb.msg(f"Got uuid and password successfully: {uuid}, {password}")
567
-
568
- self.cb.msg("Failed to get uuid and password")
546
+ self.cb.put(msg)
569
547
 
570
548
  if args.telethon_setup:
571
- telethon_setup = TelethonSetup(opt_cred, self.cb.ask_str)
572
- success, _, telethon_api_id, telethon_api_hash = telethon_setup.start()
549
+ telethon_setup = AuthTelethon(opt_cred, self.cb)
550
+ success, _, telethon_api_id, telethon_api_hash, msg = telethon_setup.start(
551
+ check_auth_only=True
552
+ )
573
553
 
574
554
  if success:
575
555
  opt_cred.telethon_api_id = telethon_api_id
576
556
  opt_cred.telethon_api_hash = telethon_api_hash
577
557
 
578
- self.cb.msg("Telethon setup successful")
579
- else:
580
- self.cb.msg("Telethon setup failed")
558
+ self.cb.put(msg)
581
559
 
582
560
  if args.line_get_auth:
583
- get_line_auth = GetLineAuth()
561
+ get_line_auth = AuthLine(opt_cred, self.cb)
584
562
 
585
- line_cookies = get_line_auth.get_cred()
563
+ line_cookies, msg = get_line_auth.get_cred()
586
564
 
587
565
  if line_cookies:
588
566
  opt_cred.line_cookies = line_cookies
589
567
 
590
- self.cb.msg("Got Line cookies successfully")
591
- else:
592
- self.cb.msg(
593
- "Failed to get Line cookies. Have you logged in the web browser?"
594
- )
568
+ self.cb.put(msg)
595
569
 
596
570
  if args.viber_get_auth:
597
- get_viber_auth = GetViberAuth(self.cb.ask_str)
571
+ get_viber_auth = AuthViber(opt_cred, self.cb)
598
572
 
599
573
  viber_bin_path = None
600
574
  if args.viber_bin_path:
@@ -605,20 +579,20 @@ class CLI:
605
579
  if viber_auth:
606
580
  opt_cred.viber_auth = viber_auth
607
581
 
608
- self.cb.msg(msg)
582
+ self.cb.put(msg)
609
583
 
610
584
  if args.discord_get_auth:
611
- get_discord_auth = GetDiscordAuth(self.cb.msg)
585
+ get_discord_auth = AuthDiscord(opt_cred, self.cb)
612
586
  discord_token, msg = get_discord_auth.get_cred()
613
587
 
614
588
  if discord_token:
615
589
  opt_cred.discord_token = discord_token
616
590
 
617
- self.cb.msg(msg)
591
+ self.cb.put(msg)
618
592
 
619
593
  if args.save_cred:
620
594
  creds_path = CONFIG_DIR / "creds.json"
621
595
  JsonManager.save_json(creds_path, opt_cred.to_dict())
622
- self.cb.msg("Saved credentials to creds.json")
596
+ self.cb.put("Saved credentials to creds.json")
623
597
 
624
598
  return opt_cred
@@ -14,9 +14,9 @@ import requests
14
14
  from bs4 import BeautifulSoup
15
15
  from PIL import Image
16
16
 
17
+ from sticker_convert.auth.auth_line import AuthLine
17
18
  from sticker_convert.downloaders.download_base import DownloadBase
18
19
  from sticker_convert.job_option import CredOption, InputOption
19
- from sticker_convert.utils.auth.get_line_auth import GetLineAuth
20
20
  from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
21
21
  from sticker_convert.utils.files.metadata_handler import MetadataHandler
22
22
  from sticker_convert.utils.media.apple_png_normalize import ApplePngNormalize
@@ -190,7 +190,7 @@ class DownloadLine(DownloadBase):
190
190
  'Warning: Line cookies invalid, you will not be able to add text to "Custom stickers"'
191
191
  )
192
192
 
193
- if not GetLineAuth.validate_cookies(cookies):
193
+ if not AuthLine.validate_cookies(cookies):
194
194
  self.cb.put(
195
195
  'Warning: Line cookies invalid, you will not be able to add text to "Custom stickers"'
196
196
  )
@@ -5,9 +5,9 @@ from urllib.parse import urlparse
5
5
 
6
6
  import anyio
7
7
 
8
+ from sticker_convert.auth.telegram_api import BotAPI, TelegramAPI, TelethonAPI
8
9
  from sticker_convert.downloaders.download_base import DownloadBase
9
10
  from sticker_convert.job_option import CredOption, InputOption
10
- from sticker_convert.utils.auth.telegram_api import BotAPI, TelegramAPI, TelethonAPI
11
11
  from sticker_convert.utils.callback import CallbackProtocol, CallbackReturn
12
12
  from sticker_convert.utils.files.metadata_handler import MetadataHandler
13
13
 
sticker_convert/gui.py CHANGED
@@ -4,19 +4,18 @@ import os
4
4
  import platform
5
5
  import signal
6
6
  import sys
7
- from functools import partial
8
7
  from json.decoder import JSONDecodeError
9
8
  from math import ceil
10
9
  from multiprocessing import Event, cpu_count
11
10
  from pathlib import Path
12
11
  from threading import Thread
13
- from typing import Any, Callable, Dict, Optional, Union, cast
12
+ from typing import Any, Callable, Dict, Optional, cast
14
13
  from urllib.parse import urlparse
15
14
 
16
15
  from mergedeep import merge # type: ignore
17
16
  from PIL import ImageFont
18
- from ttkbootstrap import BooleanVar, DoubleVar, IntVar, StringVar, Toplevel, Window # type: ignore
19
- from ttkbootstrap.dialogs import Messagebox, Querybox # type: ignore
17
+ from ttkbootstrap import BooleanVar, DoubleVar, IntVar, StringVar, Window # type: ignore
18
+ from ttkbootstrap.dialogs import Messagebox # type: ignore
20
19
 
21
20
  from sticker_convert.definitions import CONFIG_DIR, DEFAULT_DIR, ROOT_DIR
22
21
  from sticker_convert.gui_components.frames.comp_frame import CompFrame
@@ -29,6 +28,7 @@ from sticker_convert.gui_components.frames.progress_frame import ProgressFrame
29
28
  from sticker_convert.gui_components.gui_utils import GUIUtils
30
29
  from sticker_convert.job import Job
31
30
  from sticker_convert.job_option import CompOption, CredOption, InputOption, OutputOption
31
+ from sticker_convert.utils.callback import CallbackGui
32
32
  from sticker_convert.utils.files.json_manager import JsonManager
33
33
  from sticker_convert.utils.files.metadata_handler import MetadataHandler
34
34
  from sticker_convert.utils.url_detect import UrlDetect
@@ -38,6 +38,7 @@ from sticker_convert.version import __version__
38
38
  class GUI(Window):
39
39
  def __init__(self) -> None:
40
40
  super().__init__(themename="darkly", alpha=0) # type: ignore
41
+ self.cb = CallbackGui(self)
41
42
  self.init_done = False
42
43
  self.load_jsons()
43
44
 
@@ -79,11 +80,13 @@ class GUI(Window):
79
80
 
80
81
  def quit(self) -> None:
81
82
  if self.job:
82
- response = self.cb_ask_bool("Job is running, really quit?")
83
+ response = self.cb.put(
84
+ ("ask_bool", ("Job is running, really quit?",), None)
85
+ )
83
86
  if response is False:
84
87
  return
85
88
 
86
- self.cb_msg(msg="Quitting, please wait...")
89
+ self.cb.put("Quitting, please wait...")
87
90
 
88
91
  self.save_config()
89
92
  if self.settings_save_cred_var.get() is True:
@@ -241,7 +244,7 @@ class GUI(Window):
241
244
  msg += "Please use the stickers with your friends only.\n"
242
245
  msg += "It is illegal and immoral to sell stickers downloaded from this program.\n"
243
246
 
244
- self.cb_msg(msg)
247
+ self.cb.put(msg)
245
248
 
246
249
  def warn_tkinter_bug(self) -> None:
247
250
  if (
@@ -255,13 +258,13 @@ class GUI(Window):
255
258
  msg += "on title bar or move mouse cursor away from window for a while.\n"
256
259
  msg += "(This is a bug in tkinter specific to macOS 14 python <=3.11.6)\n"
257
260
  msg += "(https://github.com/python/cpython/issues/110218)\n"
258
- self.cb_msg(msg)
261
+ self.cb.put(msg)
259
262
 
260
263
  def load_jsons(self) -> None:
261
264
  try:
262
265
  from sticker_convert.utils.files.json_resources_loader import COMPRESSION_JSON, EMOJI_JSON, HELP_JSON, INPUT_JSON, OUTPUT_JSON
263
266
  except RuntimeError as e:
264
- self.cb_msg(str(e))
267
+ self.cb.put(str(e))
265
268
  return
266
269
 
267
270
  self.help = HELP_JSON
@@ -286,7 +289,7 @@ class GUI(Window):
286
289
  self.settings_path
287
290
  )
288
291
  except JSONDecodeError:
289
- self.cb_msg("Warning: config.json content is corrupted")
292
+ self.cb.put("Warning: config.json content is corrupted")
290
293
  self.settings = {}
291
294
  else:
292
295
  self.settings = {}
@@ -296,7 +299,7 @@ class GUI(Window):
296
299
  try:
297
300
  self.creds = JsonManager.load_json(self.creds_path)
298
301
  except JSONDecodeError:
299
- self.cb_msg("Warning: creds.json content is corrupted")
302
+ self.cb.put("Warning: creds.json content is corrupted")
300
303
  self.creds = {}
301
304
  else:
302
305
  self.creds = {}
@@ -494,17 +497,7 @@ class GUI(Window):
494
497
  opt_comp = self.get_opt_comp()
495
498
  opt_cred = self.get_opt_cred()
496
499
 
497
- self.job = Job(
498
- opt_input,
499
- opt_comp,
500
- opt_output,
501
- opt_cred,
502
- self.cb_msg,
503
- self.cb_msg_block,
504
- self.cb_bar,
505
- self.cb_ask_bool,
506
- self.cb_ask_str,
507
- )
500
+ self.job = Job(opt_input, opt_comp, opt_output, opt_cred, self.cb)
508
501
 
509
502
  signal.signal(signal.SIGINT, self.job.cancel)
510
503
 
@@ -643,84 +636,6 @@ class GUI(Window):
643
636
  self.response = self.action()
644
637
  self.response_event.set()
645
638
 
646
- def cb_ask_str(
647
- self,
648
- question: str,
649
- initialvalue: Optional[str] = None,
650
- cli_show_initialvalue: bool = True,
651
- parent: Optional[object] = None,
652
- ) -> str:
653
- self.action = partial(
654
- Querybox.get_string, # type: ignore
655
- question,
656
- title="sticker-convert",
657
- initialvalue=initialvalue,
658
- parent=parent,
659
- )
660
- self.event_generate("<<exec_in_main>>")
661
- self.response_event.wait()
662
- self.response_event.clear()
663
-
664
- if self.response is None:
665
- return ""
666
- elif isinstance(self.response, str):
667
- return self.response
668
- else:
669
- raise RuntimeError(f"Invalid response in cb_ask_str: {self.response}")
670
-
671
- def cb_ask_bool(
672
- self, question: str, parent: Union[Window, Toplevel, None] = None
673
- ) -> bool:
674
- self.action = partial(
675
- Messagebox.yesno, # type: ignore
676
- question,
677
- title="sticker-convert",
678
- parent=parent,
679
- )
680
- self.event_generate("<<exec_in_main>>")
681
- self.response_event.wait()
682
- self.response_event.clear()
683
-
684
- if self.response == "Yes":
685
- return True
686
- return False
687
-
688
- def cb_msg(self, *args: Any, **kwargs: Any) -> None:
689
- self.progress_frame.update_message_box(*args, **kwargs)
690
-
691
- def cb_msg_block(
692
- self,
693
- *args: Any,
694
- message: Optional[str] = None,
695
- parent: Optional[object] = None,
696
- **_kwargs: Any,
697
- ) -> Any:
698
- if message is None and len(args) > 0:
699
- message = " ".join(str(i) for i in args)
700
- self.action = partial(
701
- Messagebox.show_info, # type: ignore
702
- message,
703
- title="sticker-convert",
704
- parent=parent,
705
- )
706
- self.event_generate("<<exec_in_main>>")
707
- self.response_event.wait()
708
- self.response_event.clear()
709
-
710
- return self.response
711
-
712
- def cb_bar(
713
- self,
714
- set_progress_mode: Optional[str] = None,
715
- steps: int = 0,
716
- update_bar: int = 0,
717
- *args: Any,
718
- **kwargs: Any,
719
- ) -> None:
720
- self.progress_frame.update_progress_bar(
721
- set_progress_mode, steps, update_bar, *args, **kwargs
722
- )
723
-
724
639
  def highlight_fields(self) -> bool:
725
640
  if not self.init_done:
726
641
  return True
@@ -21,7 +21,9 @@ class CompFrame(LabelFrame):
21
21
  self,
22
22
  text="?",
23
23
  width=1,
24
- command=lambda: self.gui.cb_msg_block(self.gui.help["comp"]["no_compress"]),
24
+ command=lambda: self.gui.cb.put(
25
+ ("msg_block", (self.gui.help["comp"]["no_compress"],), None)
26
+ ),
25
27
  bootstyle="secondary", # type: ignore
26
28
  )
27
29
  self.no_compress_lbl = Label(self, text="No compression")
@@ -38,7 +40,9 @@ class CompFrame(LabelFrame):
38
40
  self,
39
41
  text="?",
40
42
  width=1,
41
- command=lambda: self.gui.cb_msg_block(self.gui.help["comp"]["preset"]),
43
+ command=lambda: self.gui.cb.put(
44
+ ("msg_block", (self.gui.help["comp"]["preset"],), None)
45
+ ),
42
46
  bootstyle="secondary", # type: ignore
43
47
  )
44
48
  self.comp_preset_lbl = Label(self, text="Preset")
@@ -56,7 +60,9 @@ class CompFrame(LabelFrame):
56
60
  self,
57
61
  text="?",
58
62
  width=1,
59
- command=lambda: self.gui.cb_msg_block(self.gui.help["comp"]["steps"]),
63
+ command=lambda: self.gui.cb.put(
64
+ ("msg_block", (self.gui.help["comp"]["steps"],), None)
65
+ ),
60
66
  bootstyle="secondary", # type: ignore
61
67
  )
62
68
  self.steps_lbl = Label(self, text="Number of steps")
@@ -67,7 +73,9 @@ class CompFrame(LabelFrame):
67
73
  self,
68
74
  text="?",
69
75
  width=1,
70
- command=lambda: self.gui.cb_msg_block(self.gui.help["comp"]["processes"]),
76
+ command=lambda: self.gui.cb.put(
77
+ ("msg_block", (self.gui.help["comp"]["processes"],), None)
78
+ ),
71
79
  bootstyle="secondary", # type: ignore
72
80
  )
73
81
  self.processes_lbl = Label(self, text="Number of processes")
@@ -78,27 +78,35 @@ class ConfigFrame(LabelFrame):
78
78
  )
79
79
 
80
80
  def cb_clear_cred(self, *_: Any, **kwargs: Any) -> None:
81
- response = self.gui.cb_ask_bool("Are you sure you want to clear credentials?")
81
+ response = self.gui.cb.put(
82
+ ("ask_bool", ("Are you sure you want to clear credentials?",), None)
83
+ )
82
84
  if response is True:
83
85
  self.gui.delete_creds()
84
86
  self.gui.load_jsons()
85
87
  self.gui.apply_creds()
86
88
  self.gui.highlight_fields()
87
- self.gui.cb_msg_block("Credentials cleared.")
89
+ self.gui.cb.put(("msg_block", ("Credentials cleared.",), None))
88
90
 
89
91
  def cb_restore_default(self, *_: Any, **kwargs: Any) -> None:
90
- response = self.gui.cb_ask_bool(
91
- "Are you sure you want to restore default config? (This will not clear credentials.)"
92
+ response = self.gui.cb.put(
93
+ (
94
+ "ask_bool",
95
+ (
96
+ "Are you sure you want to restore default config? (This will not clear credentials.)",
97
+ ),
98
+ None,
99
+ )
92
100
  )
93
101
  if response is True:
94
102
  self.gui.delete_config()
95
103
  self.gui.load_jsons()
96
104
  self.gui.apply_config()
97
105
  self.gui.highlight_fields()
98
- self.gui.cb_msg_block("Restored to default config.")
106
+ self.gui.cb.put(("msg_block", ("Restored to default config.",), None))
99
107
 
100
108
  def cb_open_config_directory(self, *_: Any, **kwargs: Any) -> None:
101
- self.gui.cb_msg(msg=f"Config is located at {CONFIG_DIR}")
109
+ self.gui.cb.put(f"Config is located at {CONFIG_DIR}")
102
110
  if platform.system() == "Windows":
103
111
  os.startfile(CONFIG_DIR) # type: ignore
104
112
  elif platform.system() == "Darwin":
@@ -23,7 +23,7 @@ class ControlFrame(Frame):
23
23
 
24
24
  def cb_start_btn(self, *args: Any, **kwargs: Any) -> None:
25
25
  if self.gui.job:
26
- response = self.gui.cb_ask_bool("Cancel job?")
26
+ response = self.gui.cb.ask_bool("Cancel job?")
27
27
  if response is True:
28
28
  self.gui.cancel_job()
29
29
  else:
@@ -4,13 +4,13 @@ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from ttkbootstrap import Button, Entry, Label, LabelFrame # type: ignore
6
6
 
7
+ from sticker_convert.auth.auth_telethon import AuthTelethon
7
8
  from sticker_convert.gui_components.frames.right_clicker import RightClicker
8
9
  from sticker_convert.gui_components.windows.discord_get_auth_window import DiscordGetAuthWindow
9
10
  from sticker_convert.gui_components.windows.kakao_get_auth_window import KakaoGetAuthWindow
10
11
  from sticker_convert.gui_components.windows.line_get_auth_window import LineGetAuthWindow
11
12
  from sticker_convert.gui_components.windows.signal_get_auth_window import SignalGetAuthWindow
12
13
  from sticker_convert.gui_components.windows.viber_get_auth_window import ViberGetAuthWindow
13
- from sticker_convert.utils.auth.telethon_setup import TelethonSetup
14
14
 
15
15
  if TYPE_CHECKING:
16
16
  from sticker_convert.gui import GUI # type: ignore
@@ -188,19 +188,17 @@ class CredFrame(LabelFrame):
188
188
  faq_site = "https://github.com/laggykiller/sticker-convert#faq"
189
189
  success = webbrowser.open(faq_site)
190
190
  if not success:
191
- self.gui.cb_ask_str("You can get help from:", initialvalue=faq_site)
191
+ self.gui.cb.ask_str("You can get help from:", initialvalue=faq_site)
192
192
 
193
193
  def cb_telethon_get_auth(self, *_: Any) -> None:
194
- success, _client, api_id, api_hash = TelethonSetup(
195
- self.gui.get_opt_cred(), self.gui.cb_ask_str
196
- ).start()
194
+ success, _client, api_id, api_hash, msg = AuthTelethon(
195
+ self.gui.get_opt_cred(), self.gui.cb
196
+ ).start(check_auth_only=True)
197
197
  if success:
198
198
  self.gui.telethon_api_id_var.set(api_id)
199
199
  self.gui.telethon_api_hash_var.set(api_hash)
200
200
  self.gui.save_creds()
201
- self.gui.cb_msg_block("Telethon setup successful")
202
- else:
203
- self.gui.cb_msg_block("Telethon setup failed")
201
+ self.gui.cb.put(("msg_block", (msg,), None))
204
202
 
205
203
  def cb_kakao_get_auth(self, *_: Any) -> None:
206
204
  KakaoGetAuthWindow(self.gui)
@@ -2,7 +2,6 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  import re
5
- from functools import partial
6
5
  from tkinter import colorchooser
7
6
  from typing import Any, List, Tuple
8
7
 
@@ -650,13 +649,13 @@ class AdvancedCompressionWindow(BaseWindow):
650
649
  self.set_emoji_btn()
651
650
 
652
651
  def add_help_btn(self, msg: str) -> Button:
653
- cb_msg_block_adv_comp_win = partial(self.gui.cb_msg_block, parent=self)
654
-
655
652
  return Button(
656
653
  self.frame_advcomp,
657
654
  text="?",
658
655
  width=1,
659
- command=lambda: cb_msg_block_adv_comp_win(msg),
656
+ command=lambda: self.gui.cb.put(
657
+ ("msg_block", None, {"message": msg, "parent": self})
658
+ ),
660
659
  bootstyle="secondary", # type: ignore
661
660
  )
662
661
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
  import platform
3
- from typing import TYPE_CHECKING, Tuple
3
+ from typing import TYPE_CHECKING, Optional, Tuple
4
4
 
5
5
  from ttkbootstrap import Toplevel # type: ignore
6
6
 
@@ -11,10 +11,15 @@ if TYPE_CHECKING:
11
11
 
12
12
 
13
13
  class BaseWindow(Toplevel):
14
- def __init__(self, gui: "GUI") -> None:
14
+ def __init__(self, gui: "GUI", parent: Optional[Toplevel] = None) -> None:
15
15
  super().__init__(alpha=0) # type: ignore
16
16
  self.gui = gui
17
17
 
18
+ if parent is None:
19
+ self.parent = gui
20
+ else:
21
+ self.parent = parent
22
+
18
23
  GUIUtils.set_icon(self)
19
24
 
20
25
  self.mousewheel: Tuple[str, ...]