Exemple #1
0
    def initUI(self):
        self.parent.title("Pythagram: Photo")
        self.style = Style()
        self.style.theme_use("default")

        raw = self.api.call_resource('media', 'info', media_id=self.id)
        data = raw['data']

        #Photo
        f = WebFetch()
        photoFrame = Frame(self, relief=RAISED)
        photoFrame.pack(fill=BOTH, expand=1)
        photoUrl = "http://photos-d.ak.instagram.com/hphotos-ak-frc/" + data['images']['thumbnail']['url'].replace("http:http://origincache-frc.fbcdn.netorigincache-frc.fbcdn.net/","")
        profpict = Image.open(f.retrieve(photoUrl))
        profilePicture = ImageTk.PhotoImage(profpict)
        label2 = Label(photoFrame, image=profilePicture)
        label2.image = profilePicture
        label2.pack(padx=5, pady=5)

        #Photo info
        infoFrame = Frame(self,relief=RAISED)
        infoFrame.pack(fill=BOTH, expand=1)
        try:
            info = Label(infoFrame, text=data['caption']['text'])
        except:
            info = Label(infoFrame, text="")
        info.pack(side=LEFT, padx=5, pady=5)

        #People who liked
        likesFrame = Frame(self,relief=RAISED)
        likesFrame.pack(fill=BOTH, expand=1)
        likeLabel = Label(likesFrame, text="Likes:")
        likeLabel.pack()
        proto_likes = data['likes']['data']
        self.likes = []
        lb = Listbox(likesFrame, width=100)
        for element in proto_likes:
            try:
                lb.insert(END, "@{0}: {1}".format(element['username'],element['full_name']))
            except:
                continue
            self.likes.append(element['id'])
        lb.bind("<<ListboxSelect>>", self.onSelect)
        lb.pack(side=LEFT, padx=5, pady=5)

        self.pack(fill=BOTH, expand=1)
Exemple #2
0
    def initUI(self,name,bio,prof_picture,full_name,followed,follows):
        self.parent.title("Pythagram: "+name)
        self.style = Style()
        self.style.theme_use("default")

        headerFrame = Frame(self,relief=RAISED)
        headerFrame.pack(fill=BOTH, expand=1)

        #Profile Picture
        f = WebFetch()
        prof_picture = "http://images.ak.instagram.com/profiles/" + prof_picture.replace('http:http://images.ak.instagram.comimages.ak.instagram.com/profilesprofiles/','')

        profpict = Image.open(f.retrieve(prof_picture))
        profilePicture = ImageTk.PhotoImage(profpict)
        label2 = Label(headerFrame, image=profilePicture)
        label2.image = profilePicture
        label2.pack(side=LEFT,padx=5, pady=5)

        #ProfileName
        FullName = Label(headerFrame, text=full_name)
        FullName.pack(side=LEFT)
        
        #PersonalInfo
        bioFrame = Frame(self,relief=RAISED)
        bioFrame.pack(fill=BOTH, expand=1)
        bio = Label(bioFrame, text=bio)
        bio.pack(side=LEFT, padx=5, pady=5)

        #Followers/Following
        followFrame = Frame(self,relief=RAISED)
        followFrame.pack(fill=BOTH, expand=1)
        followersButton = Button(followFrame, text="Followers: "+str(followed), command=self.followed)
        followingButton = Button(followFrame, text="Following: "+str(follows), command=self.follows)
        followersButton.pack(side=LEFT, padx=5, pady=5)
        followingButton.pack(side=LEFT, padx=5, pady=5)

        #Follow/Unfollow
        global GlobalID
        if (self.id != GlobalID):
            joinFrame = Frame(self,relief=RAISED)
            joinFrame.pack(fill=BOTH, expand=1)
            if (self.api.call_resource('users','relationship', user_id=self.id)['data']['outgoing_status'] == "none"):
                followButton = Button(joinFrame, text="Follow", command=self.follow)
                followButton.pack(side=LEFT, padx=5, pady=5)
            else:
                unfollowButton = Button(joinFrame, text="Unfollow", command=self.unfollow)
                unfollowButton.pack(side=LEFT, padx=5, pady=5)

        #Photo List
        photoFrame = Frame(self,relief=RAISED)
        photoFrame.pack(fill=BOTH, expand=1)
        raw = self.api.call_resource('users', 'recent', user_id=self.id)
        data = raw['data']
        lb = Listbox(photoFrame, width=100)
        self.photos = []
        for element in data:
            try:
                lb.insert(END, element['caption']['text'])
            except:
                continue
            self.photos.append(element['id'])
        lb.bind("<<ListboxSelect>>", self.onSelect)
        lb.pack(side=LEFT, padx=5, pady=5)

        self.pack(fill=BOTH, expand=1)

        searchButton = Button(self, text="Search", command=self.search)
        searchButton.pack(side=RIGHT, padx=5, pady=5)