示例#1
0
    def __init__(self,app):
        #Needs access to the app use open method
        self.app = app
        tdStyle = {'padding':10}

        #The controlled variables
        lbl1 = gui.Label("The equations below show the line the equation for the graph")
        dataTbl = gui.Table()
        dataTbl.tr()
        dataTbl.td(lbl1)

        #The equation needed
        equationImg = gui.Image(resM.absoluteZero)
        imgTable = gui.Table()
        imgTable.td(gui.Image(resM.measuregEquation))

        #The question
        questionLbl = gui.Label("What is g to 2dp?")
        questionTable = gui.Table()
        questionTable.tr()
        questionTable.td(questionLbl)

        #The Options for answers
        answerTbl = gui.Table()
        gLbl = gui.Label("g")
        gAns = gui.Input()
        answerTbl.tr()
        answerTbl.td(gLbl)
        answerTbl.td(gAns,style = tdStyle)



        #Checking User Answers
        checkAnswerBtn = gui.Button("Check Answer",width=100,height=30)

        def checkAnswer():
            if gAns.value == "9.81":
                dlg = gui.Dialog(gui.Label("Your answer was..."),gui.Label("Correct. Well Done"))
            else:
                dlg = gui.Dialog(gui.Label("Your answer was..."),gui.Label("Wrong. Try Again"))

            self.app.open(dlg)

        checkAnswerBtn.connect(gui.CLICK,checkAnswer)

        #Adding the labels to the table
        tbl = gui.Table()
        tbl.tr()
        tbl.td(dataTbl,style = tdStyle)
        tbl.tr()
        tbl.td(imgTable,style = tdStyle)
        tbl.tr()
        tbl.td(questionTable,style = tdStyle)
        tbl.tr()
        tbl.td(answerTbl,style = tdStyle)
        tbl.tr()
        tbl.td(checkAnswerBtn,style = tdStyle)


        gui.Dialog.__init__(self,gui.Label("Question"),tbl)
示例#2
0
def createButton(imgName, text):
    splitText = textwrap.wrap(
        text, width=30)  # Splits text and sets width of line to 30 characters

    #Loads Image
    img = pygame.image.load(imgName)
    #Stretches Image keeping height:width ratio constant
    height = int(250 * img.get_height() / img.get_width())
    img = pygame.transform.scale(img, (250, height))

    #If the image is too tall
    if img.get_height() > 80:
        #Resize with max height
        height = 80
        width = int(height * img.get_width() / img.get_height())
        img = pygame.transform.scale(img, (width, height))

    #Add Image and label to table
    main = gui.Table()
    main.tr()
    main.td(gui.Image(img))
    for each in splitText:  # Puts each line in a label then adds it to the widget
        main.tr()
        main.td(gui.Label(each))

    return gui.Button(main, height=130, width=250)
示例#3
0
    def __init__(self, xPoints, yPoints):
        gradient, yIntercept = graph.createGraph(xPoints, yPoints,
                                                 "Current Length/cm",
                                                 "Resistance/Ω")
        gradientLbl = gui.Label("Gradient:" + str(round(gradient, 3)))
        yInterceptLbl = gui.Label("Y-Intercept:" + str(round(yIntercept, 3)))

        tbl = gui.Table()
        tbl.tr()
        tbl.td(gui.Image("graph.png"))
        tbl.tr()
        tbl.td(gradientLbl)
        tbl.tr()
        tbl.td(yInterceptLbl)

        gui.Dialog.__init__(self, gui.Label("Graph"), tbl)
示例#4
0
    def __init__(self,table):
        self.tableArea = table
        xPoints = self.tableArea.xPoints
        yPoints = self.tableArea.yPoints
        gradient,yIntercept = graph.createGraph(xPoints,yPoints,"Height/m","Time²/s²")
        gradientLbl = gui.Label("Gradient:" + str(round(gradient,6)))
        yInterceptLbl = gui.Label("Y-Intercept:" + str(round(yIntercept,3)))

        tbl = gui.Table()
        tbl.tr()
        tbl.td(gui.Image("graph.png"))
        tbl.tr()
        tbl.td(gradientLbl)
        tbl.tr()
        tbl.td(yInterceptLbl)

        gui.Dialog.__init__(self,gui.Label("Graph"),tbl)
示例#5
0
    def __init__(self,table):
        self.tableArea = table
        xPoints = self.tableArea.xPoints
        yPoints = self.tableArea.yPoints
        gradient,yIntercept = graph.createGraph(xPoints,yPoints,"Weight Force of Mass Holder/N","Acceleration/(m/s²)")
        gradientLbl = gui.Label("Gradient:" + str(round(gradient,6)))
        yInterceptLbl = gui.Label("Y-Intercept:" + str(round(yIntercept,3)))

        tbl = gui.Table()
        tbl.tr()
        tbl.td(gui.Image("graph.png"))
        tbl.tr()
        tbl.td(gradientLbl)
        tbl.tr()
        tbl.td(yInterceptLbl)

        gui.Dialog.__init__(self,gui.Label("Graph"),tbl)
示例#6
0
    def __init__(self,table):
        self.tableArea = table
        xPoints = self.tableArea.xPoints
        yPoints = self.tableArea.yPoints
        gradient,yIntercept = graph.createGraph(xPoints,yPoints,"Temperature/°C","Pressure/kPa")
        gradientLbl = gui.Label("Gradient:" + str(round(gradient,3)))
        yInterceptLbl = gui.Label("Y-Intercept:" + str(round(yIntercept,3)))

        tbl = gui.Table()
        tbl.tr()
        tbl.td(gui.Image("graph.png"))
        tbl.tr()
        tbl.td(gradientLbl)
        tbl.tr()
        tbl.td(yInterceptLbl)

        gui.Dialog.__init__(self,gui.Label("Graph"),tbl)
示例#7
0
    def setup(self):
        #Get Variables
        cartWeights = self.app.engine.cartWeights
        massHolderWeights = self.app.engine.massHolderWeights
        weightSize = self.app.engine.weightSize

        cellStyle = {'border': 1}  #Sets border for each cell

        self.tr()
        self.td(gui.Label("Weight Force on Mass Holder/kg"),
                style=cellStyle)  #First Table heading
        while cartWeights >= 0:
            #Adds each weight which the mass holder will have on it
            weightInKg = massHolderWeights * weightSize
            lbl = gui.Label(str(round(weightInKg, 2)))
            self.td(lbl, style=cellStyle)
            #Shifts weight from cart to massHolder
            cartWeights -= 1
            massHolderWeights += 1

        #Renew Variables
        cartWeights = self.app.engine.cartWeights
        massHolderWeights = self.app.engine.massHolderWeights
        weightSize = self.app.engine.weightSize

        self.tr()
        self.td(gui.Label("Weight Force of Mass Holder/N"),
                style=cellStyle)  #2nd Table Header
        while cartWeights >= 0:
            #Adds Weight Force for Mass Holder
            weightInN = massHolderWeights * weightSize * 9.81
            self.xPoints.append(weightInN)
            lbl = gui.Label(str(round(weightInN, 3)))
            self.td(lbl, style=cellStyle)
            cartWeights -= 1
            massHolderWeights += 1

        #Adds columns for velocities and acceleration equation
        self.tr()
        self.td(gui.Label("Initial Velocity/(m/s)"), style=cellStyle)
        self.tr()
        self.td(gui.Label("Final Velocity/(m/s)"), style=cellStyle)
        self.tr()
        self.td(gui.Image(resM.accelerationEquation, height=48, width=84),
                style=cellStyle)
示例#8
0
    def __init__(self,tableArea):

        firstGraph = tableArea.exponentialGraph
        secondGraph = tableArea.lnGraph
        firstGraph.drawGraph(True)
        secondGraph.drawGraph(False)

        s1 = self.createSection(firstGraph,True)
        s2 = self.createSection(secondGraph,False)

        subTbl = gui.Table(width = 640)
        subTbl.tr()
        subTbl.td(s1)
        subTbl.td(s2)


        tbl = gui.Table()
        tbl.tr()
        tbl.td(gui.Image("graphs.png"))
        tbl.tr()
        tbl.td(subTbl)

        gui.Dialog.__init__(self,gui.Label("Graphs"),tbl)
示例#9
0
    def __init__(self):

        instructions = """<p>
         1. Look at the Instructions Dialog<br>
         2. Input your variables<br>
         3. Click start experiment to begin the animation<br>
         4. While the animation is running, you can pause it by using the pause button or toggle labels using the show labels button<br>
         5. Once all the values in the table have been filled in, try and plot the graph<br>
         6. After plotting the graph yourself, you can look at the graph that should have been plotted<br>
         7. Finally answer the question to see if you have understood the experiment correctly<br>
         </p>
         """
        #Adding the method to the document which html
        doc = html.HTML(instructions, width=800)

        tbl = gui.Table()

        tbl.tr()
        tbl.td(gui.Image(resourceManager.exampleExperiment))
        tbl.tr()
        tbl.td(doc)
        #tbl.td(instructions)

        gui.Dialog.__init__(self, gui.Label("Help"), tbl)
示例#10
0
def generateLayout(app):
    pygame.font.init()
    font = pygame.font.SysFont("cambria", 60)
    text = font.render("Main Menu", True, (0, 128, 0))

    menuTable = gui.Table(width=800, height=600)

    btnStyle = {"padding": 10}

    def help_cb():
        dlg = HelpDialog()
        dlg.open()

    help = gui.Button("Help", height=50, width=100)
    help.connect(gui.CLICK, help_cb)

    menuTable.tr()
    menuTable.td(gui.Label(""))
    menuTable.td(gui.Image(text))
    menuTable.td(help)
    menuTable.tr()

    def btn1_cb():
        import Experiments.ResistivityOfAMetal.experiment as e
        e.run()

    btn1 = createButton(resourceManager.menuResistivity,
                        "Determination of the Resistivity of a Metal")
    menuTable.td(btn1, style=btnStyle)
    btn1.connect(gui.CLICK, btn1_cb)

    def btn2_cb():
        import Experiments.InternalResistance.experiment as e
        e.run()

    btn2 = createButton(resourceManager.menuInternalResistance,
                        "Determination of the Internal Resistance of a Cell")
    menuTable.td(btn2, style=btnStyle)
    btn2.connect(gui.CLICK, btn2_cb)

    def btn3_cb():
        import Experiments.EstimateAbsoluteZero.experiment as e
        e.run()

    btn3 = createButton(resourceManager.menuAbsoluteZero,
                        "Estimation of Absolute Zero by Use of the Gas Laws")
    menuTable.td(btn3, style=btnStyle)
    btn3.connect(gui.CLICK, btn3_cb)

    menuTable.tr()

    def btn4_cb():
        import Experiments.Newtons2ndLaw.experiment as e
        e.run()

    btn4 = createButton(resourceManager.menuNewtons2ndLaw,
                        "Investigation of Newton's 2nd Law")
    menuTable.td(btn4, style=btnStyle)
    btn4.connect(gui.CLICK, btn4_cb)

    def btn5_cb():
        import Experiments.RadioactiveDecay.experiment as e
        e.run()

    btn5 = createButton(resourceManager.menuRadioactiveDecay,
                        "Investigation of Radioactive Decay")
    menuTable.td(btn5, style=btnStyle)
    btn5.connect(gui.CLICK, btn5_cb)

    def btn6_cb():
        import Experiments.Measureg.experiment as e
        e.run()

    btn6 = createButton(resourceManager.menugByFrefall,
                        "Measurement of g by free-fall")
    menuTable.td(btn6, style=btnStyle)
    btn6.connect(gui.CLICK, btn6_cb)

    menuTable.tr()

    def btn7_cb():
        import Experiments.SHCofSolid.experiment as e
        e.run()

    btn7 = createButton(
        resourceManager.menuSHC,
        "Measurement of the Specific Heat Capacity for a Solid")
    menuTable.td(btn7, col=1, style=btnStyle)
    btn7.connect(gui.CLICK, btn7_cb)

    return menuTable
示例#11
0
    def __init__(self,app):
        #Needs access to the app use open method
        self.app = app
        tdStyle = {'padding':10}

        #The controlled variables
        lbl1 = gui.Label("The equations below show the line the equation for the graph")
        dataTbl = gui.Table()
        dataTbl.tr()
        dataTbl.td(lbl1)

        #The equation needed
        equationImg = gui.Image(resM.radioactiveDecayEquations)
        imgTable = gui.Table()
        imgTable.td(equationImg)

        #The question
        questionLbl = gui.Label("Which radioactive isotope was used in this experiment?")
        questionTable = gui.Table()
        questionTable.tr()
        questionTable.td(questionLbl)

        #The Options for answers
        optionsTbl = gui.Table()
        optionsGroup = gui.Group()
        correctAnswer = gui.Label("Fermium - 252")
        correctAnswerCheckBox = gui.Radio(optionsGroup,value=1)
        incorrectAnswer1 = gui.Label("Gold - 196")
        incorrectAnswer1CheckBox = gui.Radio(optionsGroup,value=2)
        incorrectAnswer2 = gui.Label("Uranium - 236")
        incorrectAnswer2CheckBox = gui.Radio(optionsGroup,value=3)

        tdStyle = {'padding':10}
        optionsTbl.td(incorrectAnswer1,style = tdStyle)
        optionsTbl.td(incorrectAnswer2,style = tdStyle)
        optionsTbl.td(correctAnswer,style = tdStyle)
        optionsTbl.tr()
        optionsTbl.td(incorrectAnswer1CheckBox)
        optionsTbl.td(incorrectAnswer2CheckBox)
        optionsTbl.td(correctAnswerCheckBox)



        #Checking User Answers
        checkAnswerBtn = gui.Button("Check Answer",width=100,height=30)

        def checkAnswer():
            if optionsGroup.value == 1:
                dlg = gui.Dialog(gui.Label("Your answer was..."),gui.Label("Correct. Well Done"))
            else:
                dlg = gui.Dialog(gui.Label("Your answer was..."),gui.Label("Wrong. Try Again"))

            self.app.open(dlg)

        checkAnswerBtn.connect(gui.CLICK,checkAnswer)

        #Adding the labels to the table
        tbl = gui.Table()
        tbl.tr()
        tbl.td(dataTbl,style = tdStyle)
        tbl.tr()
        tbl.td(imgTable,style = tdStyle)
        tbl.tr()
        tbl.td(questionTable,style = tdStyle)
        tbl.tr()
        tbl.td(optionsTbl,style = tdStyle)
        tbl.tr()
        tbl.td(checkAnswerBtn,style = tdStyle)


        gui.Dialog.__init__(self,gui.Label("Question"),tbl)
示例#12
0
    def __init__(self, app):
        #Needs access to the app use open method
        self.app = app
        #The controlled variables
        materialLbl = gui.Label("Material: Constantan")
        CSALbl = gui.Label("Cross-Sectional Area: 2.01 x 10^-8")
        voltageLbl = gui.Label("Voltage:" + str(exp.voltage) + "V")
        dataTbl = gui.Table()
        dataTbl.tr()
        dataTbl.td(materialLbl)
        dataTbl.tr()
        dataTbl.td(CSALbl)
        dataTbl.tr()
        dataTbl.td(voltageLbl)

        #The equation needed

        equationImg = gui.Image(resM.resistivityEquations,
                                width=210,
                                height=150)
        defintionsImg = gui.Image(resM.resistivityDefinitions,
                                  width=210,
                                  height=150)
        imgTable = gui.Table()
        imgTable.td(equationImg)
        imgTable.td(defintionsImg)

        #The question
        questionLbl = gui.Label(
            "Find the resistivity of constantan using the equation above and the gradient of the graph"
        )
        answerPrompt = gui.Label(
            "Select one of the options below then click answer")
        questionTable = gui.Table()
        questionTable.tr()
        questionTable.td(questionLbl)
        questionTable.tr()
        questionTable.td(answerPrompt)

        #The Options for answers
        optionsTbl = gui.Table()
        optionsGroup = gui.Group()
        correctAnswer = gui.Label("4.9 x 10^-7 Ωm")
        correctAnswerCheckBox = gui.Radio(optionsGroup, value=1)
        incorrectAnswer1 = gui.Label("6.7 x 10 ^ -11 Ωm")
        incorrectAnswer1CheckBox = gui.Radio(optionsGroup, value=2)
        incorrectAnswer2 = gui.Label("2.2 x 10 ^ -9 Ωm")
        incorrectAnswer2CheckBox = gui.Radio(optionsGroup, value=3)

        tdStyle = {'padding': 10}
        optionsTbl.td(correctAnswer, style=tdStyle)
        optionsTbl.td(incorrectAnswer1, style=tdStyle)
        optionsTbl.td(incorrectAnswer2, style=tdStyle)
        optionsTbl.tr()
        optionsTbl.td(correctAnswerCheckBox)
        optionsTbl.td(incorrectAnswer1CheckBox)
        optionsTbl.td(incorrectAnswer2CheckBox)

        #Checking User Answers
        checkAnswerBtn = gui.Button("Check Answer", width=100, height=30)

        def checkAnswer():
            if optionsGroup.value == 1:
                dlg = gui.Dialog(gui.Label("Your answer was..."),
                                 gui.Label("Correct. Well Done"))
            else:
                dlg = gui.Dialog(gui.Label("Your answer was..."),
                                 gui.Label("Wrong. Try Again"))

            self.app.open(dlg)

        checkAnswerBtn.connect(gui.CLICK, checkAnswer)

        #Adding the labels to the table
        tbl = gui.Table()
        tbl.tr()
        tbl.td(dataTbl, style=tdStyle)
        tbl.tr()
        tbl.td(imgTable, style=tdStyle)
        tbl.tr()
        tbl.td(questionTable, style=tdStyle)
        tbl.tr()
        tbl.td(optionsTbl, style=tdStyle)
        tbl.tr()
        tbl.td(checkAnswerBtn, style=tdStyle)

        gui.Dialog.__init__(self, gui.Label("Question"), tbl)
示例#13
0
 def __init__(self, experimentDone):
     if experimentDone:
         msg = gui.Image(pygame.image.load("graphImg.png"))
     else:
         msg = gui.Label("Complete the experiment first")
     gui.Dialog.__init__(self, gui.Label("Graph"), msg)
示例#14
0
    def __init__(self,app):
        #Needs access to the app use open method
        self.app = app
        tdStyle = {'padding':10}

        #The controlled variables
        lbl1 = gui.Label("The equations below show the line the equation for the graph")
        dataTbl = gui.Table()
        dataTbl.tr()
        dataTbl.td(lbl1)

        #The equation needed
        equationImg = gui.Image(resM.absoluteZero)
        imgTable = gui.Table()
        imgTable.td(gui.Image(resM.newtons2ndLawEquation))

        #The question
        questionLbl = gui.Label("What does the k represent?")
        questionTable = gui.Table()
        questionTable.tr()
        questionTable.td(questionLbl)

        #The Options for answers
        optionsTbl = gui.Table()
        optionsGroup = gui.Group()
        correctAnswer = gui.Label("1/(M+m)")
        correctAnswerCheckBox = gui.Radio(optionsGroup,value=1)
        incorrectAnswer1 = gui.Label("M+m")
        incorrectAnswer1CheckBox = gui.Radio(optionsGroup,value=2)
        incorrectAnswer2 = gui.Label("M")
        incorrectAnswer2CheckBox = gui.Radio(optionsGroup,value=3)

        tdStyle = {'padding':10}
        optionsTbl.td(incorrectAnswer1,style = tdStyle)
        optionsTbl.td(incorrectAnswer2,style = tdStyle)
        optionsTbl.td(correctAnswer,style = tdStyle)
        optionsTbl.tr()
        optionsTbl.td(incorrectAnswer1CheckBox)
        optionsTbl.td(incorrectAnswer2CheckBox)
        optionsTbl.td(correctAnswerCheckBox)



        #Checking User Answers
        checkAnswerBtn = gui.Button("Check Answer",width=100,height=30)

        def checkAnswer():
            if optionsGroup.value == 1:
                dlg = gui.Dialog(gui.Label("Your answer was..."),gui.Label("Correct. Well Done"))
            else:
                dlg = gui.Dialog(gui.Label("Your answer was..."),gui.Label("Wrong. Try Again"))

            self.app.open(dlg)

        checkAnswerBtn.connect(gui.CLICK,checkAnswer)

        #Adding the labels to the table
        tbl = gui.Table()
        tbl.tr()
        tbl.td(dataTbl,style = tdStyle)
        tbl.tr()
        tbl.td(imgTable,style = tdStyle)
        tbl.tr()
        tbl.td(questionTable,style = tdStyle)
        tbl.tr()
        tbl.td(optionsTbl,style = tdStyle)
        tbl.tr()
        tbl.td(checkAnswerBtn,style = tdStyle)


        gui.Dialog.__init__(self,gui.Label("Question"),tbl)