Since for a while, ChatGPT is very popular, I have been using ChatGPT a lot lately so I thought that it would be much cooler if I have that in Houdini. If anybody is interested to have ChatGPT in the Houdini tab, I figured out the code for that and wanted to share it with you guys.
Shelf Code:
import hou
import PySide2
from PySide2.QtCore import QUrl
from PySide2.QtWidgets import QApplication, QWidget, QVBoxLayout
from PySide2.QtWebEngineWidgets import QWebEngineView
app = QApplication.instance()
if app is None:
app = QApplication([])
def create_web_viewer(url):
widget = QWidget()
layout = QVBoxLayout()
widget.setLayout(layout)
web_view = QWebEngineView()
web_view.load(QUrl(url))
layout.addWidget(web_view)
return widget
url = "https://chat.openai.com/"
web_viewer = create_web_viewer(url)
web_viewer.setWindowTitle("OpenAI Chat")
web_viewer.resize(1024, 768)
web_viewer.show()
Houdini Python Panel Ediyor Code:
import hou
from PySide2.QtCore import QUrl
from PySide2.QtWidgets import QApplication, QWidget, QVBoxLayout
from PySide2.QtWebEngineWidgets import QWebEngineView
app = QApplication.instance()
if app is None:
app = QApplication([])
class WebViewer(QWidget):
def __init__(self, parent=None):
super(WebViewer, self).__init__(parent)
url = "https://chat.openai.com/"
layout = QVBoxLayout()
self.setLayout(layout)
web_view = QWebEngineView()
web_view.load(QUrl(url))
layout.addWidget(web_view)
def onCreateInterface():
return WebViewer()