示例#1
0
    def __init__(self):
        self.root = Tk()
        self.display = gui.Display(self.root, 'Annotation tool')
        self.root.focus_set()
        self.source_directory_path = filedialog.askdirectory()
        self.csv_file_path = filedialog.asksaveasfilename()
        self.csv_data = [['filename', 'counting']]
        self.filename_list = self.create_files_list()
        self.label = ['0' for i in range(len(self.filename_list))]
        self.index = 0
        self.counter = 0
        self.display.grid(row=0, column=0)
        self.exit = False
        self.framesList = Listbox(self.root)

        for fname in self.filename_list:
            self.framesList.insert(END, fname)

        self.framesList.grid(row=0, column=1, rowspan=2, sticky=NSEW)

        buttonFrame = Frame(self.root)
        Button(buttonFrame, text='Proximo', command=self.next).pack(side=LEFT)
        Button(buttonFrame, text='Anterior',
               command=self.previous).pack(side=LEFT)
        Button(buttonFrame, text='Incrementar',
               command=self.increment_counter).pack(side=LEFT)
        Button(buttonFrame, text='Decrementar',
               command=self.decrement_counter).pack(side=LEFT)
        Button(buttonFrame, text='Salvar', command=self.finish).pack(side=LEFT)
        buttonFrame.grid(row=1, column=0, columnspan=2)
示例#2
0
def searchRequest(message="What artist are you interested in?", arbitraryFunction=main):
   global requestWindow, artistField
   requestWindow = gui.Display("Choose Artist",300,100,(getScreenWidth()/2)-150, (getScreenHeight()/2)-100)
   requestWindow.add(gui.Label(message), 25, 15)
   artistField = gui.TextField("What Artist?", 8)
   requestWindow.add(artistField, 25, 40)
   okButton = gui.Button("OK", arbitraryFunction)
   requestWindow.add(okButton, 215, 60)
示例#3
0
def setup():
  global window, frameTimer, fadeRectangle, carvedPumpkin, questionIcon, pumpkinHitbox, text, musicSound, icon1, creeperX, creeperY, houseOpen, output
  
  cleanup()

  setMediaPath(pickAFolder())
  window = gui.Display("Minecard", 640,480)
  
  baseState = gui.Icon(getMediaPath("baseState.jpg"),640,480)
  window.add(baseState, 0, 0)
  
  carvedPumpkin = gui.Icon(getMediaPath("croppedPumpkinCarved.png"),640,480)
  
  pumpkinHitbox = gui.Rectangle(103,272,190,334,gui.Color(0,0,0,0),true,0)
  pumpkinHitbox.onMouseDown(carvePumpkin)
  pumpkinHitbox.onMouseEnter(questionOn)
  pumpkinHitbox.onMouseExit(questionOff)
  window.add(pumpkinHitbox)
  
  houseOpen = gui.Icon(getMediaPath("lightOnFixed.png"),640,480)
  
  doorHitbox = gui.Rectangle(395,233,479,275,gui.Color(0,0,0,0),true,0)
  doorHitbox.onMouseDown(openDoor)
  doorHitbox.onMouseEnter(questionOn2)
  doorHitbox.onMouseExit(questionOff)
  window.add(doorHitbox)
  
  icon1=gui.Icon(getMediaPath("creeper_0.png"))
  icon2=gui.Icon(getMediaPath("creeper_1.png"))
  icon3=gui.Icon(getMediaPath("creeper_2.png"))
  icon4=gui.Icon(getMediaPath("creeper_3.png"))
  #create output list
  output.append(icon1)
  output.append(icon2)
  output.append(icon3)
  output.append(icon4)
  #creeper coordinates
  creeperX=400
  creeperY=270

  window.remove(icon2)
  window.remove(icon3)
  window.remove(icon4)
  window.add(icon1,creeperX,creeperY)
  icon1.onMouseDown(startCreeperAnimation)

  fadeRectangle = gui.Rectangle(0,0,640,480,gui.Color(0,0,0,255),true,0)
  fadeRectangle.onMouseEnter(fadeInRectangle)
  window.add(fadeRectangle)
  
  questionIcon = gui.Icon(getMediaPath("question.png"), 50, 50)
  
  text = gui.Icon(getMediaPath("text.png"), 500, 57)
  
  frameTimer = timer.Timer(1000/60, update, [], true)
  frameTimer.start()
  musicSound = makeAndPlay(getMediaPath("minecraftmusic.wav"))
示例#4
0
#JES 5
#Kyra Moran and Patricia Chin
#created on 12/06/19

import gui

#draw gui panel
disp = gui.Display('Filter GUI', 200, 630)

#just setting values so we can make these variables global
orig = 1
image = 1


#select image callback function
def selectImage():
    global orig, image
    file = pickAFile()  #image must be relatively small
    image = makePicture(
        file)  #making two copies so that we can reset image later
    orig = makePicture(
        file)  #making two copies so that we can reset image later
    show(image)


#red tint
def Red(image):
    for p in getPixels(image):
        newRed = getRed(p) * 1.1
        newGreen = getGreen(p) * 0.2
        newBlue = getBlue(p) * 0.2
baseMediaPath = pickAFolder()
setMediaPath(baseMediaPath)

icon1 = gui.Icon(baseMediaPath + "creeper_0.png")
icon2 = gui.Icon(baseMediaPath + "creeper_1.png")
icon3 = gui.Icon(baseMediaPath + "creeper_2.png")
icon4 = gui.Icon(baseMediaPath + "creeper_3.png")
#create output list
output = []
output.append(icon1)
output.append(icon2)
output.append(icon3)
output.append(icon4)
#attach the output to frames variable
#add gui window
window = gui.Display("Animation", 400, 400)


def startAnimation(x, y):
    while true:
        window.add(output[1], x, y)
        window.remove(output[0])
        time.sleep(1)
        window.add(output[2], x, y)
        window.remove(output[1])
        time.sleep(1)
        window.add(output[3], x, y)
        window.remove(output[2])
        time.sleep(1)
        window.add(output[0], x, y)
        window.remove(output[3])
import gui
from random import *
import timer
from time import sleep

#created by Kyra Moran and Patricia Chin
#created on 10/04/19
#JES 5
#This program creates a petri dish with animated microbes.

#create panel and petri dish
disp = gui.Display("petri dish", 500, 500, 0, 0, gui.Color.GRAY)
circle2 = gui.Oval(25, 25, 475, 475, gui.Color.WHITE, true)
disp.add(circle2)
circle = gui.Oval(40, 40, 460, 460, gui.Color(210, 180, 140), true)
disp.add(circle)


#define random color function
def randColor():
    r = randint(0, 255)
    g = randint(0, 255)
    b = randint(0, 255)
    color = gui.Color(r, g, b)
    return color


#create empty list to be appended later
MicrobeList = []

        def bubbleDivision(
            x, y
        ):  #this function breaks the enemy bubble into two neutral bubbles
            disp.remove(bubble)  #removes enemy bubble from display
            objList.remove(bubble)  #removes enemy bubble from list
            for i in range(2):  #creates 2 neutral bubbles
                newNeutralBubble = controller.draw(disp)
                objList.append(newNeutralBubble)

        bubble.onMouseDown(bubbleDivision)

        return bubble


#now let's draw our panel and control the behavior
disp = gui.Display('Click Game', 600, 600)

#create instances for each of our classes
controller = neutral()
friendBubble = friend(color=gui.Color.GREEN, diam=40)
enemyBubble = enemy(color=gui.Color.RED, diam=60)

#empty list to store our objects
objList = []

#start game announcement
start = gui.TextArea('START GAME', 1, 8)
disp.add(start, 250, 280)
sleep(3)
disp.remove(start)
示例#8
0
def main():
   global window, requestWindow, artistField, removables
   if(window == None):
      window = gui.Display("spotiVis", getScreenWidth(), getScreenHeight(),0,0, gui.Color(60,60,60))
   #Run cleanup first, to make sure we have a clean slate to display on.
   cleanup()
   #Close the request window, the user shouldn't be asked to search once they already have!
   requestWindow.close()
   
   #Add a search button for future searches.
   searchButton = gui.Button("New Artist", searchRequest)
   window.add(searchButton, getScreenWidth()-155, 15)
   removables.append(searchButton)
   #Search for the artist on spotify
   searchName = artistField.getText()
   artistSearch = spotify.search(q='artist:' + searchName, type='artist')
   #If there aren't any results, start over!
   if(getMostPopularArtist(artistSearch) == -1):
      window = None
      searchRequest("That artist returned no results!", main)
      return -1
   artist = getMostPopularArtist(artistSearch)
   
   #Get number of followers
   artistFollowers = str(artist["followers"]["total"])
   
   #Get their icon
   artistImageURL = str(artist["images"][0]["url"])
   
   #Pulls the image from the internet. 
   getImage(artistImageURL, "artistImageCache.jpg")
   path = os.path.dirname(os.path.realpath(__file__))
   
   #Shorten the artists name if it happens to be too long
   artistName = str(artist["name"])
   maxNameLength = 15
   if(len(artistName)>maxNameLength):
      artistName = artistName[0:maxNameLength] + "..."
   
   #Add all static information to the window
   followerCount = gui.Label("Followers: "+ artistFollowers, gui.LEFT, gui.Color(255, 255, 255))
   followerCount.setFont(gui.Font("Futura", gui.Font.ITALIC, 24))
   artistImage = gui.Icon(path + "/cache/artistImageCache.jpg",300)
   artistLabel = gui.Label(artistName, gui.LEFT, gui.Color(255, 255, 255))
   artistLabel.setFont(gui.Font("Futura", gui.Font.BOLD, 100))
   genreLabel = gui.Label("Genre: " + str(artist["genres"][0]).title(), gui.LEFT, gui.Color(255, 255, 255))
   genreLabel.setFont(gui.Font("Futura", gui.Font.ITALIC, 36))
   
   window.add(artistImage, getScreenWidth() - 350, 50)
   window.add(artistLabel, 50, 20)
   window.add(genreLabel, 50, 150)
   window.add(followerCount, 50, 215)
   removables.append(artistImage)
   removables.append(artistLabel)
   removables.append(genreLabel)
   removables.append(followerCount)
   
   albumLabel = gui.Label("Top Albums:", gui.LEFT, gui.Color(255, 255, 255))
   albumLabel.setFont(gui.Font("Futura", gui.Font.BOLD, 20))
   window.add(albumLabel, 50, 275)
   removables.append(albumLabel)
   
   spotifyLogo = gui.Icon(path + "/spotifyLogo.png", 100)
   window.add(spotifyLogo, 50, getScreenHeight() - 250)
   removables.append(spotifyLogo)

   relatedArtistLabel = "Related Artists:"
   relatedLabel = gui.Label(relatedArtistLabel, gui.LEFT, gui.Color(255, 255, 255))
   relatedLabel.setFont(gui.Font("Futura", gui.Font.BOLD, 28))
   window.add(relatedLabel, getScreenWidth() - 550, 525)
   removables.append(relatedLabel)
   
   topTrackLabel="Top Tracks:"
   topLabel=gui.Label(topTrackLabel,gui.LEFT,gui.Color(255,255,255))
   topLabel.setFont(gui.Font("Futura",gui.Font.BOLD,20))
   window.add(topLabel, getScreenWidth()-1050, 275)
   removables.append(topLabel)
   
   #Find related artists from Spotify API
   relatedArtistSearch = spotify.artist_related_artists(artist["id"])
   relatedArtistSearch = relatedArtistSearch["artists"]
   relatedArtists = []
   #Only ever display 5 related artists, but allow fewer too.
   relatedArtistCount = None
   for relatedArtist in relatedArtistSearch:
      relatedArtists.append(relatedArtist)
   if(len(relatedArtists) >= 5):
         artistCount = 5
   else:
      artistCount = len(relatedArtists)
   #Display each related artist in a line, as well as their pictures.
   for i in range(artistCount):
      getImage(relatedArtists[i]["images"][0]["url"],"relatedArtistCache.jpg")
      relatedArtistIcon = gui.Icon(path + "/cache/relatedArtistCache.jpg",100)
      window.add(relatedArtistIcon, getScreenWidth() - 225 - i*125, 625)
      removables.append(relatedArtistIcon)
      relatedArtistName = relatedArtists[i]["name"]
      #Limit the length of the related artist name.
      maxNameLength = 10
      if(len(relatedArtistName)>maxNameLength):
         relatedArtistName = relatedArtistName[0:maxNameLength] + "..."
      relatedArtistNameLabel = gui.Label(relatedArtistName, gui.LEFT, gui.Color(255, 255, 255))
      window.add(relatedArtistNameLabel, getScreenWidth() - 225 - i*125, 600)
      removables.append(relatedArtistNameLabel)
   
   #Use the spotipy function to get JSON data for the artist's top tracks
   artistTrackSearch=spotify.artist_top_tracks(artist["id"],country='US')
   artistTracks=[]
   trackCount=None
   #Append all of the artist's top tracks to the list artistTracks
   for i in artistTrackSearch['tracks']:
      track= i
      artistTracks.append(i)
   #This loop is a safety in case the artist has less than 5 tracks released
   #Sets the number of tracks displayed to 5 unless there are less than 5, then set it to that number
   if(len(artistTracks)>=5):
      trackCount=5
   else:
      trackCount= len(artistTracks)
   #Incorporates GUI elemnts
   for i in range(trackCount):
      #pulls individual track names from the list artistTracks and gives them a number based on popularity
      trackName=str(i+1) + ". " + artistTracks[i]['name']
      maxNameLength = 25
      if(len(trackName)>maxNameLength):
         trackName = trackName[0:maxNameLength] + "..."
      trackNameLabel = gui.Label(trackName,gui.RIGHT,gui.Color(255,255,255))
      trackNameLabel.setFont(gui.Font("Futura", gui.Font.ITALIC, 20))
      window.add(trackNameLabel, getScreenWidth()-1050, 325 +i*50)
      removables.append(trackNameLabel)
   
   
   #Get the artists most recent albums in order.  
   artistAlbumSearch = spotify.artist_albums(artist["id"], album_type=None, country="US",limit=20,offset=0)
   artistAlbumSearch = artistAlbumSearch["items"]
   
   #Create a new Album object for each of these albums.
   for albumData in artistAlbumSearch:
      Album(albumData)
   
   #Return 0 if we are successful!
   return 0
示例#9
0
            else:
                randomPiece()

        # redraw the board
        visualBoard.reDraw()

        # sleep and recall gameLoop
        score.changeTime()
        sleep(score.fps)


#----------------------------------------------
#    Set Up Variables
#----------------------------------------------

world = gui.Display(config['name'], config['worldSize'], config['worldSize'])
score = Score()
visualBoard = VisualBoard()
gamePiece = GamePiece()

clap = makeSound(pickAFile())
cry = makeSound(pickAFile())
song = makeSound(pickAFile())


# key event function
def keyDown(key):
    keyHit = key

    if keyHit == 37:
        gamePiece.move('left')