Esempio n. 1
0
    def graph(self):
        """ Loads a Graph instance into main window """
        self.main_window.close()
        self.main_window = Graph()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()
Esempio n. 2
0
    def nonogram(self):
        """ Loads a Nonogram instance into main window """
        self.main_window.close()
        self.main_window = Nonogram()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()
Esempio n. 3
0
    def navigation(self):
        """ Loads a Navigation instance into main window """
        self.main_window.close()
        self.main_window = Navigation()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()
Esempio n. 4
0
class App(object):
    """ Loads a navigation window as default, and lets the user choose between
    all the different modules from the course """
    def __init__(self, qt_app):
        self.qt_app = qt_app
        self.main_window = Play2048()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()

    def navigation(self):
        """ Loads a Navigation instance into main window """
        self.main_window.close()
        self.main_window = Navigation()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()

    def graph(self):
        """ Loads a Graph instance into main window """
        self.main_window.close()
        self.main_window = Graph()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()

    def nonogram(self):
        """ Loads a Nonogram instance into main window """
        self.main_window.close()
        self.main_window = Nonogram()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()

    def play_2048(self):
        """ Loads a Nonogram instance into main window """
        self.main_window.close()
        self.main_window = Play2048()
        self.qt_app.setActiveWindow(self.main_window)

        self.add_switcher_menu()

    def add_switcher_menu(self):
        """ Adds the following items to the menubar:
         Modules -> [ Navigation, Graphs, Nonograms ]
        """
        navigation_action = QtGui.QAction('&Navigation', self.main_window)
        navigation_action.triggered.connect(self.navigation)

        graph_action = QtGui.QAction('&Graphs', self.main_window)
        graph_action.triggered.connect(self.graph)

        nonogram_action = QtGui.QAction('&Nonograms', self.main_window)
        nonogram_action.triggered.connect(self.nonogram)

        play_2048_action = QtGui.QAction('&2048', self.main_window)
        play_2048_action.triggered.connect(self.play_2048)

        menu = self.main_window.menuBar()
        module_menu = menu.addMenu('&Modules')
        module_menu.addAction(navigation_action)
        module_menu.addAction(graph_action)
        module_menu.addAction(nonogram_action)
        module_menu.addAction(play_2048_action)