Simplify the calling of the application. Remove unneeded label.
This commit is contained in:
parent
c3bb8b453d
commit
a4e22c1f9b
|
@ -1,30 +1,31 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from PySide.QtCore import QCoreApplication
|
||||||
from PySide.QtGui import QWidget, QApplication, QLabel, QPushButton, QDesktopWidget, QVBoxLayout
|
from PySide.QtGui import QWidget, QApplication, QLabel, QPushButton, QDesktopWidget, QVBoxLayout
|
||||||
|
|
||||||
|
|
||||||
class MenuScreen(QWidget):
|
class MenuScreen(QWidget):
|
||||||
# TODO Divide up into separate widgets for the window and its contents.
|
# TODO Divide up into separate widgets for the window and its contents.
|
||||||
# TODO Figure out testing mechanism for PySide UIs.
|
# TODO Setup functional testing with PySide.QtTest
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self):
|
||||||
super(MenuScreen, self).__init__()
|
super(MenuScreen, self).__init__()
|
||||||
self.setWindowTitle('justCheckers')
|
self.setWindowTitle('justCheckers')
|
||||||
self.setGeometry(300, 300, 800, 600)
|
self.setGeometry(300, 300, 800, 600)
|
||||||
self.setup_components()
|
self.setup_components()
|
||||||
self.app = app
|
|
||||||
self.center()
|
self.center()
|
||||||
|
|
||||||
def setup_components(self):
|
def setup_components(self):
|
||||||
self.systemLabel = QLabel(self.get_system_info(), self)
|
"""Setup the components that make up the widget."""
|
||||||
self.exitButton = QPushButton('Exit', self)
|
print(self.get_system_info())
|
||||||
self.exitButton.clicked.connect(self.exit_app)
|
self.exit_button = QPushButton('Exit', self)
|
||||||
|
self.exit_button.clicked.connect(self.exit_app)
|
||||||
|
|
||||||
widget_layout = QVBoxLayout(self)
|
widget_layout = QVBoxLayout(self)
|
||||||
widget_layout.addWidget(self.systemLabel)
|
widget_layout.addWidget(self.systemLabel)
|
||||||
widget_layout.addStretch()
|
widget_layout.addStretch()
|
||||||
widget_layout.addWidget(self.exitButton)
|
widget_layout.addWidget(self.exit_button)
|
||||||
widget_layout.addStretch()
|
widget_layout.addStretch()
|
||||||
self.setLayout(widget_layout)
|
self.setLayout(widget_layout)
|
||||||
|
|
||||||
|
@ -44,13 +45,14 @@ class MenuScreen(QWidget):
|
||||||
self.move(widget_rectangle.topLeft())
|
self.move(widget_rectangle.topLeft())
|
||||||
|
|
||||||
def exit_app(self):
|
def exit_app(self):
|
||||||
self.app.quit()
|
"""Exits the application."""
|
||||||
|
QCoreApplication.instance().exit()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# TODO Should be moved out into a separate module
|
# TODO Should be moved out into a separate module
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
view = MenuScreen(app)
|
view = MenuScreen()
|
||||||
view.show()
|
view.show()
|
||||||
app.exec_()
|
app.exec_()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Reference in New Issue