tkinterweb-tkhtml 1.1.4__py3-none-linux_armv7l.whl → 2.1.0__py3-none-linux_armv7l.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.
@@ -1,117 +1,120 @@
1
1
  """
2
- TkinterWeb-Tkhtml v1.1
3
- This package provides pre-built binaries of a modified version of the Tkhtml3 widget from http://tkhtml.tcl.tk/tkhtml.html,
2
+ TkinterWeb-Tkhtml v2.1
3
+ This package provides pre-built binaries of a modified version of the Tkhtml3 widget from https://github.com/Andereoo/TkinterWeb-Tkhtml,
4
4
  which enables the display of styled HTML and CSS code in Tkinter applications.
5
5
 
6
- This package can be used to import the Tkhtml widget into Tkinter projects
6
+ If you are not using the compile script's --install option, to add a new Tkhtml version, use the following file naming conventions:
7
+ - For Tcl/Tk 8:
8
+ - For a standard release: libTkhtml[major_version.minor_version].[dll/dylib/so] (eg. libTkhtml3.0.dll)
9
+ - For an experimental release: libTkhtml[major_version.minor_version]exp.[dll/dylib/so] (eg. libTkhtml3.1exp.dll)
10
+ - For Tcl/Tk 9:
11
+ - For a standard release: libTkhtml[major_version.minor_version]-TclTk9.[dll/dylib/so] (eg. libTkhtml3.0-TclTk9.dll)
12
+ - For an experimental release: libTkhtml[major_version.minor_version]exp-TclTk9.[dll/dylib/so] (eg. libTkhtml3.1exp-TclTk9.dll)
13
+
14
+ This package can be used to load the Tkhtml widget into Tkinter applications.
7
15
  but is mainly intended to be used through TkinterWeb, which provides a full Python interface.
8
16
  See https://github.com/Andereoo/TkinterWeb.
9
17
 
10
- Copyright (c) 2025 Andereoo
18
+ Copyright (c) 2025 Andrew Clarke
11
19
  """
12
20
 
13
21
  import os
14
22
 
15
-
16
-
23
+ from tkinter import TclVersion
17
24
 
18
25
  __title__ = 'TkinterWeb-Tkhtml'
19
- __author__ = "Andereoo"
20
- __copyright__ = "Copyright (c) 2025 Andereoo"
26
+ __author__ = "Andrew Clarke"
27
+ __copyright__ = "Copyright (c) 2025 Andrew Clarke"
21
28
  __license__ = "MIT"
22
- __version__ = '1.1.4'
29
+ __version__ = '2.1.0'
23
30
 
24
- TKHTML_RELEASE = "3.0 (TkinterWeb standard)" # Backwards-compatibility. Not useful or even necessarily true anymore. Will be removed.
25
31
 
26
32
  TKHTML_ROOT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "tkhtml")
27
33
 
34
+ try:
35
+ from tkinterweb_tkhtml_extras import TKHTML_EXTRAS_ROOT_DIR
36
+ if TKHTML_EXTRAS_ROOT_DIR == None:
37
+ ALL_TKHTML_BINARIES = [[TKHTML_ROOT_DIR, file] for file in os.listdir(TKHTML_ROOT_DIR) if "libTkhtml" in file]
38
+ else:
39
+ ALL_TKHTML_BINARIES = [[TKHTML_ROOT_DIR, file] for file in os.listdir(TKHTML_ROOT_DIR) if "libTkhtml" in file] + \
40
+ [[TKHTML_EXTRAS_ROOT_DIR, file] for file in os.listdir(TKHTML_EXTRAS_ROOT_DIR) if "libTkhtml" in file]
41
+ except (ImportError, ModuleNotFoundError,):
42
+ TKHTML_EXTRAS_ROOT_DIR = None
43
+ ALL_TKHTML_BINARIES = [[TKHTML_ROOT_DIR, file] for file in os.listdir(TKHTML_ROOT_DIR) if "libTkhtml" in file]
28
44
 
45
+ if TclVersion >= 9:
46
+ TKHTML_BINARIES = [[loc, file] for loc, file in ALL_TKHTML_BINARIES if "TclTk9" in file]
47
+ HELP_MESSAGE_EXP = f"Download https://github.com/Andereoo/TkinterWeb-Tkhtml/tree/experimental and run 'python compile.py' to compile Tkhtml. \
48
+ Copy the binary into {TKHTML_ROOT_DIR}, adding 'exp-TclTk9' after the filename (eg. 'libTkhtml3.1exp-TclTk9.dll')"
49
+ else:
50
+ TKHTML_BINARIES = [[loc, file] for loc, file in ALL_TKHTML_BINARIES if "TclTk9" not in file]
51
+ HELP_MESSAGE_EXP = f"Download https://github.com/Andereoo/TkinterWeb-Tkhtml/tree/experimental and run 'python compile.py' to compile Tkhtml. \
52
+ Copy the binary into {TKHTML_ROOT_DIR}, adding 'exp' after the filename (eg. 'libTkhtml3.1exp.dll')"
29
53
 
30
- TKHTML_BINARIES = [file for file in os.listdir(TKHTML_ROOT_DIR) if "libTkhtml" in file]
31
-
32
- # NOTE:
33
- # File names should be in the format libTkhtml[major].[minor].[so/dll/dylib]
34
- # Experimental file names should be in the format libTkhtml[major].[minor]exp.[so/dll/dylib]
35
-
36
- tkhtml_file = None
37
-
38
- help_message = f"To add a new Tkhtml version, drop your binary into the {TKHTML_ROOT_DIR} folder, named using the following conventions:\n\
39
- - For a standard release: libTkhtml[major_version.minor_version].[dll/dylib.so] (eg. libTkhtml3.0.dll)\n\
40
- - For an experimental release: libTkhtml[major_version.minor_version]exp.[dll/dylib.so] (eg. libTkhtml3.1exp.dll)"
54
+ HELP_MESSAGE = f"Download https://github.com/Andereoo/TkinterWeb-Tkhtml/tree/3.1-TclTk9 and run 'python compile.py --install' to compile and install Tkhtml. If you think this is a bug, consider filing a bug report."
41
55
 
42
- def get_tkhtml_folder():
43
- # Backwards-compatibility. Will be removed.
44
- return TKHTML_ROOT_DIR
45
56
 
46
- def get_loaded_tkhtml_version():
47
- global tkhtml_file
48
- if tkhtml_file:
49
- version = os.path.basename(tkhtml_file).replace("libTkhtml", "")
50
- return version[:version.rfind(".")]
51
- else:
52
- return None
53
-
54
57
  def get_tkhtml_file(version=None, index=-1, experimental=False):
55
58
  "Get the location of the platform's Tkhtml binary"
59
+ if not TKHTML_BINARIES:
60
+ if ALL_TKHTML_BINARIES:
61
+ raise OSError(f"No Tkhtml versions could be found for Tcl/Tk {int(TclVersion)}. {HELP_MESSAGE}")
62
+ else:
63
+ raise OSError(f"No Tkhtml versions could be found for your system. {HELP_MESSAGE}")
64
+
56
65
  if isinstance(version, float):
57
66
  version = str(version)
58
67
  if version:
59
- for file in TKHTML_BINARIES:
68
+ for loc, file in TKHTML_BINARIES:
60
69
  if version in file:
61
70
  # Note: experimental can be "auto"
62
71
  if "exp" in file:
63
72
  if not experimental:
64
- raise OSError(f"Tkhtml version {version} is an experimental release but experimental mode is disabled. {help_message}")
73
+ raise OSError(f"Tkhtml version {version} is an experimental release but experimental mode is disabled. {HELP_MESSAGE_EXP}")
65
74
  experimental = True
66
75
  else:
67
76
  if experimental == True:
68
- raise OSError(f"Tkhtml version {version} is not an experimental release but experimental mode is enabled. {help_message}")
77
+ raise OSError(f"Tkhtml version {version} is not an experimental release but experimental mode is enabled. {HELP_MESSAGE_EXP}")
69
78
  experimental = False
70
- return os.path.join(TKHTML_ROOT_DIR, file), version, experimental
71
- raise OSError(f"Tkhtml version {version} either does not exist or is unsupported on your system. {help_message}")
79
+ return os.path.join(loc, file), version, experimental
80
+ raise OSError(f"Tkhtml version {version} either does not exist or is unsupported on your system. {HELP_MESSAGE}")
72
81
  else:
73
82
  # Get highest numbered avaliable file if a version is not provided
74
83
  if experimental == True:
75
84
  files = [k for k in TKHTML_BINARIES if 'exp' in k]
76
85
  if not files:
77
- raise OSError(f"No experimental Tkhtml versions could be found on your system. {help_message}")
86
+ raise OSError(f"No experimental Tkhtml versions could be found on your system. {HELP_MESSAGE_EXP}")
78
87
  elif not experimental:
79
88
  files = [k for k in TKHTML_BINARIES if 'exp' not in k]
80
89
  else:
81
90
  files = TKHTML_BINARIES
82
- file = sorted(files)[index]
91
+ loc, file = sorted(files)[index]
83
92
  if "exp" in file:
84
93
  experimental = True
85
94
  else:
86
95
  experimental = False
87
96
  version = file.replace("libTkhtml", "").replace("exp", "")
88
97
  version = version[:version.rfind(".")]
89
- return os.path.join(TKHTML_ROOT_DIR, file), version, experimental
98
+ return os.path.join(loc, file), version, experimental
99
+
90
100
 
101
+ def get_loaded_tkhtml_version(master):
102
+ """Get the version of the loaded Tkhtml instance.
103
+ This will raise a TclError if Tkhtml is not loaded.
104
+ Only call load_tkhtml_file or load_tkhtml if this fails or if you know this will fail."""
105
+ return master.tk.call("package", "present", "Tkhtml")
91
106
 
92
- def load_tkhtml_file(master, file, force=False):
107
+
108
+ def load_tkhtml_file(master, file):
93
109
  "Load Tkhtml into the current Tcl/Tk instance"
94
- global tkhtml_file
95
- if (not tkhtml_file) or force:
96
- if TKHTML_ROOT_DIR not in os.environ["PATH"].split(os.pathsep):
97
- os.environ["PATH"] = os.pathsep.join([
98
- TKHTML_ROOT_DIR,
99
- os.environ["PATH"]
100
- ])
101
- master.tk.call("load", file)
102
- tkhtml_file = file
103
-
104
-
105
- def load_tkhtml(master, force=False, use_prebuilt=False):
110
+ paths = os.environ["PATH"].split(os.pathsep)
111
+ for path in (TKHTML_ROOT_DIR, TKHTML_EXTRAS_ROOT_DIR):
112
+ if path and path not in paths:
113
+ paths.insert(0, path)
114
+ os.environ["PATH"] = os.pathsep.join(paths)
115
+ master.tk.call("load", file)
116
+
117
+
118
+ def load_tkhtml(master):
106
119
  "Load Tkhtml into the current Tcl/Tk instance"
107
- if use_prebuilt:
108
- # Backwards-compatibility. Will likely be removed.
109
- file, version, experimental = get_tkhtml_file(None, 0)
110
- load_tkhtml_file(master, file, force)
111
- return version
112
-
113
- global tkhtml_file
114
- if (not tkhtml_file) or force:
115
- master.tk.call("package", "require", "Tkhtml")
116
- tkhtml_file = True
117
- return master.tk.call("package", "present", "Tkhtml")
120
+ master.tk.call("package", "require", "Tkhtml")
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Andereoo
3
+ Copyright (c) 2025 Andrew Clarke
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tkinterweb-tkhtml
3
- Version: 1.1.4
3
+ Version: 2.1.0
4
4
  Summary: HTML/CSS viewer for Tkinter
5
5
  Home-page: https://github.com/Andereoo/TkinterWeb-Tkhtml
6
6
  License: MIT
@@ -18,8 +18,8 @@ License-File: LICENSE.md
18
18
 
19
19
  # TkinterWeb-Tkhtml
20
20
 
21
- **This package provides pre-built binaries of a modified version of the Tkhtml3 widget from http://tkhtml.tcl.tk, which enables the display of styled HTML and CSS code in Tkinter applications.**
21
+ **This package provides pre-built binaries of a modified version of the Tkhtml3 widget from https://github.com/Andereoo/TkinterWeb-Tkhtml, which enables the display of styled HTML and CSS code in Tkinter applications.**
22
22
 
23
- This package can be used to import the Tkhtml widget into Tkinter projects but is mainly intended to be used through TkinterWeb, which provides a full Python interface.
23
+ This package can be used to load the Tkhtml widget into Tkinter applications but is mainly intended to be used through TkinterWeb, which provides a full Python interface.
24
24
 
25
25
  **See https://github.com/Andereoo/TkinterWeb for more information.**
@@ -0,0 +1,8 @@
1
+ tkinterweb_tkhtml/__init__.py,sha256=FegmuZXZYVYHIhPPI3UEuP3t9hKUSad9PZMHhzhg5WY,5956
2
+ tkinterweb_tkhtml/tkhtml/COPYRIGHT,sha256=DTaLs2-wF2uscyoCSsLB1oOqXwhtLRVZW1EdLa77OMs,1622
3
+ tkinterweb_tkhtml/tkhtml/libTkhtml3.0.so,sha256=7SLetf_4DXwz_iphlIRAvuuDnm6qYcfAdjVnnapfekc,310504
4
+ tkinterweb_tkhtml-2.1.0.dist-info/LICENSE.md,sha256=-PeosTLMUn2PEQ5Q12HUqYH4n_gjoKVxd107WE7BcMQ,1069
5
+ tkinterweb_tkhtml-2.1.0.dist-info/METADATA,sha256=mHABLscCqrleD4-QDF8m7wbu2S-9-lSJDNU3qj9fChk,1104
6
+ tkinterweb_tkhtml-2.1.0.dist-info/WHEEL,sha256=SfWbrUo49UCeTn4ZCaOubJz9Wtdk5gtBke9gOM6rnWs,101
7
+ tkinterweb_tkhtml-2.1.0.dist-info/top_level.txt,sha256=ZsOj9XY_g_0oGsUoDORlQhP0qdbT4X_Ts6yyFWG7i1A,18
8
+ tkinterweb_tkhtml-2.1.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- tkinterweb_tkhtml/__init__.py,sha256=VK1KKWqtBJnnyGSL3L9vszqCS5VgJqv7Bey9XMXKxfg,4637
2
- tkinterweb_tkhtml/tkhtml/COPYRIGHT,sha256=DTaLs2-wF2uscyoCSsLB1oOqXwhtLRVZW1EdLa77OMs,1622
3
- tkinterweb_tkhtml/tkhtml/libTkhtml3.0.so,sha256=7SLetf_4DXwz_iphlIRAvuuDnm6qYcfAdjVnnapfekc,310504
4
- tkinterweb_tkhtml-1.1.4.dist-info/LICENSE.md,sha256=A4A41a28mznzn27r63D6_15V0UfRNrfIbKrX3sabiX8,1064
5
- tkinterweb_tkhtml-1.1.4.dist-info/METADATA,sha256=4b3C7XdPCpKT9souv25p13M8QzE8YIFoXxVhqPdFqjI,1077
6
- tkinterweb_tkhtml-1.1.4.dist-info/WHEEL,sha256=SfWbrUo49UCeTn4ZCaOubJz9Wtdk5gtBke9gOM6rnWs,101
7
- tkinterweb_tkhtml-1.1.4.dist-info/top_level.txt,sha256=ZsOj9XY_g_0oGsUoDORlQhP0qdbT4X_Ts6yyFWG7i1A,18
8
- tkinterweb_tkhtml-1.1.4.dist-info/RECORD,,