-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This widget allows embedding custom toolkit-specific widgets into the Enaml widget hierarchy.
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#------------------------------------------------------------------------------ | ||
# Copyright (c) 2013, Nucleic Development Team. | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file COPYING.txt, distributed with this software. | ||
#------------------------------------------------------------------------------ | ||
from enaml.widgets.raw_widget import ProxyRawWidget | ||
|
||
from .qt_control import QtControl | ||
|
||
|
||
class QtRawWidget(QtControl, ProxyRawWidget): | ||
""" A Qt implementation of an Enaml ProxyRawWidget. | ||
""" | ||
def create_widget(self): | ||
""" Create the underlying widget for the control. | ||
""" | ||
self.widget = self.declaration.create_widget(self.parent_widget()) | ||
|
||
#-------------------------------------------------------------------------- | ||
# ProxyRawWidget API | ||
#-------------------------------------------------------------------------- | ||
def get_widget(self): | ||
""" Retrieve the underlying toolkit widget. | ||
""" | ||
return self.widget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#------------------------------------------------------------------------------ | ||
# Copyright (c) 2013, Nucleic Development Team. | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file COPYING.txt, distributed with this software. | ||
#------------------------------------------------------------------------------ | ||
from atom.api import Typed, ForwardTyped | ||
|
||
from .control import Control, ProxyControl | ||
|
||
|
||
class ProxyRawWidget(ProxyControl): | ||
""" The abstract definition of a proxy RawWidget object. | ||
""" | ||
#: A reference to the RawWidget declaration. | ||
declaration = ForwardTyped(lambda: RawWidget) | ||
|
||
def get_widget(self): | ||
raise NotImplementedError | ||
|
||
|
||
class RawWidget(Control): | ||
""" A raw toolkit-specific control. | ||
Use this widget when the toolkit backend for the application is | ||
known ahead of time, and Enaml does provide an implementation of | ||
the required widget. This can be used as a hook to inject custom | ||
widgets into an Enaml widget hierarchy. | ||
""" | ||
#: A reference to the proxy Control object. | ||
proxy = Typed(ProxyRawWidget) | ||
|
||
def create_widget(self, parent): | ||
""" Create the toolkit widget for the control. | ||
This method should create and initialize the widget. | ||
Parameters | ||
---------- | ||
parent : toolkit widget or None | ||
The parent toolkit widget for the control. | ||
Returns | ||
------- | ||
result : toolkit widget | ||
The toolkit specific widget for the control. | ||
""" | ||
raise NotImplementedError | ||
|
||
def get_widget(self): | ||
""" Retrieve the toolkit widget for the control. | ||
Returns | ||
------- | ||
result : toolkit widget or None | ||
The toolkit widget that was previously created by the | ||
call to 'create_widget' or None if the proxy is not | ||
active or the widget has been destroyed. | ||
""" | ||
if self.proxy_is_active: | ||
return self.proxy.get_widget() |