fontlab.flAbstractEditor
flAbstractEditor
Inline canvas widget editor.
What is flAbstractEditor?
flAbstractEditor is the base class for small input widgets that appear directly inside the glyph editor canvas. The most familiar example is the metric value field that pops up when you click on a sidebearing line in metrics editing mode — you can type a new value without leaving the canvas. FontLab creates these inline editors by subclassing flAbstractEditor.
If you are building a custom canvas tool that needs inline numeric input (for example, a dialog-free way to let the user type a value at a specific canvas position), you subclass flAbstractEditor and implement the widget using Qt.
Tutorial
The typical pattern for an inline editor in a custom tool is: detect a click on an editable value → activate the editor → commit or cancel on key press.
from PythonQt.QtCore import QPointF
import fontlab as fl
from fontlab import flAbstractEditor
# ============================================================
# flAbstractEditor is a base class — you subclass it to create
# a real inline editor. This example shows the lifecycle.
#
# In a real plugin, your editor subclass would:
# 1. Set up a Qt QLineEdit (or similar) as its widget
# 2. Override activate() to show and position the widget
# 3. Override deactivate() to hide it and process the input
# ============================================================
# Check whether any item on the canvas has an active editor:
ws = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
if canvas:
gi = canvas.activeGlyphInfo()
if gi:
print(f"Active glyph: '{gi.name}'")
# In a real tool, you would detect a click on a sidebearing
# line and activate a metric editor like this:
#
# class MetricEditor(flAbstractEditor):
# def __init__(self):
# super().__init__()
# self._line_edit = QtWidgets.QLineEdit()
# # ... set up the widget
#
# def activate(self):
# self._line_edit.show()
# self._line_edit.setFocus()
#
# def deactivate(self):
# new_value = int(self._line_edit.text())
# # apply new_value to the glyph metrics
# self._line_edit.hide()
#
# editor = MetricEditor()
# editor.activate()
print("(No inline editor created — subclass flAbstractEditor to build one.)")
# ============================================================
# Check whether the currently hovered canvas item has an editor.
# This is how tools decide whether a click should open editing.
# ============================================================
if canvas:
# flVisualItem.haveEditor(pos) tells you if clicking at a
# specific canvas position would trigger inline editing:
test_pos = QPointF(300, 200)
# (would call item.haveEditor(test_pos) on each visible item)
print("Use item.haveEditor(canvas_pos) to check before activating.")
Common Scripting Patterns
Programmatically deactivate any active inline editor
import fontlab as fl
ws = fl.flWorkspace.instance()
canvas = ws.getActiveCanvas()
if canvas:
# In a real tool, you'd hold a reference to your active editor
# and call its deactivate() when committing or cancelling:
# my_editor.deactivate()
#
# Or use the canvas item API:
# item.deactivateEditor()
print("Call my_editor.deactivate() to dismiss the inline editor.")
Inherited binding members: flObject.
Constructors: flAbstractEditor() flAbstractEditor(flObject)
Native bases: object
Captured native MRO: flAbstractEditor, object
Native new allocation evidence (not an init overload): (args, *kwargs) Create and return a new object. See help(type) for accurate signature.
Supplemental documentation:
Abstract editor. The captured declaration exposes activate, deactivate and widget. It is created with no captured constructor overloads. It also carries the shared object members changed, clone, cloneObject, getProperty, setProperty, release, remove and update and the shared attributes id, name, type, isValid and isNull.
Source: FontLab Proteus API documentation
Source: generated/fontlab.py: flAbstractEditor captured declaration
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
__init__ |
function | (self, /, *args: Any, **kwargs: Any) -> None |
Initialize self. (shared captured text) |
activate |
function | (self) -> Any |
Makes this editor visible and gives it keyboard focus. |
changed |
function | (self) -> Any |
|
checkInitHistoryState |
function | (self, history_ix: int) -> Any |
|
clearAboveHistory |
function | (self, history_ix: int) -> Any |
|
clearFlag |
function | (self, f: int) -> Any |
|
clearFlags |
function | (self) -> Any |
|
clone |
function | (self, *args: Any, **kwargs: Any) -> Any |
Clone the object |
cloneObject |
function | (*args: Any, **kwargs: Any) -> Any |
|
createObject |
function | (*args: Any, **kwargs: Any) -> Any |
FlObject/Nothing createObject(int); |
currentHistoryState |
function | (self, *args: Any, **kwargs: Any) -> Any |
|
deactivate |
function | (self) -> Any |
Hides the editor and returns keyboard focus to the canvas. |
flObjectFlags |
attribute | dict |
|
flag |
function | (self, f: int) -> Any |
|
getProperties |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get object's properties list |
getProperty |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get object property by 'key' or number |
getPropertyFloat |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get float object property by 'key' |
getPropertyInt |
function | (self, *args: Any, **kwargs: Any) -> Any |
Get int object property by 'key' |
hasChanges |
attribute | Any |
|
hasHistoryState |
function | (self, history_ix: int) -> Any |
|
hasHistoryStates |
attribute | Any |
|
haveObject |
function | (*args: Any, **kwargs: Any) -> Any |
|
historyStates |
function | (self, accepted_state: bool) -> Any |
|
id |
attribute | Any |
Object id |
independedAll |
function | (self) -> Any |
|
initialHistoryState |
function | (self, *args: Any, **kwargs: Any) -> Any |
|
instanceType |
function | (*args: Any, **kwargs: Any) -> Any |
|
isChanged |
attribute | Any |
|
isEqual |
function | (self, arg0: flObject) -> Any |
|
isNull |
attribute | Any |
|
isPresent |
attribute | Any |
|
isReleased |
attribute | Any |
|
isValid |
attribute | Any |
|
name |
attribute | Any |
Object name |
propertyNames |
function | (self, *args: Any, **kwargs: Any) -> Any |
PropertyNames(): sorted snapshot of dynamic property keys |
refCnt |
attribute | Any |
Object references count |
release |
function | (self) -> Any |
|
remove |
function | (self, *args: Any, **kwargs: Any) -> Any |
|
removeChild |
function | (self, arg0: flObject) -> Any |
|
restoreHistoryState |
function | (self, history_ix: int) -> Any |
|
setFlag |
function | (self, *args: Any, **kwargs: Any) -> Any |
|
setProperty |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set object property by 'key' or number |
setPropertyFloat |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set float object property by 'key' |
setPropertyInt |
function | (self, *args: Any, **kwargs: Any) -> Any |
Set int object property by 'key' |
tag |
function | (self, *args: Any, **kwargs: Any) -> Any |
|
type |
attribute | Any |
Object type |
update |
function | (self) -> Any |
(shared captured text) |
widget |
attribute | Any |
The underlying Qt widget that implements the editor UI. |