Example #1
0
File: list.py Project: kd0kfo/todo
    def get_box(self):
        if not self.dialog:
            from Tkinter import Tk,Listbox,Button,Scrollbar,X,Y,BOTTOM,RIGHT,HORIZONTAL,VERTICAL,OptionMenu,StringVar
            self.dialog = Tk()
            self.dialog.title("TODO")
            scrollbar = Scrollbar(self.dialog,orient=HORIZONTAL)
            yscrollbar = Scrollbar(self.dialog,orient=VERTICAL)
            self.todolist = Listbox(self.dialog,width=50,xscrollcommand=scrollbar.set,yscrollcommand=yscrollbar.set)
            scrollbar.config(command=self.todolist.xview)
            scrollbar.pack(side=BOTTOM,fill=X)
            yscrollbar.config(command=self.todolist.yview)
            yscrollbar.pack(side=RIGHT,fill=Y)
            self.todolist.pack(side="left",fill="both",expand=True)
            
            cat_list_name = StringVar()
            cat_list_name.set("Category")
            

            btn = Button(self.dialog,text="Refresh",command=self.refresh_list)
            btn.pack()
            
            self.refresh_list()
            if self.categories:
                self.cat_list = OptionMenu(self.dialog,cat_list_name,*(self.categories+["ALL","NONE"]),command=self.filter_list)
                self.cat_list.pack()
        
        return (self.dialog,self.todolist)
Example #2
0
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args, **kw)
        vscrollbar = Scrollbar(self, orient=VERTICAL)
        vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE)
        canvas = Canvas(self,
                        bd=0,
                        highlightthickness=0,
                        yscrollcommand=vscrollbar.set)
        canvas.pack(side=LEFT, fill=BOTH, expand=TRUE)
        vscrollbar.config(command=canvas.yview)
        canvas.xview_moveto(0)
        canvas.yview_moveto(0)
        self.interior = interior = Frame(canvas)
        interior_id = canvas.create_window(0, 0, window=interior, anchor=NW)
        self.canv = canvas  # @UndefinedVariable
        self.scroller = vscrollbar

        def _configure_interior(event):
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            canvas.config(scrollregion="0 0 %s %s" % size)
            if interior.winfo_reqwidth() != canvas.winfo_width():
                canvas.config(width=interior.winfo_reqwidth())

        interior.bind('<Configure>', _configure_interior)

        def _configure_canvas(event):
            if interior.winfo_reqwidth() != canvas.winfo_width():
                canvas.itemconfigure(interior_id, width=canvas.winfo_width())

        canvas.bind('<Configure>', _configure_canvas)
Example #3
0
    def _init_grammar(self, parent):
        # Grammar view.
        self._prodframe = listframe = Frame(parent)
        self._prodframe.pack(fill='both', side='left', padx=2)
        self._prodlist_label = Label(self._prodframe, font=self._boldfont,
                                     text='Available Expansions')
        self._prodlist_label.pack()
        self._prodlist = Listbox(self._prodframe, selectmode='single',
                                 relief='groove', background='white',
                                 foreground='#909090', font=self._font,
                                 selectforeground='#004040',
                                 selectbackground='#c0f0c0')

        self._prodlist.pack(side='right', fill='both', expand=1)

        self._productions = list(self._parser.grammar().productions())
        for production in self._productions:
            self._prodlist.insert('end', ('  %s' % production))
        self._prodlist.config(height=min(len(self._productions), 25))

        # Add a scrollbar if there are more than 25 productions.
        if len(self._productions) > 25:
            listscroll = Scrollbar(self._prodframe,
                                   orient='vertical')
            self._prodlist.config(yscrollcommand = listscroll.set)
            listscroll.config(command=self._prodlist.yview)
            listscroll.pack(side='left', fill='y')

        # If they select a production, apply it.
        self._prodlist.bind('<<ListboxSelect>>', self._prodlist_select)
Example #4
0
    def __init__(self, parent, tile_size, grid_vm=None):
        Frame.__init__(self, parent, relief=RAISED, borderwidth=1)
        self.parent = parent
        self.tile_size = tile_size
        self.grid_vm = grid_vm
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, pad=3)
        self.rowconfigure(0, weight=1)
        self.rowconfigure(1, pad=3)
        hbar = Scrollbar(self, orient=HORIZONTAL)
        vbar = Scrollbar(self, orient=VERTICAL)
        canvas = Canvas(self, xscrollcommand=hbar.set, yscrollcommand=vbar.set)
        self.canvas = canvas
        self.lines = []

        canvas.bind_all("<MouseWheel>", self._on_mousewheel_vertical)
        canvas.bind_all("<Shift-MouseWheel>", self._on_mousewheel_horizontal)

        # Set up scroll bars
        hbar.pack(side=BOTTOM, fill=X)
        hbar.config(command=canvas.xview)
        vbar.pack(side=RIGHT, fill=Y)
        vbar.config(command=canvas.yview)

        canvas.grid(column=0, row=0, sticky=N + W + E + S)
        hbar.grid(column=0, row=1, sticky=W + E)
        vbar.grid(column=1, row=0, sticky=N + S)

        if grid_vm:
            self.set_vm(grid_vm)
Example #5
0
    def buildDisplay(self):
        winWidth = 1000
        winHeight = 800
        frame = Frame(self.root, width=winWidth, height=winHeight)
        frame.pack(side=TOP, expand=YES, fill=X)

        c = Canvas(frame,
                   width=winWidth,
                   height=winHeight,
                   scrollregion=(0, 0, self.canvasWidth, self.canvasHeight))

        hbar = Scrollbar(frame, orient=HORIZONTAL)
        hbar.pack(side=BOTTOM, fill=X)
        hbar.config(command=c.xview)
        vbar = Scrollbar(frame, orient=VERTICAL)
        vbar.pack(side=RIGHT, fill=Y)
        vbar.config(command=c.yview)

        c.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
        c.pack(side=LEFT, expand=YES, fill=BOTH)
        self.canvas = c

        editFrame = Frame(self.root, width=winWidth, height=0)
        editFrame.pack(side=BOTTOM, fill=X)
        self.editFrame = editFrame
Example #6
0
    def _init_grammar(self, parent):
        # Grammar view.
        self._prodframe = listframe = Frame(parent)
        self._prodframe.pack(fill='both', side='left', padx=2)
        self._prodlist_label = Label(self._prodframe,
                                     font=self._boldfont,
                                     text='Available Expansions')
        self._prodlist_label.pack()
        self._prodlist = Listbox(self._prodframe,
                                 selectmode='single',
                                 relief='groove',
                                 background='white',
                                 foreground='#909090',
                                 font=self._font,
                                 selectforeground='#004040',
                                 selectbackground='#c0f0c0')

        self._prodlist.pack(side='right', fill='both', expand=1)

        self._productions = list(self._parser.grammar().productions())
        for production in self._productions:
            self._prodlist.insert('end', ('  %s' % production))
        self._prodlist.config(height=min(len(self._productions), 25))

        # Add a scrollbar if there are more than 25 productions.
        if len(self._productions) > 25:
            listscroll = Scrollbar(self._prodframe, orient='vertical')
            self._prodlist.config(yscrollcommand=listscroll.set)
            listscroll.config(command=self._prodlist.yview)
            listscroll.pack(side='left', fill='y')

        # If they select a production, apply it.
        self._prodlist.bind('<<ListboxSelect>>', self._prodlist_select)
    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        self.selected = "";
        self.controller = controller
        label = Label(self, text="Select server", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
        label.pack(side="top", fill="x", pady=10)
        
        self.button1 = Button(self, text="Next",state="disabled", command=self.callback_choose)
        button2 = Button(self, text="Refresh", command=self.callback_refresh)        
        button3 = Button(self, text="Back", command=self.callback_start)
        
        scrollbar = Scrollbar(self)
        self.mylist = Listbox(self, width=100, yscrollcommand = scrollbar.set )
        self.mylist.bind("<Double-Button-1>", self.twoClick)

        self.button1.pack()
        button2.pack()
        button3.pack()
        # create list with a scroolbar
        scrollbar.pack( side = "right", fill="y" )
        self.mylist.pack( side = "top", fill = "x", ipadx=20, ipady=20, padx=20, pady=20 )
        scrollbar.config( command = self.mylist.yview )
        # create a progress bar
        label2 = Label(self, text="Refresh progress bar", justify='center', anchor='center')
        label2.pack(side="top", fill="x")
        
        self.bar_lenght = 200
        self.pb = Progressbar(self, length=self.bar_lenght, mode='determinate')
        self.pb.pack(side="top", anchor='center', ipadx=20, ipady=20, padx=10, pady=10)
        self.pb.config(value=0)
Example #8
0
    def _init_exampleListbox(self, parent):
        self._exampleFrame = listframe = Frame(parent)
        self._exampleFrame.pack(fill='both', side='left', padx=2)
        self._exampleList_label = Label(self._exampleFrame, font=self._boldfont,
                                     text='Examples')
        self._exampleList_label.pack()
        self._exampleList = Listbox(self._exampleFrame, selectmode='single',
                                 relief='groove', background='white',
                                 foreground='#909090', font=self._font,
                                 selectforeground='#004040',
                                 selectbackground='#c0f0c0')

        self._exampleList.pack(side='right', fill='both', expand=1)

        for example in self._examples:
            self._exampleList.insert('end', ('  %s' % example))
        self._exampleList.config(height=min(len(self._examples), 25), width=40)

        # Add a scrollbar if there are more than 25 examples.
        if len(self._examples) > 25:
            listscroll = Scrollbar(self._exampleFrame,
                                   orient='vertical')
            self._exampleList.config(yscrollcommand = listscroll.set)
            listscroll.config(command=self._exampleList.yview)
            listscroll.pack(side='left', fill='y')

        # If they select a example, apply it.
        self._exampleList.bind('<<ListboxSelect>>', self._exampleList_select)
Example #9
0
class console:
    def __init__(self, master):

        self.Yscroll = Scrollbar(master)
        self.Yscroll.pack(side=RIGHT, fill=Y)

        self.text = Text(master,
                         padx=5,
                         pady=5,
                         height=10,
                         bg="Black",
                         fg="White",
                         font=(DEFAULT_FONT, 12),
                         yscrollcommand=self.Yscroll.set)

        self.Yscroll.config(command=self.text.yview)

        self.text.bind("<Key>", lambda e: "break")

        self.text.pack(fill=BOTH, expand=1)

    def __str__(self):
        """ str(s) -> string """
        return self.text.get()

    def write(self, string):
        """ Adds string to the bottom of the console """
        self.text.insert(END, string)
        self.text.see(END)
        return

    def read(self):
        """ Returns contents of the console widget """
        return str(self)
Example #10
0
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args, **kw)

        # create a canvas object and a vertical scrollbar for scrolling it
        vscrollbar = Scrollbar(self, orient=Tkinter.VERTICAL)
        vscrollbar.pack(fill=Tkinter.Y,
                        side=Tkinter.RIGHT,
                        expand=Tkinter.FALSE)

        hscrollbar = Scrollbar(self, orient=Tkinter.HORIZONTAL)
        hscrollbar.pack(fill=Tkinter.X,
                        side=Tkinter.BOTTOM,
                        expand=Tkinter.FALSE)

        canvas = Canvas(self,
                        bd=0,
                        highlightthickness=0,
                        yscrollcommand=vscrollbar.set,
                        xscrollcommand=hscrollbar.set)
        canvas.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=Tkinter.TRUE)
        vscrollbar.config(command=canvas.yview)
        hscrollbar.config(command=canvas.xview)

        # reset the view

        canvas.xview_moveto(0)
        canvas.yview_moveto(0)

        # create a frame inside the canvas which will be scrolled with it

        self.interior = interior = Frame(canvas)
        interior_id = canvas.create_window(0,
                                           0,
                                           window=interior,
                                           anchor=Tkinter.NW)

        # track changes to the canvas and frame width and sync them,
        # also updating the scrollbar

        def _configure_interior(event):
            '''
            update the scrollbars to match the size of the inner frame
            '''
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            canvas.config(scrollregion='0 0 %s %s' % size)
            if interior.winfo_reqwidth() != canvas.winfo_width():
                # update the canvas's width to fit the inner frame
                canvas.config(width=interior.winfo_reqwidth())

        interior.bind('<Configure>', _configure_interior)

        def _configure_canvas(event):
            '''
            _configure_canvas is used to resize the window size to fit content.
            Can be used when changing window.
            '''

            if interior.winfo_reqwidth() != canvas.winfo_width():
                # update the inner frame's width to fill the canvas
                canvas.itemconfigure(interior_id, width=canvas.winfo_width())
Example #11
0
class console:

    def __init__(self, master):

        self.Yscroll = Scrollbar(master)
        self.Yscroll.pack(side=RIGHT, fill=Y)        
        
        self.text = Text( master, padx=5, pady=5,
                            height=10,
                            bg="Black", fg="White",
                            font=(DEFAULT_FONT, 12),
                            yscrollcommand=self.Yscroll.set)

        self.Yscroll.config(command=self.text.yview)

        self.text.bind("<Key>", lambda e: "break")

        self.text.pack(fill=BOTH, expand=1)

    def __str__(self):
        """ str(s) -> string """
        return self.text.get()        

    def write(self, string):
        """ Adds string to the bottom of the console """
        self.text.insert( END, string )
        self.text.see(END)
        return

    def read(self):
        """ Returns contents of the console widget """
        return str(self)
Example #12
0
    def __init__(self, master, d_list, a_function):
        Frame.__init__(self, master)

        scrl_bar = Scrollbar(self)
        self.listbox = Listbox(self)

        scrl_bar.config(command=self.listbox.yview)
        scrl_bar.pack(side=RIGHT, fill=Y)

        self.listbox.config(yscrollcommand=scrl_bar.set)
        self.listbox.pack(side=LEFT, expand=YES, fill=BOTH)

        #load the listbox
        idx = 0
        for item in d_list:
            fparts = item.split('.')
            # DEBUG print fparts
            if fparts[-1] == 'csv':
                self.listbox.insert(idx, item)
                idx += 1

        # link double click to the processList
        self.listbox.bind('<Double-1>', self.processList)
        # attach a function passed form the master
        # not this si done as passd function so it could be anything
        self.passed_function = a_function
Example #13
0
 def __init__(self, list_=None, master=None, title=None):
     '''Must have master, title is optional, li is too.'''
     self.master = master
     if self.master is not None:
         self.top = Toplevel(self.master)
     else:
         return
     self.v = None
     if list_ is None or not isinstance(list_, list):
         self.list = []
     else:
         self.list = list_[:]
     self.top.transient(self.master)
     self.top.grab_set()
     self.top.bind("<Return>", self._choose)
     self.top.bind("<Escape>", self._cancel)
     if title:
         self.top.title(title)
     lf = Frame(self.top)  #Sets up the list.
     lf.pack(side=TOP)
     scroll_bar = Scrollbar(lf)
     scroll_bar.pack(side=RIGHT, fill=Y)
     self.lb = Listbox(lf, selectmode=SINGLE)
     self.lb.pack(side=LEFT, fill=Y)
     scroll_bar.config(command=self.lb.yview)
     self.lb.config(yscrollcommand=scroll_bar.set)
     self.list.sort()
     for item in self.list:
         self.lb.insert(END, item)  #Inserts items into the list.
     bf = Frame(self.top)
     bf.pack(side=BOTTOM)
     Button(bf, text="Select", command=self._choose).pack(side=LEFT)
     Button(bf, text="New", command=self._new).pack(side=LEFT)
     Button(bf, text="Cancel", command=self._cancel).pack(side=LEFT)
Example #14
0
    def initUI(self):
      
        self.parent.title("Food List Editor")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        self.rowconfigure(4, weight=1)
        self.rowconfigure(5, pad=7)
        
        lbl = Label(self, text="Food List")
        lbl.grid(sticky=W, pady=4, padx=5)
                
        abtn = Button(self, text="Add Food", command=self.sequence)
        abtn.grid(row=1, column=3)

        dbtn = Button(self, text="Delete Food", command=self.delete_food)
        dbtn.grid(row=2, column=3, pady=4)
		
        upbtn = Button(self, text="Refresh", command=self.update_list)
        upbtn.grid(row=3, column=3)

        cbtn = Button(self, text="Close", command=self.close_program)
        cbtn.grid(row=5, column=3)

        scrollbar = Scrollbar(self, orient="vertical")
        self.lb = Listbox(self, width=50, height=20,\
            yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.lb.yview)

        self.make_list()
Example #15
0
class ScrolledList(object):
    # TODO add columns to the Scrolled list:
    #   http://stackoverflow.com/questions/5286093/display-listbox-with-columns-using-tkinter

    def __init__(self, parent_frame):
        self._vsbar = Scrollbar(parent_frame)
        self._hsbar = Scrollbar(parent_frame, orient='horizontal')
        self._list = Listbox(parent_frame, relief=SUNKEN, font=('courier', 12))

        self._vsbar.config(command=self._list.yview, relief=SUNKEN)
        self._hsbar.config(command=self._list.xview, relief=SUNKEN)
        self._list.config(yscrollcommand=self._vsbar.set, relief=SUNKEN)
        self._list.config(xscrollcommand=self._hsbar.set)

        self._vsbar.pack(side=RIGHT, fill=Y)
        self._hsbar.pack(side=BOTTOM, fill=X)
        self._list.pack(side=LEFT, expand=YES, fill=BOTH)
        #self._list.bind('<Double-1>', self.handlelist)

        self._list_pos = 0

    def clear(self):
        self._list.delete(0, END)
        self._list_pos = 0

    def append_list_entry(self, entry_str, fg=None):
        pos = self._list_pos
        self._list_pos += 1
        self._list.insert(END, entry_str)
        if fg:
            self._list.itemconfig(pos, fg=fg)
        return pos

    def highlight_entry(self, entry_index, bg):
        self._list.itemconfig(index=entry_index, bg=bg)
Example #16
0
    def initUI(self):
        self.parent.title("Book downloader")
        self.style = Style()
        self.style.theme_use("default")
        
        framesearch = Frame(self)
        framesearch.pack(fill=BOTH)

        search_label = Label(framesearch, text="Filter books:", padx=5, pady=5, width=15)
        search_label.pack(side=LEFT)

        self.search_entry = Entry(framesearch)
        self.search_entry.pack(side=RIGHT, fill=X)
        self.search_entry.bind("<Return>", self.searchHandler)
        #self.search_entry.bind("<Key>", self.searchHandler)
        
        framelist = Frame(self, relief=RAISED, borderwidth=1)
        framelist.pack(fill=BOTH, expand=True)

        self.lb = Listbox(framelist, height=30)
        scrollbar = Scrollbar(framelist)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.lb.config(yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.lb.yview)
        
        self.loadLibrary()
        for b in self.book_list:
            self.lb.insert(END, b[0])
        self.lb.pack(fill=BOTH)
        
        self.pack(fill=BOTH, expand=True)
        
        DownButton = Button(self, text="Download", command=self.downloadAction)
        DownButton.pack(side=RIGHT)
Example #17
0
    def _init_grammar(self, parent):
        # Grammar view.
        self._prodframe = listframe = Frame(parent)
        self._prodframe.pack(fill="both", side="left", padx=2)
        self._prodlist_label = Label(self._prodframe, font=self._boldfont, text="Available Expansions")
        self._prodlist_label.pack()
        self._prodlist = Listbox(
            self._prodframe,
            selectmode="single",
            relief="groove",
            background="white",
            foreground="#909090",
            font=self._font,
            selectforeground="#004040",
            selectbackground="#c0f0c0",
        )

        self._prodlist.pack(side="right", fill="both", expand=1)

        self._productions = list(self._parser.grammar().productions())
        for production in self._productions:
            self._prodlist.insert("end", ("  %s" % production))
        self._prodlist.config(height=min(len(self._productions), 25))

        # Add a scrollbar if there are more than 25 productions.
        if len(self._productions) > 25:
            listscroll = Scrollbar(self._prodframe, orient="vertical")
            self._prodlist.config(yscrollcommand=listscroll.set)
            listscroll.config(command=self._prodlist.yview)
            listscroll.pack(side="left", fill="y")

        # If they select a production, apply it.
        self._prodlist.bind("<<ListboxSelect>>", self._prodlist_select)
Example #18
0
 def setup_UI(self):
     # setup tk
     self.root = tk.Tk()
     self.root.title(settings.S_LIST_VERSION)
     self.root.geometry("180x" + str(self.root.winfo_screenheight() - 100) + "-50+20")
     self.root.wm_attributes("-topmost", 1)
     self.root.protocol("WM_DELETE_WINDOW", self.xmlrpc_kill)
     self.customFont = tkFont.Font(family="Helvetica", size=8)
      
     # set up lists
     listframe = Frame(self.root)
     scrollbar = Scrollbar(listframe, orient=tk.VERTICAL)
     self.listbox_numbering = tk.Listbox(listframe, yscrollcommand=scrollbar.set, font=self.customFont)
     self.listbox_content = tk.Listbox(listframe, yscrollcommand=scrollbar.set, font=self.customFont)
     
     h = 52
     lbn_opt = {"height":h, "width":4}
     lbn_opt2 = {"height":h}
      
     scrollbar.config(command=self._scroll_lists)
     scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
     self.listbox_numbering.config(lbn_opt)
     self.listbox_numbering.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
     self.listbox_content.config(lbn_opt2)
     self.listbox_content.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
      
     listframe.pack()
Example #19
0
    def _init_exampleListbox(self, parent):
        self._exampleFrame = listframe = Frame(parent)
        self._exampleFrame.pack(fill="both", side="left", padx=2)
        self._exampleList_label = Label(self._exampleFrame, font=self._boldfont, text="Examples")
        self._exampleList_label.pack()
        self._exampleList = Listbox(
            self._exampleFrame,
            selectmode="single",
            relief="groove",
            background="white",
            foreground="#909090",
            font=self._font,
            selectforeground="#004040",
            selectbackground="#c0f0c0",
        )

        self._exampleList.pack(side="right", fill="both", expand=1)

        for example in self._examples:
            self._exampleList.insert("end", ("  %s" % example))
        self._exampleList.config(height=min(len(self._examples), 25), width=40)

        # Add a scrollbar if there are more than 25 examples.
        if len(self._examples) > 25:
            listscroll = Scrollbar(self._exampleFrame, orient="vertical")
            self._exampleList.config(yscrollcommand=listscroll.set)
            listscroll.config(command=self._exampleList.yview)
            listscroll.pack(side="left", fill="y")

        # If they select a example, apply it.
        self._exampleList.bind("<<ListboxSelect>>", self._exampleList_select)
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args, **kw)
        vscrollbar = Scrollbar(self, orient=VERTICAL)
        vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE)
        canvas = Canvas(
            self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set)
        canvas.pack(side=LEFT, fill=BOTH, expand=TRUE)
        vscrollbar.config(command=canvas.yview)
        canvas.xview_moveto(0)
        canvas.yview_moveto(0)
        self.interior = interior = Frame(canvas)
        interior_id = canvas.create_window(0, 0, window=interior, anchor=NW)
        self.canv = canvas  # @UndefinedVariable
        self.scroller = vscrollbar

        def _configure_interior(event):
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            canvas.config(scrollregion="0 0 %s %s" % size)
            if interior.winfo_reqwidth() != canvas.winfo_width():
                canvas.config(width=interior.winfo_reqwidth())
        interior.bind('<Configure>', _configure_interior)

        def _configure_canvas(event):
            if interior.winfo_reqwidth() != canvas.winfo_width():
                canvas.itemconfigure(interior_id, width=canvas.winfo_width())
        canvas.bind('<Configure>', _configure_canvas)
Example #21
0
    def _init_exampleListbox(self, parent):
        self._exampleFrame = listframe = Frame(parent)
        self._exampleFrame.pack(fill='both', side='left', padx=2)
        self._exampleList_label = Label(self._exampleFrame,
                                        font=self._boldfont,
                                        text='Examples')
        self._exampleList_label.pack()
        self._exampleList = Listbox(self._exampleFrame,
                                    selectmode='single',
                                    relief='groove',
                                    background='white',
                                    foreground='#909090',
                                    font=self._font,
                                    selectforeground='#004040',
                                    selectbackground='#c0f0c0')

        self._exampleList.pack(side='right', fill='both', expand=1)

        for example in self._examples:
            self._exampleList.insert('end', ('  %s' % example))
        self._exampleList.config(height=min(len(self._examples), 25), width=40)

        # Add a scrollbar if there are more than 25 examples.
        if len(self._examples) > 25:
            listscroll = Scrollbar(self._exampleFrame, orient='vertical')
            self._exampleList.config(yscrollcommand=listscroll.set)
            listscroll.config(command=self._exampleList.yview)
            listscroll.pack(side='left', fill='y')

        # If they select a example, apply it.
        self._exampleList.bind('<<ListboxSelect>>', self._exampleList_select)
Example #22
0
def buscar(pattern, index):
    def listar(event):
        lista.delete(0, END)
        ix = open_dir(index)
        with ix.searcher() as searcher:
            query = QueryParser(pattern,
                                ix.schema).parse(unicode(entrada.get()))
            results = searcher.search(query)
            for r in results:
                lista.insert(END, r['titulo'])
                lista.insert(END, r['fecha'])
                lista.insert(END, r['username'])
                lista.insert(END, '')

    root = Tkinter.Toplevel()
    frame1 = Frame(root)
    entrada = Entry(frame1, bd=2, width=60)
    lab = Label(frame1, text="Buscar: ")

    entrada.bind("<Return>", listar)
    sc = Scrollbar(root)
    sc.pack(side=RIGHT, fill=Y)
    lista = Listbox(root, yscrollcommand=sc.set)
    frame1.pack(side=TOP)

    lista.pack(side=TOP, fill=BOTH)
    lab.pack(side=LEFT)
    entrada.pack(side=LEFT)
    sc.config(command=lista.yview)
    root.mainloop()
Example #23
0
    def _init_readingListbox(self, parent):
        self._readingFrame = listframe = Frame(parent)
        self._readingFrame.pack(fill='both', side='left', padx=2)
        self._readingList_label = Label(self._readingFrame,
                                        font=self._boldfont,
                                        text='Readings')
        self._readingList_label.pack()
        self._readingList = Listbox(self._readingFrame,
                                    selectmode='single',
                                    relief='groove',
                                    background='white',
                                    foreground='#909090',
                                    font=self._font,
                                    selectforeground='#004040',
                                    selectbackground='#c0f0c0')

        self._readingList.pack(side='right', fill='both', expand=1)

        # Add a scrollbar if there are more than 25 examples.
        listscroll = Scrollbar(self._readingFrame, orient='vertical')
        self._readingList.config(yscrollcommand=listscroll.set)
        listscroll.config(command=self._readingList.yview)
        listscroll.pack(side='right', fill='y')

        self._populate_readingListbox()
 def setPixelList(self):
     if "pixelListBox" in self.widgetDict.keys():
         pixelListBox = self.widgetDict["pixelListBox"]
         pixelListBox.delete(0, "end")
         self.widgetDict["kernelListbox"].config(text="Pixels: %s" % len(
             self.RepLine.getKernel(self.activeCob,
                                    self.activeKernel).keys()))
     else:
         pixelListbox = Listbox(self)
         self.widgetDict["pixelListbox"] = pixelListbox
         scrollbar = Scrollbar(pixelListbox, orient="vertical")
         pixelListbox.config(yscrollcommand=scrollbar.set)
         scrollbar.config(command=pixelListbox.yview)
         self.widgetDict["pixelsLabel"].config(text="Pixels: %s" % len(
             self.RepLine.getKernel(self.activeCob,
                                    self.activeKernel).keys()))
         pixelListbox.grid(row=3, column=2, rowspan=3, sticky="nsew")
         pixelListbox.columnconfigure(0, weight=1)
         pixelListbox.bind("<<ListboxSelect>>", self.updateActivePixel)
         scrollbar.grid(column=2, sticky="e")
     cobNumber = self.activeCob[:self.activeCob.index("_")]
     kernelNumber = self.activeKernel[self.activeKernel.index(" ") + 1:]
     kernel = self.RepLine.getKernel(int(cobNumber), int(kernelNumber))
     for pixelNumber in xrange(len(kernel.keys())):
         pixelListbox.insert(pixelNumber, "Pixel: %s" % pixelNumber)
Example #25
0
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args, **kw)
        # create a canvas object and a vertical scrollbar for scrolling it
        vscrollbar = Scrollbar(self, orient=VERTICAL)
        vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE)
        canvas = Canvas(self, bd=0, highlightthickness=0,
                        yscrollcommand=vscrollbar.set)
        canvas.pack(side=LEFT, fill=BOTH, expand=TRUE)
        vscrollbar.config(command=canvas.yview)

        # reset the view
        canvas.xview_moveto(0)
        canvas.yview_moveto(0)

        # create a frame inside the canvas which will be scrolled with it
        self.interior = interior = Frame(canvas)
        interior_id = canvas.create_window(0, 0, window=interior,
                                           anchor=NW)

        # track changes to the canvas and frame width and sync them,
        # also updating the scrollbar
        def _configure_interior(event=None):
            # update the scrollbars to match the size of the inner frame
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            canvas.config(scrollregion="0 0 %s %s" % size)
            if interior.winfo_reqwidth() != canvas.winfo_width():
                # update the canvas's width to fit the inner frame
                canvas.config(width=interior.winfo_reqwidth())
        interior.bind('<Configure>', _configure_interior)

        def _configure_canvas(event=None):
            if interior.winfo_reqwidth() != canvas.winfo_width():
                # update the inner frame's width to fill the canvas
                canvas.itemconfigure(interior_id, width=canvas.winfo_width())
        canvas.bind('<Configure>', _configure_canvas)
Example #26
0
 def _init_results_box(self, parent):
     innerframe = Frame(parent)
     i1 = Frame(innerframe)
     i2 = Frame(innerframe)
     vscrollbar = Scrollbar(i1, borderwidth=1)
     hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz')
     self.results_box = Text(i1,
                             font=tkFont.Font(family='courier', size='16'),
                             state='disabled',
                             borderwidth=1,
                             yscrollcommand=vscrollbar.set,
                             xscrollcommand=hscrollbar.set,
                             wrap='none',
                             width='40',
                             height='20',
                             exportselection=1)
     self.results_box.pack(side='left', fill='both', expand=True)
     self.results_box.tag_config(self._HIGHLIGHT_WORD_TAG,
                                 foreground=self._HIGHLIGHT_WORD_COLOUR)
     self.results_box.tag_config(self._HIGHLIGHT_LABEL_TAG,
                                 foreground=self._HIGHLIGHT_LABEL_COLOUR)
     vscrollbar.pack(side='left', fill='y', anchor='e')
     vscrollbar.config(command=self.results_box.yview)
     hscrollbar.pack(side='left', fill='x', expand=True, anchor='w')
     hscrollbar.config(command=self.results_box.xview)
     #there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!!
     Label(i2, text='   ',
           background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e')
     i1.pack(side='top', fill='both', expand=True, anchor='n')
     i2.pack(side='bottom', fill='x', anchor='s')
     innerframe.pack(side='top', fill='both', expand=True)
Example #27
0
def addScrollingFigure(figure, frame):
    global canvas, mplCanvas, interior, interior_id, cwid
    # set up a canvas with scrollbars
    canvas = Canvas(frame)
    canvas.grid(row=1, column=1, sticky=Tkconstants.NSEW)

    xScrollbar = Scrollbar(frame, orient=Tkconstants.HORIZONTAL)
    yScrollbar = Scrollbar(frame)

    xScrollbar.grid(row=2, column=1, sticky=Tkconstants.EW)
    yScrollbar.grid(row=1, column=2, sticky=Tkconstants.NS)

    canvas.config(xscrollcommand=xScrollbar.set)
    xScrollbar.config(command=canvas.xview)
    canvas.config(yscrollcommand=yScrollbar.set)
    yScrollbar.config(command=canvas.yview)

    # plug in the figure
    figAgg = FigureCanvasTkAgg(figure, canvas)
    mplCanvas = figAgg.get_tk_widget()

    # and connect figure with scrolling region
    cwid = canvas.create_window(0, 0, window=mplCanvas, anchor=Tkconstants.NW)
    printBboxes("Init")
    changeSize(figure, 1)
Example #28
0
 def __init__(self, list_=None, master=None, title=None):
     '''Must have master, title is optional, li is too.'''
     self.master = master
     if self.master is not None:
         self.top = Toplevel(self.master)
     else:
         return
     self.v = None
     if list_ is None or not isinstance(list_, list):
         self.list = []
     else:
         self.list = list_[:]
     self.top.transient(self.master)
     self.top.grab_set()
     self.top.bind("<Return>", self._choose)
     self.top.bind("<Escape>", self._cancel)
     if title:
         self.top.title(title)
     lf = Frame(self.top)         #Sets up the list.
     lf.pack(side=TOP)
     scroll_bar = Scrollbar(lf)
     scroll_bar.pack(side=RIGHT, fill=Y)
     self.lb = Listbox(lf, selectmode=SINGLE)
     self.lb.pack(side=LEFT, fill=Y)
     scroll_bar.config(command=self.lb.yview)
     self.lb.config(yscrollcommand=scroll_bar.set)
     self.list.sort()
     for item in self.list:
         self.lb.insert(END, item)     #Inserts items into the list.
     bf = Frame(self.top)
     bf.pack(side=BOTTOM)
     Button(bf, text="Select", command=self._choose).pack(side=LEFT)
     Button(bf, text="New", command=self._new).pack(side=LEFT)
     Button(bf, text="Cancel", command=self._cancel).pack(side=LEFT)
Example #29
0
    def construct(self):
        status = Frame(self)
        self._update_bar = StatusBar(status)
        self._drawer = MazeCanvas.MazePlannerCanvas(self, self._update_bar, manager=self.manager)
        self._drawer.pack(expand=True,fill=BOTH)
        self._status_bar = StatusBar(status)
        Debug.d_level.set_message_pad(self._status_bar)

        self._status_bar.pack(side=BOTTOM, fill=X)
        self._update_bar.pack(side=BOTTOM, fill=X)

        x_scroll = Scrollbar(self._parent, orient=HORIZONTAL)
        x_scroll.config(command=self._drawer._canvas.xview)
        x_scroll.pack(side=BOTTOM,fill=X)

        y_scroll = Scrollbar(self._parent, orient=VERTICAL)
        y_scroll.config(command=self._drawer._canvas.yview)
        y_scroll.pack(side=RIGHT,fill=Y)

        self._drawer._canvas.config(xscrollcommand=x_scroll.set, yscrollcommand=y_scroll.set,
                                    scrollregion=(-MAX_CANVAS_X, -MAX_CANVAS_Y,
                                                  MAX_CANVAS_X, MAX_CANVAS_Y))
        self._drawer._canvas.bind()

        status.pack(side=BOTTOM, fill=X)
Example #30
0
    def _init_readingListbox(self, parent):
        self._readingFrame = listframe = Frame(parent)
        self._readingFrame.pack(fill="both", side="left", padx=2)
        self._readingList_label = Label(self._readingFrame, font=self._boldfont, text="Readings")
        self._readingList_label.pack()
        self._readingList = Listbox(
            self._readingFrame,
            selectmode="single",
            relief="groove",
            background="white",
            foreground="#909090",
            font=self._font,
            selectforeground="#004040",
            selectbackground="#c0f0c0",
        )

        self._readingList.pack(side="right", fill="both", expand=1)

        # Add a scrollbar if there are more than 25 examples.
        listscroll = Scrollbar(self._readingFrame, orient="vertical")
        self._readingList.config(yscrollcommand=listscroll.set)
        listscroll.config(command=self._readingList.yview)
        listscroll.pack(side="right", fill="y")

        self._populate_readingListbox()
Example #31
0
    def instructions(self):
        """Open instructions window."""
        # Instantiates separate Toplevel instruction window.
        instr_window = Toplevel(self.root)
        instr_window.geometry('550x575+25+25')
        instr_window.title('Instructions')
        instr_window.wm_iconbitmap(constants.ICO)
        instr_window.resizable(False, False)

        # Creatse Scrollbar and Frame for containing other widgets.
        instr_scroll = Scrollbar(instr_window)
        instr_scroll.pack(fill=Y, side="right")
        instr_frame = Frame(instr_window, bg='white')
        instr_frame.pack(fill=BOTH, side="left")

        # Adds instruction text from constants and adds image of Cinzano's diagram.
        instr = Text(instr_frame,
                     width=65,
                     height=40,
                     padx=10,
                     pady=5,
                     bd=0,
                     wrap="word")
        instr.insert("end", constants.INSTR)
        cdiagram_file = Image.open("./static/cinzano_diagram.PNG")
        cdiagram_file = cdiagram_file.resize((500, 450), Image.ANTIALIAS)
        self.cdiag = ImageTk.PhotoImage(cdiagram_file)
        instr.image_create("end", image=self.cdiag)
        instr.tag_add("top", "1.0", "4.10")
        instr.tag_config("top", font='Times 12 bold')
        instr.tag_add("body", "5.0", "19.20")
        instr.tag_config("body", font='Times 12')
        instr.insert("end", constants.CDIAG)
        instr.pack()
        instr_scroll.config(command=instr.yview)
Example #32
0
    def __init__(self, master, mech):
        self.mech = mech
        frame = Frame(master)
        frame.grid()
        rct_label = Label(frame, text='Select Reactants')
        rct_label.grid(column=1, row=1)
        and_or = Label(frame, text='AND/OR')
        and_or.grid(column=3, row=1)
        prod_label = Label(frame, text='Select Products')
        prod_label.grid(column=4, row=1)
        what_to_do = Label(frame, text='Execute')
        what_to_do.grid(column=6, row=1)
        reactants_scrollbar = Scrollbar(frame, orient=VERTICAL)
        self.reactants = Listbox(frame,
                                 selectmode=EXTENDED,
                                 exportselection=0,
                                 yscrollcommand=reactants_scrollbar.set)
        self.reactants.grid(column=1, row=2)
        reactants_scrollbar.config(command=self.reactants.yview)
        reactants_scrollbar.grid(column=2, row=2, sticky=N + S)

        self.logical_and = IntVar()
        self.logical_and.set(1)
        c = Checkbutton(frame, text="AND", variable=self.logical_and)
        c.grid(column=3, row=2)

        products_scrollbar = Scrollbar(frame, orient=VERTICAL)
        self.products = Listbox(frame, selectmode=EXTENDED, exportselection=0)
        self.products.grid(column=4, row=2)
        products_scrollbar.config(command=self.products.yview)
        products_scrollbar.grid(column=5, row=2, sticky=N + S)

        self.method_list = Listbox(frame,
                                   selectmode=EXTENDED,
                                   exportselection=0)
        self.method_list.grid(column=6, row=2)
        #self.methods = [k for k in dir(self.mech) if k[:1] != '_' and isinstance(getattr(self.mech, k), MethodType)]
        self.methods = [
            'plot_rxns', 'find_rxns', 'print_rxns', 'print_irrs',
            'print_net_rxn', 'plot_proc'
        ]
        method_labels = [
            'Plot Reactions', 'Show Rxn Ids', 'Print Rxns', 'Print IRRs',
            'Print Net Rxn', 'Process Plot'
        ]
        for method in method_labels:
            self.method_list.insert(END, method)

        species_keys = self.mech.species_dict.keys()
        species_keys.sort()
        self.species_objects = [
            self.mech.species_dict[spc] for spc in species_keys
        ]

        for spc in species_keys:
            self.reactants.insert(END, spc)
            self.products.insert(END, spc)
        self.execute_button = Button(frame, text="go", command=self.execute)
        self.execute_button.grid(column=6, row=4)
Example #33
0
def xGC_skew(seq, window = 1000, zoom = 100,
                         r = 300, px = 100, py = 100):
    """Calculates and plots normal and accumulated GC skew (GRAPHICS !!!)."""
    from Tkinter import Scrollbar, Canvas, BOTTOM, BOTH, ALL, \
                        VERTICAL, HORIZONTAL, RIGHT, LEFT, X, Y
    yscroll = Scrollbar(orient = VERTICAL)
    xscroll = Scrollbar(orient = HORIZONTAL)
    canvas = Canvas(yscrollcommand = yscroll.set,
                    xscrollcommand = xscroll.set, background = 'white')
    win = canvas.winfo_toplevel()
    win.geometry('700x700')

    yscroll.config(command = canvas.yview)
    xscroll.config(command = canvas.xview)
    yscroll.pack(side = RIGHT, fill = Y)
    xscroll.pack(side = BOTTOM, fill = X)
    canvas.pack(fill=BOTH, side = LEFT, expand = 1)
    canvas.update()

    X0, Y0 = r + px, r + py
    x1, x2, y1, y2 = X0 - r, X0 + r, Y0 -r, Y0 + r

    ty = Y0
    canvas.create_text(X0, ty, text = '%s...%s (%d nt)' % (seq[:7], seq[-7:], len(seq)))
    ty +=20
    canvas.create_text(X0, ty, text = 'GC %3.2f%%' % (GC(seq)))
    ty +=20
    canvas.create_text(X0, ty, text = 'GC Skew', fill = 'blue')
    ty +=20
    canvas.create_text(X0, ty, text = 'Accumulated GC Skew', fill = 'magenta')
    ty +=20
    canvas.create_oval(x1,y1, x2, y2)

    acc = 0
    start = 0
    for gc in GC_skew(seq, window):
        r1 = r
        acc+=gc
        # GC skew
        alpha = pi - (2*pi*start)/len(seq)
        r2 = r1 - gc*zoom
        x1 = X0 + r1 * sin(alpha)
        y1 = Y0 + r1 * cos(alpha)
        x2 = X0 + r2 * sin(alpha)
        y2 = Y0 + r2 * cos(alpha)
        canvas.create_line(x1,y1,x2,y2, fill = 'blue')
        # accumulated GC skew
        r1 = r - 50
        r2 = r1 - acc
        x1 = X0 + r1 * sin(alpha)
        y1 = Y0 + r1 * cos(alpha)
        x2 = X0 + r2 * sin(alpha)
        y2 = Y0 + r2 * cos(alpha)
        canvas.create_line(x1,y1,x2,y2, fill = 'magenta')

        canvas.update()
        start += window

    canvas.configure(scrollregion = canvas.bbox(ALL))
Example #34
0
def xGC_skew(seq, window=1000, zoom=100,
                         r=300, px=100, py=100):
    """Calculates and plots normal and accumulated GC skew (GRAPHICS !!!)."""
    from Tkinter import Scrollbar, Canvas, BOTTOM, BOTH, ALL, \
                        VERTICAL, HORIZONTAL, RIGHT, LEFT, X, Y
    yscroll = Scrollbar(orient=VERTICAL)
    xscroll = Scrollbar(orient=HORIZONTAL)
    canvas = Canvas(yscrollcommand=yscroll.set,
                    xscrollcommand=xscroll.set, background='white')
    win = canvas.winfo_toplevel()
    win.geometry('700x700')

    yscroll.config(command=canvas.yview)
    xscroll.config(command=canvas.xview)
    yscroll.pack(side=RIGHT, fill=Y)
    xscroll.pack(side=BOTTOM, fill=X)
    canvas.pack(fill=BOTH, side=LEFT, expand=1)
    canvas.update()

    X0, Y0 = r + px, r + py
    x1, x2, y1, y2 = X0 - r, X0 + r, Y0 - r, Y0 + r

    ty = Y0
    canvas.create_text(X0, ty, text='%s...%s (%d nt)' % (seq[:7], seq[-7:], len(seq)))
    ty += 20
    canvas.create_text(X0, ty, text='GC %3.2f%%' % (GC(seq)))
    ty += 20
    canvas.create_text(X0, ty, text='GC Skew', fill='blue')
    ty += 20
    canvas.create_text(X0, ty, text='Accumulated GC Skew', fill='magenta')
    ty += 20
    canvas.create_oval(x1, y1, x2, y2)

    acc = 0
    start = 0
    for gc in GC_skew(seq, window):
        r1 = r
        acc += gc
        # GC skew
        alpha = pi - (2*pi*start)/len(seq)
        r2 = r1 - gc*zoom
        x1 = X0 + r1 * sin(alpha)
        y1 = Y0 + r1 * cos(alpha)
        x2 = X0 + r2 * sin(alpha)
        y2 = Y0 + r2 * cos(alpha)
        canvas.create_line(x1, y1, x2, y2, fill='blue')
        # accumulated GC skew
        r1 = r - 50
        r2 = r1 - acc
        x1 = X0 + r1 * sin(alpha)
        y1 = Y0 + r1 * cos(alpha)
        x2 = X0 + r2 * sin(alpha)
        y2 = Y0 + r2 * cos(alpha)
        canvas.create_line(x1, y1, x2, y2, fill='magenta')

        canvas.update()
        start += window

    canvas.configure(scrollregion=canvas.bbox(ALL))
Example #35
0
class TextViewer(Toplevel):
    """A simple text viewer dialog for IDLE

    """
    def __init__(self, parent, title, text):
        """Show the given text in a scrollable window with a 'close' button

        """
        Toplevel.__init__(self, parent)
        self.configure(borderwidth=5)
        self.geometry(
            "=%dx%d+%d+%d" %
            (625, 500, parent.winfo_rootx() + 10, parent.winfo_rooty() + 10))
        #elguavas - config placeholders til config stuff completed
        self.bg = '#ffffff'
        self.fg = '#000000'

        self.CreateWidgets()
        self.title(title)
        self.transient(parent)
        self.grab_set()
        self.protocol("WM_DELETE_WINDOW", self.Ok)
        self.parent = parent
        self.textView.focus_set()
        #key bindings for this dialog
        self.bind('<Return>', self.Ok)  #dismiss dialog
        self.bind('<Escape>', self.Ok)  #dismiss dialog
        self.textView.insert(0.0, text)
        self.textView.config(state=DISABLED)
        self.wait_window()

    def CreateWidgets(self):
        frameText = Frame(self, relief=SUNKEN, height=700)
        frameButtons = Frame(self)
        self.buttonOk = Button(frameButtons,
                               text='Close',
                               command=self.Ok,
                               takefocus=False)
        self.scrollbarView = Scrollbar(frameText,
                                       orient=VERTICAL,
                                       takefocus=False)
        self.textView = Text(frameText,
                             wrap=WORD,
                             fg=self.fg,
                             bg=self.bg,
                             highlightthickness=0)
        self.scrollbarView.config(command=self.textView.yview)
        self.textView.config(yscrollcommand=self.scrollbarView.set)
        self.buttonOk.pack()
        self.scrollbarView.pack(side=RIGHT, fill=Y)
        self.textView.pack(side=LEFT, expand=True, fill=BOTH)
        frameButtons.pack(side=BOTTOM)
        frameText.pack(side=TOP, expand=True, fill=BOTH)

        if TTK:
            frameButtons['style'] = 'RootColor.TFrame'

    def Ok(self, event=None):
        self.destroy()
Example #36
0
 def make_widgets(self):
     sbar = Scrollbar(self)
     text = Text(self, relief=SUNKEN)
     sbar.config(command=text.yview)  # xlink sbar and text
     text.config(yscrollcommand=sbar.set)  # move one moves other
     sbar.pack(side=RIGHT, fill=YES)  # pack first=clip last
     text.pack(side=LEFT, expand=YES, fill=BOTH)  # text clipped first
     self.text = text
Example #37
0
 def makewidgets(self):
     sbar = Scrollbar(self)
     text = Text(self, relief=SUNKEN)
     sbar.config(command=text.yview)
     text.config(yscrollcommand=sbar.set)
     sbar.pack(side=RIGHT, fill=YES)
     text.pack(side=LEFT, expand=YES, fill=BOTH)
     self.text = text
 def makeWidgets(self, width):
     scrbar_width = 30 
     scrbar = Scrollbar(self, width=scrbar_width)
     self.list = Listbox(self, relief=SUNKEN, width=width-30)
     scrbar.config(command=self.list.yview)
     self.list.config(yscrollcommand=scrbar.set)
     scrbar.pack(side=RIGHT, fill=Y)
     self.list.pack(side=LEFT, expand=YES, fill=BOTH)
Example #39
0
 def make_widgets(self):
     sbar = Scrollbar(self)
     text = Text(self, relief=SUNKEN)
     sbar.config(command=text.yview)                   # xlink sbar and text
     text.config(yscrollcommand=sbar.set)             # move one moves other
     sbar.pack(side=RIGHT, fill=YES)                   # pack first=clip last
     text.pack(side=LEFT, expand=YES, fill=BOTH)       # text clipped first
     self.text = text
Example #40
0
class TextViewer(Toplevel):
    """A simple text viewer dialog for IDLE

    """
    def __init__(self, parent, title, text, modal=True, _htest=False):
        """Show the given text in a scrollable window with a 'close' button

        If modal option set to False, user can interact with other windows,
        otherwise they will be unable to interact with other windows until
        the textview window is closed.

        _htest - bool; change box location when running htest.
        """
        Toplevel.__init__(self, parent)
        self.configure(borderwidth=5)
        # place dialog below parent if running htest
        self.geometry("=%dx%d+%d+%d" % (750, 500,
                           parent.winfo_rootx() + 10,
                           parent.winfo_rooty() + (10 if not _htest else 100)))
        #elguavas - config placeholders til config stuff completed
        self.bg = '#ffffff'
        self.fg = '#000000'

        self.CreateWidgets()
        self.title(title)
        self.protocol("WM_DELETE_WINDOW", self.Ok)
        self.parent = parent
        self.textView.focus_set()
        #key bindings for this dialog
        self.bind('<Return>',self.Ok) #dismiss dialog
        self.bind('<Escape>',self.Ok) #dismiss dialog
        self.textView.insert(0.0, text)
        self.textView.config(state=DISABLED)

        if modal:
            self.transient(parent)
            self.grab_set()
            self.wait_window()

    def CreateWidgets(self):
        frameText = Frame(self, relief=SUNKEN, height=700)
        frameButtons = Frame(self)
        self.buttonOk = Button(frameButtons, text='Close',
                               command=self.Ok, takefocus=FALSE)
        self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
                                       takefocus=FALSE, highlightthickness=0)
        self.textView = Text(frameText, wrap=WORD, highlightthickness=0,
                             fg=self.fg, bg=self.bg)
        self.scrollbarView.config(command=self.textView.yview)
        self.textView.config(yscrollcommand=self.scrollbarView.set)
        self.buttonOk.pack()
        self.scrollbarView.pack(side=RIGHT,fill=Y)
        self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
        frameButtons.pack(side=BOTTOM,fill=X)
        frameText.pack(side=TOP,expand=TRUE,fill=BOTH)

    def Ok(self, event=None):
        self.destroy()
Example #41
0
def setScrollBar(canvas,frame):
    hbar=Scrollbar(frame,orient=HORIZONTAL)
    hbar.pack(side=BOTTOM,fill=X)
    hbar.config(command=canvas.xview)
    vbar=Scrollbar(frame,orient=VERTICAL)
    vbar.pack(side=RIGHT,fill=Y)
    vbar.config(command=canvas.yview)
    canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
    canvas.pack(side=LEFT,expand=True,fill=BOTH)
Example #42
0
class Writer(Toplevel):
    def __init__(self, parent):
        Toplevel.__init__(self)
        self.parent = parent
        self.row = 0
        self.maxsize(650, 850)
        self.resizable(0,0)
        self.scroll = Scrollbar(self)
        self.scroll.pack(side="right", fill="y", expand=True)
        self.frame = Listbox(self, yscrollcommand=self.scroll.set)
        self.scroll.config(command=self.frame.yview)
        self.frame.pack()

        self.init_ui()


    def init_ui(self):

        name = self.insert_entry_field("Name")
        events = self.insert_entry_field("Events")
        location = self.insert_entry_field("Location")
        statement = self.insert_text_field("Statement")
        reply1 = self.insert_text_field("Reply1")
        reply2 = self.insert_text_field("Reply2")
        reply3 = self.insert_text_field("Reply3")
        reply4 = self.insert_text_field("Reply4")


        buttonframe = Frame(self)
        button1 = Button(buttonframe, text="Ok")
        button2 = Button(buttonframe, text="Cancel")
        button2.pack(side="right", anchor="s", padx=5, pady=5)
        button1.pack(side="right", anchor="s", pady=5)
        buttonframe.pack(side="bottom", anchor="e")

    def insert_entry_field(self, txt):
        frame = Frame(self.frame)
        frame.grid(row=self.row, column=0)
        frame.pack(fill="x")
        label = Label(frame, text=txt, width=6)
        label.pack(side="left", anchor="n", padx=5, pady=5)
        entry = Entry(frame)
        entry.pack(fill="x", padx=5, pady=5, expand=True)
        entryfield = [frame, label, entry]

        return entryfield

    def insert_text_field(self, txt):
        frame = Frame(self.frame)
        frame.grid(row=self.row, column=0)
        frame.pack(fill="x")
        label = Label(frame, text=txt, width=6)
        label.pack(side="left", anchor="n", padx=5, pady=5)
        entry = Text(frame)
        entry.pack(fill="both", pady=5, padx=5, expand=True)
        textfield = [frame, label, entry]
        return textfield
Example #43
0
def displaysampleAutomata(event):
    global frameSampleDisplay
    try:
        if (srcStateTextVariable.get())=='':
            tkMessageBox.showerror("Initial State","Please select an initial state first.")
            return
        elif (destStateTextVariable.get())=='':
            tkMessageBox.showerror("Accepting States","Please select accepting states first.")
            return
        
        if sInputCheck.get()==1:
            import resizeimage
            frameSampleDisplay=ttk.LabelFrame(statsFrame,width=300,height=200)
            samplaCanvas=Canvas(frameSampleDisplay,bg='#FFFFFF',height=200,width=300)
            configGrid(frameSampleDisplay,1,2,1,1)
            samplaCanvas.pack(side=tk.TOP,fill=BOTH)
            filename='../graph/sample.png'
            
            def displaySampleFSM():
                resizeimage.resizeImage(filename,0.5)
                img = PhotoImage(file="../graph/sample0.5.png")
                label1.image = img # keep a reference!
                
                samplaCanvas.delete(img) #reset canvas
                samplaCanvas.create_image(0, 80, anchor='nw',image=img,tags="bg_img")
                
            displaySampleFSM()
            vbar=Scrollbar(frameSampleDisplay,orient=VERTICAL)
            vbar.pack(side=tk.RIGHT,fill=Y,anchor='ne')
            hbar=Scrollbar(frameSampleDisplay,orient=HORIZONTAL)
            hbar.pack(side=tk.TOP,fill=X,anchor='sw')
            hbar.config(command=samplaCanvas.xview)
            vbar.config(command=samplaCanvas.yview)
            canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
            
            samplaCanvasLogFrame=Canvas(frameSampleDisplay,bg='#FFFFFF',height=200,width=300)
            samplaCanvasLogFrame.pack(side=BOTTOM)
            displaysamplelogProcesslog=ttk.Button(samplaCanvasLogFrame,text='Process Log',width=10)
            displaysamplelogProcesslog.pack(side=LEFT,fill=X,anchor='w')
            displaysamplelogFSM=ttk.Button(samplaCanvasLogFrame,text='FSM',width=10,command=combine_funcs(generateSampleAutomata,displaySampleFSM))
            
            displaysamplelogFSM.pack(side=LEFT,fill=X,anchor='e')
            
            displaysamplelogPreview=ttk.Button(samplaCanvasLogFrame,text='Preview',width=10)
            displaysamplelogPreview.pack(side=LEFT,fill=X,anchor='e')
            
            def displaysampleFromBrowsercallback(event):
                displayFromBrowser(samplaCanvas,'sample')
                
            displaysamplelogPreview.bind('<ButtonRelease-1>',displaysampleFromBrowsercallback)
            
        elif sInputCheck.get()==0:
            #frameSampleDisplay.pack_forget()
            frameSampleDisplay.grid_forget() #Remove the Frame
    except (NameError,Exception):
        pass
Example #44
0
class Writer(Toplevel):
    def __init__(self, parent):
        Toplevel.__init__(self)
        self.parent = parent
        self.row = 0
        self.maxsize(650, 850)
        self.resizable(0, 0)
        self.scroll = Scrollbar(self)
        self.scroll.pack(side="right", fill="y", expand=True)
        self.frame = Listbox(self, yscrollcommand=self.scroll.set)
        self.scroll.config(command=self.frame.yview)
        self.frame.pack()

        self.init_ui()

    def init_ui(self):

        name = self.insert_entry_field("Name")
        events = self.insert_entry_field("Events")
        location = self.insert_entry_field("Location")
        statement = self.insert_text_field("Statement")
        reply1 = self.insert_text_field("Reply1")
        reply2 = self.insert_text_field("Reply2")
        reply3 = self.insert_text_field("Reply3")
        reply4 = self.insert_text_field("Reply4")

        buttonframe = Frame(self)
        button1 = Button(buttonframe, text="Ok")
        button2 = Button(buttonframe, text="Cancel")
        button2.pack(side="right", anchor="s", padx=5, pady=5)
        button1.pack(side="right", anchor="s", pady=5)
        buttonframe.pack(side="bottom", anchor="e")

    def insert_entry_field(self, txt):
        frame = Frame(self.frame)
        frame.grid(row=self.row, column=0)
        frame.pack(fill="x")
        label = Label(frame, text=txt, width=6)
        label.pack(side="left", anchor="n", padx=5, pady=5)
        entry = Entry(frame)
        entry.pack(fill="x", padx=5, pady=5, expand=True)
        entryfield = [frame, label, entry]

        return entryfield

    def insert_text_field(self, txt):
        frame = Frame(self.frame)
        frame.grid(row=self.row, column=0)
        frame.pack(fill="x")
        label = Label(frame, text=txt, width=6)
        label.pack(side="left", anchor="n", padx=5, pady=5)
        entry = Text(frame)
        entry.pack(fill="both", pady=5, padx=5, expand=True)
        textfield = [frame, label, entry]
        return textfield
Example #45
0
 def layout(self):
     canvas = Canvas(self.Widget, width=400, height=10)
     canvas.create_line(10, 2, 400, 2, fill='black', tags="line")
     self.rowindex = self.rowindex + 1
     canvas.grid(row=self.rowindex, column=1, columnspan=4)
     lblTarget = Label(self.Widget,
                       text=self.conf.get("TargetDeviceName", "title",
                                          "目标设备"),
                       font=self.fontSize)
     lblTarget.grid(row=self.rowindex, column=1, columnspan=4)
     lblTargetW = Label(self.Widget,
                        text=self.conf.get("TargetDeviceName", "width",
                                           "宽度(px)"),
                        font=self.fontSize)
     self.rowindex = self.rowindex + 1
     lblTargetW.grid(row=self.rowindex, column=1)
     entryTargetW = Entry(self.Widget, width=10, font=self.fontSize)
     entryTargetW.grid(row=self.rowindex, column=2)
     self.entryTargetW = entryTargetW
     lblTargetH = Label(self.Widget,
                        text=self.conf.get("TargetDeviceName", "width",
                                           "高度(px)"),
                        font=self.fontSize)
     lblTargetH.grid(row=self.rowindex, column=3)
     entryTargetH = Entry(self.Widget, width=10, font=self.fontSize)
     entryTargetH.grid(row=self.rowindex, column=4)
     self.entryTargetH = entryTargetH
     fmBox = Frame(self.Widget)
     scrollbar = Scrollbar(fmBox)
     scrollbar.pack(side=RIGHT, fill=Y)
     lb = Listbox(fmBox,
                  yscrollcommand=scrollbar.set,
                  width=25,
                  selectmode=EXTENDED)
     lb.pack(side=LEFT, fill=BOTH)
     scrollbar.config(command=lb.yview)
     self.rowindex = self.rowindex + 1
     fmBox.grid(row=self.rowindex, column=1, columnspan=2)
     self.lb = lb
     fmOper = Frame(self.Widget)
     fmAdd = Frame(fmOper, pady=10)
     btAdd = Button(fmAdd, text="添加", command=self.processAdd)
     btAdd.pack()
     fmDel = Frame(fmOper, pady=10)
     btDel = Button(fmDel, text="删除", command=self.processDel)
     btDel.pack()
     fmAdd.pack(side=TOP)
     fmDel.pack(side=BOTTOM)
     fmOper.grid(row=self.rowindex, column=3)
     canvas = Canvas(self.Widget, width=400, height=10)
     canvas.create_line(10, 2, 400, 2, fill='black', tags="line")
     self.rowindex = self.rowindex + 1
     canvas.grid(row=self.rowindex, column=1, columnspan=4)
     self.readDefDevice()
     return self.rowindex
def generate_listbox(row, fill_list):

    scrollbar = Scrollbar(row, orient=VERTICAL)
    Flistbox = Listbox(row, yscrollcommand=scrollbar.set, height=1)  #,
    scrollbar.config(command=Flistbox.yview)
    scrollbar.pack(side='right', fill=Y)
    for item in fill_list:
        Flistbox.insert(END, item)
    Flistbox.pack(side='left', fill=X, expand=1)

    return Flistbox
Example #47
0
    def setup_gui(self):
        # set up the gui
 
        # root is the Tkinter root widget
        self.root.title("Remote Monitor for Pi Presents")

        # self.root.configure(background='grey')

        self.root.resizable(False,False)

        # define response to main window closing
        self.root.protocol ("WM_DELETE_WINDOW", self.app_exit)

        # bind some display fields
        self.desc=StringVar()
        self.filename = StringVar()
        self.display_show = StringVar()
        self.results = StringVar()
        self.status = StringVar()

        # define menu
        menubar = Menu(self.root)

        osc_configmenu = Menu(menubar, tearoff=0, bg="grey", fg="black")
        menubar.add_cascade(label='Options', menu = osc_configmenu)
        osc_configmenu.add_command(label='Edit', command = self.e_edit_osc)

        helpmenu = Menu(menubar, tearoff=0, bg="grey", fg="black")
        menubar.add_cascade(label='Help', menu = helpmenu)
        helpmenu.add_command(label='Help', command = self.show_help)
        helpmenu.add_command(label='About', command = self.about)
         
        self.root.config(menu=menubar)

        # info frame
        info_frame=Frame(self.root,padx=5,pady=5)
        info_frame.pack(side=TOP, fill=BOTH, expand=1)
        info_name = Label(info_frame, text="Slave Unit's Name: "+self.osc_config.this_unit_name,font="arial 12 bold")
        info_name.pack(side=TOP)
        info_this_address = Label(info_frame, textvariable=self.desc,font="arial 12 bold")
        info_this_address.pack(side=TOP)

        
        # status_frame      
        status_frame=Frame(self.root,padx=5,pady=5)
        status_frame.pack(side=TOP, fill=BOTH, expand=1)
        status_label = Label(status_frame, text="Status:",font="arial 12 bold")
        status_label.pack(side=LEFT)
        scrollbar = Scrollbar(status_frame, orient=VERTICAL)
        self.status_display=Text(status_frame,height=20, yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.status_display.yview)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.status_display.pack(side=LEFT,fill=BOTH, expand=1)
Example #48
0
class TextViewer(Toplevel):
    """A simple text viewer dialog for IDLE

    """
    def __init__(self, parent, title, text):
        """Show the given text in a scrollable window with a 'close' button

        """
        Toplevel.__init__(self, parent)
        self.configure(borderwidth=5)
        self.geometry("=%dx%d+%d+%d" % (625, 500,
                                        parent.winfo_rootx() + 10,
                                        parent.winfo_rooty() + 10))
        #elguavas - config placeholders til config stuff completed
        self.bg = '#ffffff'
        self.fg = '#000000'

        self.CreateWidgets()
        self.title(title)
        self.transient(parent)
        self.grab_set()
        self.protocol("WM_DELETE_WINDOW", self.Ok)
        self.parent = parent
        self.textView.focus_set()
        #key bindings for this dialog
        self.bind('<Return>',self.Ok) #dismiss dialog
        self.bind('<Escape>',self.Ok) #dismiss dialog
        self.textView.insert(0.0, text)
        self.textView.config(state=DISABLED)
        self.wait_window()

    def CreateWidgets(self):
        frameText = Frame(self, relief=SUNKEN, height=700)
        frameButtons = Frame(self)
        self.buttonOk = Button(frameButtons, text='Close',
                               command=self.Ok, takefocus=False)
        self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
                                       takefocus=False)
        self.textView = Text(frameText, wrap=WORD, fg=self.fg, bg=self.bg,
                             highlightthickness=0)
        self.scrollbarView.config(command=self.textView.yview)
        self.textView.config(yscrollcommand=self.scrollbarView.set)
        self.buttonOk.pack()
        self.scrollbarView.pack(side=RIGHT,fill=Y)
        self.textView.pack(side=LEFT,expand=True,fill=BOTH)
        frameButtons.pack(side=BOTTOM)
        frameText.pack(side=TOP,expand=True,fill=BOTH)

        if TTK:
            frameButtons['style'] = 'RootColor.TFrame'

    def Ok(self, event=None):
        self.destroy()
Example #49
0
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args, **kw)

        # create a canvas object and a vertical scrollbar for scrolling it
        vscrollbar = Scrollbar(self, orient=Tkinter.VERTICAL)
        vscrollbar.pack(fill=Tkinter.Y, side=Tkinter.RIGHT, expand=Tkinter.FALSE)

        hscrollbar = Scrollbar(self, orient=Tkinter.HORIZONTAL)
        hscrollbar.pack(fill=Tkinter.X, side=Tkinter.BOTTOM, expand=Tkinter.FALSE)

        canvas = Canvas(self, bd=0, highlightthickness=0,
                        yscrollcommand=vscrollbar.set, xscrollcommand=hscrollbar.set)
        canvas.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=Tkinter.TRUE)
        vscrollbar.config(command=canvas.yview)
        hscrollbar.config(command=canvas.xview)


        # reset the view

        canvas.xview_moveto(0)
        canvas.yview_moveto(0)

        # create a frame inside the canvas which will be scrolled with it

        self.interior = interior = Frame(canvas)
        interior_id = canvas.create_window(0, 0, window=interior, anchor=Tkinter.NW)

        # track changes to the canvas and frame width and sync them,
        # also updating the scrollbar

        def _configure_interior(event):

            '''
            update the scrollbars to match the size of the inner frame
            '''
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            canvas.config(scrollregion='0 0 %s %s' % size)
            if interior.winfo_reqwidth() != canvas.winfo_width():
                # update the canvas's width to fit the inner frame
                canvas.config(width=interior.winfo_reqwidth())
        interior.bind('<Configure>', _configure_interior)

        def _configure_canvas(event):

            '''
            _configure_canvas is used to resize the window size to fit content.
            Can be used when changing window.
            '''

            if interior.winfo_reqwidth() != canvas.winfo_width():
                # update the inner frame's width to fill the canvas
                canvas.itemconfigure(interior_id, width=canvas.winfo_width())
Example #50
0
 def addPortfolioList(self, companies):
     portfolioFrame = Frame(self.stocksFrame)
     scrollbar = Scrollbar(portfolioFrame, orient="vertical")
     companyList = Listbox(portfolioFrame, yscrollcommand=scrollbar.set)
     scrollbar.config(command=companyList.yview)
     
     scrollbar.pack(side="right", fill="y")
     #lb = Listbox(root, width=50, height=20, yscrollcommand=scrollbar.set)        
     companyList.pack(fill=X, expand=0, side=TOP, padx=PAD, pady=PAD)
     
     for company in companies:
         companyList.insert(END,company) 
     
     portfolioFrame.pack(fill=BOTH, expand=1, side=TOP)
Example #51
0
	def __init__(self, master=None, title=None, message=None, clist=[], newmessage=None):
		self.master = master
		self.value = None
		self.newmessage = newmessage
		self.list = clist[:]
		
		self.modalPane = Toplevel(self.master)

		self.modalPane.transient(self.master)
		self.modalPane.grab_set()

		self.modalPane.bind("<Return>", self._choose)
		self.modalPane.bind("<Escape>", self._cancel)

		if title:
			self.modalPane.title(title)

		if message:
			Label(self.modalPane, text=message).pack(padx=5, pady=5)

		listFrame = Frame(self.modalPane)
		listFrame.pack(side=TOP, padx=5, pady=5)
		
		scrollBar = Scrollbar(listFrame)
		scrollBar.pack(side=RIGHT, fill=Y)
		self.listBox = Listbox(listFrame, selectmode=SINGLE)
		self.listBox.pack(side=LEFT, fill=Y)
		scrollBar.config(command=self.listBox.yview)
		self.listBox.config(yscrollcommand=scrollBar.set)
		self.list.sort()
		for item in self.list:
			self.listBox.insert(END, item)

		if newmessage is not None:
			newFrame = Frame(self.modalPane)
			newFrame.pack(side=TOP, padx=5)
			Label(newFrame, text=newmessage).pack(padx=5, pady=5)
			self.entry = Entry(newFrame, width=30)
			self.entry.pack(side=TOP, padx=5)
			self.entry.bind("<Return>", self._choose_entry)


		buttonFrame = Frame(self.modalPane)
		buttonFrame.pack(side=BOTTOM)

		chooseButton = Button(buttonFrame, text="Choose", command=self._choose_entry)
		chooseButton.pack()

		cancelButton = Button(buttonFrame, text="Cancel", command=self._cancel)
		cancelButton.pack(side=RIGHT)
Example #52
0
class GestureView(Frame):
    def __init__(self, gesture, master=None):
        self.gesture = gesture
        Frame.__init__(self, master=master)
        self.pack(fill="both", expand="yes")

        # self.xscroll = Scrollbar(self)
        # self.xscroll.pack(side="bottom", fill="x")
        # self.xscroll.config(command=self.xview)
        self.yscroll = Scrollbar(self)
        self.yscroll.pack(side="right", fill="y")

        self.details = GestureDetails(gesture=self.gesture, master=self, yscrollcommand=self.yscroll.set)

        self.yscroll.config(command=self.details.yview)
Example #53
0
 def __init__(self, parent, height=35, width=40):
     Frame.__init__(self, parent)
     
     #Create a scrollbar so that list can be of arbitrary length
     scrollbar = Scrollbar(self)
     #Create a listbox to hold/display the word list
     self.listbox  = Listbox(self, height = height, width = width, 
     yscrollcommand = scrollbar.set)
     scrollbar.config(command = self.listbox.yview)
     self.listbox.pack(side=LEFT, fill = BOTH)
     scrollbar.pack(side=RIGHT, fill = Y)
     
     #Allow the widget to react to single or double clicks
     self.listbox.bind("<Double-Button-1>", self.doubleclicked)
     self.listbox.bind("<Button-1>", self.singleclicked)
Example #54
0
 def __init__(self, parent, title, display_it):
     self.display_it = display_it
     self.errors = 0
     self.warnings = 0
     if self.display_it is False:
         return
     top = Toplevel()
     top.title(title)
     scrollbar = Scrollbar(top, orient=VERTICAL)
     self.textb = Text(top, width=80, height=40, wrap="word", font="arial 11", padx=5, yscrollcommand=scrollbar.set)
     scrollbar.config(command=self.textb.yview)
     scrollbar.pack(side=RIGHT, fill=Y)
     self.textb.pack(side=LEFT, fill=BOTH, expand=1)
     self.textb.config(state=NORMAL)
     self.textb.delete(1.0, END)
     self.textb.config(state=DISABLED)
Example #55
-1
class ResultList(Frame):
    """
    Result List widget
    """

    def __init__(self, master=None):
        Frame.__init__(self, master, padx=3, pady=3)
        self.columnconfigure(0, weight=1, minsize=50)
        self.columnconfigure(1, weight=1000)
        self.columnconfigure(2, weight=1, minsize=10)
        self.__createWidgets()
        self.show()

    def __createWidgets(self):
        self.lbl = Label(text="")
        self.lbl.grid(row=1, column=0, columnspan=2, in_=self)
        self.__hide_button = Button(text="Hide", command=self.hide)
        self.__hide_button.grid(row=0, column=0, columnspan=2, in_=self)
        self.__yScroll = Scrollbar(orient=VERTICAL)
        self.list = Listbox(yscrollcommand=self.__yScroll.set, selectmode=SINGLE)
        self.__yScroll.config(command=self.list.yview)

    def show(self):
        self.__hide_button.config(text="Hide", command=self.hide)
        self.list.grid(row=2, column=0, columnspan=2, sticky=N + S + E + W, in_=self)
        self.__yScroll.grid(row=2, column=2, sticky=W + N + S, in_=self)

    def hide(self):
        self.__hide_button.config(text="Show", command=self.show)
        self.list.grid_forget()
        self.__yScroll.grid_forget()

    def clear(self):
        self.list.delete(0, END)

    def fill(self, valList):
        self.clear()
        for v in valList:
            self.list.insert(END, v)
        self.list.see(0)
        self.select(0)

    def append(self, val):
        self.list.insert(END, val)
        self.list.see(END)

    def select(self, index=0):
        self.list.selection_set(index)

    def selected(self):
        return int(self.list.curselection()[0])

    def width(self, width):
        self.list.config(width=width)