p3lib 1.1.120__py2.py3-none-any.whl → 1.1.122__py2.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.
p3lib/ngt.py CHANGED
@@ -274,6 +274,9 @@ class TabbedNiceGui(object):
274
274
  def setLogFile(self, logFile):
275
275
  pass
276
276
 
277
+ def storeToDebugLog(self, msg):
278
+ pass
279
+
277
280
  # End ------------------------------
278
281
 
279
282
  def _saveLogMsg(self, msg):
@@ -311,6 +314,14 @@ class TabbedNiceGui(object):
311
314
  self._logMessageCount += 1
312
315
  # We've received a log message so update progress bar if required.
313
316
  self._updateProgressBar(msg)
317
+ # Wait a moment for DOM to update, then scroll to the end of the log
318
+ # so that the message just added is visible.
319
+ ui.timer(0.05, lambda: ui.run_javascript("""
320
+ const el = document.querySelector('.my-log');
321
+ if (el) {
322
+ el.scrollTop = el.scrollHeight;
323
+ }
324
+ """), once=True)
314
325
 
315
326
  def _infoGT(self, msg):
316
327
  """@brief Update an info level message. This must be called from the GUI thread.
@@ -403,7 +414,7 @@ class TabbedNiceGui(object):
403
414
  self._progress.min = 0
404
415
  # Don't allow user to adjust progress bar thumb
405
416
  self._progress.disable()
406
- self._log = ui.log(max_lines=2000)
417
+ self._log = ui.log(max_lines=2000).classes('my-log')
407
418
  self._log.set_visibility(True)
408
419
 
409
420
  with ui.row():
p3lib/windows_app.py ADDED
@@ -0,0 +1,83 @@
1
+ import sys
2
+ import os
3
+ from p3lib.helper import getAbsFile
4
+
5
+
6
+ class WindowsApp():
7
+ """@brief Responsible for adding and removing Windows app shortcuts to the desktop for launching applications on a Windows system."""
8
+
9
+ def __init__(self, uio=None):
10
+ self._uio = uio
11
+
12
+ def info(self, msg):
13
+ """@brief Show an info level message to the user.
14
+ @param msg The msessage text."""
15
+ if self._uio:
16
+ self._uio.info(msg)
17
+
18
+ def _get_startup_file(self):
19
+ """@return Get the abs name of the program first started."""
20
+ return os.path.abspath(sys.argv[0])
21
+
22
+ def _get_app_name(self):
23
+ """@return The name of the running program without the .py extension."""
24
+ app_name = self._get_startup_file()
25
+ app_name = os.path.basename(app_name)
26
+ return app_name.replace(".py", "")
27
+
28
+ def _get_shortcut_folder(self):
29
+ temp_dir = os.path.join(os.getenv("TEMP"), "my_temp_shortcuts")
30
+ os.makedirs(temp_dir, exist_ok=True)
31
+ return temp_dir
32
+
33
+ def _get_shortcut(self):
34
+ package_name = self._get_app_name()
35
+ desktop = os.path.join(os.getenv("USERPROFILE"), "Desktop")
36
+ shortcut_path = os.path.join(desktop, f"{package_name}.lnk")
37
+ return shortcut_path
38
+
39
+ def create(self, icon_filename=None):
40
+ """@brief Create a start menu item to launch a program.
41
+ @param package_name The name of the package.
42
+ @param icon_filename The name of the icon file."""
43
+ from win32com.client import Dispatch
44
+ package_name = self._get_app_name()
45
+ exe_name = f"{package_name}.exe"
46
+
47
+ # Locate the pipx-installed executable
48
+ pipx_venv_path = os.path.expanduser(f"~\\.local\\bin\\{exe_name}")
49
+ if not os.path.isfile(pipx_venv_path):
50
+ raise Exception(f"{pipx_venv_path} file not found.")
51
+
52
+ icon_path = None
53
+ if icon_filename:
54
+ icon_path = getAbsFile(icon_filename)
55
+ if icon_path:
56
+ if os.path.isfile(icon_path):
57
+ self.info(f"{icon_path} icon file found.")
58
+ else:
59
+ raise Exception(f"{icon_path} file not found.")
60
+
61
+ shortcut_path = self._get_shortcut()
62
+
63
+ # Create the shortcut
64
+ shell = Dispatch("WScript.Shell")
65
+ shortcut = shell.CreateShortcut(shortcut_path)
66
+ shortcut.TargetPath = pipx_venv_path # Path to your executable or script
67
+ shortcut.WorkingDirectory = os.path.dirname(pipx_venv_path)
68
+ shortcut.IconLocation = icon_path # Optional: Set an icon
69
+ shortcut.Save()
70
+
71
+ if not os.path.isfile(shortcut_path):
72
+ raise Exception(f"{shortcut_path} shortcut file missing after creation.")
73
+
74
+ self.info(f"{shortcut_path} shortcut created.")
75
+
76
+ def delete(self):
77
+ shortcut_path = self._get_shortcut()
78
+
79
+ if os.path.exists(shortcut_path):
80
+ os.remove(shortcut_path)
81
+ self.info(f"Removed '{shortcut_path}' shortcut.")
82
+ else:
83
+ raise Exception(f"{shortcut_path} file not found.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: p3lib
3
- Version: 1.1.120
3
+ Version: 1.1.122
4
4
  Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
5
5
  License: MIT
6
6
  Author: Paul Austen
@@ -13,12 +13,13 @@ p3lib/login.html,sha256=DADTJGuvWQ-LTO4X6SaFdqK7JMW03DAa3lRieGD0d6g,2748
13
13
  p3lib/mqtt_rpc.py,sha256=6LmFA1kR4HSJs9eWbOJORRHNY01L_lHWjvtE2fmY8P8,10511
14
14
  p3lib/netif.py,sha256=3QV5OGdHhELIf4MBj6mx5MNCtVeZ7JXoNEkeu4KzCaE,9796
15
15
  p3lib/netplotly.py,sha256=PMDx-w1jtRVW6Od5u_kuKbBxNpTS_Y88mMF60puMxLM,9363
16
- p3lib/ngt.py,sha256=N8y0C9q4cMlzTPiHiaInGBu03dKYhfKR6KotVDJOTm0,43340
16
+ p3lib/ngt.py,sha256=nTV1Pdq58EzTPjWjiufjyNDd3hF18AICXBU1ACUHbUw,43758
17
17
  p3lib/pconfig.py,sha256=wGC6UJAIBksRjwKTfaw3Y6vAMkgey0QC2nhkCtqj1MQ,37738
18
18
  p3lib/ssh.py,sha256=OyoAQ_h1L2RfkjTAChDrvLFfl4Fe_gBNdX5rvK-wKiw,42125
19
19
  p3lib/table_plot.py,sha256=RPncwVlGUkkx5Fw0dHQedXo0TSPlTi__VrJBDzaMsuI,32116
20
20
  p3lib/uio.py,sha256=Aaxc99XiE3d2f9vLjaN-bZsckoNxay5t0ujdK6PXGrw,23265
21
- p3lib-1.1.120.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
22
- p3lib-1.1.120.dist-info/METADATA,sha256=bPzcexms-odMwfMwbEP9YYbcISjbBZKBa-L-cICEZgc,1382
23
- p3lib-1.1.120.dist-info/WHEEL,sha256=5druYqcII7zHXzX7qmN0TH895Jg3yuTtfjMgJIVBrKE,92
24
- p3lib-1.1.120.dist-info/RECORD,,
21
+ p3lib/windows_app.py,sha256=cSkGDIakamxylhOYk0BHjjUQwBBhOq7sij4a7xs9v44,3057
22
+ p3lib-1.1.122.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
23
+ p3lib-1.1.122.dist-info/METADATA,sha256=Fl4uT0pl-vO2cDXxd4u0L1lD6knolE721BmAPCUKDOU,1382
24
+ p3lib-1.1.122.dist-info/WHEEL,sha256=5druYqcII7zHXzX7qmN0TH895Jg3yuTtfjMgJIVBrKE,92
25
+ p3lib-1.1.122.dist-info/RECORD,,