From 7e625b521cc7cf8f99894457a34b4a7251efbb1f Mon Sep 17 00:00:00 2001 From: ColinDuquesnoy Date: Fri, 16 May 2014 23:34:59 +0200 Subject: [PATCH] Use logging instead of print --- example/example_pyqt.py | 8 +++++--- example/example_pyside.py | 7 +++++-- qdarkstyle/__init__.py | 8 +++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/example/example_pyqt.py b/example/example_pyqt.py index f3f43663f..fcb4bf594 100755 --- a/example/example_pyqt.py +++ b/example/example_pyqt.py @@ -36,20 +36,22 @@ Requirements: the example """ +import logging import sys from PyQt4 import QtGui, QtCore -from os.path import abspath, dirname # make the example runnable without the need to install +from os.path import abspath, dirname sys.path.insert(0, abspath(dirname(abspath(__file__)) + '/..')) + import qdarkstyle import example_pyqt_ui as example_ui -print(qdarkstyle.__file__) def main(): """ Application entry point - """ + """ + logging.basicConfig(level=logging.DEBUG) # create the application and the main window app = QtGui.QApplication(sys.argv) window = QtGui.QMainWindow() diff --git a/example/example_pyside.py b/example/example_pyside.py index 3d07df255..4732a4efa 100755 --- a/example/example_pyside.py +++ b/example/example_pyside.py @@ -36,11 +36,13 @@ Requirements: the example """ +import logging import sys from PySide import QtGui, QtCore -from os.path import abspath, dirname # make the example runnable without the need to install +from os.path import abspath, dirname sys.path.insert(0, abspath(dirname(abspath(__file__)) + '/..')) + import qdarkstyle import example_pyside_ui as example_ui @@ -48,7 +50,8 @@ import example_pyside_ui as example_ui def main(): """ Application entry point - """ + """ + logging.basicConfig(level=logging.DEBUG) # create the application and the main window app = QtGui.QApplication(sys.argv) window = QtGui.QMainWindow() diff --git a/qdarkstyle/__init__.py b/qdarkstyle/__init__.py index b5ae6cfd2..68a6eb269 100644 --- a/qdarkstyle/__init__.py +++ b/qdarkstyle/__init__.py @@ -28,12 +28,17 @@ Initialise the QDarkStyleSheet module when used with python. This modules provides a function to transparently load the stylesheets with the correct rc file. """ +import logging import platform __version__ = "1.9" +def _logger(): + return logging.getLogger('qdarkstyle') + + def load_stylesheet(pyside=True): """ Loads the stylesheet. Takes care of importing the rc module. @@ -56,7 +61,8 @@ def load_stylesheet(pyside=True): f = QFile(":qdarkstyle/style.qss") if not f.exists(): - print("Unable to set stylesheet, file not found\n") + _logger().error("Unable to load stylesheet, file not found in " + "resources") return "" else: f.open(QFile.ReadOnly | QFile.Text)