Hello, I am trying to minimally wrap PyQt5's QWebEngineView:
```from PyQt5.QtWebEngineWidgets import QWebEngineView
from atom.api import Unicode, observe, set_default
from enaml.core.declarative import d_
from enaml.widgets.api import RawWidget
class WebEngineViewWidget(RawWidget):
__slots__ = '__weakref__'
url = d_(Unicode())
hug_width = set_default('ignore')
hug_height = set_default('ignore')
def create_widget(self, parent):
return QWebEngineView(parent)
@observe('url')
def _update_proxy(self, change):
print('change', change)
super()._update_proxy(change)
```
In my *.enaml-file I have this line
```
WebEngineViewWidget:
url << folder.image_path
```
My model (folder-)model looks like this:
```import os
import magic
import natsort
from atom.api import Atom, Bytes, Int, List, Str, observe
from enaml.image import Image
class ImageFolder(Atom):
path = Str()
image_data = Bytes()
image_path = Str()
items = List(str)
index = Int(default=0)
_supported_formats = set(Image.format.items).union({'jpeg'}) - {'auto'}
def _load_image(self):
if self.items:
self.image_path = self.items[self.index]
with open(self.image_path, 'rb') as file:
self.image_data = file.read()
@observe('path')
def _on_path(self, change):
# Clear image, items, and reset index
self.image_data = b''
self.items.clear()
self.index = 0
# If the path is empty or doesn't exist just return
path = change['value']
if not os.path.isdir(path):
return
# Collect all images recursively
for root, folders, file_names in os.walk(path):
for file_name in file_names:
path = os.path.join(root, file_name)
mime = magic.from_file(path, mime=True)
kind, format = mime.split('/', 1)
if kind == 'image' and format in self._supported_formats:
self.items.append(path)
self.items = natsort.natsorted(self.items)
self._load_image()
def next(self):
self.index += 1
if self.index >= len(self.items):
self.index = 0
self._load_image()
def previous(self):
self.index -= 1
if self.index < 0:
self.index = len(self.items) - 1
self._load_image()
```
I know that image_path definitely changes, but it never seems to trigger the observer method. The observer method successfully works for other (default attributes):
```change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'background', 'value': None}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'foreground', 'value': None}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'font', 'value': None}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'minimum_size', 'value': Size(width=-1, height=-1)}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'maximum_size', 'value': Size(width=-1, height=-1)}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'tool_tip', 'value': ''}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'status_tip', 'value': ''}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'enabled', 'value': True}
change {'type': 'create', 'object': <widgets.WebEngineViewWidget object at 0x7f7812e273a8>, 'name': 'visible', 'value': True}```
What am I doing wrong here?