0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 19:21:50 +02:00

fix(website): fixed designer integration for website widget

This commit is contained in:
2024-08-28 21:19:12 +02:00
parent 9925bbdb48
commit 5f37e862c9

View File

@ -1,4 +1,4 @@
from qtpy.QtCore import QUrl, qInstallMessageHandler
from qtpy.QtCore import Property, QUrl, Slot, qInstallMessageHandler
from qtpy.QtWebEngineWidgets import QWebEngineView
from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
@ -32,6 +32,27 @@ class WebsiteWidget(BECWidget, QWidget):
self.setLayout(layout)
self.set_url(url)
@Property(str)
def url(self) -> str:
"""
The url of the website widget
Returns:
str: The url
"""
return self.get_url()
@url.setter
def url(self, url: str) -> None:
"""
Set the url of the website widget
Args:
url (str): The url to set
"""
self.set_url(url)
@Slot(str)
def set_url(self, url: str) -> None:
"""
Set the url of the website widget
@ -41,6 +62,8 @@ class WebsiteWidget(BECWidget, QWidget):
"""
if not url:
return
if not isinstance(url, str):
return
self.website.setUrl(QUrl(url))
def get_url(self) -> str:
@ -52,18 +75,21 @@ class WebsiteWidget(BECWidget, QWidget):
"""
return self.website.url().toString()
@Slot()
def reload(self):
"""
Reload the website
"""
QWebEngineView.reload(self.website)
@Slot()
def back(self):
"""
Go back in the history
"""
QWebEngineView.back(self.website)
@Slot()
def forward(self):
"""
Go forward in the history