Beispiel #1
0
    def init(self):
        isz = (16,16)       
        il = wx.ImageList(isz[0], isz[1])

        self.contact = il.Add(load_bitmap(os.path.join(self.rundir, 'bitmaps/16/contact.png')))
        self.online  = il.Add(load_bitmap(os.path.join(self.rundir, 'bitmaps/16/online.png')))
        self.offline = il.Add(load_bitmap(os.path.join(self.rundir, 'bitmaps/16/offline.png')))
        self.SetImageList(il)
        self.il = il

        self.root = self.AddRoot("/")
        keys = self.linkman.groups['groupname']
        for k in keys:
            item = self.AppendItem(self.root, k)
            self.SetItemImage(item, self.contact, wx.TreeItemIcon_Normal)
            self.SetPyData(item, None)
            
            v = self.linkman.groups[k]
            for x in v:
                sub = self.AppendItem(item, x[0])
                self.SetPyData(sub, x)
                self.SetItemImage(sub, self.offline, wx.TreeItemIcon_Normal)
        
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate)
        self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
Beispiel #2
0
 def make_toolbar(self):
     self.ID_TOOLBAR_REPLY = wx.NewId()
     self.ID_TOOLBAR_FORWARD = wx.NewId()
     
     self.toolbar = wx.ToolBar(self, -1, wx.DefaultPosition, wx.Size(48, 48), style=wx.TB_HORIZONTAL|wx.TB_FLAT|wx.TB_TEXT)
     self.toolbar.SetToolBitmapSize(wx.Size(48,48))
 
     self.toolbar.AddLabelTool(self.ID_TOOLBAR_REPLY, u'回复', load_bitmap(self.bmpdir+'/32/mail_reply.png'), shortHelp=u'回复邮件', longHelp=u'回复邮件')
     self.toolbar.AddLabelTool(self.ID_TOOLBAR_FORWARD, u'转发', load_bitmap(self.bmpdir+'/32/mail_forward.png'), shortHelp=u'转发邮件', longHelp=u'转发邮件')
     
     self.toolbar.Realize()
     self.SetToolBar(self.toolbar)
     self.Bind(wx.EVT_TOOL, self.OnMailReply, id=self.ID_TOOLBAR_REPLY) 
     self.Bind(wx.EVT_TOOL, self.OnMailForward, id=self.ID_TOOLBAR_FORWARD) 
Beispiel #3
0
    def make_toolbar(self):
        self.toolbar = wx.ToolBar(self, -1, wx.DefaultPosition, wx.Size(48, 48), wx.TB_HORIZONTAL|wx.TB_FLAT|wx.TB_TEXT)
        self.toolbar.SetToolBitmapSize(wx.Size (48, 48))
        
        for tb in uiconfig.toolbar:            
            if type(tb) != type([]):
                self.toolbar.AddSeparator()
                continue 
            setattr(self, tb[1], tb[0])
            self.toolbar.AddLabelTool(tb[0], tb[2], load_bitmap(tb[3]), shortHelp=tb[4], longHelp=tb[4])
            if tb[-1]:
                self.Bind(wx.EVT_TOOL, getattr(self, tb[-1]), id=tb[0])

        searchctl = search.MailSearchCtrl(self.toolbar, size=(180,-1), doSearch=self.DoSearch)
        self.toolbar.AddControl(searchctl)

        self.toolbar.Realize ()
        self.SetToolBar(self.toolbar)
Beispiel #4
0
    def __init__(self, parent, path):       
        wx.Panel.__init__(self, parent, -1)
        self.parent = parent
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.tree = wx.gizmos.TreeListCtrl(self, -1, style = wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.TR_FULL_ROW_HIGHLIGHT)
            
        self.path = path

        parts = path.split('/')
        self.user = parts[1]
        if len(parts) > 2:
            self.boxname = parts[2]
        else:
            self.boxname = ''
        loginfo('boxname:', self.boxname)
        self.il = wx.ImageList(16, 16)
        #self.idx = self.il.Add(images.getSmilesBitmap())
        
        self.tree.SetImageList(self.il)
        cols = [u'发件人','attach',u'邮件主题','mark',u'日期']
        
        self.lastitem = None

        self.image_attach = config.cf.home+'/bitmaps/16/attach.png'
        self.image_flag = config.cf.home+'/bitmaps/16/flag.png'
        self.image_mark = config.cf.home+'/bitmaps/16/bookmark.png'
        self.pngs = {self.image_attach:0, self.image_flag:0, self.image_mark:0}
        
        for k in self.pngs:
            #loginfo('load png:', k)
            try:
                self.pngs[k] = self.il.Add(load_bitmap(k))
            except:
                testfile = os.path.join(config.cf.home , 'bitmaps/16/blender.png')
                self.pngs[k] = self.il.Add(load_bitmap(testfile))
        
        for c in cols:        
            if c == 'attach':
                info = wx.gizmos.TreeListColumnInfo()
                info.SetImage(self.pngs[self.image_attach])                
                info.SetWidth(22)
                self.tree.AddColumnInfo(info)
            elif c == 'flag':
                info = wx.gizmos.TreeListColumnInfo()
                info.SetImage(self.pngs[self.image_flag])                
                info.SetWidth(22)
                self.tree.AddColumnInfo(info)
            elif c == 'mark':
                info = wx.gizmos.TreeListColumnInfo()
                info.SetImage(self.pngs[self.image_mark])                
                info.SetWidth(22)
                self.tree.AddColumnInfo(info)
            elif c == u'发件人':                
                info = wx.gizmos.TreeListColumnInfo()
                info.SetText(c)                
                info.SetWidth(200)
                self.tree.AddColumnInfo(info)
            elif c == u'邮件主题':
                info = wx.gizmos.TreeListColumnInfo()
                info.SetText(c)                
                info.SetWidth(300)
                self.tree.AddColumnInfo(info)
            elif c == u'日期':
                info = wx.gizmos.TreeListColumnInfo()
                info.SetText(c)                
                info.SetWidth(130)
                self.tree.AddColumnInfo(info)
            else:
                self.tree.AddColumn(c)
        self.tree.SetMainColumn(0)
        self.root = self.tree.AddRoot("root")
        
        self.earlier = self.add_item([u' 更早 ',0,'',0,'', wx.TreeItemData({'new':0, 'all':0})])
        self.month = self.add_item([u' 本月 ',0,'',0,'', wx.TreeItemData({'new':0, 'all':0})]) 
        self.week  = self.add_item([u' 本周 ',0,'',0,'', wx.TreeItemData({'new':0, 'all':0})]) 
        self.yestoday = self.add_item([u' 昨天 ',0,'',0,'', wx.TreeItemData({'new':0, 'all':0})]) 
        self.today = self.add_item([u' 今天 ',0,'',0,'', wx.TreeItemData({'new':0, 'all':0})]) 

        self.parent_items = [self.earlier, self.month, self.week, self.yestoday, self.today]
        
        timenow = time.localtime()
        self.time_today = time.mktime((timenow[0], timenow[1], timenow[2], 0, 0, 0, 0, 0, 0))
        self.time_yestoday = self.time_today - 86400
        self.time_week = self.time_today - 86400 * timenow[6]
        self.time_month = time.mktime((timenow[0], timenow[1], 1, 0, 0, 0, 0, 0, 0))
        
        self.mail_new = 0
        self.mail_all = 0
        #self.add_item(item, self.week)
        #self.add_item(item, self.yestoday)
        #self.add_item(item, self.today)
        
        self.tree.Expand(self.root)
        self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
        #self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate)
        self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
        self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnActivate)
        self.tree.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
Beispiel #5
0
 def load_unix_icon(self, extname):
     return load_bitmap(os.path.join(self.rundir, 'bitmaps', '32', 'www.png'))