From b1254d782043b020f05e4c8b19f9ddfa09f6c2d3 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 12 Dec 2009 13:03:57 +0000 Subject: [PATCH] gtk is hidden in methods to not import it overall for cli svn: r13777 --- src/gui/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/utils.py b/src/gui/utils.py index 7f9691ebf..81aec6789 100644 --- a/src/gui/utils.py +++ b/src/gui/utils.py @@ -31,12 +31,14 @@ Utility functions that depend on GUI components or for GUI components #------------------------------------------------------------------------- import os from gettext import gettext as _ +# gtk is not included here, because this file is currently imported +# by code that needs to run without the DISPLAY variable (eg, in +# the cli only). #------------------------------------------------------------------------- # # GNOME/GTK # -import gtk #------------------------------------------------------------------------- #------------------------------------------------------------------------- @@ -57,6 +59,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 +96,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 @@ -157,6 +161,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 @@ -180,6 +185,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 @@ -204,6 +210,7 @@ class ProgressMeter(object): return self.__cancelled def set_header(self, text): + import gtk self.__lbl.set_text(text) while gtk.events_pending(): gtk.main_iteration()