Changeset 16960 for lang/python
- Timestamp:
- 08/01/08 23:54:17 (4 months ago)
- Files:
-
- 1 modified
-
lang/python/crochet/chat_allsrc.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/python/crochet/chat_allsrc.py
r16911 r16960 50 50 list = self.list = wx.ListCtrl(recentPage,-1,style=wx.LC_REPORT|wx.LC_HRULES) 51 51 list.Bind(wx.EVT_KEY_DOWN, self.myKeyHandler) 52 52 list.Bind(wx.EVT_LIST_ITEM_ACTIVATED,self.OnDoubleClick) 53 53 # Reply 54 54 replyPage = wx.NotebookPage(notebook,-1) … … 68 68 69 69 70 messageText=self.messageText = wx.TextCtrl(self,-1,style=wx.TE_MULTILINE|wx.TE_ READONLY)70 messageText=self.messageText = wx.TextCtrl(self,-1,style=wx.TE_MULTILINE|wx.TE_AUTO_URL|wx.TE_READONLY) 71 71 userIcon = self.userIcon = wx.StaticBitmap(self,-1,wx.NullBitmap,(0,0),(64,64)) 72 72 userName = self.userName = wx.StaticText(self,-1,"test") … … 131 131 def RefleshTw(self): 132 132 #name = XRCCTRL(self,'ID_NAME') 133 list = self.list #XRCCTRL(self,'ID_TWITLIST')133 list = self.list 134 134 a = self.tw.get("") 135 135 dataList = [] … … 160 160 i+=1 161 161 self.dataList = dataList + self.dataList 162 162 #if self.selectRow != -1 :self.selectRow+=len(dataList) 163 163 def OnUpdate(self, event): 164 164 self.RefleshTw() … … 166 166 167 167 def OnTwitListSelect(self,event): 168 import re 168 169 self.selectedRow = event.GetIndex() 169 170 label = self.userName … … 172 173 text.SetValue(self.dataList[selectedRow][2]) 173 174 label.SetLabel(self.dataList[selectedRow][1]) 174 self.LoadImage(self.GetImageListElement(self.dataList[selectedRow][4]),self.userIcon) 175 self.LoadImage(self.GetImageListElement(self.dataList[selectedRow][4]),self.userIcon) 176 #選択したユーザに関する発言の色を変えてみる 177 p = re.compile(self.dataList[selectedRow][1]) 178 for i in range(0,self.list.GetItemCount()): 179 if p.search(self.dataList[i][1]): 180 self.list.SetItemBackgroundColour(i,wx.Color(225,225,225)) 181 elif p.search(self.dataList[i][2]) : 182 self.list.SetItemBackgroundColour(i,wx.Color(192,225,225)) 183 else: 184 self.list.SetItemBackgroundColour(i,wx.Color(255,255,255)) 175 185 176 186 def SetNowTime2StatusBar(self): … … 192 202 if self.selectedRow < self.list.GetItemCount()-1: 193 203 self.MoveList(self.selectedRow+1) 204 if evt.GetKeyCode() in [ord('h'),ord('H'),wx.WXK_LEFT]: 205 print ('left') 206 leftcol = self.GetPrevItem(self.selectedRow) 207 if leftcol != -1: 208 self.MoveList(leftcol) 209 if evt.GetKeyCode() in [ord('l'),ord('L'),wx.WXK_RIGHT]: 210 print ('right') 211 rightcol = self.GetNextItem(self.selectedRow) 212 if rightcol != -1: 213 self.MoveList(rightcol) 214 194 215 #print list. 195 216 if evt.GetKeyCode() in [ord('q'), ord('Q')]: 196 217 wx.Exit() 218 219 # 今のユーザ名を含む、前の発言を検索 220 def GetPrevItem(self,row): 221 import re 222 print ('getprevItem') 223 224 userName = self.dataList[row][1] 225 p = re.compile(userName) 226 currentRow = row-1 227 while currentRow >= 0 : 228 if (p.search(self.dataList[currentRow][1])): 229 return currentRow 230 currentRow-=1 231 return -1 232 233 # 今のユーザ名を含む、後ろの発言を取得 234 def GetNextItem(self,row): 235 import re 236 print ('getnextItem') 237 userName = self.dataList[row][1] 238 p = re.compile(userName) 239 currentRow = row+1 240 while currentRow < len(self.dataList) : 241 if (p.search(self.dataList[currentRow][1])): 242 return currentRow 243 currentRow+=1 244 return -1 197 245 198 246 def MoveList(self,newRow): … … 205 253 """ 206 254 def GetImageListElement(self,url): 207 if self.imageList.has_key(url): 255 unicodeUrl = url 256 if self.imageList.has_key(unicodeUrl): 208 257 pass 209 258 else: 210 self.imageList[u rl] = self.WebImage2StringIO(url)211 return self.imageList[u rl]259 self.imageList[unicodeUrl] = self.WebImage2StringIO(url) 260 return self.imageList[unicodeUrl] 212 261 213 262 # Web上の画像を引っ張ってくる … … 217 266 218 267 #try: 219 imagePath = urllib.urlopen(url).read() 268 urlName = urllib.quote_plus(url,':;/') 269 #print "url:"+url 270 #print "urlName:"+urlName 271 imagePath = urllib.urlopen(urlName).read() 220 272 221 273 image_pil = Image.open(StringIO(imagePath)) … … 225 277 image_wx.SetData(image_pil.convert('RGB').tostring()) 226 278 return image_wx 227 #self.LoadImage(StringIO(buffer),bmp)228 279 #except: 229 280 # print "Error:URL not valid!:"+url … … 234 285 bmp.SetBitmap(image.ConvertToBitmap()) 235 286 287 #ダブルクリック時 288 def OnDoubleClick(self,event): 289 print ("dblclk") 236 290 # startup application. 237 291 if __name__=='__main__':
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)