Hi, I'm trying to make a GUI for a pyrthon script, but I can't figure out how to make the layout work. Below is the code I have (most of it is stolen from tutorials) so far, I would like to insert a user input field and a button below the html page. Any help or advice is appreciated.
Code
import sys, os
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QPushButton
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtGui import QIcon
class main(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
vbox = QVBoxLayout(self)
self.webEngineView = QWebEngineView()
self.loadPage()
vbox.addWidget(self.webEngineView)
self.setLayout(vbox)
self.resize(630, 600)
self.setWindowTitle('This is a test')
scriptDir = os.path.dirname(os.path.realpath(__file__))
self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'web.png'))
self.show()
def loadPage(self):
html1 = '''
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div id="tradingview_69585" style="display: inline-block"></div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget(
{
"width": 600,
"height": 340,
"symbol": "'''
htmlvar = 'EURUSD'
html2 = '''",
"interval": "1",
"timezone": "Etc/UTC",
"theme": "dark",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"save_image": false,
"container_id": "tradingview_69585"
}
);
</script>
</div>
<!-- TradingView Widget END -->'''
htm = html1+htmlvar+html2
self.webEngineView.setHtml(html1+htmlvar+html2)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = main()
sys.exit(app.exec_())