CVS: anygui/lib/anygui __init__.py,1.73,1.74

"Dallas T. Johnston" <[email protected]> Sat, 16 Nov 2002 04:41:12 -0800
Newsgroups gmane.comp.python.anygui.cvs
Message-ID <[email protected]>
Update of /cvsroot/anygui/anygui/lib/anygui
In directory usw-pr-cvs1:/tmp/cvs-serv24516/lib/anygui

Modified Files:
	__init__.py 
Log Message:
dded frontend widgets and ported ComboBox to the new architecture.
Still some layout bugs in cb, but that will be fixed by tomorrow.
Also, changed the dialogs to remove Anygui, and fixed OpenFileDialog
to pretty much work perfectly now.
We just need to think of a clean way to have dialogs return their
values.


Index: __init__.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/__init__.py,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -r1.73 -r1.74
*** __init__.py	13 Nov 2002 17:19:22 -0000	1.73
--- __init__.py	16 Nov 2002 12:41:10 -0000	1.74
***************
*** 1,166 ****
! #_backends = 'msw gtk java wx tk beos qt curses text'
! _backends = 'java msw wx qt tk'
! 
! def application():
!     'Returns the global application object'
!     #global _application
!     if not _application:
!         #_application = factory()._map['Application']()
!         raise RuntimeError, 'no application exists'
!     return _application
! 
! def backend():
!     'Returns the name of the current backend'
!     if not _backend_name:
!         raise RuntimeError, 'no backend exists'
!     return _backend_name
! 
! def backendModule():
!     'Returns the current backend module'
!     if not _backend:
!         raise RuntimeError, 'no backend exists'
!     return _backend
! 
! def setup(self, **kwds):
!     'Used to configure Anygui'
!     raise NotImplementedError
! 
! 
! ########## Begin Imports ##################################################
! 
! import os, sys
! from anygui.Attribs          import Attrib
! from anygui.Utils            import Options
! #from anygui.Applications     import AbstractApplication
! from anygui.Windows          import Window
! from anygui.Buttons          import Button
! #from anygui.Canvases         import Canvas
! #from anygui                  import Colors
! from anygui.Labels           import Label
! from anygui.CheckBoxes       import CheckBox
! from anygui.RadioButtons     import RadioButton
! from anygui.RadioGroups      import RadioGroup
! from anygui.TextFields       import TextField
! from anygui.TextAreas        import TextArea
! from anygui.ListBoxes        import ListBox
! from anygui.Models           import BooleanModel, ListModel, TextModel
! from anygui.Events           import *
! from anygui.Frames           import Frame, GroupBox
! from anygui.LayoutManagers   import LayoutManager, Placer
! from anygui.Menus            import MenuBar, Menu, MenuCommand, MenuCheck, MenuSeparator
! 
! # import objects from dialogs
! from anygui.dialogs          import *
! 
! ########### End Imports ###################################################
! 
! # 20020208:mlh -- starting to experiment with new architecture
! __all__ = """
! 
!   Application
!   Frame
!   GroupBox
!   Button
!   CheckBox
!   Options
!   Window
!   Label
!   TextField
!   TextArea
!   ListBox
!   RadioButton
!   RadioGroup
!   BooleanModel
!   ListModel
!   TextModel
!   any
!   application
!   backend
!   link
!   send
!   sender
!   setup
!   unlink
!   unlinkHandler
!   unlinkMethods
!   unlinkSource
!   AboutAnyguiDlg
!   AnyguiOpenFileDlg
! 
! """.split()
! 
! 
! """
! # Original export list:
! __all__ = ['application', 'Application',
!            'Window', 'Button', 'CheckBox', 'Label',
!            'RadioButton', 'RadioGroup', 'ListBox', 'TextField', 'TextArea',
!            'BooleanModel', 'ListModel', 'TextModel', 'Options',
!            'LayoutManager', 'Placer',
!            'send', 'sender', 'link', 'unlink', 'any', 'unlinkSource', 'unlinkHandler',
!            'unlinkMethods', 'Frame', 'Placer', 'backend'
!            ] # FIXME: Add stuff from Colors and Fonts
! """
! 
! # Try to get the environment variables ANYGUI_WISHLIST (overrides
! # anygui.wishlist), and ANYGUI_DEBUG (to print out stacktraces when
! # importing backends):
! 
! if hasattr(sys, 'registry'):
!     # Jython:
!     wishlist = sys.registry.getProperty('ANYGUI_WISHLIST', _backends).split()
!     DEBUG = sys.registry.getProperty('ANYGUI_DEBUG', '0')
! else:
!     # CPython:
!     wishlist = os.environ.get('ANYGUI_WISHLIST', _backends).split()
!     DEBUG = os.environ.get('ANYGUI_DEBUG', '0')
! 
! # Non-empty string may be zero (i.e. false):
! if DEBUG:
!     try:
!         DEBUG = int(DEBUG)
!     except ValueError:
!         pass
! 
! _application  = None
! _backend      = None
! _backend_name = None
! 
! def _dotted_import(name):
!     # version of __import__ which handles dotted names
!     # copied from python docs for __import__
!     import string
!     mod = __import__(name, globals(), locals(), [])
!     components = string.split(name, '.')
!     for comp in components[1:]:
!         mod = getattr(mod, comp)
!     return mod
! 
! def _backend_passthrough():
!     global _backends, _backend, _backend_name
!     _backends = _backends.split()
!     _backends = [b for b in _backends if not b in wishlist]
!     if wishlist:
!         try:
!             idx = wishlist.index('*')
!             wishlist[idx:idx+1] = _backends
!         except ValueError: pass
!         _backends = wishlist
!     for name in _backends:
!         try:
!             mod = _dotted_import('anygui.backends.%sgui' % name,)
!             for key in mod.__all__:
!                 globals()[key] = mod.__dict__[key]
!         except (ImportError, AttributeError, KeyError):
!             if DEBUG and not (DEBUG in _backends and not DEBUG==name):
!                 import traceback
!                 traceback.print_exc()
!             continue
!         else:
!             _backend_name = name
!             _backend      = mod
!             return
!     raise RuntimeError, "no usable backend found"
! 
! # Pass the backend namespace through:
! _backend_passthrough()
--- 1,178 ----
! #_backends = 'msw gtk java wx tk beos qt curses text'
! _backends = 'java msw wx qt tk'
! 
! # 20020208:mlh -- starting to experiment with new architecture
! __all__ = """
! 
!   Application
!   Frame
!   GroupBox
!   Button
!   CheckBox
!   Options
!   Window
!   Label
!   TextField
!   TextArea
!   ListBox
!   ComboBox
!   RadioButton
!   RadioGroup
!   BooleanModel
!   ListModel
!   TextModel
!   any
!   application
!   backend
!   link
!   send
!   sender
!   setup
!   unlink
!   unlinkHandler
!   unlinkMethods
!   unlinkSource
!   AboutDialog
!   OpenFileDialog
! 
! """.split()
! 
! def application():
!     'Returns the global application object'
!     #global _application
!     if not _application:
!         #_application = factory()._map['Application']()
!         raise RuntimeError, 'no application exists'
!     return _application
! 
! def backend():
!     'Returns the name of the current backend'
!     if not _backend_name:
!         raise RuntimeError, 'no backend exists'
!     return _backend_name
! 
! def backendModule():
!     'Returns the current backend module'
!     if not _backend:
!         raise RuntimeError, 'no backend exists'
!     return _backend
! 
! def frontEndWrappers():
!     'Returns the list of available frontend widgets'
!     if not _frontend_wrappers:
!         raise RuntimeError, 'no frontend wrappers exists'
!     return _frontend_wrappers
! 
! def setup(self, **kwds):
!     'Used to configure Anygui'
!     raise NotImplementedError
! 
! 
! ########## Get the list of frontend wrappers ##############################
! import anygui.frontend_wrappers as few
! _frontend_wrappers = few
! ########## End get list of frontend wrappers ##############################
! 
! ########## Begin Imports ##################################################
! 
! import os, sys
! from anygui.Attribs          import Attrib
! from anygui.Utils            import Options
! #from anygui.Applications     import AbstractApplication
! from anygui.Windows          import Window
! from anygui.Buttons          import Button
! #from anygui.Canvases         import Canvas
! #from anygui                  import Colors
! from anygui.Labels           import Label
! from anygui.CheckBoxes       import CheckBox
! from anygui.RadioButtons     import RadioButton
! from anygui.RadioGroups      import RadioGroup
! from anygui.TextFields       import TextField
! from anygui.TextAreas        import TextArea
! from anygui.ListBoxes        import ListBox
! from anygui.ComboBoxes       import ComboBox
! from anygui.Models           import BooleanModel, ListModel, TextModel
! from anygui.Events           import *
! from anygui.Frames           import Frame, GroupBox
! from anygui.LayoutManagers   import LayoutManager, Placer
! from anygui.Menus            import MenuBar, Menu, MenuCommand, MenuCheck, MenuSeparator
! 
! # import objects from dialogs
! from anygui.dialogs          import *
! 
! ########### End Imports ###################################################
! 
! """
! # Original export list:
! __all__ = ['application', 'Application',
!            'Window', 'Button', 'CheckBox', 'Label',
!            'RadioButton', 'RadioGroup', 'ListBox', 'TextField', 'TextArea',
!            'BooleanModel', 'ListModel', 'TextModel', 'Options',
!            'LayoutManager', 'Placer',
!            'send', 'sender', 'link', 'unlink', 'any', 'unlinkSource', 'unlinkHandler',
!            'unlinkMethods', 'Frame', 'Placer', 'backend'
!            ] # FIXME: Add stuff from Colors and Fonts
! """
! 
! # Try to get the environment variables ANYGUI_WISHLIST (overrides
! # anygui.wishlist), and ANYGUI_DEBUG (to print out stacktraces when
! # importing backends):
! 
! if hasattr(sys, 'registry'):
!     # Jython:
!     wishlist = sys.registry.getProperty('ANYGUI_WISHLIST', _backends).split()
!     DEBUG = sys.registry.getProperty('ANYGUI_DEBUG', '0')
! else:
!     # CPython:
!     wishlist = os.environ.get('ANYGUI_WISHLIST', _backends).split()
!     DEBUG = os.environ.get('ANYGUI_DEBUG', '0')
! 
! # Non-empty string may be zero (i.e. false):
! if DEBUG:
!     try:
!         DEBUG = int(DEBUG)
!     except ValueError:
!         pass
! 
! _application  = None
! _backend      = None
! _backend_name = None
! 
! def _dotted_import(name):
!     # version of __import__ which handles dotted names
!     # copied from python docs for __import__
!     import string
!     mod = __import__(name, globals(), locals(), [])
!     components = string.split(name, '.')
!     for comp in components[1:]:
!         mod = getattr(mod, comp)
!     return mod
! 
! def _backend_passthrough():
!     global _backends, _backend, _backend_name
!     _backends = _backends.split()
!     _backends = [b for b in _backends if not b in wishlist]
!     if wishlist:
!         try:
!             idx = wishlist.index('*')
!             wishlist[idx:idx+1] = _backends
!         except ValueError: pass
!         _backends = wishlist
!     for name in _backends:
!         try:
!             mod = _dotted_import('anygui.backends.%sgui' % name,)
!             for key in mod.__all__:
!                 globals()[key] = mod.__dict__[key]
!         except (ImportError, AttributeError, KeyError):
!             if DEBUG and not (DEBUG in _backends and not DEBUG==name):
!                 import traceback
!                 traceback.print_exc()
!             continue
!         else:
!             _backend_name = name
!             _backend      = mod
!             return
!     raise RuntimeError, "no usable backend found"
! 
! # Pass the backend namespace through:
! _backend_passthrough()



-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing 
your web site with SSL, click here to get a FREE TRIAL of a Thawte 
Server Certificate: http://www.gothawte.com/rd524.html