I have an HTML page which contains some <datalist>
elements.
I'm able to run it properly in Chrome but when running it using Python-PyQt5, the Datalist doesn't function as needed (It functions as a text-box i.e. the drop-down isn't displayed).
In Python I'm running it using PyQt5: load(QtCore.QUrl.fromLocalFile(filepath))
.
Where the filepath
is the path for index.html
.
I've gone through several articles and got to know that HTML Datalist isn't supported in Older Webkit Engines but found some workarounds like: Datalist-polyfill but they aren't working either.
Is there a workaround for this or Datalist is just not possible here?
HTML Code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<body>
<div id="formContainer">
<form id="mainForm">
<div class="form-label-group">
<input list="subject-area" name="subjectArea" class="form-control" placeholder="Select or Enter a Subject Area">
</div>
</form>
</div>
<div id="datalistContainer">
<datalist id="subject-area" class="form-control" style="display: none;">
<option value="Account" class="form-control">Account</option>
<option value="Adjustments" class="form-control">Adjustments</option>
<option value="Alliance Sales" class="form-control">Alliance Sales</option>
<option value="Assets" class="form-control">Assets</option>
<option value="Business Plan" class="form-control">Business Plan</option>
<option value="Calendar" class="form-control">Calendar</option>
<option value="Chargeback" class="form-control">Chargeback</option>
<option value="Company" class="form-control">Company</option>
</datalist>
</div>
</body>
Python Code:
import os
import sys
from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets
class WebPage(QtWebEngineWidgets.QWebEngineView):
def __init__(self, parent=None):
super().__init__(parent)
filepath = os.path.abspath(
os.path.join(os.path.dirname(__file__), "temp.html")
)
self.load(QtCore.QUrl.fromLocalFile(filepath))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
web = WebPage()
web.show()
sys.exit(app.exec_())
Note: The Python code is not yet updated. All I want to do is to get the datalist
working for now.