Anchor¶
See also
- Notifications:
- The Anchor object uses notifications to notify observers of changes.
Tasks¶
Notifications¶
Parent¶
getParent()
setParent()
Anchor¶
-
class
defcon.
Anchor
(glyph=None, anchorDict=None)¶ This object represents an anchor point.
This object posts the following notifications:
Anchor.Changed Anchor.XChanged Anchor.YChanged Anchor.NameChanged Anchor.ColorChanged Anchor.IdentifierChanged ========================
During initialization an anchor dictionary can be passed. If so, the new object will be populated with the data from the dictionary.
-
addObserver
(observer, methodName, notification)¶ Add an observer to this object’s notification dispatcher.
- observer An object that can be referenced with weakref.
- methodName A string representing the method to be called when the notification is posted.
- notification The notification that the observer should be notified of.
The method that will be called as a result of the action must accept a single notification argument. This will be a
defcon.tools.notifications.Notification
object.This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.addObserver(observer=observer, methodName=methodName, notification=notification, observable=anObject)
-
color
¶ The anchors’s
Color
object. When setting, the value can be a UFO color string, a sequence of (r, g, b, a) or aColor
object. Setting this posts Anchor.ColorChanged and Anchor.Changed notifications.
-
copy
() → a shallow copy of D¶
-
destroyAllRepresentations
(notification=None)¶ Destroy all representations.
-
destroyRepresentation
(name, **kwargs)¶ Destroy the stored representation for name and **kwargs. If no kwargs are given, any representation with name will be destroyed regardless of the kwargs passed when the representation was created.
-
dirty
¶ The dirty state of the object. True if the object has been changed. False if not. Setting this to True will cause the base changed notification to be posted. The object will automatically maintain this attribute and update it as you change the object.
-
disableNotifications
(notification=None, observer=None)¶ Disable this object’s notifications until told to resume them.
- notification The specific notification to disable. This is optional. If no notification is given, all notifications will be disabled.
This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.disableNotifications( observable=anObject, notification=notification, observer=observer)
-
dispatcher
¶ The
defcon.tools.notifications.NotificationCenter
assigned to the parent of this object.
-
enableNotifications
(notification=None, observer=None)¶ Enable this object’s notifications.
- notification The specific notification to enable. This is optional.
This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.enableNotifications( observable=anObject, notification=notification, observer=observer)
-
fromkeys
(S[, v]) → New dict with keys from S and values equal to v.¶ v defaults to None.
-
generateIdentifier
()¶ Create a new, unique identifier for and assign it to the guideline. This will post Anchor.IdentifierChanged and Anchor.Changed notifications.
-
get
(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
-
getRepresentation
(name, **kwargs)¶ Get a representation. name must be a registered representation name. **kwargs will be passed to the appropriate representation factory.
-
hasCachedRepresentation
(name, **kwargs)¶ Returns a boolean indicating if a representation for name and **kwargs is cached in the object.
-
hasObserver
(observer, notification)¶ Returns a boolean indicating is the observer is registered for notification.
This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.hasObserver(observer=observer, notification=notification, observable=anObject)
-
has_key
(k) → True if D has a key k, else False¶
-
holdNotifications
(notification=None)¶ Hold this object’s notifications until told to release them.
- notification The specific notification to hold. This is optional. If no notification is given, all notifications will be held.
This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.holdNotifications( observable=anObject, notification=notification)
-
identifier
¶ The identifier. Setting this will post Anchor.IdentifierChanged and Anchor.Changed notifications.
-
identifiers
¶ Set of identifiers for the glyph that this anchor belongs to. This is primarily for internal use.
-
items
() → list of D's (key, value) pairs, as 2-tuples¶
-
iteritems
() → an iterator over the (key, value) items of D¶
-
iterkeys
() → an iterator over the keys of D¶
-
itervalues
() → an iterator over the values of D¶
-
keys
() → list of D's keys¶
-
move
(values)¶ Move the anchor by (x, y).
This will post Anchor.XChange, Anchor.YChanged and Anchor.Changed notifications if anything changed.
-
name
¶ The name. Setting this will post Anchor.NameChanged and Anchor.Changed notifications.
-
pop
(k[, d]) → v, remove specified key and return the corresponding value.¶ If key is not found, d is returned if given, otherwise KeyError is raised
-
popitem
() → (k, v), remove and return some (key, value) pair as a¶ 2-tuple; but raise KeyError if D is empty.
-
postNotification
(notification, data=None)¶ Post a notification through this object’s notification dispatcher.
- notification The name of the notification.
- data Arbitrary data that will be stored in the
Notification
object.
This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.postNotification( notification=notification, observable=anObject, data=data)
-
releaseHeldNotifications
(notification=None)¶ Release this object’s held notifications.
- notification The specific notification to hold. This is optional.
This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.releaseHeldNotifications( observable=anObject, notification=notification)
-
removeObserver
(observer, notification)¶ Remove an observer from this object’s notification dispatcher.
- observer A registered object.
- notification The notification that the observer was registered to be notified of.
This is a convenience method that does the same thing as:
dispatcher = anObject.dispatcher dispatcher.removeObserver(observer=observer, notification=notification, observable=anObject)
-
representationKeys
()¶ Get a list of all representation keys that are currently cached.
-
setdefault
(k[, d]) → D.get(k,d), also set D[k]=d if k not in D¶
-
undoManager
¶ The undo manager assigned to this object.
-
values
() → list of D's values¶
-
viewitems
() → a set-like object providing a view on D's items¶
-
viewkeys
() → a set-like object providing a view on D's keys¶
-
viewvalues
() → an object providing a view on D's values¶
-
x
¶ The x coordinate. Setting this will post Anchor.XChanged and Anchor.Changed notifications.
-
y
¶ The y coordinate. Setting this will post Anchor.YChanged and Anchor.Changed notifications.
-