def loadActresses(self, count=100): """function to read actresses data and create a relationship between actress and movie,""" # read actresses from file actresses = self.readArtists("actress", count) self.filePointerActresses = self.fileHandleActresses.tell() objActress = Actress("", 0) objMovie = Movie("", "", 0) for actress in actresses: name, title, year = actress actress = objActress.getArtistByName(name, self.actressesList) # check if actress already not exist then add it if actress == None: self.artistCounter += 1 actressId = self.artistCounter newActress = Actress(actressId, name) self.actressesList.append(newActress) else: actressId = actress.getArtistId() # check if movie already exists. only if the movie doesn't exist, it will create an ID and if not objMovie.doesMovieExist(title, self.moviesList) and \ objMovie.getMovieByName(title, self.moviesList) == None: self.movieCounter += 1 movieId = self.movieCounter movie = Movie(movieId, title, year) self.moviesList.append(movie) # create relation between actor and movie relation = ArtistMovieRelation(actressId, movieId) self.relationsList.append(relation)
def onObjectClick(self, event): """function to get movie details on the movie when clicked.""" tempMovie = Movie(2, 4, "132") tempMovie = tempMovie.getMovieByOvalId(event.widget.find_closest(event.x, event.y)[0], self.moviesList) # get id's of the artists starring in this movie artistmovierelation = ArtistMovieRelation(0,0) artistStarring = artistmovierelation.getArtistsByMovieId(tempMovie.getMovieId(), self.relationsList) tempActor = Actor("","") tempActress = Actress("","") # fetches the name of the actor or actress. finds out whether it originated from tbe actor or actress class. artistsStartingNames = [] for artistId in artistStarring: actor = tempActor.getArtistByid(artistId, self.actorsList) if actor != None: artistsStartingNames.append(actor.getArtistName()) else: actress = tempActress.getArtistByid(artistId, self.actressesList) if actress != None: artistsStartingNames.append(actress.getArtistName()) # labels to show the film details self.movieDetailsVar.set('Title of the Film : ' + tempMovie.getMovieTitle() + "\n" + "\n" "Year Film Released : " + tempMovie.getMovieYear() + "\n"+ "\n" "Actor/Actress Name : " + ", ".join(artistsStartingNames))