class NewProject(QtGui.QWidget): def __init__(self, session, lastWidget): super(NewProject, self).__init__() self.session = session self.setWindowTitle("New Project") self.lastWidget = lastWidget self.widgetLayout = QtGui.QGridLayout() self.setLayout(self.widgetLayout) self.widgetLayout.setRowMinimumHeight(2, 7) self.projectNameLabel = QtGui.QLabel() self.projectNameLabel.setText("Project Name:") self.widgetLayout.addWidget(self.projectNameLabel, 1, 1) self.projectNameLineEdit = QtGui.QLineEdit() self.widgetLayout.addWidget(self.projectNameLineEdit, 1, 3, 1, 3) self.cancelButton = QtGui.QPushButton() self.cancelButton.setText("Cancel") self.widgetLayout.addWidget(self.cancelButton, 3, 3) self.okButton = QtGui.QPushButton() self.okButton.setText("OK") self.okButton.setDefault(True) self.widgetLayout.addWidget(self.okButton, 3, 5) self.setFixedSize(self.sizeHint()) self.frameGeometry = self.frameGeometry() desktopGeometry = QtGui.QDesktopWidget().availableGeometry().center() self.frameGeometry.moveCenter(desktopGeometry) self.move(self.frameGeometry.topLeft()) QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), self.createNewProject) QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), self.showLastScreen) def createNewProject(self): newProject = self.session.createProject( self.projectNameLineEdit.text()) self.session.workspace.persFacade.persistproject(newProject) self.MainWindow = QtGui.QMainWindow() self.mainWindow_ui = Ui_MainWindow() self.mainWindow_ui.setupUi(self.MainWindow, self.session) self.deleteLater() self.lastWidget.deleteLater() self.MainWindow.show() def showLastScreen(self): self.hide() self.lastWidget.show()
class NewProject(QtGui.QWidget): def __init__(self, session, lastWidget): super(NewProject, self).__init__() self.session = session self.setWindowTitle("New Project") self.lastWidget = lastWidget self.widgetLayout = QtGui.QGridLayout() self.setLayout(self.widgetLayout) self.widgetLayout.setRowMinimumHeight(2, 7) self.projectNameLabel = QtGui.QLabel() self.projectNameLabel.setText("Project Name:") self.widgetLayout.addWidget(self.projectNameLabel, 1, 1) self.projectNameLineEdit = QtGui.QLineEdit() self.widgetLayout.addWidget(self.projectNameLineEdit, 1, 3, 1, 3) self.cancelButton = QtGui.QPushButton() self.cancelButton.setText("Cancel") self.widgetLayout.addWidget(self.cancelButton, 3, 3) self.okButton = QtGui.QPushButton() self.okButton.setText("OK") self.okButton.setDefault(True) self.widgetLayout.addWidget(self.okButton, 3, 5) self.setFixedSize(self.sizeHint()) self.frameGeometry = self.frameGeometry() desktopGeometry = QtGui.QDesktopWidget().availableGeometry().center() self.frameGeometry.moveCenter(desktopGeometry) self.move(self.frameGeometry.topLeft()) QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), self.createNewProject) QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), self.showLastScreen) def createNewProject(self): newProject = self.session.createProject(self.projectNameLineEdit.text()) self.session.workspace.persFacade.persistproject(newProject) self.MainWindow = QtGui.QMainWindow() self.mainWindow_ui = Ui_MainWindow() self.mainWindow_ui.setupUi(self.MainWindow, self.session) self.deleteLater() self.lastWidget.deleteLater() self.MainWindow.show() def showLastScreen(self): self.hide() self.lastWidget.show()
class StartUpScreen(QtGui.QWidget): def __init__(self): super(StartUpScreen, self).__init__() self.startUpScreenLayout = QtGui.QGridLayout() self.setLayout(self.startUpScreenLayout) self.setWindowTitle("AstroPhoto") self.session = workflow.Session() self.session.workspace.load() self.loadProjectLabel = QtGui.QLabel() self.loadProjectLabel.setText("Load Project") self.startUpScreenLayout.addWidget(self.loadProjectLabel, 1, 1) self.projectList = QtGui.QListWidget() self.startUpScreenLayout.addWidget(self.projectList, 2, 1, 1, 3) for project in self.session.workspace.projectList: self.projectList.addItem(project.name) self.loadProjectButton = QtGui.QPushButton() self.loadProjectButton.setText("Load Project") self.startUpScreenLayout.addWidget(self.loadProjectButton, 3, 3) self.openNewProjectButton = QtGui.QPushButton() self.openNewProjectButton.setText("New Project") self.startUpScreenLayout.addWidget(self.openNewProjectButton, 4, 3) self.cancelButton = QtGui.QPushButton() self.cancelButton.setText("Cancel") self.startUpScreenLayout.addWidget(self.cancelButton, 4, 2) self.setFixedSize(self.sizeHint()) self.frameGeometry = self.frameGeometry() desktopGeometry = QtGui.QDesktopWidget().availableGeometry().center() self.frameGeometry.moveCenter(desktopGeometry) self.move(self.frameGeometry.topLeft()) QtCore.QObject.connect(self.openNewProjectButton, QtCore.SIGNAL("clicked()"), self.newProject) QtCore.QObject.connect(self.loadProjectButton, QtCore.SIGNAL("clicked()"), self.loadProject) QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), sys.exit) def newProject(self): self.newProject = NewProject(self.session, self) self.hide() self.newProject.show() def loadProject(self): for project in self.session.workspace.projectList: if project.name == self.projectList.currentItem().text(): self.session.currentProject = project from astrophoto.gui.MainWindow import Ui_MainWindow self.MainWindow = MainFrame(self.session) self.mainWindow_ui = Ui_MainWindow() self.mainWindow_ui.setupUi(self.MainWindow, self.session) self.MainWindow.show() self.mainWindow_ui.planWidget.loadProject() self.mainWindow_ui.spectralWidget.loadAllSpectralColourWidgets() self.hide() self.deleteLater()