Esempio n. 1
0
def findTweets():
    user = textBox.value
    app.hide()

    # Loading Window Appears
    loadingWindow = Window(app, title="Loading Tweets", visible=True)
    loadingText = Text(loadingWindow, text="Loading Tweets... This may take up to 30 seconds")
    loadingWindow.update()

    # Checking to make sure everything is working on console
    print(user)
    myuser = api.get_user(screen_name=user)
    print(user, " has ", myuser.statuses_count, " total tweets")

    # Doing our first search so we can get our maxid to search from on the rest
    print("First Search...")
    for tweet in tw.Cursor(api.user_timeline, screen_name=user).items(200):
        tweets.append(tweet)

    for tweet in tweets:
        maxtweetid = tweet.id

    # Doing the rest of our searches resetting the maxid everytime.
    print("Rest of searches...")
    for x in range(0, 30):
        print(x, end=" ", flush=True)
        newtweets = tw.Cursor(api.user_timeline,
                              screen_name=user,
                              max_id=maxtweetid,
                              count=0).items(100)
        for tweet in newtweets:
            maxtweetid = tweet.id
            tweets.append(tweet)
    tracker = 0

    # Close our loading window
    loadingWindow.hide()

    tweetsWindow = Window(app, title="Tweets for @" + user)
    # Setting up our date stuff to print on window Format of datetime: YYYY-MM-DD
    createDate = str(myuser.created_at)
    createDate = createDate[:4]
    todayMonth = datetime.datetime.now()
    todayMonth = todayMonth.strftime("%B")
    todayDay = str(datetime.date.today())
    todayDay = todayDay[8:10]
    todayYear = str(datetime.date.today())
    todayYear = todayYear[0:4]

    text1 = Text(tweetsWindow, text="Tweet(s) from @" + user + " on " + todayMonth + " " + todayDay + " between " +
                                    createDate + "-" + todayYear)
    tweetsWindow.hide()

    myDate = str(datetime.date.today())
    newDate = myDate[4:]

    # Setting our text in our tweet window
    for tweet in tweets:
        if newDate in tweet.created_at.strftime("%Y-%m-%d %H:%M:%S"):
            tracker = tracker + 1
            text = Text(tweetsWindow,
                        text="Tweet " + str(tracker) + ": \"" + tweet.text + "\"\n" + str(tweet.created_at) + "\n")
            # print("Tweet: ", tracker)
            # print("\"" + tweet.text + "\"")
            # print(tweet.created_at)
    # Display our tweets and program is concluded
    exitprogrambutton = PushButton(tweetsWindow, exitprogram, text="Exit")
    tweetsWindow.show()
Esempio n. 2
0
def questiontwo():
    global timelimit
    qt = Window(app,
                layout="grid",
                title="Question Two",
                width=800,
                height=400)
    qt.show()
    print("start question 2")

    f1 = Box(qt, width=100, height=400, grid=[0, 1])
    f1.border = 1
    f1.bg = "black"

    f2 = Box(qt, width=100, height=400, grid=[1, 1])
    f2.border = 1
    f2.bg = "black"

    f3 = Box(qt, width=100, height=400, grid=[3, 1])
    f3.border = 1
    f3.bg = "black"

    f4 = Box(qt, width=100, height=400, grid=[4, 1])
    f4.border = 1
    f4.bg = "black"

    f5 = Box(qt, width=100, height=400, grid=[5, 1])
    f5.border = 1
    f5.bg = "black"

    f6 = Box(qt, width=100, height=400, grid=[6, 1])
    f6.border = 1
    f6.bg = "black"

    f7 = Box(qt, width=100, height=400, grid=[7, 1])
    f7.border = 1
    f7.bg = "black"

    f8 = Box(qt, width=100, height=400, grid=[8, 1])
    f8.border = 1
    f8.bg = "black"

    bl = [f1, f3, f5, f7]
    x = 0
    for i in range(1, randint(1, 4)):
        bl[i - 1].bg = "yellow"
        x = i
    print(x)

    qt.update()
    sleep(7.35478205493597)

    f1.visible = False
    f2.visible = False
    f3.visible = False
    f4.visible = False
    f5.visible = False
    f6.visible = False
    f7.visible = False
    f8.visible = False

    bo2 = Box(qt, width=800, height=80, grid=[0, 1], layout="grid")
    bo2.border = 1

    b2pp = Box(qt, width=790, height=100, layout="grid", grid=[0, 2])
    b2pp.border = 1

    questiotwo = Text(qt,
                      text="How many yellow lines were there?",
                      grid=[0, 0])
    questiotwo.text_size = 38

    answer1 = PushButton(b2pp,
                         grid=[0, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="One")
    answer1.text_size = 21
    answer1.bg = 'red'
    answer1.update_command(checknumber, args=['1', x])

    answer2 = PushButton(b2pp,
                         grid=[1, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Two")
    answer2.text_size = 21
    answer2.bg = 'orange'
    answer2.update_command(checknumber, args=['2', x])

    answer3 = PushButton(b2pp,
                         grid=[2, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Three")
    answer3.text_size = 21
    answer3.bg = 'yellow'
    answer3.update_command(checknumber, args=['3', x])

    answer4 = PushButton(b2pp,
                         grid=[3, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Four")
    answer4.text_size = 21
    answer4.bg = 'green'
    answer4.update_command(checknumber, args=['4', x])

    answer5 = PushButton(b2pp,
                         grid=[0, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Five")
    answer5.text_size = 21
    answer5.bg = 'brown'
    answer5.update_command(checknumber, args=['5', x])

    answer6 = PushButton(b2pp,
                         grid=[1, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Six")
    answer6.text_size = 21
    answer6.bg = 'grey'
    answer6.update_command(checknumber, args=['6', x])

    answer7 = PushButton(b2pp,
                         grid=[2, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Zero")
    answer7.text_size = 21
    answer7.bg = 'purple'
    answer7.update_command(checknumber, args=['0', x])

    answer8 = PushButton(b2pp,
                         grid=[3, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Dunno")
    answer8.text_size = 21
    answer8.bg = 'blue'
    answer8.update_command(checknumber, args=['7', x])

    timelimit = time()
Esempio n. 3
0
def test_update():
    a = App()
    w = Window(a)
    # just testing it doesnt fail
    w.update()
    a.destroy()
Esempio n. 4
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()