Got this to open a browser inside a specific frame, and i need it to be changeable, any ideas?
been readin pyqt5 but cant seem to manage this
import sys
from tkinter import Tk, ttk
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
mainwind = Tk()
w, h = mainwind.winfo_screenwidth(), mainwind.winfo_screenheight()
mainwind.geometry("%dx%d+0+0" % (w, h))
mainwind.title("browser")
url = "https://www.google.com"
def seturl(urlbtn):
url = urlbtn
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.browser = QWebEngineView()
self.browser.setUrl(QUrl(url))
self.setCentralWidget(self.browser)
self.showNormal()
# navbar
navbar = QToolBar()
self.addToolBar(navbar)
home_btn = QAction('Home', self)
home_btn.triggered.connect(self.navigate_home)
navbar.addAction(home_btn)
self.url_bar = QLineEdit()
self.url_bar.returnPressed.connect(self.navigate_to_url)
navbar.addWidget(self.url_bar)
self.browser.urlChanged.connect(self.update_url)
def navigate_home(self):
self.browser.setUrl(QUrl(url))
def navigate_to_url(self):
url = self.url_bar.text()
self.browser.setUrl(QUrl(url))
def update_url(self, q):
self.url_bar.setText(q.toString())
frm_window_left = ttk.Frame(mainwind)
frm_window_left.grid(column=0, row=0, rowspan=99)
frm_browser = ttk.Frame(mainwind)
frm_browser.grid(column=1, row=0, rowspan=99)
frm_window_right = ttk.Frame(mainwind)
frm_window_right.grid(column=2, row=0, rowspan=99)
ttk.Label(frm_window_left, text=":::::::::::::left:::::::::::::").grid(column=0, row=0, padx=10, pady=10)
ttk.Button(frm_window_left, text="url1_L", command=seturl("https://outlook.com/")).grid(column=0, row=1, padx=10,pady=10, ipady=35)
ttk.Button(frm_window_left, text="url2_L", command=seturl("https://www.Facebook.com")).grid(column=0, row=2, padx=10,pady=10, ipady=35)
ttk.Label(frm_browser, text="............................Browser Window Open Here................................\n\n\n\n\n\n\n\n\a").grid(column=0, row=0, padx=10, pady=10)
ttk.Label(frm_window_right, text=":::::::::::::right:::::::::::::").grid(column=0, row=0, padx=10, pady=10)
ttk.Button(frm_window_right, text="url1_R", command=seturl("https://www.google.com/")).grid(column=0, row=1, padx=10,pady=10, ipady=35)
ttk.Button(frm_window_right, text="url2_R", command=seturl("https://www.daniweb.com/")).grid(column=0, row=2, padx=10,pady=10, ipady=35)
app = QApplication(sys.argv)
window = MainWindow()
app.exec_()
thanks