#
#   PyGUI - Top level package initialisation
#

#  The first item of each of the following pairs is the name of a module
#  to try to import. If the import is successful, the platform-dependent
#  directory named by the second item is used.

_versions = [
    ("objc", "Cocoa"),
    ("gtk", "Gtk"),
]

#
#  The environment variable PYGUI_IMPLEMENTATION may be set to the
#  name of one of the platform-dependent directories to force that
#  implementation to be used. This can be useful if more than one
#  PyGUI implementation is usable on your setup.
#

from os import environ as _env
_platdir = _env.get("PYGUI_IMPLEMENTATION")
if not _platdir:
    for _testmod, _platdir in _versions:
        try:
            __import__(_testmod)
            break
        except ImportError:
            continue
    else:
        raise ImportError("Unable to find an implementation of PyGUI for this installation")

if _env.get("PYGUI_IMPLEMENTATION_DEBUG"):
    print "PyGUI: Using implementation:", _platdir

#
#  Append the chosen platform-dependent directory to the search
#  path for submodules of this package.
#

from os.path import join as _join
_here = __path__[0]
__path__.append(_join(_here, _platdir))
__path__.append(_join(_here, "Generic"))

#
#  Now import all the stuff to be made public.
#

from Version import version

from Actions import Action
from AlertFunctions import alert, alert2, alert3, stop_alert, note_alert, \
    confirm, ask, confirm_or_cancel, ask_or_cancel
from Applications import Application
from GApplications import application, run
from Buttons import Button
from CheckBoxes import CheckBox
from Colors import Color, rgb
from Components import Component
from Cursors import Cursor
from Dialogs import Dialog
from Documents import Document
from Events import Event
from Exceptions import Cancel, ResourceNotFoundError, ApplicationError
from FileDialogs import \
    request_old_file, request_old_files, request_new_file, \
    request_old_directory, request_old_directories, request_new_directory
from Files import FileRef, DirRef, FileType
from Fonts import Font
from Frames import Frame
from ImageBases import ImageBase
from Images import Image
from Labels import Label
from Menus import Menu, MenuItem
from MenuLists import MenuList
from MessageHandlers import MessageHandler
from ModalDialogs import ModalDialog
from Models import Model
from Pixmaps import Pixmap
from Properties import Properties, overridable_property
from RadioButtons import RadioButton
from RadioGroups import RadioGroup
from Resources import resource_path, find_resource
from ScrollableViews import ScrollableView
from Sliders import Slider
import StdColors
import StdFonts
import StdMenus
from Tasks import Task
from TextFields import TextField
##from TextModels import TextModel
##from TextViews import TextView
from ViewBases import ViewBase
from Views import View
from Windows import Window

from Resources import _add_file_path, _add_module_path
import __main__
_add_file_path(__file__)
_add_module_path(__main__)
_add_module_path(__main__, 1)
#print "GUI: resource_path =", resource_path ###
