Changeset 28600

Show
Ignore:
Timestamp:
01/18/09 19:10:29 (4 years ago)
Author:
showyou
Message:

auto chdir/30char newline/Add time to List(tima)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/python/crochet/crochet.py

    r25225 r28600  
    44import sys,os,time,re 
    55import wx 
    6 import wx.lib.ClickableHtmlWindow  
     6import wx.lib.ClickableHtmlWindow 
    77import main_icon 
    88import urllib 
     
    1717 
    1818import config 
     19 
     20"""自動で chdirし,working directory を crochet のあるディレクトリにする""" 
     21dir = os.path.split(sys.argv[0])[0] 
     22os.chdir(dir) 
     23 
    1924 
    2025g_config = {} 
     
    2227g_config['listIcon'] = False 
    2328g_config['popup'] = True 
     29g_config['narrowmsg'] = True 
    2430 
    2531"""自動リサイズするListCtrl""" 
     
    228234                list.InsertColumn(0," ",1,20) 
    229235                list.InsertColumn(1,u"ユーザ") 
    230                 list.InsertColumn(2,u"発言",0,200) 
     236                list.InsertColumn(2,u"発言",width=300) 
     237                list.InsertColumn(3,u"時刻",width=60); 
    231238                list.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnTwitListSelect) 
    232239                 
     
    242249                mainText = dataList[selectedRow][2] 
    243250                mainText = mainText.replace("href=\"/","href=\"http://twitter.com/") 
     251 
     252                """ 30文字折り返し""" 
     253                if g_config['narrowmsg']: 
     254                        tmpTextLen = len(mainText); 
     255                        tmpText = mainText; 
     256                        tmpTagRe = re.compile("(<.+?>)") 
     257                        tmpTagSplit = tmpTagRe.split(tmpText); 
     258                        mainText = "" 
     259                        tb = 30 
     260                        tbc = 0 
     261                        for s in tmpTagSplit: 
     262                                tmplen = len(s); 
     263                                print "s:",s,",",tmplen,",",tbc 
     264                                if tmpTagRe.match(s) != None: 
     265                                        mainText += s 
     266                                        continue 
     267                                if tbc != 0: 
     268                                        if  tb <= tbc+tmplen: 
     269                                                mainText+=s[0:tb-tbc] 
     270                                                mainText += u"<BR>" 
     271                                                i = tb-tbc 
     272                                                tbc = 0 
     273                                        else: 
     274                                                mainText+=s 
     275                                                tbc += tmplen 
     276                                                continue 
     277                                else: i=0 
     278                                 
     279                                while i<tmplen-tb: 
     280                                        mainText += s[i:i+tb] 
     281                                        mainText += u"<BR>" 
     282                                        i+=tb 
     283                                if i<tmplen: 
     284                                        mainText += s[i:tmplen] 
     285                                        tbc+=tmplen-i; 
     286                                         
    244287                print "mainText",mainText 
     288                 
    245289                text.SetValue(mainText) 
    246290                label.SetLabel(dataList[selectedRow][1]) 
     
    341385                                        description=gdescription,sticky=False) 
    342386        def RemoveATag(self,text): 
    343  
    344387                regATagBegin = re.compile("<a href=.*?>") 
    345388                text2 = regATagBegin.sub("",text) 
     
    374417                        b2.append(b[1]) 
    375418                        b2.append(self.RemoveATag(b[2])) 
    376                         for j in range(3): 
     419                        b2.append(b[3]); 
     420                        for j in range(4): 
    377421                                self.list.SetStringItem(i,j,b2[j]) 
    378422                 
     
    474518                                dataListElement.append(x[0]) 
    475519                                dataListElement.append(x[1]) 
    476                                 x2 = toDate2.toDate2(x[2]).strftime("%y-%m-%d %H:%M:%S") 
     520                                x2 = toDate2.toDate2(x[2]).strftime("%b %d %H:%M:%S") 
    477521                                dataListElement.append(x2) 
    478522                                dataListElement.append(x[3]) 
     
    499543 
    500544                user = self.owner.tw.user['user'] 
    501                 if g_growl == True and g_config['popup']: 
     545                if g_growl == True and g_config['popup'] and outCount > 0: 
    502546                        if outString.find("@"+user) != -1: 
    503547                                TmpTwitPage.CallGrowl(self,"Recent 新着"+str(outCount)+"件", 
     
    543587                                #x2 = toDate2.toDate2(x[2]).strftime("%y-%m-%d %H:%M:%S") 
    544588                                x2 = "--" 
     589 
    545590                                dataListElement.append(x2) 
    546591                                dataListElement.append(x[3]) 
     
    662707                wx.Frame.__init__(self,None, -1, "crochet") 
    663708                 
    664  
    665709                if g_growl == True: 
    666710                        self.g = Growl.GrowlNotifier( 
     
    691735                for p in twTabConfig['tabName']: 
    692736                        page = CustomPage(p,self,self.httpThreadLock) 
    693                         self.recentPage.AppendCustomPage(page,p)         
     737                        self.recentPage.AppendCustomPage(page,p) 
    694738                 
    695739                inputSizer = wx.BoxSizer(wx.HORIZONTAL) 
     
    731775                self.tw.setAuthService("twitter") 
    732776                self.SetIcon(main_icon.getIcon()) 
    733                 self.SetSize((300,400)) 
     777                self.SetSize((600,400)) 
    734778                self.timer = wx.Timer(self,self.TIMER_ID) 
    735779                wx.EVT_TIMER(self,self.TIMER_ID,self.OnUpdate)