-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor fields #1234
Refactor fields #1234
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with a (not very thorough) review. Amongst other comments, there are some copy-paste errors, and a typo in pyface.fields.api
that breaks from pyface.fields.api import EditableField
.
@@ -14,6 +14,8 @@ | |||
|
|||
- :class:`~.CheckBoxField` | |||
- :class:`~.ComboField` | |||
- :class:`~.ImageField` | |||
- :class:`~.LabelField` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Field
and EditableField
be added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
pyface/fields/i_field.py
Outdated
raise NotImplementedError() | ||
def _get_control_alignment(self): | ||
""" Toolkit specific method to get the control's read_only state. """ | ||
raise NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency nit:
raise NotImplementedError | |
raise NotImplementedError() |
|
||
|
||
def alignment_to_qalignment(alignment): | ||
return ALIGNMENT_TO_QALIGNMENT[alignment] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have docstrings (or maybe just type annotations) here.
import wx | ||
|
||
|
||
class ImageControl(wx.Window): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I wanted to see this code in action, what's the easiest way for me to exercise this code manually? Are there examples that make use of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No examples currently, but this was copied and simplified from the wx TraitsUI ImageEditor's ImageControl: https://github.com/enthought/traitsui/blob/main/traitsui/wx/image_control.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could exercise it with something like:
import wx
from pyface.api import ImageResource
from pyface.wx.image_control import ImageControl
window = wx.Frame()
# hack to get a wx bitmap - could also get it through wx api and an image file
bitmap = ImageResource('splash').create_bitmap()
control = ImageControl(window, bitmap)
window.Show()
I think (my wx is rusty)
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
This is probably going to fail because of PySide 6.5 and Numpy issues discussed in #1238 |
This is a refactor of the Field class to split it into display and editable variants: base
Fields
may not be editable,EditaleFields
add editability (ie. the value can be changed by the user). Includes tests and documentation, including fixes to make the documentation actually compile.Adds a LabelField and ImageField to demonstrate the non-editable Fields.