d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Looking Ro Some Help With Python/pyqt5 Layout
Add Reply New Topic New Poll
Member
Posts: 2,830
Joined: Mar 13 2011
Gold: 6,940.00
Jan 22 2021 09:45am
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_())
Member
Posts: 2,830
Joined: Mar 13 2011
Gold: 6,940.00
Jan 23 2021 05:47am
nevermind, figured it out
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll