gtk is hidden in methods to not import it overall for cli

svn: r13777
This commit is contained in:
Doug Blank 2009-12-12 13:03:57 +00:00
parent 1f6d87182b
commit b1254d7820

View File

@ -31,12 +31,14 @@ Utility functions that depend on GUI components or for GUI components
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os import os
from gettext import gettext as _ 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 # 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 add a menuitem to menu with label msg, which activates func, and has data
obj obj
""" """
import gtk
item = gtk.MenuItem(msg) item = gtk.MenuItem(msg)
item.set_data('o', obj) item.set_data('o', obj)
item.connect("activate", func) item.connect("activate", func)
@ -93,6 +96,7 @@ class ProgressMeter(object):
""" """
Specify the title and the current pass header. Specify the title and the current pass header.
""" """
import gtk
self.__mode = ProgressMeter.MODE_FRACTION self.__mode = ProgressMeter.MODE_FRACTION
self.__pbar_max = 100.0 self.__pbar_max = 100.0
self.__pbar_index = 0.0 self.__pbar_index = 0.0
@ -157,6 +161,7 @@ class ProgressMeter(object):
Reset for another pass. Provide a new header and define number Reset for another pass. Provide a new header and define number
of steps to be used. of steps to be used.
""" """
import gtk
self.__mode = mode self.__mode = mode
self.__pbar_max = total self.__pbar_max = total
self.__pbar_index = 0.0 self.__pbar_index = 0.0
@ -180,6 +185,7 @@ class ProgressMeter(object):
def step(self): def step(self):
"""Click the progress bar over to the next value. Be paranoid """Click the progress bar over to the next value. Be paranoid
and insure that it doesn't go over 100%.""" and insure that it doesn't go over 100%."""
import gtk
if self.__mode is ProgressMeter.MODE_FRACTION: if self.__mode is ProgressMeter.MODE_FRACTION:
self.__pbar_index = self.__pbar_index + 1.0 self.__pbar_index = self.__pbar_index + 1.0
@ -204,6 +210,7 @@ class ProgressMeter(object):
return self.__cancelled return self.__cancelled
def set_header(self, text): def set_header(self, text):
import gtk
self.__lbl.set_text(text) self.__lbl.set_text(text)
while gtk.events_pending(): while gtk.events_pending():
gtk.main_iteration() gtk.main_iteration()