예제 #1
0
    def test_view(self):
        view = MVC.View()
        controller = ControllerMock(view)
        view.register(controller)

        self.assertIs(view.answer_button, None,
                      "The answer button should not be set.")
        self.assertIs(view.continue_button, None,
                      "The continue button should not be set.")
        view.new_question("Test", ["correct", "incorrect"])

        self.assertIsNot(view.answer_button, None,
                         "The answer button should be set.")
        self.assertIs(view.continue_button, None,
                      "The continue button should not be set.")
        # simulate a button press
        view.answer_button.invoke()
        self.assertIs(view.answer_button, None,
                      "The answer button should not be set.")
        self.assertIsNot(view.continue_button, None,
                         "The continue button should be set.")

        self.assertEqual(controller.question, "Test",
                         "The question asked should be \"Test\".")
        self.assertEqual(controller.answer, "correct",
                         "The answer given should be \"correct\".")

        # continue
        view.continue_button.invoke()
        self.assertIsNot(view.answer_button, None,
                         "The answer button should be set.")
        self.assertIs(view.continue_button, None,
                      "The continue button should not be set.")
예제 #2
0
from PIL import ImageTk, Image
from tkinter import Tk, filedialog, simpledialog, Frame, LabelFrame, Label, Button, Menu
import platform
import csv
import MVC
import threading
# Root window created, can add more later
# windows within windows.
root = Tk()
c = MVC.Controller(MVC.Model(), MVC.View())


class Window(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.master = master
        self.init_window()

    # Creation of init_window
    def init_window(self):

        # changing the title of our master widget
        self.master.title("GUI")


def popup():
    S1 = simpledialog.askstring('Input file name', 'file name')
    # prints the string typed in by the user, make a funtion to save the file by that name.
    print(S1)
    if platform.system() == 'Windows':
        newline = ''