tkinterweb 4.16.10__tar.gz → 4.17.0__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 (23) hide show
  1. {tkinterweb-4.16.10/tkinterweb.egg-info → tkinterweb-4.17.0}/PKG-INFO +1 -1
  2. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/setup.py +5 -5
  3. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/bindings.py +24 -8
  4. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/handlers.py +4 -1
  5. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/htmlwidgets.py +26 -20
  6. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/utilities.py +2 -2
  7. {tkinterweb-4.16.10 → tkinterweb-4.17.0/tkinterweb.egg-info}/PKG-INFO +1 -1
  8. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb.egg-info/requires.txt +4 -4
  9. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/LICENSE.md +0 -0
  10. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/MANIFEST.in +0 -0
  11. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/README.md +0 -0
  12. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/setup.cfg +0 -0
  13. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/__init__.py +0 -0
  14. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/dom.py +0 -0
  15. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/extensions.py +0 -0
  16. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/imageutils.py +0 -0
  17. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/js.py +0 -0
  18. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/resources/combobox-2.3.tm +0 -0
  19. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/resources/pkgIndex.tcl +0 -0
  20. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb/subwidgets.py +0 -0
  21. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb.egg-info/SOURCES.txt +0 -0
  22. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb.egg-info/dependency_links.txt +0 -0
  23. {tkinterweb-4.16.10 → tkinterweb-4.17.0}/tkinterweb.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tkinterweb
3
- Version: 4.16.10
3
+ Version: 4.17.0
4
4
  Summary: HTML/CSS viewer, editor, and app builder for Tkinter
5
5
  Home-page: https://github.com/Andereoo/TkinterWeb
6
6
  License: MIT
@@ -6,7 +6,7 @@ README = (HERE / "README.md").read_text()
6
6
 
7
7
  setup(
8
8
  name="tkinterweb",
9
- version="4.16.10",
9
+ version="4.17.0",
10
10
  python_requires=">=3.2",
11
11
  description="HTML/CSS viewer, editor, and app builder for Tkinter",
12
12
  long_description=README,
@@ -27,13 +27,13 @@ setup(
27
27
  include_package_data=True,
28
28
  install_requires=["tkinterweb-tkhtml>=2.1.0"],
29
29
  extras_require = {
30
- "html": ["tkinterweb-tkhtml-extras>=1.1.1"],
30
+ "html": ["tkinterweb-tkhtml-extras>=1.2.0"],
31
31
  "images": ["pillow"],
32
- "svg": ["tkinterweb-tkhtml-extras>=1.1.1", "pillow", "cairosvg"],
32
+ "svg": ["tkinterweb-tkhtml-extras>=1.2.0", "pillow", "cairosvg"],
33
33
  "javascript": ["pythonmonkey"],
34
34
  "requests": ["brotli"],
35
35
 
36
- "recommended": ["tkinterweb-tkhtml-extras>=1.1.1", "pillow"],
37
- "full": ["tkinterweb-tkhtml-extras>=1.1.1", "pillow", "cairosvg", "pythonmonkey", "brotli"],
36
+ "recommended": ["tkinterweb-tkhtml-extras>=1.2.0", "pillow"],
37
+ "full": ["tkinterweb-tkhtml-extras>=1.2.0", "pillow", "cairosvg", "pythonmonkey", "brotli"],
38
38
  },
39
39
  )
@@ -36,6 +36,9 @@ class TkinterWeb(tk.Widget):
36
36
  _delayed_options = {"dark_theme_enabled", "caches_enabled", "threading_enabled"}
37
37
  tkinterweb_options = self._setup_settings(tkinterweb_options, _delayed_options)
38
38
 
39
+ # Load Tkhtml3
40
+ self._load_tkhtml()
41
+
39
42
  # Register image loading infrastructure
40
43
  if "imagecmd" not in kwargs:
41
44
  kwargs["imagecmd"] = master.register(self._on_image_cmd)
@@ -49,14 +52,27 @@ class TkinterWeb(tk.Widget):
49
52
  # if "logcmd" not in kwargs:
50
53
  # kwargs["logcmd"] = tkhtml_notifier
51
54
 
52
- # Set the default style if needed
53
- if kwargs.get("shrink", False) == True and self.default_style:
54
- self.default_style += utilities.SHRINK_STYLE
55
+ shrink = bool(kwargs.get("shrink"))
56
+ textwrap = kwargs.get("textwrap")
57
+
58
+ # Set the textwrap value if needed
59
+ if self.using_tkhtml30:
60
+ if self.default_style:
61
+ # For Tkhtml 3.0, we do our best by applying CSS to block word wrapping
62
+ if textwrap == "auto" and shrink:
63
+ self.default_style += utilities.TEXTWRAP_STYLE
64
+ elif not textwrap:
65
+ self.default_style += utilities.TEXTWRAP_STYLE
66
+ # Version 3.0 doesn't support textwrap
67
+ kwargs.pop("textwrap", None)
68
+ elif textwrap == "auto":
69
+ kwargs["textwrap"] = not(shrink)
55
70
 
56
- if kwargs.get("defaultstyle", "") == "" and self.default_style:
71
+ # Set the default style if needed
72
+ if not kwargs.get("defaultstyle", "") and self.default_style:
57
73
  kwargs["defaultstyle"] = self.default_style
58
74
 
59
- # Unset width and height if -0
75
+ # Unset width and height if null
60
76
  if kwargs.get("width") == 0:
61
77
  del kwargs["width"]
62
78
  if kwargs.get("height") == 0:
@@ -65,8 +81,7 @@ class TkinterWeb(tk.Widget):
65
81
  # Provide OS information for troubleshooting
66
82
  self.post_message(f"Starting TkinterWeb for {utilities.PLATFORM.processor} {utilities.PLATFORM.system} with Python {'.'.join(utilities.PYTHON_VERSION)}")
67
83
 
68
- # Load and initialize the Tkhtml3 widget
69
- self._load_tkhtml()
84
+ # Initialize the Tkhtml3 widget
70
85
  tk.Widget.__init__(self, master, "html", kwargs)
71
86
 
72
87
  # Setup threading settings
@@ -312,6 +327,7 @@ It is likely that not all dependencies are installed. Make sure Cairo is install
312
327
  self.post_message(f"Tkhtml {loaded_version} successfully loaded")
313
328
 
314
329
  self.tkhtml_version = loaded_version
330
+ self.using_tkhtml30 = loaded_version == "3.0"
315
331
 
316
332
  # --- Extensions ----------------------------------------------------------
317
333
 
@@ -1065,7 +1081,7 @@ It is likely that not all dependencies are installed. Make sure Cairo is install
1065
1081
  data = "".join(c for c in data if c <= "\uFFFF")
1066
1082
 
1067
1083
  # I moved these workarounds to Tkhtml in version 3.1
1068
- if self.tkhtml_version == "3.0":
1084
+ if self.using_tkhtml30:
1069
1085
  data = sub(
1070
1086
  "font-family:[^;']*(;)?",
1071
1087
  self._remove_noto_emoji,
@@ -796,9 +796,11 @@ class ObjectManager(utilities.BaseManager):
796
796
  "Handle <iframe> elements."
797
797
  src = self.html.get_node_attribute(node, "src")
798
798
  srcdoc = self.html.get_node_attribute(node, "srcdoc")
799
- scrolling = "auto"
799
+
800
800
  if self.html.get_node_attribute(node, "scrolling") == "no":
801
801
  scrolling = False
802
+ else:
803
+ scrolling = "auto"
802
804
 
803
805
  if srcdoc:
804
806
  self._create_iframe(node, None, srcdoc, scrolling)
@@ -826,6 +828,7 @@ class ObjectManager(utilities.BaseManager):
826
828
  message_func=self.html.message_func,
827
829
  overflow_scroll_frame=self.html,
828
830
  stylesheets_enabled = self.html.stylesheets_enabled,
831
+ vertical_scrollbar = vertical_scrollbar,
829
832
  images_enabled = self.html.images_enabled,
830
833
  forms_enabled = self.html.forms_enabled,
831
834
  objects_enabled = self.html.objects_enabled,
@@ -42,14 +42,19 @@ class HtmlFrame(Frame):
42
42
  :type zoom: float
43
43
  :param fontscale: The page fontscale multiplier.
44
44
  :type fontscale: float
45
- :param vertical_scrollbar: Show the vertical scrollbar. Consider using the CSS ``overflow`` property on the ``<html>`` or ``<body>`` element instead.
46
- :type vertical_scrollbar: bool or "auto"
47
- :param horizontal_scrollbar: Show the horizontal scrollbar. It is usually best to leave this hidden. Consider adding the ``tkinterweb-overflow-x="scroll" | "auto" | "hidden"`` attribute on the ``<html>`` or ``<body>`` element instead.
48
- :type horizontal_scrollbar: bool or "auto"
49
- :param shrink: If False, the widget's width and height are set by the width and height options as per usual. If this option is set to True, the widget's width and height are determined by the current document.
50
- :type shrink: bool
51
45
  :param defaultstyle: The default stylesheet to use when parsing HTML. Use caution when changing this setting. The default is ``tkintereb.utilities.DEFAULT_STYLE``.
52
46
  :type defaultstyle: str
47
+
48
+ Widget sizing and overflow:
49
+
50
+ :param vertical_scrollbar: Show the vertical scrollbar. You can also set the CSS ``overflow`` property on the ``<html>`` or ``<body>`` element instead.
51
+ :type vertical_scrollbar: bool, "auto", or "dynamic"
52
+ :param horizontal_scrollbar: Show the horizontal scrollbar. It is usually best to leave this hidden. You can also set the ``tkinterweb-overflow-x="scroll" | "auto" | "hidden"`` attribute on the ``<html>`` or ``<body>`` element instead.
53
+ :type horizontal_scrollbar: bool, "auto", or "dynamic"
54
+ :param shrink: If False, the widget's width and height are set by the width and height options as per usual. If this option is set to True, the widget's width and height are determined by the current document.
55
+ :type shrink: bool
56
+ param textwrap: Determines whether text is allowed to wrap. This is similar to the CSS ``text-wrap: normal | nowrap`` property, but more forceful. By default, wrapping will be disabled when shrink is True and will be enabled when shrink is False. Make sure the tkinterweb-tkhtml-extras package is installed; this is only partially supported in Tkhtml version 3.0. New in version 4.17.
57
+ :type textwrap: bool or "auto"
53
58
 
54
59
  Debugging:
55
60
 
@@ -136,7 +141,7 @@ class HtmlFrame(Frame):
136
141
 
137
142
  :raise TypeError: If the value type is wrong and cannot be converted to the correct type."""
138
143
 
139
- def __init__(self, master, *, zoom = 1.0, fontscale = 1.0, messages_enabled = True, vertical_scrollbar = "auto", horizontal_scrollbar = False, \
144
+ def __init__(self, master, *, zoom = 1.0, fontscale = 1.0, messages_enabled = True, vertical_scrollbar = "dynamic", horizontal_scrollbar = False, \
140
145
  on_navigate_fail = None, on_link_click = None, on_form_submit = None, on_script = None, on_element_script = None, on_resource_setup = None, \
141
146
  message_func = utilities.notifier, request_func = None, caret_browsing_enabled = False, selection_enabled = True, \
142
147
  stylesheets_enabled = True, images_enabled = True, forms_enabled = True, objects_enabled = True, caches_enabled = True, \
@@ -146,7 +151,7 @@ class HtmlFrame(Frame):
146
151
  find_current_text_color = "#000", selected_text_highlight_color = "#9bc6fa", selected_text_color = "#000", \
147
152
  insecure_https = False, ssl_cafile = None, request_timeout = 15, headers = utilities.HEADERS, experimental = False, \
148
153
  use_prebuilt_tkhtml = True, tkhtml_version = "", parsemode = utilities.DEFAULT_PARSE_MODE, \
149
- shrink = False, mode = utilities.DEFAULT_ENGINE_MODE, defaultstyle = "", height = 0, width = 0, **kwargs):
154
+ shrink = False, textwrap="auto", mode = utilities.DEFAULT_ENGINE_MODE, defaultstyle = "", height = 0, width = 0, **kwargs):
150
155
 
151
156
  # State and settings variables
152
157
  self._current_url = ""
@@ -226,6 +231,7 @@ class HtmlFrame(Frame):
226
231
  "fontscale": fontscale,
227
232
  "parsemode": parsemode,
228
233
  "shrink": shrink,
234
+ "textwrap": textwrap,
229
235
  "mode": mode,
230
236
  "defaultstyle": defaultstyle,
231
237
  "height": height,
@@ -1131,18 +1137,23 @@ class HtmlFrame(Frame):
1131
1137
  )
1132
1138
  self._prev_configure = (event.width, event.x)
1133
1139
 
1140
+ def _adjust_allow(self, allow):
1141
+ if allow == "auto":
1142
+ allow = 2
1143
+ elif allow == "dynamic":
1144
+ if self._html.cget("shrink") == 1:
1145
+ allow = 0
1146
+ else:
1147
+ allow = 2
1148
+ return allow
1149
+
1134
1150
  def _manage_vsb(self, allow=None, check=False):
1135
1151
  "Show or hide the scrollbars."
1136
1152
  if check:
1137
1153
  return self._vsb.scroll
1138
-
1139
1154
  if allow == None:
1140
1155
  allow = self.vertical_scrollbar
1141
- if allow == "auto":
1142
- if self._html.cget("shrink") == 1:
1143
- allow = 0
1144
- else:
1145
- allow = 2
1156
+ allow = self._adjust_allow(allow)
1146
1157
  self._vsb.set_type(allow, *self._html.yview())
1147
1158
  return allow
1148
1159
 
@@ -1150,14 +1161,9 @@ class HtmlFrame(Frame):
1150
1161
  "Show or hide the scrollbars."
1151
1162
  if check:
1152
1163
  return self._hsb.scroll
1153
-
1154
1164
  if allow == None:
1155
1165
  allow = self.horizontal_scrollbar
1156
- if allow == "auto":
1157
- if self._html.cget("shrink") == 1:
1158
- allow = 0
1159
- else:
1160
- allow = 2
1166
+ allow = self._adjust_allow(allow)
1161
1167
  self._hsb.set_type(allow, *self._html.xview())
1162
1168
  return allow
1163
1169
 
@@ -31,7 +31,7 @@ __title__ = "TkinterWeb"
31
31
  __author__ = "Andrew Clarke"
32
32
  __copyright__ = "(c) 2021-2025 Andrew Clarke"
33
33
  __license__ = "MIT"
34
- __version__ = "4.16.10"
34
+ __version__ = "4.17.0"
35
35
 
36
36
 
37
37
  ROOT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "resources")
@@ -447,7 +447,7 @@ INPUT[type="submit"],INPUT[type="button"], INPUT[type="reset"], BUTTON {
447
447
  }
448
448
  """
449
449
 
450
- SHRINK_STYLE = "BODY { white-space: nowrap; }"
450
+ TEXTWRAP_STYLE = "BODY { white-space: nowrap; }"
451
451
 
452
452
  class BuiltinPageGenerator():
453
453
  """BUILTIN_PAGES used to be a dictionary of URIs and corresponding HTML code.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tkinterweb
3
- Version: 4.16.10
3
+ Version: 4.17.0
4
4
  Summary: HTML/CSS viewer, editor, and app builder for Tkinter
5
5
  Home-page: https://github.com/Andereoo/TkinterWeb
6
6
  License: MIT
@@ -5,10 +5,10 @@ brotli
5
5
  cairosvg
6
6
  pillow
7
7
  pythonmonkey
8
- tkinterweb-tkhtml-extras>=1.1.1
8
+ tkinterweb-tkhtml-extras>=1.2.0
9
9
 
10
10
  [html]
11
- tkinterweb-tkhtml-extras>=1.1.1
11
+ tkinterweb-tkhtml-extras>=1.2.0
12
12
 
13
13
  [images]
14
14
  pillow
@@ -18,7 +18,7 @@ pythonmonkey
18
18
 
19
19
  [recommended]
20
20
  pillow
21
- tkinterweb-tkhtml-extras>=1.1.1
21
+ tkinterweb-tkhtml-extras>=1.2.0
22
22
 
23
23
  [requests]
24
24
  brotli
@@ -26,4 +26,4 @@ brotli
26
26
  [svg]
27
27
  cairosvg
28
28
  pillow
29
- tkinterweb-tkhtml-extras>=1.1.1
29
+ tkinterweb-tkhtml-extras>=1.2.0
File without changes
File without changes
File without changes
File without changes