From f272ce3dd105fd96108e244c958e240c2d8b259a Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Mon, 16 Nov 2009 22:39:54 +0000 Subject: [PATCH] Move gtk-based items out of scope of import for cli svn: r13599 --- src/ImgManip.py | 6 ++++-- src/gen/db/write.py | 2 +- src/gui/utils.py | 9 ++++++--- src/plugins/docgen/HtmlDoc.py | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/ImgManip.py b/src/ImgManip.py index 437c4a351..2f8f4a4cc 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -37,8 +37,6 @@ import tempfile # GTK/Gnome modules # #------------------------------------------------------------------------- -import gtk -import gobject #------------------------------------------------------------------------- # @@ -59,6 +57,7 @@ def resize_to_jpeg(source, destination, width, height): :param height: desired height of the destination image :type height: int """ + import gtk img = gtk.gdk.pixbuf_new_from_file(source) scaled = img.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR) scaled.save(destination, 'jpeg') @@ -77,6 +76,8 @@ def image_size(source): :rtype: tuple(int, int) :returns: a tuple consisting of the width and height """ + import gtk + import gobject try: img = gtk.gdk.pixbuf_new_from_file(source) width = img.get_width() @@ -105,6 +106,7 @@ def resize_to_jpeg_buffer(source, width, height): :rtype: buffer of data :returns: jpeg image as raw data """ + import gtk filed, dest = tempfile.mkstemp() img = gtk.gdk.pixbuf_new_from_file(source) scaled = img.scale_simple(int(width), int(height), gtk.gdk.INTERP_BILINEAR) diff --git a/src/gen/db/write.py b/src/gen/db/write.py index 3524ae7d8..a927e8757 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -59,7 +59,6 @@ from gen.db.dbconst import * from gen.utils.callback import Callback from BasicUtils import UpdateCallback import Errors -from QuestionDialog import QuestionDialog2 _LOG = logging.getLogger(DBLOGNAME) _MINVERSION = 9 @@ -472,6 +471,7 @@ class GrampsDBDir(GrampsDbRead, Callback, UpdateCallback): # self.secondary_connected flag should be set accordingly. if self.need_upgrade(): + from QuestionDialog import QuestionDialog2 if QuestionDialog2(_("Need to upgrade database!"), _("You cannot open this database " "without upgrading it.\n" diff --git a/src/gui/utils.py b/src/gui/utils.py index a2d132cd4..3773550a3 100644 --- a/src/gui/utils.py +++ b/src/gui/utils.py @@ -37,7 +37,6 @@ from gettext import gettext as _ # GNOME/GTK # #------------------------------------------------------------------------- -import gtk #------------------------------------------------------------------------- # @@ -46,7 +45,6 @@ import gtk #------------------------------------------------------------------------- import gen.lib import Errors -from QuestionDialog import WarningDialog, ErrorDialog #------------------------------------------------------------------------- # @@ -58,6 +56,7 @@ def add_menuitem(menu, msg, obj, func): add a menuitem to menu with label msg, which activates func, and has data obj """ + import gtk item = gtk.MenuItem(msg) item.set_data('o', obj) item.connect("activate", func) @@ -93,6 +92,7 @@ class ProgressMeter(object): """ Specify the title and the current pass header. """ + import gtk self.__mode = ProgressMeter.MODE_FRACTION self.__pbar_max = 100.0 self.__pbar_index = 0.0 @@ -127,6 +127,7 @@ class ProgressMeter(object): Reset for another pass. Provide a new header and define number of steps to be used. """ + import gtk self.__mode = mode self.__pbar_max = total self.__pbar_index = 0.0 @@ -148,7 +149,7 @@ class ProgressMeter(object): def step(self): """Click the progress bar over to the next value. Be paranoid and insure that it doesn't go over 100%.""" - + import gtk if self.__mode is ProgressMeter.MODE_FRACTION: self.__pbar_index = self.__pbar_index + 1.0 @@ -179,6 +180,7 @@ class ProgressMeter(object): """ Don't let the user close the progress dialog. """ + from QuestionDialog import WarningDialog WarningDialog( _("Attempt to force closing the dialog"), _("Please do not force closing this important dialog."), @@ -207,6 +209,7 @@ def open_file_with_default_application( file_path ): @type file_path: string @return: nothing """ + from QuestionDialog import ErrorDialog norm_path = os.path.normpath( file_path ) if not os.path.exists(norm_path): diff --git a/src/plugins/docgen/HtmlDoc.py b/src/plugins/docgen/HtmlDoc.py index 49bc96690..0f9bf813d 100644 --- a/src/plugins/docgen/HtmlDoc.py +++ b/src/plugins/docgen/HtmlDoc.py @@ -48,7 +48,6 @@ import const from gen.plug.docgen import BaseDoc, TextDoc, FONT_SANS_SERIF from libhtmlbackend import HtmlBackend from libhtml import Html -from QuestionDialog import WarningDialog #------------------------------------------------------------------------ # @@ -261,6 +260,7 @@ class HtmlDoc(BaseDoc, TextDoc): if from_fname != dest: shutil.copyfile(from_fname, dest) elif self.warn_dir: + from QuestionDialog import WarningDialog WarningDialog( _("Possible destination error") + "\n" + _("You appear to have set your target directory "