outlook bar like widget

Mohammad Tayseer m_tayseer82 at yahoo.com
Wed Feb 21 05:33:53 EST 2007


I implemented this module using Tkinter

---------------------------
from Tkinter import *

class OutlookBar(Frame):
    def __init__(self, *args, **options):
        Frame.__init__(self, *args, **options)
        self.panes = {}
        
    def add_pane(self, name, pane):
        self.panes[name] = pane
        pane.pack(side=TOP, fill=X)
        
    def get_frame(self, name):
        return self.panes[name]
        
class OutlookPane(Frame):
    def __init__(self, *args, **options):
        if options.get('text'):
            text = options['text']
            del options['text']
            
        Frame.__init__(self, *args, **options)
        self.btn = Button(self, text=text, command=self.toggle_collapse)
        self.btn.pack(side=TOP, fill=X)
        self.child_frame = Frame(self)
        self.child_frame.pack(side=TOP, fill=X)
        if options.get('collapsed'):
            self.collapsed = True
            del options['collapsed']
        else:
            self.collapsed = False
            self.child_frame.pack(side=TOP, fill=X)
            
    def frame(self):
        return self.child_frame
        
    def toggle_collapse(self):
        if self.collapsed:
            self.child_frame.pack(side=TOP) # show
        else:
            self.child_frame.pack_forget()
        self.collapsed = not self.collapsed
        
    def add_widget(self, widget):
        widget.pack(side=TOP)
if __name__ == '__main__':
    #import bwidget as bw
    root = Tk()
    root.title('Outlook Bar Demo')
    bar = OutlookBar(root)
    bar.pack(expand=1, fill=BOTH)
    bar.add_pane('pane1', OutlookPane(bar, text='Hello'))
    pane1 = bar.get_frame('pane1')
    pane1.add_widget(Button(pane1.frame(), text='Button 1'))
    pane1.add_widget(Button(pane1.frame(), text='Button 2'))
    pane1.add_widget(Button(pane1.frame(), text='Button 3'))

    bar.add_pane('pane2', OutlookPane(bar, text='Zankalon'))
    pane2 = bar.get_frame('pane2')
    pane2.add_widget(Button(pane2.frame(), text='Button 1'))
    pane2.add_widget(Button(pane2.frame(), text='Button 2'))
    pane2.add_widget(Button(pane2.frame(), text='Button 3'))

    mainloop()
            

-------------------------

Jaime Casanova <systemguards at gmail.com> wrote: Hi,

i'm trying to make an outlook bar like widget basically buttons that
when pressed extends to lists...

any idea where to start?

-- 
regards,
Jaime Casanova



 
---------------------------------
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070221/b2d64e2d/attachment.html>


More information about the Python-list mailing list