Beispiel #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)
    def __init__(self, screen):
        super(Experiment, self).__init__(screen)
        gui.Desktop.__init__(self)
        self.connect(gui.QUIT, self.quit)

        self.engine = None
        self.animationAreaWidth = 650
        self.animationAreaHeight = 400
        self.animationArea = template.DrawingArea(self.animationAreaWidth,
                                                  self.animationAreaHeight)

        self.menuArea = areaObjects.MenuArea(
            screen.get_width() - self.animationAreaWidth,
            self.animationAreaHeight, self)

        self.tableArea = areaObjects.TableArea(screen.get_width(), 200, self)

        topTbl = gui.Table()
        topTbl.tr()
        topTbl.td(self.animationArea)
        topTbl.td(self.menuArea)
        screenTbl = gui.Table(height=screen.get_height(),
                              width=screen.get_width())

        screenTbl.tr()
        screenTbl.td(topTbl)
        screenTbl.tr()
        screenTbl.td(self.tableArea)

        self.init(screenTbl, screen)
Beispiel #3
0
    def __init__(self, disp):
        gui.Desktop.__init__(self)
        self.disp = disp
        self.startAnimation = False
        self.paused = False
        self.minVar, self.maxVar = None, None

        # Setup the 'game' area where the action takes place
        self.gameArea = DrawingArea(self.gameAreaWidth, self.gameAreaHeight)
        # Setup the gui area
        self.menuArea = gui.Container(width=disp.get_width() -
                                      self.gameAreaWidth,
                                      height=self.gameAreaHeight)

        self.tableArea = gui.Table(width=disp.get_width(), height=200)

        tbl = gui.Table(width=disp.get_width())
        tbl2 = gui.Table(width=self.gameAreaWidth)
        tbl2.tr()
        tbl2.td(self.gameArea)
        tbl2.td(self.menuArea)

        tbl.tr()
        tbl.td(tbl2)
        tbl.tr()
        tbl.td(self.tableArea)

        self.setupMenu()
        self.init(tbl, disp)
Beispiel #4
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)
Beispiel #5
0
    def createSection(self,graph,isExponential):
        graphDataTbl = gui.Table()
        gradient = graph.gradient
        graphDataTbl.td(gui.Label("Gradient:"))
        graphDataTbl.td(gui.Label(str(gradient)))
        graphDataTbl.tr()
        yInt = graph.yInt
        graphDataTbl.td(gui.Label("Y-Intercept:"))
        graphDataTbl.td(gui.Label(str(yInt)))

        tbl = gui.Table()
        tbl.tr()
        tbl.td(gui.Label(graph.graphName))
        if not isExponential:
            tbl.tr()
            tbl.td(graphDataTbl)

        return tbl
    def __init__(self, screen):
        gui.Desktop.__init__(self)
        self.connect(gui.QUIT, self.quit)

        self.disp = screen
        self.engine = None
        self.animationAreaWidth = 650
        self.animationAreaHeight = 400
        self.animationArea = DrawingArea(self.animationAreaWidth,
                                         self.animationAreaHeight)

        self.menuArea = MenuAreaTemplate(
            screen.get_width() - self.animationAreaWidth,
            self.animationAreaHeight, self)

        self.tableArea = TableAreaTemplate(screen.get_width(), 200, self)

        self.variablesInputted = False
        self.animationRunning = False
        self.showLabels = False
        self.experimentFinished = False

        self.minIV = None
        self.maxIV = None
        self.interval = None

        topTbl = gui.Table()
        topTbl.tr()
        topTbl.td(self.animationArea)
        topTbl.td(self.menuArea)
        screenTbl = gui.Table(height=screen.get_height(),
                              width=screen.get_width())

        screenTbl.tr()
        screenTbl.td(topTbl)
        screenTbl.tr()
        screenTbl.td(self.tableArea)

        self.menuArea.setup()

        self.init(screenTbl, screen)
Beispiel #7
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)
Beispiel #8
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)
Beispiel #9
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)
Beispiel #10
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)
Beispiel #11
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)
Beispiel #12
0
    def __init__(self):

        constantsLbl = gui.Label("Constants")
        batteryVoltageLbl = gui.Label("Battery Voltage = 1.5 Volts")
        wireAreaLbl = gui.Label("Wire Cross Sectional Area = 0.00785 cm²")
        wireTypeLbl = gui.Label("Wire Type = Nichrome")

        tbl = gui.Table()

        lblStyle = {'padding': 5}

        tbl.tr()
        tbl.td(constantsLbl, style=lblStyle)
        tbl.tr()
        tbl.td(batteryVoltageLbl, style=lblStyle)
        tbl.tr()
        tbl.td(wireAreaLbl, style=lblStyle)
        tbl.tr()
        tbl.td(wireTypeLbl, style=lblStyle)

        gui.Dialog.__init__(self, gui.Label("CONSTANTS"), tbl)
Beispiel #13
0
    def __init__(self,app):
        self.app = app
        menuBtn = gui.Button("Back to Menu",width = 200,height=50)

        restartBtn = gui.Button("Restart Experiment",width = 200,height=50)

        def restartExperimentBtn_cb():
            self.app.restart()

        restartBtn.connect(gui.CLICK, restartExperimentBtn_cb)

        def menuBtn_cb():
            import MainMenu as m
            m.run()

        menuBtn.connect(gui.CLICK, menuBtn_cb)
        tbl = gui.Table()
        tbl.tr()
        tbl.td(menuBtn)
        tbl.tr()
        tbl.td(restartBtn)

        gui.Dialog.__init__(self,gui.Label("Options"),tbl)
Beispiel #14
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)
Beispiel #15
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)
Beispiel #16
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)
Beispiel #17
0
    def __init__(self):
        #The method
        method = """<p>
         1. Set up the equipment as shown in the diagram<br>
         2. Release the ball from start height<br>
         3. Measure the time taken for the ball to drop to the floor<br>
         4. Increase the height by the your interval and repeat steps 2-3<br>
         5. After testing for the final height, plot a graph of height(x-axis) against t²(y-axis)<br>
         6. Use the gradient of the graph to determine g<br>
         </p>
         """
        #Adding the method to the document which html
        doc = html.HTML(method,width = 700)

        #Links to the useful websites
        link1 = "http://www.physicsclassroom.com/class/1DKin/Lesson-5/Representing-Free-Fall-by-Graphs"
        link2 = "http://www.physicsclassroom.com/class/1DKin/Lesson-5/Acceleration-of-Gravity"
        link3 = "http://practicalphysics.org/investigating-free-fall-light-gate.html"
        pdf = "file:///D:/My%20Docs/School/Physics/Teacher%20-%20technician%20guidance%20for%20specified%20practicals/Measurement%20of%20g%20by%20freefall.pdf"

        #Linking websites to buttons
        def link1_cb():
            webbrowser.open(link1)

        def link2_cb():
            webbrowser.open(link2)

        def link3_cb():
            webbrowser.open(link3)

        def link4_cb():
            webbrowser.open(pdf)

        btnWidth = 200
        btnHeight = 50
        link1Btn = gui.Button("Freefall Graphs",width = btnWidth, height=btnHeight)
        link1Btn.connect(gui.CLICK,link1_cb)
        link2Btn = gui.Button("Information on acceleration due to gravity",width = btnWidth, height=btnHeight)
        link2Btn.connect(gui.CLICK, link2_cb)
        link3Btn = gui.Button("Alternative Method",width = btnWidth, height=btnHeight)
        link3Btn.connect(gui.CLICK, link3_cb)
        link4Btn = gui.Button("Eduqas Practical Sheet", width=btnWidth, height=btnHeight)
        link4Btn.connect(gui.CLICK, link4_cb)

        #Adding buttons to the dialog
        tbl = gui.Table()
        tbl.tr()
        tbl.td(doc)
        tbl.tr()
        tbl.td(gui.Label("Links"))
        topBtnTbl = gui.Table()
        topBtnTbl.tr()
        topBtnTbl.td(link2Btn)
        topBtnTbl.td(link1Btn)
        bottomBtnTbl = gui.Table()
        bottomBtnTbl.tr()
        bottomBtnTbl.td(link3Btn)
        bottomBtnTbl.td(link4Btn)
        tbl.tr()
        tbl.td(topBtnTbl)
        tbl.tr()
        tbl.td(bottomBtnTbl)

        gui.Dialog.__init__(self,gui.Label("Instructions and Links"), tbl)
Beispiel #18
0
    def __init__(self):
        #The method
        method = """<p>
         1. Set up the equipment as shown in the diagram<br>
         2. Place all the weights on the cart<br>
         3. Release the cart, the cart should begin to move<br>
         4. The two light gates will record the velocity which can be used to calculate the acceleration of the cart<br>
         5. Then move a mass from the cart to the mass holder and repeat step 3-4<br>
         6. Once all the weights have been transferred, plot a graph of mg against a where m is the mass on the hanger and a is the acceleration of the cart<br>
         </p>
         """
        #Adding the method to the document which html
        doc = html.HTML(method,width = 600)

        #Links to the useful websites
        link1 = "http://www.physicsandmathstutor.com/physics-revision/a-level-wjec-eduqas/component-1/"
        link2 = "http://www.physicsclassroom.com/class/newtlaws/Lesson-3/Newton-s-Second-Law"
        link3 = "http://practicalphysics.org/investigating-newtons-second-law-motion.html"
        pdf = "file:///D:/My%20Docs/School/Computer%20Science/Programming%20Project/physicssimulationapp/resources/Methods/Investigation%20of%20Newton's%20second%20law.pdf"

        #Linking websites to buttons
        def link1_cb():
            webbrowser.open(link1)

        def link2_cb():
            webbrowser.open(link2)

        def link3_cb():
            webbrowser.open(link3)

        def link4_cb():
            webbrowser.open(pdf)

        btnWidth = 200
        btnHeight = 50
        link1Btn = gui.Button("Questions for Forces",width = btnWidth, height=btnHeight)
        link1Btn.connect(gui.CLICK,link1_cb)
        link2Btn = gui.Button("Newton's 2nd Law",width = btnWidth, height=btnHeight)
        link2Btn.connect(gui.CLICK, link2_cb)
        link3Btn = gui.Button("Alternative Method",width = btnWidth, height=btnHeight)
        link3Btn.connect(gui.CLICK, link3_cb)
        link4Btn = gui.Button("Eduqas Practical Sheet", width=btnWidth, height=btnHeight)
        link4Btn.connect(gui.CLICK, link4_cb)

        #Adding buttons to the dialog
        tbl = gui.Table()
        tbl.tr()
        tbl.td(doc)
        tbl.tr()
        tbl.td(gui.Label("Links"))
        topBtnTbl = gui.Table()
        topBtnTbl.tr()
        topBtnTbl.td(link2Btn)
        topBtnTbl.td(link1Btn)
        bottomBtnTbl = gui.Table()
        bottomBtnTbl.tr()
        bottomBtnTbl.td(link3Btn)
        bottomBtnTbl.td(link4Btn)
        tbl.tr()
        tbl.td(topBtnTbl)
        tbl.tr()
        tbl.td(bottomBtnTbl)

        gui.Dialog.__init__(self,gui.Label("Instructions and Links"), tbl)
Beispiel #19
0
    def __init__(self):
        #The method
        method = """<p>
         1. This experiment is dependent on observations rather than a practical method<br>
         2. The radioactive isotope shown is to be determined by you<br>
         3. The undecayed nuclei will be red while the decayed are yellow<br>
         4. When this isotope decays, it releases a electron and increases the proton number by one<br>
         5. Therefore it is beta decay<br>
         6. Take regular recordings of the number of undecayed nuclei<br>
         7. Plot the ln(n of undecayed nuclei) against the time(x-axis)<br>
         8. Rearrange and use the gradient to find the decay constant
         </p>
         """
        #Adding the method to the document which html
        doc = html.HTML(method,width = 600)

        #Links to the useful websites
        link1 = "https://en.wikipedia.org/wiki/List_of_radioactive_isotopes_by_half-life#100_seconds"
        link2 = "http://www.a-levelphysicstutor.com/nucphys-radioactivity.php"
        link3 = "https://phet.colorado.edu/en/simulation/alpha-decay"
        pdf = "file:///D:/My%20Docs/School/Computer%20Science/Programming%20Project/physicssimulationapp/resources/Methods/RadioactiveDecay.pdf"

        #Linking websites to buttons
        def link1_cb():
            webbrowser.open(link1)

        def link2_cb():
            webbrowser.open(link2)

        def link3_cb():
            webbrowser.open(link3)

        def link4_cb():
            webbrowser.open(pdf)

        btnWidth = 200
        btnHeight = 50
        link1Btn = gui.Button("List of Radioactive Isotopes",width = btnWidth, height=btnHeight)
        link1Btn.connect(gui.CLICK,link1_cb)
        link2Btn = gui.Button("Information on Radioactivity",width = btnWidth, height=btnHeight)
        link2Btn.connect(gui.CLICK, link2_cb)
        link3Btn = gui.Button("Alternative Simulation",width = btnWidth, height=btnHeight)
        link3Btn.connect(gui.CLICK, link3_cb)
        link4Btn = gui.Button("Eduqas Practical Sheet", width=btnWidth, height=btnHeight)
        link4Btn.connect(gui.CLICK, link4_cb)

        #Adding buttons to the dialog
        tbl = gui.Table()
        tbl.tr()
        tbl.td(doc)
        tbl.tr()
        tbl.td(gui.Label("Links"))
        topBtnTbl = gui.Table()
        topBtnTbl.tr()
        topBtnTbl.td(link2Btn)
        topBtnTbl.td(link1Btn)
        bottomBtnTbl = gui.Table()
        bottomBtnTbl.tr()
        bottomBtnTbl.td(link3Btn)
        bottomBtnTbl.td(link4Btn)
        tbl.tr()
        tbl.td(topBtnTbl)
        tbl.tr()
        tbl.td(bottomBtnTbl)

        gui.Dialog.__init__(self,gui.Label("Instructions and Links"), tbl)
Beispiel #20
0
    def __init__(self):
        #The method
        method = """<p>
         1. Set up the circuit as shown in the diagram<br>
         2. Turn on the heater and begin the timer<br>
         3. Record the temperature at regular time intervals<br>
         4. Once taking 5 or more results, plot a graph for temperature against time<br>
         5. Use the gradient to find the specific heat capacity of the material<br>
         6. Readings from the ammeter and voltmeter are shown by labels.<br>
         7. Click the button "Show labels" to see the readings
         </p>
         """
        #Adding the method to the document which html
        doc = html.HTML(method, width=600)

        #Links to the useful websites
        link1 = "https://www.miniphysics.com/specific-heat-capacity.html"
        link2 = "https://socratic.org/questions/what-are-the-applications-of-specific-heat-in-our-daily-life"
        link3 = "http://www.instructables.com/id/Measure-the-specific-heat-of-water-and-other-fluid/"
        pdf = "file:///D:/My%20Docs/School/Computer%20Science/Programming%20Project/physicssimulationapp/resources/Methods/SHC.pdf"

        #Linking websites to buttons
        def link1_cb():
            webbrowser.open(link1)

        def link2_cb():
            webbrowser.open(link2)

        def link3_cb():
            webbrowser.open(link3)

        def link4_cb():
            webbrowser.open(pdf)

        btnWidth = 200
        btnHeight = 50
        link1Btn = gui.Button("About Specific Heat Capacity",
                              width=btnWidth,
                              height=btnHeight)
        link1Btn.connect(gui.CLICK, link1_cb)
        link2Btn = gui.Button("Applications of SHC",
                              width=btnWidth,
                              height=btnHeight)
        link2Btn.connect(gui.CLICK, link2_cb)
        link3Btn = gui.Button("Alternative Method",
                              width=btnWidth,
                              height=btnHeight)
        link3Btn.connect(gui.CLICK, link3_cb)
        link4Btn = gui.Button("Eduqas Practical Sheet",
                              width=btnWidth,
                              height=btnHeight)
        link4Btn.connect(gui.CLICK, link4_cb)

        #Adding buttons to the dialog
        tbl = gui.Table()
        tbl.tr()
        tbl.td(doc)
        tbl.tr()
        tbl.td(gui.Label("Links"))
        topBtnTbl = gui.Table()
        topBtnTbl.tr()
        topBtnTbl.td(link2Btn)
        topBtnTbl.td(link1Btn)
        bottomBtnTbl = gui.Table()
        bottomBtnTbl.tr()
        bottomBtnTbl.td(link3Btn)
        bottomBtnTbl.td(link4Btn)
        tbl.tr()
        tbl.td(topBtnTbl)
        tbl.tr()
        tbl.td(bottomBtnTbl)

        gui.Dialog.__init__(self, gui.Label("Instructions and Links"), tbl)
Beispiel #21
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)
Beispiel #22
0
    def __init__(self,defaultVals):
        #Object can tell menu that inputs are valid if isValidated is True
        self.isValidated = False
        #Allows menu object to access these variables one defined
        self.startTime = None
        self.endTime = None
        self.timeInterval = None
        self.defaultVals = defaultVals

        #Explaining the paremeters of the input dialog
        explainLbl = gui.Label("Input your variables below")
        nOfResultsLbl = gui.Label("Have between 5-10 recordings")
        rangeStr = str("The time range is " + str(exp.minRange) + " to " + str(exp.maxRange))
        rangeLbl = gui.Label(rangeStr)

        # THe labels for each input
        minIVUserLbl = gui.Label("Start Time")
        maxIVUserLbl = gui.Label("End Time")
        intervalUserLbl = gui.Label("Time Interval")

        # The input boxes
        minIVUserInput = gui.Input()
        maxIVUserInput = gui.Input()
        intervalIVUserInput = gui.Input()

        # The units for each input
        minIVUnitLbl = gui.Label("s")
        maxIVUnitLbl = gui.Label("s")
        intervalIVUnitLbl = gui.Label("s")

        #Standard width and height for buttons in this dialog
        buttonHeight = 50
        buttonWidth = 120

        #Making buttons then giving them functions
        okBtn = gui.Button("Enter",height=buttonHeight, width=buttonWidth)
        defaultBtn = gui.Button("Default Values",height=buttonHeight, width=buttonWidth)

        def okBtn_cb():
            #Takes currently inputted values
            minIV = minIVUserInput.value
            maxIV = maxIVUserInput.value
            interval = intervalIVUserInput.value

            #Runs through validation algorithm
            isValidated,error = validation.validateInputs(minIV,maxIV,interval,exp.maxRange,exp.minRange)


            if not isValidated:#If they aren't valid
                # Show error
                errorDlg = template.ErrorDlg(error)
                self.open(errorDlg)
            else:
                if int(maxIV) - int(minIV) >= 200:
                    #Set object variables
                    self.isValidated = True
                    self.startTime = int(minIV)
                    self.endTime = int(maxIV)
                    self.timeInterval = int(interval)
                    self.close()
                else:
                    errorDlg = template.ErrorDlg("Make the range at least 200")
                    self.open(errorDlg)

        def defaultBtn_cb():
            #A set of values if the user can't decide
            minIVUserInput.value = self.defaultVals[0]
            maxIVUserInput.value = self.defaultVals[1]
            intervalIVUserInput.value = self.defaultVals[2]

        #Links buttons with functions on click
        okBtn.connect(gui.CLICK,okBtn_cb)
        defaultBtn.connect(gui.CLICK,defaultBtn_cb)

        #Wraps all widgets into tables then put into one large table
        textTbl = gui.Table()
        inputTbl = gui.Table()
        buttonTbl = gui.Table()

        textTbl.tr()
        textTbl.td(explainLbl)
        textTbl.tr()
        textTbl.td(nOfResultsLbl)
        textTbl.tr()
        textTbl.td(rangeLbl)

        inputTblStyle = {'padding':10}
        inputTbl.tr()
        inputTbl.td(minIVUserLbl,style=inputTblStyle)
        inputTbl.td(minIVUserInput,style=inputTblStyle)
        inputTbl.td(minIVUnitLbl,style=inputTblStyle)
        inputTbl.tr()
        inputTbl.td(maxIVUserLbl,style=inputTblStyle)
        inputTbl.td(maxIVUserInput,style=inputTblStyle)
        inputTbl.td(maxIVUnitLbl,style=inputTblStyle)
        inputTbl.tr()
        inputTbl.td(intervalUserLbl,style=inputTblStyle)
        inputTbl.td(intervalIVUserInput,style=inputTblStyle)
        inputTbl.td(intervalIVUnitLbl,style=inputTblStyle)

        buttonTbl.tr()
        buttonTbl.td(okBtn,style=inputTblStyle)
        buttonTbl.td(defaultBtn,style=inputTblStyle)

        tbl = gui.Table()
        tbl.tr()
        tbl.td(textTbl)
        tbl.tr()
        tbl.td(inputTbl)
        tbl.tr()
        tbl.td(buttonTbl)

        gui.Dialog.__init__(self,gui.Label("Variables"),tbl)
Beispiel #23
0
    def __init__(self):
        #The method
        method = """<p>
         1. Set up the circuit as shown in the diagram<br>
         2. Start with crocodile clip at your starting value, record the current<br>
         3. Increase the length of the wire by moving the crocodile clip by your chosen interval<br>
         4. Once taking 5 or more results, divide the voltage by the current for each length. This gives the resistance<br>
         5. Now plot a graph for resistance(y-axis) against length(x-axis). The gradient will be equal to the resistance over the cross-sectional area"<br>
         6. Solve for the resistivity</li>
         </p>
         """
        #Adding the method to the document which html
        doc = html.HTML(method, width=600)

        #Links to the useful websites
        link1 = "http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html"
        link2 = "http://hyperphysics.phy-astr.gsu.edu/hbase/Tables/rstiv.html"
        link3 = "http://papers.xtremepapers.com/CIE/Cambridge%20International%20A%20and%20AS%20Level/Physics%20(9702)/9702_nos_ps_9.pdf"
        pdf = "file:///D:/My%20Docs/School/Computer%20Science/Programming%20Project/physicssimulationapp/resources/Methods/DeterminationOfResistivityOfAMetal.pdf"
        chrome = "C:\Program Files (x86)\Google\Chrome\chrome.exe"

        #Linking websites to buttons
        def link1_cb():
            webbrowser.open(link1)

        def link2_cb():
            webbrowser.open(link2)

        def link3_cb():
            webbrowser.open(link3)

        def link4_cb():
            webbrowser.open(pdf)

        btnWidth = 200
        btnHeight = 50
        link1Btn = gui.Button("About Resistance and Resistivity",
                              width=2 * btnWidth,
                              height=btnHeight)
        link1Btn.connect(gui.CLICK, link1_cb)
        link2Btn = gui.Button("Compare your Results",
                              width=btnWidth,
                              height=btnHeight)
        link2Btn.connect(gui.CLICK, link2_cb)
        link3Btn = gui.Button("Another Method",
                              width=btnWidth,
                              height=btnHeight)
        link3Btn.connect(gui.CLICK, link3_cb)
        link4Btn = gui.Button("Eduqas Practical Sheet",
                              width=2 * btnWidth,
                              height=btnHeight)
        link4Btn.connect(gui.CLICK, link4_cb)

        #Adding buttons to the dialog
        tbl = gui.Table()
        tbl.tr()
        tbl.td(doc)
        tbl.tr()
        tbl.td(gui.Label("Links"))
        topBtnTbl = gui.Table()
        topBtnTbl.tr()
        topBtnTbl.td(link2Btn)
        topBtnTbl.td(link1Btn)
        bottomBtnTbl = gui.Table()
        bottomBtnTbl.tr()
        bottomBtnTbl.td(link3Btn)
        bottomBtnTbl.td(link4Btn)
        tbl.tr()
        tbl.td(topBtnTbl)
        tbl.tr()
        tbl.td(bottomBtnTbl)

        gui.Dialog.__init__(self, gui.Label("Instructions and Links"), tbl)
Beispiel #24
0
    def __init__(self,defaultVals):
        #Object can tell menu that inputs are valid if isValidated is True
        self.isValidated = False
        #Allows menu object to access these variables one defined
        self.cartWeights = None
        self.massHolderWeights = None
        self.weightSize = None
        self.defaultVals = defaultVals

        #Explaining the paremeters of the input dialog
        explainLbl = gui.Label("Input your variables below")
        nOfResultsLbl = gui.Label("Have between 5-10 recordings")
        rangeStr = str("The weight range is " + str(exp.minRange) + " to " + str(exp.maxRange))
        rangeLbl = gui.Label(rangeStr)


        #THe labels for each input
        minIVUserLbl = gui.Label("Weights on Cart")
        maxIVUserLbl = gui.Label("Weights on Mass Holder")

        #The input boxes
        # The Options for answers
        optionsTbl = gui.Table()
        optionsGroup = gui.Group()
        intervalUserLbl = gui.Label("Weights on Mass Holder")
        FiftygLbl = gui.Label("50g")
        FiftygCheckBox = gui.Radio(optionsGroup, value=1)
        HundredgLbl = gui.Label("100g")
        HundredgCheckBox = gui.Radio(optionsGroup, value=2)
        TwoHundredgLbl = gui.Label("150g")
        TwoHundredgCheckBox = gui.Radio(optionsGroup, value=3)

        tdStyle = {'padding': 10}
        optionsTbl.td(intervalUserLbl, style=tdStyle)
        optionsTbl.td(FiftygLbl, style=tdStyle)
        optionsTbl.td(FiftygCheckBox)
        optionsTbl.td(HundredgLbl, style=tdStyle)
        optionsTbl.td(HundredgCheckBox)
        optionsTbl.td(TwoHundredgLbl, style=tdStyle)
        optionsTbl.td(TwoHundredgCheckBox)

        maxIVUserInput = gui.Input()
        minIVUserInput = gui.Input()

        #The units for each input
        maxIVUnitLbl = gui.Label("g")
        minIVUnitLbl = gui.Label("g")

        #Standard width and height for buttons in this dialog
        buttonHeight = 50
        buttonWidth = 120

        #Making buttons then giving them functions
        okBtn = gui.Button("Enter",height=buttonHeight, width=buttonWidth)
        defaultBtn = gui.Button("Default Values",height=buttonHeight, width=buttonWidth)

        def okBtn_cb():
            #Takes currently inputted values
            if optionsGroup.value == 1:
                interval = "50"
            elif optionsGroup.value == 2:
                interval = "100"
            elif optionsGroup.value == 3:
                interval = "150"
            else:
                interval = ""


            cartWeights = minIVUserInput.value
            massHolderWeights = maxIVUserInput.value

            #Runs through validation algorithm
            self.isValidated,error = validation.validateNewton2ndLaw(cartWeights,massHolderWeights,interval,exp.minRange,exp.maxRange)
            if not self.isValidated:#If they aren't valid
                # Show error
                errorDlg = template.ErrorDlg(error)
                self.open(errorDlg)
            else:
                #Set object variables
                self.isValidated = True
                self.cartWeights = int(cartWeights)
                self.massHolderWeights = int(massHolderWeights)
                self.weightSize = round(int(interval) /1000,2)

                self.close()

        def defaultBtn_cb():
            #A set of values if the user can't decide
            optionsGroup.value = 2
            minIVUserInput.value = self.defaultVals[1]
            maxIVUserInput.value = self.defaultVals[2]

        #Links buttons with functions on click
        okBtn.connect(gui.CLICK,okBtn_cb)
        defaultBtn.connect(gui.CLICK,defaultBtn_cb)

        #Wraps all widgets into tables then put into one large table
        textTbl = gui.Table()
        inputTbl = gui.Table()
        buttonTbl = gui.Table()

        textTbl.tr()
        textTbl.td(explainLbl)
        textTbl.tr()
        textTbl.td(nOfResultsLbl)
        textTbl.tr()
        textTbl.td(rangeLbl)


        inputTblStyle = {'padding':10}
        inputTbl.tr()
        inputTbl.td(minIVUserLbl,style=inputTblStyle)
        inputTbl.td(minIVUserInput,style=inputTblStyle)
        inputTbl.td(minIVUnitLbl,style=inputTblStyle)
        inputTbl.tr()
        inputTbl.td(maxIVUserLbl,style=inputTblStyle)
        inputTbl.td(maxIVUserInput,style=inputTblStyle)
        inputTbl.td(maxIVUnitLbl,style=inputTblStyle)

        buttonTbl.tr()
        buttonTbl.td(okBtn,style=inputTblStyle)
        buttonTbl.td(defaultBtn,style=inputTblStyle)

        tbl = gui.Table()
        tbl.tr()
        tbl.td(textTbl)
        tbl.tr()
        tbl.td(inputTbl)
        tbl.tr()
        tbl.td(optionsTbl)
        tbl.tr()
        tbl.td(buttonTbl)


        gui.Dialog.__init__(self,gui.Label("Variables"),tbl)
Beispiel #25
0
    def setupMenu(self):
        buttonWidth = self.menuArea.get_abs_rect().width - 20
        buttonHeight = 30
        tbl = gui.Table()

        inputDlg = InputDlg()

        def dialog_cb():
            self.open(inputDlg)

        varBtn = gui.Button("Variables",
                            height=buttonHeight,
                            width=buttonWidth)
        varBtn.connect(gui.CLICK, dialog_cb)

        # Add a button for pausing / resuming the game clock
        def startBtn_cb():
            if inputDlg.varsInputted and not (self.startAnimation):
                self.minVar, self.maxVar, self.interval = inputDlg.minVar, inputDlg.maxVar, inputDlg.interval
                self.setupTable()
                self.startAnimation = True
            elif inputDlg.varsInputted and self.startAnimation:
                errorDlg = ErrorDlg("You have already started the experiment")
                errorDlg.open()
            else:
                errorDlg = ErrorDlg("Input variables first")
                errorDlg.open()

        startBtn = gui.Button("Start Experiment",
                              height=buttonHeight,
                              width=buttonWidth)
        startBtn.connect(gui.CLICK, startBtn_cb)

        def pauseBtn_cb():
            self.paused = not (self.paused)
            if self.paused:
                pauseBtn.value = "Play Experiment"
            elif not self.paused:
                pauseBtn.value = "Pause Experiment"

        pauseBtn = gui.Button("Pause Experiment",
                              height=buttonHeight,
                              width=buttonWidth)
        pauseBtn.connect(gui.CLICK, pauseBtn_cb)

        def restartBtn_cb():
            self.__init__(self.disp)
            self.engine.__init__(self.disp)

        restartBtn = gui.Button("Restart Experiment",
                                height=buttonHeight,
                                width=buttonWidth)
        restartBtn.connect(gui.CLICK, restartBtn_cb)

        def constantsBtn_cb():
            constantsDlg = ConstantsDlg()
            self.open(constantsDlg)

        constantsBtn = gui.Button("Constants",
                                  height=buttonHeight,
                                  width=buttonWidth)
        constantsBtn.connect(gui.CLICK, constantsBtn_cb)

        graphBtn = gui.Button("Show Graph",
                              height=buttonHeight,
                              width=buttonWidth)

        def graphBtn_cb():
            dlg = GraphDlg(self.engine.experimentDone)
            self.open(dlg)

            #Run a function which shows the graph and hides the diagram

        graphBtn.connect(gui.CLICK, graphBtn_cb)

        def menuBtn_cb():
            print("MAIN MENU")
            ##            if self.engine.experimentDone:
            ##                os.remove("graph.png")
            import MainMenu.MainMenuPGU as m
            m.main()

        menuBtn = gui.Button("Back to Menu",
                             height=buttonHeight,
                             width=buttonWidth)
        menuBtn.connect(gui.CLICK, menuBtn_cb)

        btnStyle = {
            'padding_left': 5,
            'padding_right': 5,
            'padding_top': 12,
            'padding_bottom': 12
        }

        tbl.tr()
        tbl.td(graphBtn, style=btnStyle)
        tbl.tr()
        tbl.td(varBtn, style=btnStyle)
        tbl.tr()
        tbl.td(startBtn, style=btnStyle)
        tbl.tr()
        tbl.td(pauseBtn, style=btnStyle)
        tbl.tr()
        tbl.td(restartBtn, style=btnStyle)
        tbl.tr()
        tbl.td(constantsBtn, style=btnStyle)
        tbl.tr()
        tbl.td(menuBtn, style=btnStyle)

        self.menuArea.add(tbl, 0, 0)
Beispiel #26
0
    def __init__(self):
        title = gui.Label("Variables")
        main = gui.Table()
        print(main)
        self.minVar = None
        self.maxVar = None
        self.interval = None
        self.varsInputted = False

        MinLbl = gui.Label("Minimum Length")
        MinInp = gui.Input("")
        MaxLbl = gui.Label("Maximum Length")
        MaxInp = gui.Input("")
        IntervalLbl = gui.Label("Interval")
        IntervalInp = gui.Input("")

        def done_cb():  #Validates user input
            minVar = MinInp.value
            maxVar = MaxInp.value
            interval = IntervalInp.value
            self.varsInputted, self.minVar, self.maxVar, self.interval, errorMsg = validateRange(
                minVar, maxVar, interval)
            if not (self.varsInputted):
                errorDlg = ErrorDlg(errorMsg)
                errorDlg.open()
                MinInp.value = ""
                MaxInp.value = ""
                IntervalInp.value = ""
            else:
                self.close()

        done = gui.Button("Done")
        done.connect(gui.CLICK, done_cb)

        def default_cb():
            MinInp.value = 10
            MaxInp.value = 100
            IntervalInp.value = 10

        default = gui.Button("Default Values")
        default.connect(gui.CLICK, default_cb)

        inputsTbl = gui.Table()
        inputsTbl.tr()
        inputsTbl.td(MinLbl)
        inputsTbl.td(MinInp)
        inputsTbl.td(gui.Label("cm"))
        inputsTbl.tr()
        inputsTbl.td(MaxLbl)
        inputsTbl.td(MaxInp)
        inputsTbl.td(gui.Label("cm"))
        inputsTbl.tr()
        inputsTbl.td(IntervalLbl)
        inputsTbl.td(IntervalInp)
        inputsTbl.td(gui.Label("cm"))

        btnsTbl = gui.Table()
        btnsTbl.tr()
        btnsTbl.td(done, style={'padding': 10})
        btnsTbl.td(default, style={'padding': 10})

        main.tr()
        main.td(
            gui.Label(
                "The numbers you choose will be rounded up to the nearest ten")
        )
        main.tr()
        main.td(gui.Label("Choose two numbers between 0 and 100"))

        main.tr()
        main.td(inputsTbl)
        main.tr()
        main.td(btnsTbl)

        gui.Dialog.__init__(self, title, main)
Beispiel #27
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
Beispiel #28
0
    def __init__(self):
        #The method
        method = """<p>
         1. Set up the circuit as shown in the diagram<br>
         2. Start with the water at your start temperature<br>
         3. Increase the temperature by adding hot water or using a bunsen burner. Record the pressure.<br>
         4. Once taking 5 or more results, plot a graph for temperature against pressure<br>
         5. Use this to find absolute zero by finding the x-intercept<br>
         </p>
         """
        #Adding the method to the document which html
        doc = html.HTML(method,width = 600)

        #Links to the useful websites
        link1 = "https://www.sciencedaily.com/terms/absolute_zero.htm"
        link2 = "https://physics.info/gas-laws/"
        link3 = "https://www.education.com/science-fair/article/coldest-temperature-estimating-absolute/"
        pdf = "file:///D:/My%20Docs/School/Computer%20Science/Programming%20Project/physicssimulationapp/resources/Methods/file:///D:/My%20Docs/School/Computer%20Science/Programming%20Project/physicssimulationapp/resources/Methods/EstimationOfAbsoluteZeroByUseOfTheGasLaws.pdf"

        #Linking websites to buttons
        def link1_cb():
            webbrowser.open(link1)

        def link2_cb():
            webbrowser.open(link2)

        def link3_cb():
            webbrowser.open(link3)

        def link4_cb():
            webbrowser.open(pdf)

        btnWidth = 200
        btnHeight = 50
        link1Btn = gui.Button("Explaing Absolute Zero",width = btnWidth, height=btnHeight)
        link1Btn.connect(gui.CLICK,link1_cb)
        link2Btn = gui.Button("The Gas Laws",width = btnWidth, height=btnHeight)
        link2Btn.connect(gui.CLICK, link2_cb)
        link3Btn = gui.Button("Alternative Method",width = btnWidth, height=btnHeight)
        link3Btn.connect(gui.CLICK, link3_cb)
        link4Btn = gui.Button("Eduqas Practical Sheet", width=btnWidth, height=btnHeight)
        link4Btn.connect(gui.CLICK, link4_cb)

        #Adding buttons to the dialog
        tbl = gui.Table()
        tbl.tr()
        tbl.td(doc)
        tbl.tr()
        tbl.td(gui.Label("Links"))
        topBtnTbl = gui.Table()
        topBtnTbl.tr()
        topBtnTbl.td(link2Btn)
        topBtnTbl.td(link1Btn)
        bottomBtnTbl = gui.Table()
        bottomBtnTbl.tr()
        bottomBtnTbl.td(link3Btn)
        bottomBtnTbl.td(link4Btn)
        tbl.tr()
        tbl.td(topBtnTbl)
        tbl.tr()
        tbl.td(bottomBtnTbl)

        gui.Dialog.__init__(self,gui.Label("Instructions and Links"), tbl)