Module dabo.ui

This is Dabo's user interface layer which is the topmost layer.

There are submodules for all supported UI libraries. As of this writing,
the only supported UI library is wxPython (uiwx).

To use a given submodule at runtime, you need to call loadUI() with the 
ui module you want as a parameter. For instance, to load wxPython, you
would issue:

	import dabo.ui
	dabo.ui.loadUI("wx")
	

Functions

areYouSure beep bitmapFromData
browse busyInfo callAfter
callAfterInterval callEvery continueEvent
createClass createForm createMenuBar
deadCheck discontinueEvent exclaim
fontMetric fontMetricFromDrawObject fontMetricFromFont
getAvailableFonts getChoice getChoices
getColor getCommonBitmap getDate
getDirectory getDisplaySize getEventData
getFile getFileAndType getFolder
getFont getFormMousePosition getImagePath
getInt getMouseObject getMousePosition
getObjectAtPosition getPositionInSizer getSaveAs
getSaveAsAndType getString getUIType
getUiApp imageFromData info
isAltDown isCommandDown isControlDown
isMouseLeftDown isMouseMiddleDown isMouseRightDown
isShiftDown loadUI makeDynamicProperty
makeGridEditor makeProxyProperty pathToBmp
resizeBmp resolvePathAndUpdate saveScreenShot
setAfter setAfterInterval setdFormClass
sortList spawnProcess stop
strToBmp yieldUI




Functions

areYouSure(message='Are you sure?', title=None, defaultNo=False, cancelButton=True, parent=None, requestUserAttention=True)
Display a dMessageBox asking the user to answer yes or no to a question.

Returns True, False, or None, for choices "Yes", "No", or "Cancel".

The default title comes from app.getAppInfo("appName"), or if the 
application object isn't available it will be "Dabo Application".

If defaultNo is True, the 'No' button will be the default button.

If cancelButton is True (default), a third 'Cancel' button will appear.

If parent isn't passed, it will automatically resolve to the current 
active form.

If requestUserAttention is True, if the operating system supports it,
the taskbar will flash (Windows) or the dock item will jump (Mac), 
showing the user that your application needs attention.
beep()

			
		
bitmapFromData(data)

			
		
browse(dataSource, parent=None, keyCaption=None, includeFields=None, colOrder=None, colWidths=None, colTypes=None, autoSizeCols=True)
Given a data source, a form with a grid containing the data
is created and displayed. If the source is a Dabo cursor object,
its getDataSet() method will be called to extract the data.

If parent is passed, the form isn't created, and the browsegrid
becomes a child of parent instead.

The columns will be taken from the first record of the dataset,	with each
column header caption being set to the field name, unless	the optional
keyCaption parameter is passed. This parameter is a 1:1 dict containing
the data set keys as its keys, and the desired caption as the
corresponding value.

If the includeFields parameter is a sequence, the only columns added will
be the fieldnames included in the includeFields sequence. If the
includeFields	parameter is None, all fields will be added to the grid.

The columns will be in the order returned by ds.keys(), unless the
optional colOrder parameter is passed. Like the keyCaption property,
this is a 1:1 dict containing key:order.
busyInfo(msg='Please wait...', *args, **kwargs)
Display a message that the system is busy.

Assign the return value to a local object, and the message will stay until the
object is explicitly unbound. For example:

bi = dabo.ui.busyInfo("Please wait while I count to 10000...")
for i in range(10000):
	pass
bi = None
callAfter(fnc, *args, **kwargs)
There are times when this functionality is needed when creating UI
code. This function simply wraps the wx.CallAfter function so that
developers do not need to use wx code in their apps.
callAfterInterval(interval, func, *args, **kwargs)
Call the given function after <interval> milliseconds have elapsed.

If the function is called again before the interval has elapsed, the original
timer is destroyed and a new one instantiated. IOW, you can call this in a
tight loop, and only the last call will get executed. Useful when you want to
refresh something because you changed it, but the frequency of changes can be
high.
callEvery(interval, func, *args, **kwargs)
Creates and returns a timer object that fires the specified function
at the specified interval. Interval is given in milliseconds. It will pass along
any additional arguments to the function when it is called.
continueEvent(evt)

			
		
createClass(srcFile, *args, **kwargs)
Given a .cdxml class definition file path, will return the
corresponding Python class.
createForm(srcFile, show=False, *args, **kwargs)
Pass in a .cdxml file from the Designer, and this will
instantiate a form from that spec. Returns a reference
to the newly-created form.
createMenuBar(srcFile, form=None, previewFunc=None)
Pass in an .mnxml file saved from the Menu Designer,
and this will instantiate a MenuBar from that spec. Returns
a reference to the newly-created MenuBar. You can optionally
pass in a reference to the form to which this menu is
associated, so that you can enter strings that represent
form functions in the Designer, such as 'form.close', which
will call the associated form's close() method. If 'previewFunc'
is passed, the menu command that would have been eval'd
and executed on a live menu will instead be passed back as
a parameter to that function.
deadCheck(fn, *args, **kwargs)
This decorator is intended to detect dead objects (objects in the process of being
destroyed) from attempts to call their methods. Currently this only supports wxPython,
but if needed in other toolkits, different functionality will need to be coded.
discontinueEvent(evt)

			
		
exclaim(message='Important!', title=None, parent=None, requestUserAttention=True)
Display a dMessageBox urgently informing the user that we cannot proceed.

Returns None.

The default title comes from app.getAppInfo("appName"), or if the 
application object isn't available it will be "Dabo Application".

If parent isn't passed, it will automatically resolve to the current 
active form.

If requestUserAttention is True, if the operating system supports it,
the taskbar will flash (Windows) or the dock item will jump (Mac), 
showing the user that your application needs attention.
fontMetric(txt=None, wind=None, face=None, size=None, bold=None, italic=None)
Calculate the width and height of the given text using the supplied
font information. If any font parameters are missing, they are taken
from the specified window, or, if no window is specified, the currently
active form. If no form is active, the app's MainForm is used.
fontMetricFromDrawObject(obj)
Given a drawn text object, returns the width and height of the text.
fontMetricFromFont(txt, font)

			
		
getAvailableFonts()
Returns a list of all fonts available on the current system.
getChoice(choices, message=None, caption=None, defaultPos=None)
Simple dialog for presenting the user with a list of choices from which
they can select one item.
getChoices(choices, message=None, caption=None, defaultPos=None)
Simple dialog for presenting the user with a list of choices from which
they can select one or more items. Returns a tuple containing the selections.
getColor(color=None)
Displays the color selection dialog for the platform.
Returns an RGB tuple of the selected color, or None if
no selection was made.
getCommonBitmap(name)
wxPython comes with several built-in bitmaps for common icons.
This wraps the procedure for generating these bitmaps. If a name is
passed for which there is no icon, an image denoting a missing image
is returned.

NOTE: this returns a raw bitmap, not a dabo.ui.dBitmap object.
getDate(dt=None)
Displays a calendar dialog for the user to select a date.
Defaults to the given date parameter, or today if no value
is passed.
getDirectory(message=u'Choose a folder', defaultPath='', wildcard='*')
Displays the folder selection dialog for the platform.
Returns the path to the selected folder, or None if no selection
was made.
getDisplaySize()
Returns the current display resolution in (width, height) format.
getEventData(wxEvt)

			
		
getFile(*args, **kwargs)
Display the file selection dialog for the platform, and return selection(s).

Send an optional multiple=True for the user to pick more than one file. In
that case, the return value will be a sequence of unicode strings.

Returns the path to the selected file or files, or None if no selection	was
made. Only file may be selected if multiple is False.

Optionally, you may send wildcard arguments to limit the displayed files by
file type. For example:
	getFile("py", "txt")
	getFile("py", "txt", multiple=True)
getFileAndType(*args, **kwargs)
Displays the file selection dialog for the platform.
Returns the path to the selected file, or None if no selection
was made, as well as the wildcard value selected by the user.
getFolder(message=u'Choose a folder', defaultPath='', wildcard='*')
Displays the folder selection dialog for the platform.
Returns the path to the selected folder, or None if no selection
was made.
getFont(font=None)
Displays the font selection dialog for the platform.
Returns a font object that can be assigned to a control's
Font property.
getFormMousePosition()
Returns the position of the mouse relative to the top left
corner of the form.
getImagePath(nm, url=False)
Given the name of an image in either the Dabo common directory, or the
current directory, returns the full path to the image. If 'url' is true, returns
the path in a 'file:///image.ext' format.
getInt(message=u'Enter an integer value:', caption='Dabo', defaultValue=0, **kwargs)
Simple dialog for returning an integer value from the user.
getMouseObject()
Returns a reference to the object below the mouse pointer
at the moment the command is issued. Useful for interactive
development when testing changes to classes 'in the wild' of a
live application.
getMousePosition()
Returns the position of the mouse on the screen.
getObjectAtPosition(x, y=None)
Given a screen position, returns the object immediately under that
position, or None if there is no such object. You can pass separate
x,y coordinates, or an x,y tuple.
getPositionInSizer(obj)
Returns the current position of this control in its containing
sizer. This is useful for when a control needs to be re-created in place.
If the containing sizer is a box sizer, the integer position will be returned. 
If it is a grid sizer, a row,col tuple will be returned. If the object is 
not contained in a sizer, None will be returned.
getSaveAs(*args, **kwargs)

			
		
getSaveAsAndType(*args, **kwargs)

			
		
getString(message=u'Please enter a string:', caption='Dabo', defaultValue='', **kwargs)
Simple dialog for returning a small bit of text from the user.

Any additional keyword arguments are passed along to the dTextBox when it
is instantiated. Some useful examples:

# Give the textbox a default value:
txt = dabo.ui.getString(defaultValue="initial string value")

# Password Entry (*'s instead of the actual text)
txt = dabo.ui.getString(PasswordEntry=True)
getUIType()
Return the identifier of the currently loaded UI, or None.
getUiApp(app, callback=None)
This returns an instance of uiApp. If one is already running, that
instance is returned. Otherwise, a new instance is created.
imageFromData(data)

			
		
info(message='Information', title=None, parent=None, requestUserAttention=True)
Display a dMessageBox offering the user some useful information.

Returns None.

The default title comes from app.getAppInfo("appName"), or if the 
application object isn't available it will be "Dabo Application".

If parent isn't passed, it will automatically resolve to the current 
active form.

If requestUserAttention is True, if the operating system supports it,
the taskbar will flash (Windows) or the dock item will jump (Mac), 
showing the user that your application needs attention.
isAltDown()

			
		
isCommandDown()

			
		
isControlDown()

			
		
isMouseLeftDown()

			
		
isMouseMiddleDown()

			
		
isMouseRightDown()

			
		
isShiftDown()

			
		
loadUI(uiType)
Load the given UI into the global namespace.
makeDynamicProperty(prop, additionalDoc=None)
Make a Dynamic property for the passed property.

Call this in your class definition, after you've defined the property
you'd like to make dynamic. For example:

Caption = property(_getCaption, _setCaption, None, None)
DynamicCaption = makeDynamicProperty(Caption)
makeGridEditor(controlClass, minWidth=None, minHeight=None)

			
		
makeProxyProperty(dct, nm, proxyAtts)
When creating composite controls, it is necessary to be able to pass through
property get/set calls to an object or objects within the composite control. For
example, if a class based on dPanel contains a textbox and a label, I might want 
to proxy the class's Caption to the label's Caption, the Value to the textbox, and
the FontSize to both. In order to do this, the object(s) to be proxied must be 
stored in the custom class as references in attributes of the custom class, and 
passed in the 'proxyAtts' parameter. In addition, passing 'self' as one of the 
proxyAtts will apply the property to the custom class itself; a good example 
would be a property like 'Height': the outer panel needs to grow as well as the 
inner controls. In this case, assuming you store a reference to the textbox and 
label in attributes named '_textbox' and '_label', respectively, the code in your 
custom composite class would look like:

	_proxyDict = {}
	Caption = makeProxyProperty(_proxyDict, "Caption", "_label")
	FontSize = makeProxyProperty(_proxyDict, "FontSize", ("_textbox", "_label"))
	Height = makeProxyProperty(_proxyDict, "Value", ("self", "_textbox"))
	Value = makeProxyProperty(_proxyDict, "Value", "_textbox")

For setter operations, if the 'proxyAtts' is a sequence of more than one object, the 
setting will be applied to all. For the getter, only the first object in the sequence 
with that property will be used.

You must declare an attribute named '_proxyDict' in the class definition before you
call this method; '_proxyDict' should be an empty dictionary. This dict needs to be
passed to this method, since there is no 'self' reference at the time that properties 
are declared in a class definition.

'nm' is the name of the property to be proxied. 'proxyAtts' is either a single string
with the name of the attribute that will hold the reference to the inner control, or
it should be a tuple of strings, each of which is the name of an attribute that contains
the reference to an inner control.
pathToBmp(pth)

			
		
resizeBmp(bmp, wd, ht)

			
		
resolvePathAndUpdate(srcFile)

			
		
saveScreenShot(obj=None, imgType=None, pth=None, delaySeconds=None)
Takes a screenshot of the specified object and writes it to a file, converting
it to the requested image type. If no object is specified, the current
ActiveForm is used. You can add an optional delaySeconds setting that
will let you set things up as needed before the image is taken; if not specified,
the image is taken immediately.
setAfter(obj, prop, val)
Like callAfter(), but allows you to set a property instead of calling
a function.
setAfterInterval(interval, obj, prop, val)
Like callAfterInterval(), but allows you to set a property instead
of calling a function.
setdFormClass(typ)
Re-defines 'dForm' as either the SDI form class, or the child MDI
form class, depending on the parameter, which can be either 'SDI'
or 'MDI'.
sortList(chc, Caption='', ListCaption='')
Wrapper function for the list sorting dialog. Accepts a list,
and returns the sorted list if the user clicks 'OK'. If they cancel
out, the original list is returned.
spawnProcess(cmd, wait=False)
Launch a separate process. Control is immediately returned to the
calling program, unless you call this with 'wait=True'.
stop(message='Stop', title=None, parent=None, requestUserAttention=True)
Display a dMessageBox informing the user that the operation cannot proceed.

Returns None.

The default title comes from app.getAppInfo("appName"), or if the 
application object isn't available it will be "Dabo Application".

If parent isn't passed, it will automatically resolve to the current 
active form.

If requestUserAttention is True, if the operating system supports it,
the taskbar will flash (Windows) or the dock item will jump (Mac), 
showing the user that your application needs attention.
strToBmp(val, scale=None, width=None, height=None)
This can be either a path, or the name of a built-in graphic.
If an adjusted size is desired, you can either pass a 'scale' value
(where 1.00 is full size, 0.5 scales it to 50% in both Height and
Width), or you can pass specific 'height' and 'width' values. The
final image will be a bitmap resized to those specs.
yieldUI(*args, **kwargs)
Yield to other apps/messages.

Dabo 0.9.0 (rev. 4908)
5 Jan 2009 23:30:33