Beispiel #1
0
class InvitePanel(wx.Panel):
    def __init__(self, *a, **k):
        if k.get('name') is not None:
            k['name'] = 'Invite Panel'

        wx.Panel.__init__(self, *a, **k)

        accounts = [
            e for e in p.emailaccounts[:]
            if e.protocol in ('gmail', 'ymail', 'aolmail', 'hotmail')
        ]

        data = []
        for acct in accounts:
            if acct.icon is not None:
                ico = acct.icon.Resized(16)
            else:
                ico = None
            data.append((ico, acct.display_name, acct.protocol, acct.name,
                         acct._decryptedpw()))
        self.data = data
        self.Construct()
        self.Fonts()
        self.Layout()

    def Construct(self):
        parent = self

        self.line1 = wx.StaticText(
            parent,
            label="We hope you've enjoyed using Digsby.",
            style=wx.TE_CENTER)
        self.line2 = wx.StaticText(
            parent,
            label="Please show your support and invite your friends.",
            style=wx.TE_CENTER)

        self.separator = wx.StaticLine(parent)

        self.name_label = wx.StaticText(parent, label='Full Name: ')
        self.name_text = wx.TextCtrl(parent)

        self.acct_list = AnyList(parent,
                                 ObservableList(self.data),
                                 row_control=StaticEmailRow,
                                 multiselect=False,
                                 edit_buttons=None,
                                 draggable_items=False,
                                 style=0,
                                 velocity=None)
        self.acct_list.SetMinSize(wx.Size(-1, (16 + 10) * 4))

        self.acct_panel = PrefPanel(parent, self.acct_list, 'Account')
        self.acct_panel._bg_brush = lambda: wx.Brush(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
        self.acct_panel._fg_pen = lambda: wx.Pen(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW))

        self.send_button = wx.Button(parent, wx.ID_OK, label='Send Invite!')
        self.send_button.MoveAfterInTabOrder(self.name_text)

    def info(self):
        # iter(AnyList) is bad news
        acct_list = self.acct_list
        acct_list = [acct_list[i] for i in xrange(len(acct_list))]
        return self.name_text.Value, [
            acct.data[2:] for acct in acct_list
            if acct.checkbox.Get3StateValue() == wx.CHK_CHECKED
        ]

    def Fonts(self):
        #===============================================================================================================
        # top 2 lines
        #===============================================================================================================
        fnt1 = self.line1.Font

        fnt1.SetPointSize(fnt1.GetPointSize() + 4)
        fnt1.SetWeight(wx.FONTWEIGHT_BOLD)

        self.line1.Font = fnt1
        self.line2.Font = fnt1

        #===============================================================================================================
        #===============================================================================================================
        fnt2 = self.name_label.Font
        fnt2.SetPointSize(fnt2.GetPointSize() + 2)
        self.name_label.Font = fnt2

    def Layout(self):
        self.Sizer = s1 = prefcontrols.VSizer()

        #===============================================================================================================
        # top 2 lines
        #===============================================================================================================
        s1.Add(self.line1, 0, wx.EXPAND | wx.ALL, 5)
        s1.Add(self.line2, 0, wx.EXPAND | wx.ALL & ~wx.TOP, 5)
        s1.Add(self.separator, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 6)

        #===============================================================================================================
        # Full Name: ---------------
        #===============================================================================================================
        s2 = prefcontrols.HSizer()

        s2.AddSpacer(6)
        s2.Add(self.name_label, 0, wx.EXPAND)
        s2.Add(self.name_text, 3, wx.EXPAND)
        s2.AddSpacer(6)

        s1.Add(s2, 0, wx.EXPAND | wx.ALL, 9)

        #===============================================================================================================
        # panel full of checkboxes
        #===============================================================================================================
        s1.Add(self.acct_panel, 1, wx.EXPAND | wx.ALL & ~wx.TOP, 15)

        #===============================================================================================================
        # Send Invites! (click)
        #===============================================================================================================
        s3 = prefcontrols.HSizer()

        s3.AddStretchSpacer(20)
        s3.Add(self.send_button, 60,
               wx.ALIGN_CENTER_HORIZONTAL | wx.ALL & ~wx.TOP, 3)
        s3.AddStretchSpacer(20)

        s1.Add(s3, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.BOTTOM, 6)