From fbe968af73601444626896eae150ea18e86ea963 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 15 Dec 2013 20:33:43 +0100 Subject: [PATCH] Move main window logic to mainwindow.py --- qutebrowser/app.py | 50 ++++++++----------------------- qutebrowser/widgets/mainwindow.py | 29 ++++++++++++++++++ 2 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 qutebrowser/widgets/mainwindow.py diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 891dc0e17..ffd81fb7b 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -1,43 +1,17 @@ import sys -from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, QWidget) -from qutebrowser.widgets.statusbar import StatusBar -from qutebrowser.widgets.tabbar import TabWidget - -class TestWindow(QMainWindow): - def __init__(self): - super().__init__() - self.setObjectName(self.__class__.__name__) - - self.cwidget = QWidget(self) - self.cwidget.setObjectName("cwidget") - self.setCentralWidget(self.cwidget) - - self.vbox = QVBoxLayout(self.cwidget) - self.vbox.setObjectName("vbox") - self.vbox.setContentsMargins(0, 0, 0, 0) - self.vbox.setSpacing(0) - - self.tabs = TabWidget(self.cwidget) - self.tabs.setObjectName("tabs") - self.tab = QWidget() - self.tab2 = QWidget() - self.tab.setObjectName("tab") - self.tab2.setObjectName("tab2") - self.tabs.addTab(self.tab, "test") - self.tabs.addTab(self.tab2, "test2") - self.vbox.addWidget(self.tabs) - - self.status = StatusBar(self.cwidget) - self.status.lbl.setText("Hello World") - self.vbox.addWidget(self.status) - - #self.retranslateUi(MainWindow) - #self.tabWidget.setCurrentIndex(0) - #QtCore.QMetaObject.connectSlotsByName(MainWindow) - - self.show() +from PyQt5.QtWidgets import QWidget, QApplication +from qutebrowser.widgets.mainwindow import MainWindow def main(): app = QApplication(sys.argv) - tw = TestWindow() + mw = MainWindow() + + tab = QWidget() + tab2 = QWidget() + tab.setObjectName("tab") + tab2.setObjectName("tab2") + mw.tabs.addTab(tab, "test") + mw.tabs.addTab(tab2, "test2") + mw.show() + sys.exit(app.exec_()) diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py new file mode 100644 index 000000000..9ca2c4c28 --- /dev/null +++ b/qutebrowser/widgets/mainwindow.py @@ -0,0 +1,29 @@ +from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, QWidget) +from qutebrowser.widgets.statusbar import StatusBar +from qutebrowser.widgets.tabbar import TabWidget + +class MainWindow(QMainWindow): + def __init__(self): + super().__init__() + self.setObjectName(self.__class__.__name__) + + self.cwidget = QWidget(self) + self.cwidget.setObjectName("cwidget") + self.setCentralWidget(self.cwidget) + + self.vbox = QVBoxLayout(self.cwidget) + self.vbox.setObjectName("vbox") + self.vbox.setContentsMargins(0, 0, 0, 0) + self.vbox.setSpacing(0) + + self.tabs = TabWidget(self.cwidget) + self.tabs.setObjectName("tabs") + self.vbox.addWidget(self.tabs) + + self.status = StatusBar(self.cwidget) + self.status.lbl.setText("Hello World") + self.vbox.addWidget(self.status) + + #self.retranslateUi(MainWindow) + #self.tabWidget.setCurrentIndex(0) + #QtCore.QMetaObject.connectSlotsByName(MainWindow)