Add option to allow opening multiple windows
This commit is contained in:
parent
01e77a5a0c
commit
9aba3ebf5e
18
BirdyNet.py
18
BirdyNet.py
@ -27,6 +27,7 @@ from qtpy.QtMultimedia import QSound
|
|||||||
import configparser
|
import configparser
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
browserWindows = []
|
||||||
|
|
||||||
os.chdir(sp)
|
os.chdir(sp)
|
||||||
distro = os.path.splitext(s.rsplit(os.path.sep)[-1])[0]
|
distro = os.path.splitext(s.rsplit(os.path.sep)[-1])[0]
|
||||||
@ -89,8 +90,10 @@ class browserWindow(QMainWindow):
|
|||||||
|
|
||||||
def cCreateElements(self):
|
def cCreateElements(self):
|
||||||
self.cMenuBar = self.menuBar()
|
self.cMenuBar = self.menuBar()
|
||||||
self.cFileMenu = self.cMenuBar.addMenu("File")
|
self.cFileMenu = self.cMenuBar.addMenu("&File")
|
||||||
self.cViewMenu = self.cMenuBar.addMenu("View")
|
self.cNewWindowButton = self.cFileMenu.addAction("New &window")
|
||||||
|
self.cNewWindowButton.triggered.connect(self.cNewWindow)
|
||||||
|
self.cViewMenu = self.cMenuBar.addMenu("&View")
|
||||||
|
|
||||||
self.cUrlBar = QLineEdit(config["default"]["home"],self)
|
self.cUrlBar = QLineEdit(config["default"]["home"],self)
|
||||||
self.cUrlBar.returnPressed.connect(self.cNavigate)
|
self.cUrlBar.returnPressed.connect(self.cNavigate)
|
||||||
@ -126,6 +129,10 @@ class browserWindow(QMainWindow):
|
|||||||
self.cHeight = self.height()
|
self.cHeight = self.height()
|
||||||
self.cResizeElements()
|
self.cResizeElements()
|
||||||
|
|
||||||
|
def closeEvent(self,event):
|
||||||
|
browserWindows.remove(self)
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def cNavigate(self,event = None):
|
def cNavigate(self,event = None):
|
||||||
try:
|
try:
|
||||||
#print(prettyJson(parseUrl(self.cUrlBar.text())))
|
#print(prettyJson(parseUrl(self.cUrlBar.text())))
|
||||||
@ -153,6 +160,11 @@ class browserWindow(QMainWindow):
|
|||||||
self.cDoc.cRenderHtml(str(e))
|
self.cDoc.cRenderHtml(str(e))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def cNewWindow(self):
|
||||||
|
w = browserWindow()
|
||||||
|
browserWindows.append(w)
|
||||||
|
w.show()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# load program default addons
|
# load program default addons
|
||||||
addonDir = p(sp,"addons")
|
addonDir = p(sp,"addons")
|
||||||
@ -183,7 +195,7 @@ def main():
|
|||||||
app.setWindowIcon(QtGui.QIcon("assets/BirdyNet-XP.ico"))
|
app.setWindowIcon(QtGui.QIcon("assets/BirdyNet-XP.ico"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Could not set window icon: " +print(e))
|
print("Could not set window icon: " +print(e))
|
||||||
window = browserWindow()
|
browserWindows.append(browserWindow())
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user