Пример #1
0
def Run():
    global startWindow
    global finalCheck
    global startButtons

    startWindow = Window(app, title="Starting Screen", layout="grid")
    startWindow.width = 360; startWindow.height = 630; startWindow.bg = "Lime"

    playersQuestionText = Text(startWindow, text="How Many Players?", grid=[0, 0], align="top")
    playersQuestionText.text_size = 25
    playerButtonContainer = Box(startWindow, layout="grid", grid=[0, 1], align="top", border=True)
    playerButtonContainer.set_border(10, "Lime")
    buttonOnePlayer = PushButton(playerButtonContainer, text="1 Player", grid=[1, 0], command=lambda: SetPlayerNumber(True, "1 Player"))
    buttonOnePlayer.width = 20; buttonOnePlayer.height = 10; buttonOnePlayer.bg = "White"
    buttonTwoPlayer = PushButton(playerButtonContainer, text="2 Player", grid=[2, 0], command=lambda: SetPlayerNumber(False, "2 Player"))
    buttonTwoPlayer.width = 20; buttonTwoPlayer.height = 10; buttonTwoPlayer.bg = "White"

    gameModeQuestionText = Text(startWindow, text="What Game Mode?", grid=[0, 2], align="top")
    gameModeQuestionText.text_size = 25
    gameModeButtonContainer = Box(startWindow, layout="grid", grid=[0, 3], align="top", border=True)
    gameModeButtonContainer.set_border(10, "Lime")
    buttonAddition = PushButton(gameModeButtonContainer, text="Addition", grid=[1, 0], command=lambda: SetGameMode(True, "Addition"))
    buttonAddition.width = 20; buttonAddition.height = 10; buttonAddition.bg = "White"
    buttonSubtraction = PushButton(gameModeButtonContainer, text="Subtraction", grid=[2, 0], command=lambda: SetGameMode(False, "Subtraction"))
    buttonSubtraction.width = 20; buttonSubtraction.height = 10; buttonSubtraction.bg = "White"

    finalCheck = Box(startWindow, layout="grid", grid=[0, 4], align="top", border=True)
    finalCheck.set_border(10, "Lime")
    startButton = PushButton(finalCheck, text="Start!", grid=[0, 2], align="top", command=StartGame)
    startButton.width = 20; startButton.height = 5; startButton.bg = "White"; startButton.disable()
Пример #2
0
def StartOnePlayer():
    global onePlayerWindow
    global drawButtonOnePlayer
    global cardImagesOnePlayer
    global guessContainerOnePlayer
    global guessCheckButtonOnePlayer
    global guessTextBoxOnePlayer
    global correctOnePlayer
    global errorTextOnePlayer

    onePlayerWindow = Window(app, title="One Player Game", layout="grid")
    onePlayerWindow.width = 320; onePlayerWindow.height = 560; onePlayerWindow.bg = "Lime"

    drawButtonOnePlayer = PushButton(onePlayerWindow, text="Draw!", grid=[0, 0], align="top", command=ButtonSwapOnePlayer)
    drawButtonOnePlayer.width = 20; drawButtonOnePlayer.height = 5; drawButtonOnePlayer.bg = "White"
    cardImagesOnePlayer = Box(onePlayerWindow, layout="grid", grid=[0, 1], align="top", border=True)
    cardImagesOnePlayer.set_border(10, "Lime")

    guessContainerOnePlayer = Box(onePlayerWindow, layout="grid", grid=[0, 2], align="top", border=True)
    guessContainerOnePlayer.set_border(10, "Lime")
    guessTextBoxOnePlayer = TextBox(guessContainerOnePlayer, grid=[0, 0], align="top")
    guessTextBoxOnePlayer.text_size = 20; guessTextBoxOnePlayer.bg = "White"; guessTextBoxOnePlayer.disable();
    guessCheckButtonOnePlayer = PushButton(guessContainerOnePlayer, text="Check!", grid=[0, 1], align="top", command=CheckValuesOnePlayer)
    guessCheckButtonOnePlayer.width = 20; guessCheckButtonOnePlayer.height = 5; guessCheckButtonOnePlayer.bg = "White"; guessCheckButtonOnePlayer.disable();
    pointsTextOnePlayer = Text(guessContainerOnePlayer, text="Score: ", grid=[0, 2], align="top")

    correctOnePlayer = Text(onePlayerWindow, text="", grid=[0, 3])
    errorTextOnePlayer = Text(onePlayerWindow, text="Please enter a number!", grid=[0, 4])
    errorTextOnePlayer.hide()
Пример #3
0
def CustomLiveCollection():
    customInformationWindow = Window(app,
                                     title="Custom Information Entry",
                                     layout="grid")
    customInformationWindow.width = 450
    customInformationWindow.height = 180
    customInformationWindow.bg = "Grey"
    usageText = Text(customInformationWindow,
                     text="Enter the number of cycles you wish to run for...",
                     grid=[0, 0],
                     align="top")
    usageText.text_size = 15
    informationText = Text(customInformationWindow,
                           text="1 Cycle = 10 seconds",
                           grid=[0, 1],
                           align="top")
    valueTextBox = TextBox(customInformationWindow, grid=[0, 2], align="top")
    valueTextBox.width = 6
    valueTextBox.bg = "White"
    beginButton = PushButton(
        customInformationWindow,
        text="Begin...",
        grid=[0, 3],
        align="top",
        command=lambda: LiveCollection(valueTextBox.value))
    beginButton.width = 15
    beginButton.height = 5
    beginButton.bg = "White"
Пример #4
0
def CreatePressGraph():
    pressArray = []
    timeArray = []
    dateArray = []

    plt.clf()

    graphWindow = Window(app, title="Pressure Graph")
    graphWindow.width = 650
    graphWindow.height = 500

    record = connection.execute("SELECT * FROM WeatherData")
    for row in record:
        pressArray.append(row[3])
        timeArray.append(row[4])
        dateArray.append(row[5])

    endDate = len(dateArray) - 1

    plt.plot(timeArray, pressArray)
    plt.ylabel("Pressure")
    plt.xlabel("Time (HHMMSS) from " + str(dateArray[0]) + " to " +
               str(dateArray[endDate - 1]) + " (YYYYMMDD)")
    plt.savefig("pressGraph.png")

    graphImage = Picture(graphWindow, image="pressGraph.png")
Пример #5
0
def test_getters_setters():
    a = App()
    w = Window(a)
    w.title = "bar"
    assert w.title == "bar"
    w.bg = "red"
    assert w.bg == "red"
    w.height = 666
    assert w.height == 666
    w.width = 666
    assert w.width == 666
    a.destroy()
Пример #6
0
def StartTwoPlayer():
    global twoPlayerWindow
    global drawButtonTwoPlayer
    global cardImagesTwoPlayer1
    global cardImagesTwoPlayer2
    global guessContainerTwoPlayer1
    global guessContainerTwoPlayer2
    global guessTextBoxTwoPlayer1
    global guessTextBoxTwoPlayer2
    global guessCheckButtonTwoPlayer
    global correctTwoPlayer1
    global correctTwoPlayer2
    global errorTextTwoPlayer

    twoPlayerWindow = Window(app, title="Two Player Game", layout="grid")
    twoPlayerWindow.width = 660; twoPlayerWindow.height = 570; twoPlayerWindow.bg = "Lime"

    drawButtonTwoPlayer = PushButton(twoPlayerWindow, text="Draw!", grid=[0, 0], align="top", padx=20, command=ButtonSwapTwoPlayer)
    drawButtonTwoPlayer.width = 20; drawButtonTwoPlayer.height = 5; drawButtonTwoPlayer.bg = "White"
    cardImagesTwoPlayer1 = Box(twoPlayerWindow, layout="grid", grid=[0, 1], align="top", border=True)
    cardImagesTwoPlayer1.set_border(5, "Lime")
    cardImagesTwoPlayer2 = Box(twoPlayerWindow, layout="grid", grid=[1, 1], align="top", border=True)
    cardImagesTwoPlayer2.set_border(5, "Lime")

    guessContainerTwoPlayer1 = Box(twoPlayerWindow, layout="grid", grid=[0, 2], align="top", border=True)
    guessContainerTwoPlayer1.set_border(10, "Lime")
    guessTextBoxTwoPlayer1 = TextBox(guessContainerTwoPlayer1, grid=[0, 0], align="top")
    guessTextBoxTwoPlayer1.text_size = 20; guessTextBoxTwoPlayer1.bg = "White"; guessTextBoxTwoPlayer1.disable()
    guessContainerTwoPlayer2 = Box(twoPlayerWindow, layout="grid", grid=[1, 2], align="top", border=True)
    guessContainerTwoPlayer2.set_border(10, "Lime")
    guessTextBoxTwoPlayer2 = TextBox(guessContainerTwoPlayer2, grid=[0, 0], align="top")
    guessTextBoxTwoPlayer2.text_size = 20; guessTextBoxTwoPlayer2.bg = "White"; guessTextBoxTwoPlayer2.disable()

    pointsTextTwoPlayer1 = Text(guessContainerTwoPlayer1, text="Player One Score: ", grid=[0, 2], align="top")
    pointsTextTwoPlayer2 = Text(guessContainerTwoPlayer2, text="Player Two Score: ", grid=[0, 2], align="top")

    guessCheckButtonTwoPlayer = PushButton(twoPlayerWindow, text="Check!", grid=[0, 3], align="top", command=CheckValuesTwoPlayer)
    guessCheckButtonTwoPlayer.width = 20; guessCheckButtonTwoPlayer.height = 5; guessCheckButtonTwoPlayer.bg = "White"; guessCheckButtonTwoPlayer.disable()

    correctTwoPlayer1 = Text(guessContainerTwoPlayer1, text="", grid=[0, 3])
    correctTwoPlayer2 = Text(guessContainerTwoPlayer2, text="", grid=[0, 3])
    errorTextTwoPlayer = Text(twoPlayerWindow, text="Please Enter a Number!", grid=[0, 4])
    errorTextTwoPlayer.hide()
Пример #7
0
def EndScreenOnePlayer():
    global endOnePlayerWindow
    global playerOnePoints

    endOnePlayerWindow = Window(app, title="One Player End Screen", layout="grid")
    endOnePlayerWindow.width = 300; endOnePlayerWindow.height = 300; endOnePlayerWindow.bg = "Lime"

    gameOverOnePlayer = Text(endOnePlayerWindow, text="Game Over!", grid=[0, 0], align="top")
    gameOverOnePlayer.text_size = 40
    yourScoreTextOnePlayer = Text(endOnePlayerWindow, text="Your Score", grid=[0, 1], align="top")
    yourScoreTextOnePlayer.text_size = 20
    displayedScoreOnePlayer = Text(endOnePlayerWindow, text=playerOnePoints, grid=[0, 2], align="top")
    displayedScoreOnePlayer.text_size = 30
    outOfOnePlayer = Text(endOnePlayerWindow, text="Out Of", grid=[0, 3], align="top")
    outOfOnePlayer.text_size = 20
    onePlayerMaxScore = Text(endOnePlayerWindow, text="26", grid=[0, 4], align="top")
    onePlayerMaxScore.text_size = 30

    restartButton = PushButton(endOnePlayerWindow, grid=[0, 5], text="Play Again", align="top", command=RestartGame)
    restartButton.bg = "White"
Пример #8
0
def SQLQueriesExecution(queryString, informationData):
    printData = []

    dataWindow = Window(app, title="Query Display", layout="grid")
    dataWindow.height = 1080
    dataWindow.width = 400
    dataWindow.bg = "Grey"

    dataRecord = connection.execute(queryString)
    printData.append(informationData)
    for row in dataRecord:
        printData.append(row)

    dataList = ListBox(dataWindow,
                       items=printData,
                       scrollbar=True,
                       grid=[0, 0],
                       align="top")
    dataList.height = 1080
    dataList.width = 400
    dataList.bg = "White"
Пример #9
0
def EndScreenTwoPlayer():
    global endTwoPlayerWindow
    global playerOnePoints
    global playerTwoPoints

    endTwoPlayerWindow = Window(app, title="Two Player End Screen", layout="grid")
    endTwoPlayerWindow.width = 550; endTwoPlayerWindow.height = 350; endTwoPlayerWindow.bg = "Lime"

    gameOverTwoPlayer = Text(endTwoPlayerWindow, text="Game Over!", grid=[0, 0], align="top")
    gameOverTwoPlayer.text_size = 40
    yourScoreTextTwoPlayer1 = Text(endTwoPlayerWindow, text="Player One Score", grid=[0, 1], align="top")
    yourScoreTextTwoPlayer1.text_size = 20
    displayedScoreTwoPlayer1 = Text(endTwoPlayerWindow, text=playerOnePoints, grid=[0, 2], align="top")
    displayedScoreTwoPlayer1.text_size = 30
    outOfTwoPlayer1 = Text(endTwoPlayerWindow, text="Out of", grid=[0, 3], align="top")
    outOfTwoPlayer1.text_size = 20
    twoPlayerMaxScore1 = Text(endTwoPlayerWindow, text="13", grid=[0, 4], align="top")
    twoPlayerMaxScore1.text_size = 30

    yourScoreTextTwoPlayer2 = Text(endTwoPlayerWindow, text="Player Two Score", grid=[1, 1])
    yourScoreTextTwoPlayer2.text_size = 20
    displayedScoreTwoPlayer2 = Text(endTwoPlayerWindow, text=playerTwoPoints, grid=[1, 2], align="top")
    displayedScoreTwoPlayer2.text_size = 30
    outOfTwoPlayer2 = Text(endTwoPlayerWindow, text="Out of", grid=[1, 3], align="top")
    outOfTwoPlayer2.text_size = 20
    twoPlayerMaxScore2 = Text(endTwoPlayerWindow, text="13", grid=[1, 4], align="top")
    twoPlayerMaxScore2.text_size = 30

    competitionText = Text(endTwoPlayerWindow, text="", grid=[0, 5], align="top")
    competitionText.text_size = 20; competitionText.hide()

    if (playerOnePoints > playerTwoPoints):
        competitionText = Text(endTwoPlayerWindow, text="Player 1 Wins!", grid=[0, 5], align="top"); competitionText.text_size = 20;
    elif (playerOnePoints < playerTwoPoints):
        competitionText = Text(endTwoPlayerWindow, text="Player 2 Wins!", grid=[0, 5], align="top"); competitionText.text_size = 20;
    elif (playerOnePoints == playerTwoPoints):
        competitionText = Text(endTwoPlayerWindow, text="It's a Draw!", grid=[0, 5], align="top"); competitionText.text_size = 20;

    restartButton = PushButton(endTwoPlayerWindow, grid=[0, 6], text="Play Again!", align="top", command=RestartGame)
    restartButton.bg = "White"
Пример #10
0
# GUI
control_app = App(title="Control App", bg='#000000', layout='grid')
control_app.tk.attributes('-fullscreen', True) # FULLSCREEN
control_app.font = 'Inter UI Bold'
control_app.text_size = 10
control_app.height = 480
control_app.width = 800
control_app.tk.config(cursor='none')
control_app.repeat(1000, thermalCountUp)

# Feedback Window
FeedbackWindow = Window(control_app)
FeedbackWindow.text_size = 18
FeedbackWindow.font = 'Nexa Bold'
FeedbackWindow.tk.attributes('-fullscreen',True)
FeedbackWindow.height = 480
FeedbackWindow.width = 800
FeedbackWindow.hide()
FeedbackWindow.bg = 'black'
FeedbackWindow.tk.config(cursor='none')

# buttons on feedback window
gap = Text(FeedbackWindow,'')
happy = Picture(FeedbackWindow, 'happy.gif')
happy.when_clicked = goodFeedback
gap = Text(FeedbackWindow,'')
#happyText = Text(FeedbackWindow, text = 'I learned something\n new today!', grid = [1,0], color = 'white', align = 'left')
confused = Picture(FeedbackWindow,'confused.gif')
confused.when_clicked = badFeedback
#confText = Text(FeedbackWindow, text = "I'm still not sure...", grid = [1,1], color = 'white', align = 'left')
Пример #11
0
def LiveCollection(cycles):
    printedData = []
    liveTime = []
    liveTemp = []
    liveHumid = []
    livePress = []

    liveWindow = Window(app, title="Data Collection Window", layout="grid")
    liveWindow.width = 620
    liveWindow.height = 920

    try:
        localCycles = int(cycles)
    except:
        print("invalid variable")
        liveWindow.error("Error", "Invalid Variable")
    else:
        x = 0
        localCycles = int(cycles)
        liveDataList = ListBox(liveWindow)
        imageContainer = Box(liveWindow,
                             layout="grid",
                             grid=[1, 0],
                             align="top",
                             border=True)
        imageContainer.border = 10
        liveTempImage = Picture(imageContainer)
        liveHumidImage = Picture(imageContainer)
        livePressImage = Picture(imageContainer)

        while x < (localCycles):
            currentTemperature = (round(sense.get_temperature(), 2))
            currentHumidity = round(sense.get_humidity(), 2)
            currentPressure = round(sense.get_pressure(), 2)
            currentTime = time.strftime("%H%M%S", time.localtime())
            currentDate = time.strftime("%Y%m%d", gmtime())
            ID = str(currentTime) + str(currentDate)

            liveTime.append(currentTime)
            liveTemp.append(currentTemperature)
            liveHumid.append(currentHumidity)
            livePress.append(currentPressure)

            printedData.append(("ID:", ID))
            printedData.append(("Temp:", currentTemperature))
            printedData.append(("Humidity:", currentHumidity))
            printedData.append(("Pressure:", currentPressure))
            printedData.append(("Time:", currentTime))
            printedData.append(("Date:", currentDate))
            printedData.append(
                ("Entry: {0} Out of: {1}".format(x + 1, localCycles)))
            printedData.append("")

            connection.execute(
                "INSERT INTO WeatherData (ID, Temp, Humid, Press, Time, Date) Values ({0}, {1}, {2}, {3}, {4}, {5});"
                .format(ID, currentTemperature, currentHumidity,
                        currentPressure, currentTime, currentDate))
            connection.commit()

            plt.clf()
            plt.plot(liveTime, liveTemp)
            plt.ylabel("Temperature")
            plt.xlabel("Time")
            plt.savefig("liveTemp.png")
            plt.clf()
            plt.plot(liveTime, liveHumid)
            plt.ylabel("Pressure")
            plt.xlabel("Time")
            plt.savefig("liveHumid.png")
            plt.clf()
            plt.plot(liveTime, livePress)
            plt.ylabel("Humidity")
            plt.xlabel("Time")
            plt.savefig("livePress.png")
            plt.clf()

            liveDataList.destroy()
            liveDataList = ListBox(liveWindow,
                                   items=printedData,
                                   grid=[0, 0],
                                   scrollbar=True)
            liveDataList.width = 200
            liveDataList.height = 920
            liveTempImage.destroy()
            liveTempImage = Picture(imageContainer,
                                    image="liveTemp.png",
                                    grid=[0, 0])
            liveTempImage.width = 400
            liveTempImage.height = 300
            liveHumidImage.destroy()
            liveHumidImage = Picture(imageContainer,
                                     image="liveHumid.png",
                                     grid=[0, 1])
            liveHumidImage.width = 400
            liveHumidImage.height = 300
            livePressImage.destroy()
            livePressImage = Picture(imageContainer,
                                     image="livePress.png",
                                     grid=[0, 2])
            livePressImage.width = 400
            livePressImage.height = 300

            liveWindow.update()
            time.sleep(10)
            x += 1
            liveWindow.focus()
Пример #12
0
def MainPage():
    global mainWindow

    mainWindow = Window(app, title="S.W.I.G.G.S", layout="grid")
    mainWindow.width = 900
    mainWindow.height = 850
    mainWindow.bg = "Grey"

    titleText = Text(
        mainWindow,
        text="Sheldon Weather Information & Graph Generating Software",
        grid=[0, 0],
        align="top")
    titleText.text_size = 25
    abbreviationText = Text(mainWindow,
                            text="---S.W.I.G.G.S---",
                            grid=[0, 1],
                            align="top")
    abbreviationText.text_size = 20

    spacerText = Text(mainWindow, text="", grid=[0, 2], align="top")
    spacerText.text_size = 20

    savedText = Text(mainWindow,
                     text="---Display Stored Data---",
                     grid=[0, 3],
                     align="top")
    savedText.text_size = 25

    standardButtonContainer = Box(mainWindow,
                                  layout="grid",
                                  grid=[0, 4],
                                  align="top",
                                  border=True)
    standardButtonContainer.set_border(10, "Grey")
    dataButton = PushButton(standardButtonContainer,
                            text="Display Data",
                            grid=[0, 0],
                            align="top",
                            command=SQLQuerySelection)
    dataButton.width = 20
    dataButton.height = 5
    dataButton.bg = "White"
    graphButtonContainer = Box(standardButtonContainer,
                               layout="grid",
                               grid=[0, 1],
                               align="top",
                               border=True)
    graphButtonContainer.set_border(10, "Grey")
    tempGraphButton = PushButton(graphButtonContainer,
                                 text="Temperature Graph",
                                 grid=[0, 1],
                                 align="top",
                                 command=CreateTempGraph)
    tempGraphButton.width = 20
    tempGraphButton.height = 5
    tempGraphButton.bg = "White"
    humidGraphButton = PushButton(graphButtonContainer,
                                  text="Humidity Graph",
                                  grid=[1, 1],
                                  align="top",
                                  command=CreateHumidGraph)
    humidGraphButton.width = 20
    humidGraphButton.height = 5
    humidGraphButton.bg = "White"
    pressGraphButton = PushButton(graphButtonContainer,
                                  text="Pressure Graph",
                                  grid=[2, 1],
                                  align="top",
                                  command=CreatePressGraph)
    pressGraphButton.width = 20
    pressGraphButton.height = 5
    pressGraphButton.bg = "White"

    liveText = Text(mainWindow,
                    text="---Live Data Collection---",
                    grid=[0, 5],
                    align="top")
    liveText.text_size = 25
    informationText = Text(mainWindow,
                           text="Collect Data for...",
                           grid=[0, 6],
                           align="top")
    informationText.text_size = 15
    liveContainer = Box(mainWindow,
                        layout="grid",
                        grid=[0, 7],
                        align="top",
                        border=True)
    liveContainer.set_border(10, "Grey")
    '''
    Runs LiveCollection function passing through the number of cycles to complete the displayed time on the button
    Doesn't get any return variables
    '''
    hrs48Button = PushButton(liveContainer,
                             text="48 Hours...",
                             grid=[0, 0],
                             align="top",
                             command=lambda: LiveCollection(17280))
    hrs48Button.width = 10
    hrs48Button.height = 5
    hrs48Button.bg = "White"
    hrs24Button = PushButton(liveContainer,
                             text="24 Hours...",
                             grid=[1, 0],
                             align="top",
                             command=lambda: LiveCollection(8640))
    hrs24Button.width = 10
    hrs24Button.height = 5
    hrs24Button.bg = "White"
    hrs12Button = PushButton(liveContainer,
                             text="12 Hours...",
                             grid=[3, 0],
                             align="top",
                             command=lambda: LiveCollection(4320))
    hrs12Button.width = 10
    hrs12Button.height = 5
    hrs12Button.bg = "White"
    hrs1Button = PushButton(liveContainer,
                            text="1 Hours...",
                            grid=[4, 0],
                            align="top",
                            command=lambda: LiveCollection(360))
    hrs1Button.width = 10
    hrs1Button.height = 5
    hrs1Button.bg = "White"
    customButton = PushButton(mainWindow,
                              text="Custom Time...",
                              grid=[0, 8],
                              align="top",
                              command=CustomLiveCollection)
    customButton.width = 15
    customButton.height = 5
    customButton.bg = "White"

    warningContainer = Box(mainWindow,
                           layout="grid",
                           grid=[0, 9],
                           align="top",
                           border=True)
    warningContainer.set_border(30, "Grey")
    databaseButton = PushButton(warningContainer,
                                text="!Create New Database!",
                                grid=[0, 0],
                                align="top",
                                command=CreateNewDatabase)
    databaseButton.width = 20
    databaseButton.height = 2
    databaseButton.bg = "Red"