From e0c2734faee6d365d28bfb9fb2f0129380fe34ac Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Sun, 6 May 2018 00:19:16 +0200 Subject: [PATCH] Fixed imports to allow usage of photobooth as script and module --- photobooth/Photobooth.py | 6 +++--- photobooth/__main__.py | 5 ++--- photobooth/gui/PyQt5Gui.py | 4 ++-- photobooth/main.py | 10 +++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/photobooth/Photobooth.py b/photobooth/Photobooth.py index 30044c8..7975014 100644 --- a/photobooth/Photobooth.py +++ b/photobooth/Photobooth.py @@ -5,10 +5,10 @@ from time import time, sleep, localtime, strftime from PIL import Image, ImageOps -from PictureList import PictureList -from PictureDimensions import PictureDimensions +from .PictureList import PictureList +from .PictureDimensions import PictureDimensions -import gui +from . import gui class Photobooth: diff --git a/photobooth/__main__.py b/photobooth/__main__.py index 49bce41..028117c 100644 --- a/photobooth/__main__.py +++ b/photobooth/__main__.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import sys, main - -sys.exit(main.main(sys.argv)) +import sys, photobooth +sys.exit(photobooth.main(sys.argv)) diff --git a/photobooth/gui/PyQt5Gui.py b/photobooth/gui/PyQt5Gui.py index 4169b50..7923a78 100644 --- a/photobooth/gui/PyQt5Gui.py +++ b/photobooth/gui/PyQt5Gui.py @@ -8,9 +8,9 @@ from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QFormLayout, QF from PyQt5.QtGui import QImage, QPainter, QPixmap from . import * -import camera, printer +from .. import camera, printer -from printer.PrinterPyQt5 import PrinterPyQt5 as Printer +from ..printer.PrinterPyQt5 import PrinterPyQt5 as Printer class PyQt5Gui(Gui): diff --git a/photobooth/main.py b/photobooth/main.py index d122d43..225c4e8 100644 --- a/photobooth/main.py +++ b/photobooth/main.py @@ -10,9 +10,9 @@ except DistributionNotFound: from multiprocessing import Pipe, Process import importlib -import camera, gui -from Config import Config -from Photobooth import Photobooth +from . import camera, gui +from .Config import Config +from .Photobooth import Photobooth def lookup_and_import(module_list, name, package=None): @@ -22,9 +22,9 @@ def lookup_and_import(module_list, name, package=None): if name == config_name), None) if package == None: - import_module = importlib.import_module(result[0]) + import_module = importlib.import_module('photobooth.' + result[0]) else: - import_module = importlib.import_module('.' + result[0], package) + import_module = importlib.import_module('photobooth.' + package + '.' + result[0]) if result[1] == None: return import_module