From cbd492155c97db84c49032a1a89af739fd63890f Mon Sep 17 00:00:00 2001 From: Axel Svensson Date: Tue, 12 Oct 2021 05:07:23 +0200 Subject: [PATCH] Don't import tkinter in batch mode --- pdf-sign | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pdf-sign b/pdf-sign index 14f7525..6e889ca 100755 --- a/pdf-sign +++ b/pdf-sign @@ -2,7 +2,7 @@ #Dependencies: python3, pdftk, gs, mv, pdfinfo -import argparse, os, queue, re, subprocess, sys, tempfile, threading, time, tkinter as tk +import argparse, os, queue, re, subprocess, sys, tempfile, threading, time signatureDir=os.path.expanduser(os.environ['PDF_SIGNATURE_DIR'] if 'PDF_SIGNATURE_DIR' in os.environ else "~/.pdf_signatures") @@ -89,6 +89,10 @@ def main(args): doSign=True gui=not args.batch if gui: + try: + import tkinter as tk + except ModuleNotFoundError: + die('Cannot find Python module `tkinter`, which is needed for interactive use.') doSign=False # Commands def uf(fun):