tkinterweb-tkhtml 1.0__py3-none-linux_armv7l.whl → 1.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,5 +1,5 @@
1
1
  """
2
- TkinterWeb-Tkhtml v1.0
2
+ TkinterWeb-Tkhtml v1.1
3
3
  This package provides pre-built binaries of a modified version of the Tkhtml3 widget from http://tkhtml.tcl.tk/tkhtml.html,
4
4
  which enables the display of styled HTML and CSS code in Tkinter applications.
5
5
 
@@ -19,26 +19,99 @@ __title__ = 'TkinterWeb-Tkhtml'
19
19
  __author__ = "Andereoo"
20
20
  __copyright__ = "Copyright (c) 2025 Andereoo"
21
21
  __license__ = "MIT"
22
- __version__ = '1.0'
22
+ __version__ = '1.1.0'
23
23
 
24
+ TKHTML_RELEASE = "3.0 (TkinterWeb standard)" # Backwards-compatibility. Not useful or even necessarily true anymore. Will be removed.
24
25
 
25
- TKHTML_RELEASE = "3.0 (TkinterWeb standard)" # For debugging; eventually this project might also bundle experimental binaries
26
- TKHTML_ROOT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "tkhtml")
26
+ TKHTML_ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
27
27
 
28
- tkhtml_loaded = False
29
28
 
30
29
 
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)"
41
+
31
42
  def get_tkhtml_folder():
32
- "Get the location of the platform's Tkhtml binary"
33
-
43
+ # Backwards-compatibility. Will be removed.
34
44
  return TKHTML_ROOT_DIR
35
45
 
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
+ def get_tkhtml_file(version=None, index=-1, experimental=False):
55
+ "Get the location of the platform's Tkhtml binary"
56
+ if isinstance(version, float):
57
+ version = str(version)
58
+ if version:
59
+ for file in TKHTML_BINARIES:
60
+ if version in file:
61
+ # Note: experimental can be "auto"
62
+ if "exp" in file:
63
+ if not experimental:
64
+ raise OSError(f"Tkhtml version {version} is an experimental release but experimental mode is disabled. {help_message}")
65
+ experimental = True
66
+ else:
67
+ if experimental == True:
68
+ raise OSError(f"Tkhtml version {version} is not an experimental release but experimental mode is enabled. {help_message}")
69
+ 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}")
72
+ else:
73
+ # Get highest numbered avaliable file if a version is not provided
74
+ if experimental == True:
75
+ files = [k for k in TKHTML_BINARIES if 'exp' in k]
76
+ if not files:
77
+ raise OSError(f"No experimental Tkhtml versions could be found on your system. {help_message}")
78
+ elif not experimental:
79
+ files = [k for k in TKHTML_BINARIES if 'exp' not in k]
80
+ else:
81
+ files = TKHTML_BINARIES
82
+ file = sorted(files)[index]
83
+ if "exp" in file:
84
+ experimental = True
85
+ else:
86
+ experimental = False
87
+ version = file.replace("libTkhtml", "").replace("exp", "")
88
+ version = version[:version.rfind(".")]
89
+ return os.path.join(TKHTML_ROOT_DIR, file), version, experimental
90
+
91
+
92
+ def load_tkhtml_file(master, file, force=False):
93
+ "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
+
36
104
 
37
- def load_tkhtml(master, location=None, force=False):
105
+ def load_tkhtml(master, force=False, use_prebuilt=False):
38
106
  "Load Tkhtml into the current Tcl/Tk instance"
39
- global tkhtml_loaded
40
- if (not tkhtml_loaded) or force:
41
- if location:
42
- master.tk.eval("set auto_path [linsert $auto_path 0 {" + location + "}]")
43
- master.tk.eval("package require Tkhtml")
44
- tkhtml_loaded = True
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")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tkinterweb-tkhtml
3
- Version: 1.0
3
+ Version: 1.1.0
4
4
  Summary: HTML/CSS viewer for Tkinter
5
5
  Home-page: https://github.com/Andereoo/TkinterWeb-Tkhtml
6
6
  License: MIT
@@ -0,0 +1,8 @@
1
+ tkinterweb_tkhtml/__init__.py,sha256=Usx8lOoxbR72hmRbNOt3WxJPIrPnveKBBhsdN8TTFOk,4613
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.0.dist-info/LICENSE.md,sha256=A4A41a28mznzn27r63D6_15V0UfRNrfIbKrX3sabiX8,1064
5
+ tkinterweb_tkhtml-1.1.0.dist-info/METADATA,sha256=sZa4OVDdqgNugzfA-oJHNvjj4Kv4hc2NtQKHL7ukMYg,1054
6
+ tkinterweb_tkhtml-1.1.0.dist-info/WHEEL,sha256=SfWbrUo49UCeTn4ZCaOubJz9Wtdk5gtBke9gOM6rnWs,101
7
+ tkinterweb_tkhtml-1.1.0.dist-info/top_level.txt,sha256=ZsOj9XY_g_0oGsUoDORlQhP0qdbT4X_Ts6yyFWG7i1A,18
8
+ tkinterweb_tkhtml-1.1.0.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- package ifneeded Tkhtml 3.0 [string map [list @ $dir] {
2
- load [file join {@} libTkhtml3.0.so]
3
- package provide Tkhtml 3.0
4
- }]
@@ -1,9 +0,0 @@
1
- tkinterweb_tkhtml/__init__.py,sha256=yeb5XCI83xqZ8cxzmFprBl_FmkNmHwsucsFpLARbVR0,1338
2
- tkinterweb_tkhtml/tkhtml/COPYRIGHT,sha256=DTaLs2-wF2uscyoCSsLB1oOqXwhtLRVZW1EdLa77OMs,1622
3
- tkinterweb_tkhtml/tkhtml/libTkhtml3.0.so,sha256=7SLetf_4DXwz_iphlIRAvuuDnm6qYcfAdjVnnapfekc,310504
4
- tkinterweb_tkhtml/tkhtml/pkgIndex.tcl,sha256=TLh_fgiI_ZWYOP04WT5fRPex4Jp8wl_FRuHFBGETFuo,125
5
- tkinterweb_tkhtml-1.0.dist-info/LICENSE.md,sha256=A4A41a28mznzn27r63D6_15V0UfRNrfIbKrX3sabiX8,1064
6
- tkinterweb_tkhtml-1.0.dist-info/METADATA,sha256=M3yHjinRnsxQzRgXjeOnatEXZ9KvOS3Bs_7sijFRHeo,1052
7
- tkinterweb_tkhtml-1.0.dist-info/WHEEL,sha256=SfWbrUo49UCeTn4ZCaOubJz9Wtdk5gtBke9gOM6rnWs,101
8
- tkinterweb_tkhtml-1.0.dist-info/top_level.txt,sha256=ZsOj9XY_g_0oGsUoDORlQhP0qdbT4X_Ts6yyFWG7i1A,18
9
- tkinterweb_tkhtml-1.0.dist-info/RECORD,,