pyPDFeditor-GUI 3.0.7__tar.gz → 3.0.8__tar.gz

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 (70) hide show
  1. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/PKG-INFO +14 -3
  2. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/README.md +1 -1
  3. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pyPDFeditor_GUI.egg-info/PKG-INFO +14 -3
  4. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/__init__.py +1 -1
  5. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/application.py +16 -11
  6. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/functions.py +21 -17
  7. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/window_effect.py +2 -1
  8. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/windows.py +11 -10
  9. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/LICENSE +0 -0
  10. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pyPDFeditor_GUI.egg-info/SOURCES.txt +0 -0
  11. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pyPDFeditor_GUI.egg-info/dependency_links.txt +0 -0
  12. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pyPDFeditor_GUI.egg-info/entry_points.txt +0 -0
  13. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pyPDFeditor_GUI.egg-info/requires.txt +0 -0
  14. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pyPDFeditor_GUI.egg-info/top_level.txt +0 -0
  15. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/__main__.py +0 -0
  16. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/Add.svg +0 -0
  17. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/Add_h.svg +0 -0
  18. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/Add_p.svg +0 -0
  19. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/Photo.svg +0 -0
  20. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/__init__.py +0 -0
  21. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/arrow_move.svg +0 -0
  22. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/book2.svg +0 -0
  23. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/chevron_down.svg +0 -0
  24. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/color.svg +0 -0
  25. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/color_h.svg +0 -0
  26. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/color_p.svg +0 -0
  27. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/delete.svg +0 -0
  28. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/delete_h.svg +0 -0
  29. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/delete_p.svg +0 -0
  30. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/dismiss.svg +0 -0
  31. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/dismiss_h.svg +0 -0
  32. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/down.svg +0 -0
  33. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/down_h.svg +0 -0
  34. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/down_p.svg +0 -0
  35. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/edit.svg +0 -0
  36. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/folder.svg +0 -0
  37. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/folder_d.svg +0 -0
  38. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/folder_h.svg +0 -0
  39. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/folder_p.svg +0 -0
  40. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/font.svg +0 -0
  41. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/font_h.svg +0 -0
  42. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/font_p.svg +0 -0
  43. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/home.svg +0 -0
  44. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/lock.svg +0 -0
  45. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/maximize.svg +0 -0
  46. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/merge.svg +0 -0
  47. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/metadata.svg +0 -0
  48. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/minimize.svg +0 -0
  49. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/more.svg +0 -0
  50. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/more_d.svg +0 -0
  51. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/more_h.svg +0 -0
  52. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/more_p.svg +0 -0
  53. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/move_page.svg +0 -0
  54. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/pdf icon.svg +0 -0
  55. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/rotate_anticlockwise.svg +0 -0
  56. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/rotate_clockwise.svg +0 -0
  57. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/settings.svg +0 -0
  58. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/settings_h.svg +0 -0
  59. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/settings_p.svg +0 -0
  60. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/square_multiple.svg +0 -0
  61. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/sync.svg +0 -0
  62. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/sync_h.svg +0 -0
  63. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/sync_p.svg +0 -0
  64. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/view.svg +0 -0
  65. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/view_h.svg +0 -0
  66. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/icons/view_p.svg +0 -0
  67. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/language.py +0 -0
  68. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/pypdfeditor_core/style_sheets.py +0 -0
  69. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/setup.cfg +0 -0
  70. {pypdfeditor_gui-3.0.7 → pypdfeditor_gui-3.0.8}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pyPDFeditor-GUI
3
- Version: 3.0.7
3
+ Version: 3.0.8
4
4
  Summary: A desktop application to edit PDF files.
5
5
  Home-page: https://github.com/Augus1999/pyPDFeditor-GUI/
6
6
  Author: Nianze A. TAO
@@ -28,6 +28,17 @@ Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
29
  Requires-Dist: PyMuPDF>=1.24.3
30
30
  Requires-Dist: PyQt6>=6.7.0
31
+ Dynamic: author
32
+ Dynamic: author-email
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: description-content-type
36
+ Dynamic: home-page
37
+ Dynamic: license
38
+ Dynamic: project-url
39
+ Dynamic: requires-dist
40
+ Dynamic: requires-python
41
+ Dynamic: summary
31
42
 
32
43
  # pyPDFeditor-GUI
33
44
 
@@ -40,7 +51,7 @@ Requires-Dist: PyQt6>=6.7.0
40
51
  ![PyQt](https://img.shields.io/badge/PyQt-6.7-blue?color=708ddd)
41
52
  ![black](https://img.shields.io/badge/code%20style-black-black)
42
53
 
43
- This project is based on PyQt5 and PyMuPDF and tested on Windows 10 & 11 and Ubuntu on WSL2.
54
+ This project is based on PyQt6 and PyMuPDF and tested on Windows 10 & 11 and Ubuntu on WSL2.
44
55
 
45
56
  ## Welcome 🎃🎉
46
57
 
@@ -9,7 +9,7 @@
9
9
  ![PyQt](https://img.shields.io/badge/PyQt-6.7-blue?color=708ddd)
10
10
  ![black](https://img.shields.io/badge/code%20style-black-black)
11
11
 
12
- This project is based on PyQt5 and PyMuPDF and tested on Windows 10 & 11 and Ubuntu on WSL2.
12
+ This project is based on PyQt6 and PyMuPDF and tested on Windows 10 & 11 and Ubuntu on WSL2.
13
13
 
14
14
  ## Welcome 🎃🎉
15
15
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pyPDFeditor-GUI
3
- Version: 3.0.7
3
+ Version: 3.0.8
4
4
  Summary: A desktop application to edit PDF files.
5
5
  Home-page: https://github.com/Augus1999/pyPDFeditor-GUI/
6
6
  Author: Nianze A. TAO
@@ -28,6 +28,17 @@ Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
29
  Requires-Dist: PyMuPDF>=1.24.3
30
30
  Requires-Dist: PyQt6>=6.7.0
31
+ Dynamic: author
32
+ Dynamic: author-email
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: description-content-type
36
+ Dynamic: home-page
37
+ Dynamic: license
38
+ Dynamic: project-url
39
+ Dynamic: requires-dist
40
+ Dynamic: requires-python
41
+ Dynamic: summary
31
42
 
32
43
  # pyPDFeditor-GUI
33
44
 
@@ -40,7 +51,7 @@ Requires-Dist: PyQt6>=6.7.0
40
51
  ![PyQt](https://img.shields.io/badge/PyQt-6.7-blue?color=708ddd)
41
52
  ![black](https://img.shields.io/badge/code%20style-black-black)
42
53
 
43
- This project is based on PyQt5 and PyMuPDF and tested on Windows 10 & 11 and Ubuntu on WSL2.
54
+ This project is based on PyQt6 and PyMuPDF and tested on Windows 10 & 11 and Ubuntu on WSL2.
44
55
 
45
56
  ## Welcome 🎃🎉
46
57
 
@@ -15,7 +15,7 @@ if not os.path.exists(app_home):
15
15
 
16
16
  __system__ = platform.system()
17
17
  __author__ = "Nianze A. TAO (Omozawa SUENO)"
18
- __version__ = "3.0.7"
18
+ __version__ = "3.0.8"
19
19
  __all__ = ["main", "reset", "remove"]
20
20
 
21
21
 
@@ -10,11 +10,11 @@ import shutil
10
10
  import getpass
11
11
  import subprocess as sp
12
12
  from pathlib import Path
13
- from typing import Dict
13
+ from typing import List, Dict, Union, Optional
14
14
  import pymupdf as fitz
15
15
  from PyQt6 import QtCore
16
16
  from PyQt6.QtGui import QColor, QPixmap, QCloseEvent
17
- from PyQt6.QtWidgets import QColorDialog
17
+ from PyQt6.QtWidgets import QColorDialog, QWidget
18
18
  from .language import set_language, lag_s, lag_p
19
19
  from .windows import (
20
20
  MainR,
@@ -158,7 +158,7 @@ class Main(MainR):
158
158
  if not self.settings.value("windowState") == None:
159
159
  self.restoreState(self.settings.value("windowState"))
160
160
 
161
- def closeEvent(self, event: QCloseEvent) -> None:
161
+ def closeEvent(self, event: Optional[QCloseEvent]) -> None:
162
162
  """
163
163
  write settings to settings.json
164
164
  """
@@ -212,7 +212,12 @@ class Main(MainR):
212
212
  self.tab3.button6.clicked.disconnect()
213
213
  self.perm_int = 4028 # value of all permissions
214
214
 
215
- def view(self, index=None, widget=None, f_name=None) -> None:
215
+ def view(
216
+ self,
217
+ index: Optional[int] = None,
218
+ widget: Optional[QWidget] = None,
219
+ f_name: Optional[str] = None,
220
+ ) -> None:
216
221
  """
217
222
  open file outside the application
218
223
 
@@ -460,7 +465,7 @@ class Main(MainR):
460
465
  del doc, state
461
466
  return
462
467
 
463
- def get_data(self, par1, par2, par3, par5) -> None:
468
+ def get_data(self, par1: str, par2: str, par3: bool, par5: str) -> None:
464
469
  """
465
470
  obtain settings from setting window
466
471
  """
@@ -472,7 +477,7 @@ class Main(MainR):
472
477
  set_language(self)
473
478
  self.setCurrentIndex(i)
474
479
 
475
- def get_font_dir(self, par) -> None:
480
+ def get_font_dir(self, par: str) -> None:
476
481
  """
477
482
  obtain font file directory from font window
478
483
  """
@@ -560,7 +565,7 @@ class Main(MainR):
560
565
  del doc
561
566
 
562
567
  @staticmethod
563
- def show_index(par, widget):
568
+ def show_index(par: List[int], widget: QWidget):
564
569
  """
565
570
  show recent clicked page number
566
571
  """
@@ -576,7 +581,7 @@ class Setting(SettingR):
576
581
 
577
582
  signal = QtCore.pyqtSignal(str, str, bool, str)
578
583
 
579
- def __init__(self, set_dict: dict):
584
+ def __init__(self, set_dict: Dict[str, Union[str, bool]]):
580
585
  super().__init__()
581
586
  self.s_dir = set_dict["start dir"]
582
587
  self.o_dir = set_dict["save dir"]
@@ -620,7 +625,7 @@ class Setting(SettingR):
620
625
  self.line1.setReadOnly(False)
621
626
  self.line2.setReadOnly(False)
622
627
 
623
- def closeEvent(self, event: QCloseEvent) -> None:
628
+ def closeEvent(self, event: Optional[QCloseEvent]) -> None:
624
629
  """
625
630
  re-write closeEvent
626
631
  """
@@ -647,7 +652,7 @@ class PermMenu(PermMenuR):
647
652
  """
648
653
  lag_p(self, language)
649
654
 
650
- def closeEvent(self, event: QCloseEvent) -> None:
655
+ def closeEvent(self, event: Optional[QCloseEvent]) -> None:
651
656
  """
652
657
  close event
653
658
  """
@@ -723,7 +728,7 @@ class FontDialog(FontDialogR):
723
728
  fitz.TOOLS.store_shrink(100) # delete MuPDF cache
724
729
  del cover, shape, page, r1, doc
725
730
 
726
- def closeEvent(self, event: QCloseEvent) -> None:
731
+ def closeEvent(self, event: Optional[QCloseEvent]) -> None:
727
732
  """
728
733
  close event
729
734
  """
@@ -8,7 +8,7 @@ import gc
8
8
  import sys
9
9
  import json
10
10
  import time
11
- from typing import Union, Optional, Tuple, List
11
+ from typing import Union, Optional, Tuple, List, Dict
12
12
  from pathlib import Path
13
13
  from pymupdf.mupdf import FzErrorFormat, FzErrorLibrary
14
14
  from pymupdf import Document, Page, Pixmap, Rect, Point, Font
@@ -38,7 +38,7 @@ class Doc(Document):
38
38
  """
39
39
 
40
40
  pass_word: Optional[str] = None
41
- rotatedPages = {}
41
+ rotatedPages: Dict[int, int] = {}
42
42
 
43
43
 
44
44
  def copy(doc: Doc) -> Doc:
@@ -76,7 +76,10 @@ def open_pdf(file_name: str, parent: QWidget) -> Tuple[Optional[Doc], bool]:
76
76
  except RuntimeError:
77
77
  return _open_warning(parent)
78
78
  if not doc.is_pdf:
79
- if file_name.endswith(SUPPORT_IMG_FORMAT[:-1]):
79
+ _support_img_format = SUPPORT_IMG_FORMAT[:-1] + tuple(
80
+ i.upper() for i in SUPPORT_IMG_FORMAT[:-1]
81
+ )
82
+ if file_name.endswith(_support_img_format):
80
83
  try: # handle wrong image formats
81
84
  pdf_bites = Pixmap(file_name).tobytes()
82
85
  doc = Doc("png", pdf_bites)
@@ -106,7 +109,7 @@ def open_pdf(file_name: str, parent: QWidget) -> Tuple[Optional[Doc], bool]:
106
109
  return doc, True
107
110
 
108
111
 
109
- def render_pdf_page(page_data: Doc.load_page) -> QtGui.QPixmap:
112
+ def render_pdf_page(page_data: Page) -> QtGui.QPixmap:
110
113
  """
111
114
  render PDF page
112
115
 
@@ -131,7 +134,7 @@ def render_pdf_page(page_data: Doc.load_page) -> QtGui.QPixmap:
131
134
  return pixmap
132
135
 
133
136
 
134
- def pdf_split(doc: Doc) -> List:
137
+ def pdf_split(doc: Doc) -> List[int]:
135
138
  """
136
139
  split the selected PDF file into pages;
137
140
 
@@ -190,7 +193,7 @@ def add_watermark(
190
193
  return doc
191
194
 
192
195
 
193
- def setting_warning(set_file_name: str, parent: QWidget) -> dict:
196
+ def setting_warning(set_file_name: str, parent: QWidget) -> Dict[str, Union[str, bool]]:
194
197
  """
195
198
  import settings from the JSON file
196
199
 
@@ -327,7 +330,7 @@ def set_icon(
327
330
  TOOLS.store_shrink(100) # delete MuPDF cache
328
331
 
329
332
 
330
- def add(main: QWidget, _format: str) -> Tuple[str]:
333
+ def add(main: QWidget, _format: str) -> Tuple[str, str]:
331
334
  """
332
335
  add a file
333
336
 
@@ -336,14 +339,15 @@ def add(main: QWidget, _format: str) -> Tuple[str]:
336
339
  :return: [f_name, state]
337
340
  """
338
341
  f_name, state = QFileDialog.getOpenFileName(main, "Open files", main.s_dir, _format)
339
- if state and not f_name.endswith(SUPPORT_FORMAT):
342
+ _support_format = SUPPORT_FORMAT + tuple(i.upper() for i in SUPPORT_FORMAT)
343
+ if state and not f_name.endswith(_support_format):
340
344
  return "", ""
341
345
  if state and main.dir_store_state:
342
346
  main.s_dir = os.path.dirname(f_name)
343
347
  return f_name, state
344
348
 
345
349
 
346
- def save(main: QWidget, _format: str) -> Tuple[str]:
350
+ def save(main: QWidget, _format: str) -> Tuple[str, str]:
347
351
  """
348
352
  save a file
349
353
 
@@ -645,7 +649,7 @@ def choose(widget: QtWidgets.QLineEdit, c_dir: str) -> None:
645
649
  widget.setText(root)
646
650
 
647
651
 
648
- def remove_invalid_xref_key(metadata: dict) -> dict:
652
+ def remove_invalid_xref_key(metadata: Dict[str, str]) -> Dict[str, str]:
649
653
  """
650
654
  remove invalid xref key(s)
651
655
  """
@@ -697,8 +701,8 @@ def set_metadata0(doc: Doc, author: Optional[str]) -> None:
697
701
 
698
702
 
699
703
  def set_metadata1(
700
- metadata: dict, title: str, author: str, subject: str, keywords: str
701
- ) -> dict:
704
+ metadata: Dict[str, str], title: str, author: str, subject: str, keywords: str
705
+ ) -> Dict[str, str]:
702
706
  """
703
707
  set metadata to pdf document
704
708
 
@@ -731,7 +735,7 @@ def set_metadata1(
731
735
  return metadata
732
736
 
733
737
 
734
- def toc2plaintext(toc: List) -> str:
738
+ def toc2plaintext(toc: List[List[Union[str, int]]]) -> str:
735
739
  """
736
740
  :param toc: table of content <- DOCUMENT.get_toc()
737
741
  :return: plaintext
@@ -744,7 +748,7 @@ def toc2plaintext(toc: List) -> str:
744
748
  return plaintext
745
749
 
746
750
 
747
- def plaintext2toc(plaintext: str) -> List[List]:
751
+ def plaintext2toc(plaintext: str) -> List[List[Union[str, int]]]:
748
752
  """
749
753
  :param plaintext: plaintext
750
754
  :return: table of content -> DOCUMENT.get_toc()
@@ -759,7 +763,7 @@ def plaintext2toc(plaintext: str) -> List[List]:
759
763
  return toc
760
764
 
761
765
 
762
- def find_font(font_dirs: List) -> Tuple[dict]:
766
+ def find_font(font_dirs: List[str]) -> Tuple[Dict[str, str], Dict[str, str]]:
763
767
  """
764
768
  find all TrueType font files (.ttf): all their font name and file addresses
765
769
  then write their directories to a json file
@@ -785,7 +789,7 @@ def find_font(font_dirs: List) -> Tuple[dict]:
785
789
  return name_dict, dir_dict
786
790
 
787
791
 
788
- def store_font_path(name_dict: dict, cache_file_name: str) -> None:
792
+ def store_font_path(name_dict: Dict[str, str], cache_file_name: str) -> None:
789
793
  """
790
794
  store the font file dict
791
795
 
@@ -796,7 +800,7 @@ def store_font_path(name_dict: dict, cache_file_name: str) -> None:
796
800
  json.dump(name_dict, f, sort_keys=True, indent=4, separators=(",", ": "))
797
801
 
798
802
 
799
- def read_from_font_cache(cache_file_name: str) -> Tuple[dict]:
803
+ def read_from_font_cache(cache_file_name: str) -> Tuple[Dict[str, str], Dict[str, str]]:
800
804
  """
801
805
  read font directories from json file
802
806
 
@@ -5,6 +5,7 @@ win32api functions and classes
5
5
  """
6
6
  from ctypes import POINTER, c_int, WinDLL, Structure, byref, cast
7
7
  from ctypes.wintypes import RECT, UINT, HWND, MSG
8
+ from PyQt6.QtCore import QRect
8
9
 
9
10
 
10
11
  class PWindowPOS(Structure):
@@ -69,7 +70,7 @@ class WindowEffect:
69
70
  self._extend(h_wnd, byref(margins))
70
71
 
71
72
  @staticmethod
72
- def monitorNCCALCSIZE(_msg: MSG, geometry) -> None:
73
+ def monitorNCCALCSIZE(_msg: MSG, geometry: QRect) -> None:
73
74
  """
74
75
  resize the window to fit the screen
75
76
 
@@ -4,7 +4,7 @@
4
4
  application window forms
5
5
  """
6
6
  import re
7
- from typing import Tuple, Union
7
+ from typing import Tuple, Union, Optional
8
8
  from PyQt6.sip import voidptr
9
9
  from PyQt6.QtGui import (
10
10
  QIcon,
@@ -60,7 +60,7 @@ class SwitchBtn(QWidget):
60
60
 
61
61
  stateChanged = QtCore.pyqtSignal(bool)
62
62
 
63
- def __init__(self, parent=None):
63
+ def __init__(self, parent: Optional[QWidget] = None):
64
64
  super().__init__(parent)
65
65
  self.checked = False
66
66
  self.bgColorOff = QColor("#e2e2dd")
@@ -80,10 +80,11 @@ class SwitchBtn(QWidget):
80
80
  self.timer.timeout.connect(self.update_value)
81
81
  self.setFont(QFont("calibri", 14))
82
82
 
83
- def setStyleSheet(self, style_sheet: str) -> None:
83
+ def setStyleSheet(self, style_sheet: Optional[str]) -> None:
84
84
  """
85
85
  define set-style-sheet behaviour
86
86
  """
87
+ assert style_sheet is not None
87
88
  style_sheet = re.sub(r"\s+", "", style_sheet)
88
89
  on_style = str(re.findall(r"SwitchBtn:on{.+?}", style_sheet))
89
90
  off_style = str(re.findall(r"SwitchBtn:off{.+?}", style_sheet))
@@ -122,7 +123,7 @@ class SwitchBtn(QWidget):
122
123
  self.timer.stop()
123
124
  self.update()
124
125
 
125
- def mousePressEvent(self, event: QMouseEvent) -> None:
126
+ def mousePressEvent(self, event: Optional[QMouseEvent]) -> None:
126
127
  """
127
128
  mousePressEvent
128
129
  """
@@ -154,7 +155,7 @@ class SwitchBtn(QWidget):
154
155
  """
155
156
  return self.checked
156
157
 
157
- def paintEvent(self, event: QPaintEvent) -> None:
158
+ def paintEvent(self, event: Optional[QPaintEvent]) -> None:
158
159
  """
159
160
  paintEvent
160
161
  """
@@ -251,7 +252,7 @@ class TableWidget(QTableWidget):
251
252
 
252
253
  Index = QtCore.pyqtSignal(tuple)
253
254
 
254
- def mousePressEvent(self, event: QMouseEvent) -> None:
255
+ def mousePressEvent(self, event: Optional[QMouseEvent]) -> None:
255
256
  """
256
257
  re-write mousePressEvent
257
258
  """
@@ -468,7 +469,7 @@ class MainR(QTabWidget):
468
469
  x, y = [int(i) for i in str(state)[2:-1].split(",")]
469
470
  self.move(x, y)
470
471
 
471
- def paintEvent(self, event: QPaintEvent) -> None:
472
+ def paintEvent(self, event: Optional[QPaintEvent]) -> None:
472
473
  """
473
474
  re-write paintEvent
474
475
  """
@@ -486,7 +487,7 @@ class MainR(QTabWidget):
486
487
 
487
488
  # -------well, why do the following ugly codes exist?-------
488
489
  # -------they are used to re-enable the window animations under Windows platform-------
489
- def mouseMoveEvent(self, event: QMouseEvent) -> None:
490
+ def mouseMoveEvent(self, event: Optional[QMouseEvent]) -> None:
490
491
  """
491
492
  re-write mouseMoveEvent
492
493
  move the frameless window
@@ -499,7 +500,7 @@ class MainR(QTabWidget):
499
500
  self.windowEffect.move_window(int(self.winId()))
500
501
  return QTabWidget.mouseMoveEvent(self, event)
501
502
 
502
- def mouseDoubleClickEvent(self, event: QMouseEvent) -> None:
503
+ def mouseDoubleClickEvent(self, event: Optional[QMouseEvent]) -> None:
503
504
  """
504
505
  re-write mouseDoubleClickEvent
505
506
  """
@@ -566,7 +567,7 @@ class MainR(QTabWidget):
566
567
 
567
568
  # -------here ends the ugly code-------
568
569
 
569
- def resizeEvent(self, event: QResizeEvent) -> None:
570
+ def resizeEvent(self, event: Optional[QResizeEvent]) -> None:
570
571
  """
571
572
  re-write resizeEvent
572
573
  """
File without changes