def show1(): user=config.misskey.reqr("users/show",{"user-id":user_["id"]}) posts=config.misskey.reqr("posts/user-timeline",{"user-id":user["id"],"limit":30}) filemng.cacheBmp(user["avatarUrl"]+"?size=120&quality=100") def show2(a): user=a[0] posts=a[1] panel=gui.get_closable_tab("@"+user["screenName"],True) panel.SetupScrolling() layout=wx.BoxSizer(wx.VERTICAL) user_layout=wx.BoxSizer(wx.HORIZONTAL) user_layout.Add(wx.StaticBitmap(panel,-1,filemng.cacheBmp(user["avatarUrl"]+"?size=120&quality=100"))) user_layout.AddSpacer((20,2)) user_info_layout=wx.FlexGridSizer(6,3) user_info_layout.Add(wx.StaticText(panel,label=user["name"]),flag=wx.ALIGN_RIGHT) user_info_layout.AddSpacer((10,1)) user_info_layout.Add(wx.StaticText(panel,label="@"+user["screenName"])) user_info_layout.Add(wx.StaticText(panel,label=str(user["postsCount"])),flag=wx.ALIGN_RIGHT) user_info_layout.AddSpacer((10,1)) user_info_layout.Add(wx.StaticText(panel,label=u"投稿")) user_info_layout.Add(wx.StaticText(panel,label=str(user["likesCount"])),flag=wx.ALIGN_RIGHT) user_info_layout.AddSpacer((10,1)) user_info_layout.Add(wx.StaticText(panel,label=u"ふぁぼ")) user_info_layout.Add(wx.StaticText(panel,label=str(user["likedCount"])),flag=wx.ALIGN_RIGHT) user_info_layout.AddSpacer((10,1)) user_info_layout.Add(wx.StaticText(panel,label=u"ふぁぼられ")) user_info_layout.Add(wx.StaticText(panel,label=str(user["followingCount"])),flag=wx.ALIGN_RIGHT) user_info_layout.AddSpacer((10,1)) user_info_layout.Add(wx.StaticText(panel,label=u"フォロー")) user_info_layout.Add(wx.StaticText(panel,label=str(user["followersCount"])),flag=wx.ALIGN_RIGHT) user_info_layout.AddSpacer((10,1)) user_info_layout.Add(wx.StaticText(panel,label=u"フォロワー")) user_layout.Add(user_info_layout) layout.Add(user_layout) tl=timeline.Timeline(panel) posts.reverse() for post in posts: tl.prepend_post(post) layout.Add(tl,1,wx.EXPAND) panel.SetSizer(layout) wx.CallAfter(show2,[user,posts])
def add_image(self,file_id): if(file_id in self.images_str): print u"同じ画像は2つ以上追加できません" return res = config.misskey.req("album/files/show",{"file-id":file_id}) img = wx.StaticBitmap(self.parent,bitmap=filemng.cacheBmp(res["url"]+"?size=60&quality=100")) img.SetToolTip(wx.ToolTip(res["name"]+"\n"+res["mimeType"]+"\n"+u"ダブルクリックで添付画像から削除")) self.images_str.append(file_id) self.images_arr.append(img) self.images.Add(img) self.images.Layout() self.Layout() orig_str=self.textbox.GetValue() self.textbox.SetValue(orig_str+"\n") self.textbox.SetValue(orig_str) def dc_callback(evt): self.images.Detach(img) img.Hide() self.images_str.remove(file_id) self.images_arr.remove(img) self.images.Layout() self.Layout() self.textbox.SetValue("\n") self.textbox.SetValue("") img.Bind(wx.EVT_LEFT_DCLICK,dc_callback)
def get_image_number(self,url): if(self.imageCache.get(url,"notfound")=="notfound"): num=self.imagelist.Add(filemng.cacheBmp(url)) self.imageCache[url]=num else: num=self.imageCache.get(url) return num
def select_post(self,post): self.spl_2.Show() if(post["type"]=="repost"): self.spl_2_rp_panel.Show() self.info_rp_name.SetLabel(post["user"]["name"]) self.info_rp_time.SetLabel(config.dateStringConvert(post["createdAt"])) post=post["post"] else: self.spl_2_rp_panel.Hide() self.info_icon.SetBitmap(filemng.cacheBmp(config.getTimelineUserURL(post["user"]["avatarUrl"]))) self.info_user_name.SetLabel(post["user"]["name"]) self.info_post_time.SetLabel(config.dateStringConvert(post["createdAt"])) if(post.get("text")): self.info_text.Enable() self.info_text.SetValue(post["text"]) else: self.info_text.Disable() self.info_text.SetValue("text is empty") if(post["isLiked"]): self.info_btn_fav.Disable() else: self.info_btn_fav.Enable() if(post["isReposted"] or post["user"]["id"]==config.meid): self.info_btn_rp.Disable() else: self.info_btn_rp.Enable() if(not post.get("inReplyToPostId")): self.info_btn_conv.Disable() else: self.info_btn_conv.Enable() for img in self.info_images: img.Hide() img.url=None if(post["files"]): for i in range(len(post["files"])): img=self.info_images[i] img.SetBitmap(filemng.cacheBmp(config.getThumbnailURL(post["files"][i]["url"]))) img.url=post["files"][i]["url"] img.Show() self.spl_2.Layout() self.spl_2.Update()
def adduser(user): _layout=wx.BoxSizer(wx.HORIZONTAL) bmp=wx.StaticBitmap(panel,bitmap=filemng.cacheBmp(user["avatarUrl"]+"?size=32&quality=100")) bmp.Bind(wx.EVT_LEFT_UP,pages.user.openUserTab({"user":user})) bmp.SetToolTip(wx.ToolTip(user["name"]+" @"+user["screenName"])) _layout.Add(bmp) fb=wx.Button(panel,label=u"フォヨー",style=wx.BU_EXACTFIT) def follow(ev): config.misskey.reqn("users/follow",{"user-id":user["id"]}) fb.Disable() background() fb.Bind(wx.EVT_BUTTON,follow) _layout.Add(fb,flag=wx.EXPAND) user_layout.Add(_layout)