diff options
Diffstat (limited to 'logout-manager-tcl.py')
-rwxr-xr-x | logout-manager-tcl.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/logout-manager-tcl.py b/logout-manager-tcl.py index 8c4bc6a..127bd54 100755 --- a/logout-manager-tcl.py +++ b/logout-manager-tcl.py @@ -7,6 +7,7 @@ # Purpose: A tcl/tk graphical program for selecting shutdown, logout, etc. # History: # Usage: +# logout-manager-tcl.py # References: # http://effbot.org/tkinterbook/button.htm # http://effbot.org/tkinterbook/tkinter-application-windows.htm @@ -22,18 +23,17 @@ # tooltips https://stackoverflow.com/questions/3221956/how-do-i-display-tooltips-in-tkinter/41381685#41381685 # Improve: # Dependencies: -# devuan: python3-tk python3-pil.imagetk python3-cairosvg +# Devuan: python3-tk python3-pil.imagetk python3-cairosvg # el7: python36-tkinter python36-pillow-tk ( pip3 install cairosvg ) -import glob, re +import glob, os, platform, re, sys import tkinter as tk from functools import partial from pathlib import Path from sys import path +from dotenv import load_dotenv # loading PIL.ImageTk after tkinter makes ImageTk use the PIL version, which supports PNG. This is important on tcl < 8.6 (that is, el7) from PIL import Image, ImageTk -path.append("/home/bgirton/dev/logout-manager") -import lmlib LM_USE_SVG = 0 try: @@ -43,8 +43,20 @@ except: print("WARNING: Unable to import cairosvg. No svg images will be displayed.") LM_USE_SVG = 0 -config = lmlib.Initialize_config() -actions = lmlib.Actions +# all this to load the libpath +try: + defaultdir="/etc/sysconfig" + thisplatform = platform.platform().lower() + if 'debian' in thisplatform or 'devuan' in thisplatform: + defaultdir="/etc/default" + # load_dotenv keeps existing environment variables as higher precedent + load_dotenv(os.path.join(defaultdir,"logout-manager")) +except: + pass +if 'LOGOUT_MANAGER_LIBPATH' in os.environ: + for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"): + sys.path.append(i) +import lmlib # graphical classes and functions print("Loading graphics...") @@ -388,9 +400,12 @@ class App: #def something(event=None): # print("Got here!") -root = tk.Tk() +# load configs +config = lmlib.Initialize_config(os.environ['LOGOUT_MANAGER_CONF']) +actions = lmlib.Actions # MAIN LOOP +root = tk.Tk() root.title("Log out options") imgicon = get_scaled_icon(config.get_logout_icon(),24,config.get_icon_theme()) root.tk.call('wm','iconphoto', root._w, imgicon) |