Python Tkinter.Listbox() Examples

The following are 25 code examples of Tkinter.Listbox(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Tkinter , or try the search function .
Example #1
Source File: components.py    From SEM with MIT License 6 votes vote down vote up
def __init__(self, root, main_window, button_opt):
        ttk.Frame.__init__(self, root)
        
        self.root = root
        self.main_window = main_window
        self.current_files = None
        self.button_opt = button_opt
        
        # define options for opening or saving a file
        self.file_opt = options = {}
        options['defaultextension'] = '.txt'
        options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
        options['initialdir'] = os.path.expanduser("~")
        options['parent'] = root
        options['title'] = 'Select files to annotate.'
        
        self.file_selector_button = ttk.Button(self.root, text=u"select file(s)", command=self.filenames)
        self.label = ttk.Label(self.root, text=u"selected file(s):")
        self.fa_search = tkinter.PhotoImage(file=os.path.join(self.main_window.resource_dir, "images", "fa_search_24_24.gif"))
        self.file_selector_button.config(image=self.fa_search, compound=tkinter.LEFT)
        
        self.scrollbar = ttk.Scrollbar(self.root)
        self.selected_files = tkinter.Listbox(self.root, yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.selected_files.yview) 
Example #2
Source File: closable_Tab_with_menu.py    From PCWG with MIT License 6 votes vote down vote up
def __init__(self, parent):

        scrollbar = tk.Scrollbar(parent, orient=tk.VERTICAL)
        self.listbox = tk.Listbox(parent, yscrollcommand=scrollbar.set, selectmode=tk.EXTENDED)
        scrollbar.configure(command=self.listbox.yview)

        self.listbox.pack(side=tk.LEFT,fill=tk.BOTH, expand=1, pady=5)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y, pady=5) 
Example #3
Source File: pcwg_tool_reborn.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, parent):

        scrollbar = tk.Scrollbar(parent, orient=tk.VERTICAL)
        self.listbox = tk.Listbox(parent, yscrollcommand=scrollbar.set, selectmode=tk.EXTENDED)
        scrollbar.configure(command=self.listbox.yview)

        self.listbox.pack(side=tk.LEFT,fill=tk.BOTH, expand=1, pady=5)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y, pady=5) 
Example #4
Source File: tooltip.py    From darkc0de-old-stuff with GNU General Public License v3.0 5 votes vote down vote up
def demo():
    root = Tkinter.Tk(className='ToolTip-demo')
    l = Tkinter.Listbox(root)
    l.insert('end', "I'm a listbox")
    l.pack(side='top')
    t1 = ToolTip(l, follow_mouse=1, text="I'm a tooltip with follow_mouse set to 1, so I won't be placed outside my parent")
    b = Tkinter.Button(root, text='Quit', command=root.quit)
    b.pack(side='bottom')
    t2 = ToolTip(b, text='Enough of this')
    root.mainloop() 
Example #5
Source File: Tkinter_Widget_Examples.py    From MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter with MIT License 5 votes vote down vote up
def ok(self):
        selection = self.listbox.curselection()
        value = ', '.join(self.listbox.get(x) for x in selection)
        print('Listbox Selection: {} "{}"'.format(selection, value)) 
Example #6
Source File: Tkinter_Widget_Examples.py    From MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter with MIT License 5 votes vote down vote up
def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.pack()

        tk.Label(self, text="This is a listbox").pack()

        list_items = ["This is a listbox!", 'Item 1', 'Item 2', 'Item 3', 'etc.']

        self.listbox = tk.Listbox(self, selectmode='extended', bg='white')
        self.listbox.pack(padx=10, pady=10)

        for l in list_items:
            self.listbox.insert('end', l)

        tk.Button(self, text='OK', command=self.ok).pack() 
Example #7
Source File: ListPanel.py    From Python-Media-Player with Apache License 2.0 5 votes vote down vote up
def create_song_list_panel(self):
        # Creating Picture Canvas as Background
        background=Tkinter.PhotoImage(file="../Icons/background.gif")
        mainframe=Tkinter.Canvas(self.root)
        mainframe.pack(side='top', expand='yes', fill='both')
        mainframe.image=background
        mainframe.create_image(0, 0, anchor="nw", image=background)
        
        frame0=Tkinter.Frame(mainframe)
        frame0.pack(side='top')
        Tkinter.Label(frame0, text='Search : ', bg='skyblue').pack(side='left', expand='yes', fill='x')
        Tkinter.Entry(frame0, textvariable=self.var1).pack(side='left', expand='yes', fill='x')
        frame0.bind_all('<Any-KeyPress>',self.search_song_trigger)
        frame=Tkinter.Frame(mainframe, bg='skyblue')
        frame.pack(side='top')
        self.list_box=Tkinter.Listbox(frame, bg='powderblue', font=list_box_song_list_font, width=list_box_width, height=list_box_height)
        scrollbar=Tkinter.Scrollbar(frame, bg='skyblue')
        scrollbar.pack(side='right',expand='yes',fill='y')
        scrollbar.config(command=self.list_box.yview)
        self.list_box.config(yscrollcommand=scrollbar.set)
        self.list_box.pack(expand='yes',fill='both',side='right')
        frame1=Tkinter.Frame(mainframe, bg='blue')
        frame1.pack(side='top', expand='yes',fill='x')
        add_fileicon=Tkinter.PhotoImage(file="../Icons/add_file.gif")
        add_directoryicon=Tkinter.PhotoImage(file="../Icons/add_directory.gif")
        list_file=[
        (add_fileicon,'self.ask_for_play_song_direct'),
        (add_directoryicon,'self.ask_for_directory'),
        ]
        for i,j in list_file:
                storeobj=Tkinter.Button(frame1, image=i, command=eval(j), bg='blue')
                storeobj.pack(side='left')
                storeobj.image=i
        self.list_box.bind('<Double-Button-1>',self.play_on_click)
        return self.update_list_box_songs() 
Example #8
Source File: tkmktap.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def setupSubCommands(self):
        self.optMap = {}
        if hasattr(self.options, 'subCommands'):
            self.commandFrame = f = Tkinter.Frame(self)
            self.cmdList = Tkinter.Listbox(f)
            for (cmd, _, opt, desc) in self.options.subCommands:
                self.cmdList.insert(Tkinter.END, cmd)
                self.optMap[cmd] = opt()
            self.cmdList.pack()
            self.subCmdPoll = reactor.callLater(0.1, self.pollSubCommands)
            f.grid(row=1, column=3) 
Example #9
Source File: strap_beam_gui.py    From Structural-Engineering with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def static_analysis_frame_builder(self):
        self.stat_service_frame = tk.LabelFrame(self.statics_data_frame, text="Service:", bd=1, relief='sunken', padx=5, pady=2)
        self.stat_service_frame.grid(row=0, column=0, padx=5)

        self.stat_ult_frame = tk.LabelFrame(self.statics_data_frame, text="Ultimate:", bd=1, relief='sunken', padx=5, pady=2)
        self.stat_ult_frame.grid(row=0, column=1, padx=5)
        wstat = 15
        tk.Label(self.stat_service_frame, text="Source:", font=self.helv_res).grid(row=0, column=0, padx=5)
        tk.Label(self.stat_service_frame, text="Load (kips):", font=self.helv_res).grid(row=0, column=1, padx=5)
        tk.Label(self.stat_service_frame, text="Location (ft):", font=self.helv_res).grid(row=0, column=2, padx=5)
        tk.Label(self.stat_service_frame, text="Moment Arm (ft):", font=self.helv_res).grid(row=0, column=3, padx=5)
        tk.Label(self.stat_service_frame, text="Moment (ft-kips):", font=self.helv_res).grid(row=0, column=4, padx=5)
        self.service_statics = []
        self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
        self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
        self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
        self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
        self.service_statics.append(tk.Listbox(self.stat_service_frame, height = 10, width = wstat, font=self.helv))
        self.service_statics[0].grid(row=1, column=0)
        self.service_statics[1].grid(row=1, column=1)
        self.service_statics[2].grid(row=1, column=2)
        self.service_statics[3].grid(row=1, column=3)
        self.service_statics[4].grid(row=1, column=4)

        tk.Label(self.stat_ult_frame, text="Source:", font=self.helv_res).grid(row=0, column=0, padx=5)
        tk.Label(self.stat_ult_frame, text="Load (kips):", font=self.helv_res).grid(row=0, column=1, padx=5)
        tk.Label(self.stat_ult_frame, text="Location (ft):", font=self.helv_res).grid(row=0, column=2, padx=5)
        tk.Label(self.stat_ult_frame, text="Moment Arm (ft):", font=self.helv_res).grid(row=0, column=3, padx=5)
        tk.Label(self.stat_ult_frame, text="Moment (ft-kips):", font=self.helv_res).grid(row=0, column=4, padx=5)
        self.ultimate_statics = []
        self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
        self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
        self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
        self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
        self.ultimate_statics.append(tk.Listbox(self.stat_ult_frame, height = 10, width = wstat, font=self.helv))
        self.ultimate_statics[0].grid(row=1, column=0)
        self.ultimate_statics[1].grid(row=1, column=1)
        self.ultimate_statics[2].grid(row=1, column=2)
        self.ultimate_statics[3].grid(row=1, column=3)
        self.ultimate_statics[4].grid(row=1, column=4) 
Example #10
Source File: pcwg_tool_reborn.py    From PCWG with MIT License 5 votes vote down vote up
def addListBox(self, master, title):
            
            scrollbar =  tk.Scrollbar(master, orient=tk.VERTICAL)
            tipLabel = tk.Label(master, text="")
            tipLabel.grid(row = self.row, sticky=tk.W, column=self.tipColumn)                
            lb = tk.Listbox(master, yscrollcommand=scrollbar, selectmode=tk.EXTENDED, height=3)  
            
            self.listboxEntries[title] = ListBoxEntry(lb,scrollbar,tipLabel)              
            self.row += 1
            self.listboxEntries[title].scrollbar.configure(command=self.listboxEntries[title].listbox.yview)
            self.listboxEntries[title].scrollbar.grid(row=self.row, sticky=tk.W+tk.N+tk.S, column=self.titleColumn)
            return self.listboxEntries[title] 
Example #11
Source File: base_dialog.py    From PCWG with MIT License 5 votes vote down vote up
def addListBox(self, master, title, height = 3):
            
        scrollbar =  tk.Scrollbar(master, orient=tk.VERTICAL)
        tipLabel = tk.Label(master, text="")
        tipLabel.grid(row = self.row, sticky=tk.W, column=self.tipColumn)                
        lb = tk.Listbox(master, yscrollcommand=scrollbar, selectmode=tk.EXTENDED, height=height)  
        
        self.listboxEntries[title] = ListBoxEntry(lb,scrollbar,tipLabel)
        self.row += 1

        self.listboxEntries[title].scrollbar.configure(command=self.listboxEntries[title].listbox.yview)
        self.listboxEntries[title].scrollbar.grid(row=self.row, sticky=tk.W+tk.N+tk.S, column=self.titleColumn)
        return self.listboxEntries[title] 
Example #12
Source File: test_widgets.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return tkinter.Listbox(self.root, **kwargs) 
Example #13
Source File: test_widgets.py    From oss-ftp with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return tkinter.Listbox(self.root, **kwargs) 
Example #14
Source File: kimmo.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def listbox(self, listOptions):
    	box = Tkinter.Frame(self)
    	self.lb = Tkinter.Listbox(box,height=len(listOptions),width=30,background='#f0f0ff', selectbackground='#c0e0ff'
    		,selectmode='single')
    	self.lb.pack()
    	
    	for x in listOptions:
    		self.lb.insert(Tkinter.END,x)
    	
    	box.pack() 
Example #15
Source File: components.py    From SEM with MIT License 5 votes vote down vote up
def __init__(self, root, resource_dir, lang="fr"):
        ttk.Frame.__init__(self, root)
        
        self.resource_dir = resource_dir
        self._lang = None
        langs = os.listdir(os.path.join(self.resource_dir, "master"))
        if langs:
            self._lang = (lang if lang in langs else langs[0])
        
        self.items = (os.listdir(os.path.join(self.resource_dir, "master", self._lang)) if self._lang else [])
        self.items.sort(key=lambda x: x.lower())
        max_length = max([len(item) for item in self.items])
        
        self.select_workflow_label = ttk.Label(root, text=u"select workflow:")
        #strVar = tkinter.StringVar()
        self.masters = tkinter.Listbox(root, width=max_length+1, height=len(self.items))#, textvariable=strVar)

        for item in self.items:
            self.masters.insert(tkinter.END, item) 
Example #16
Source File: demo.py    From PyCV-time with MIT License 4 votes vote down vote up
def __init__(self):
        root = tk.Tk()
        root.title('OpenCV Demo')

        self.win = win = tk.PanedWindow(root, orient=tk.HORIZONTAL, sashrelief=tk.RAISED, sashwidth=4)
        self.win.pack(fill=tk.BOTH, expand=1)

        left = tk.Frame(win)
        right = tk.Frame(win)
        win.add(left)
        win.add(right)

        scrollbar = tk.Scrollbar(left, orient=tk.VERTICAL)
        self.demos_lb = demos_lb = tk.Listbox(left, yscrollcommand=scrollbar.set)
        scrollbar.config(command=demos_lb.yview)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        demos_lb.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)

        self.samples = {}
        for fn in glob('*.py'):
            name = splitfn(fn)[1]
            if fn[0] != '_' and name not in exclude_list:
                demos_lb.insert(tk.END, name)
                self.samples[name] = fn
        demos_lb.bind('<<ListboxSelect>>', self.on_demo_select)

        self.cmd_entry = cmd_entry = tk.Entry(right)
        cmd_entry.bind('<Return>', self.on_run)
        run_btn = tk.Button(right, command=self.on_run, text='Run', width=8)

        self.text = text = ScrolledText(right, font=('arial', 12, 'normal'), width = 30, wrap='word')
        self.linker = linker = LinkManager(text, self.on_link)
        self.text.tag_config("header1", font=('arial', 14, 'bold'))
        self.text.tag_config("header2", font=('arial', 12, 'bold'))
        text.config(state='disabled')

        text.pack(fill='both', expand=1, side=tk.BOTTOM)
        cmd_entry.pack(fill='x', side='left' , expand=1)
        run_btn.pack() 
Example #17
Source File: demo.py    From PyCV-time with MIT License 4 votes vote down vote up
def __init__(self):
        root = tk.Tk()
        root.title('OpenCV Demo')

        self.win = win = tk.PanedWindow(root, orient=tk.HORIZONTAL, sashrelief=tk.RAISED, sashwidth=4)
        self.win.pack(fill=tk.BOTH, expand=1)

        left = tk.Frame(win)
        right = tk.Frame(win)
        win.add(left)
        win.add(right)

        scrollbar = tk.Scrollbar(left, orient=tk.VERTICAL)
        self.demos_lb = demos_lb = tk.Listbox(left, yscrollcommand=scrollbar.set)
        scrollbar.config(command=demos_lb.yview)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        demos_lb.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)

        self.samples = {}
        for fn in glob('*.py'):
            name = splitfn(fn)[1]
            if fn[0] != '_' and name not in exclude_list:
                demos_lb.insert(tk.END, name)
                self.samples[name] = fn
        demos_lb.bind('<<ListboxSelect>>', self.on_demo_select)

        self.cmd_entry = cmd_entry = tk.Entry(right)
        cmd_entry.bind('<Return>', self.on_run)
        run_btn = tk.Button(right, command=self.on_run, text='Run', width=8)

        self.text = text = ScrolledText(right, font=('arial', 12, 'normal'), width = 30, wrap='word')
        self.linker = linker = LinkManager(text, self.on_link)
        self.text.tag_config("header1", font=('arial', 14, 'bold'))
        self.text.tag_config("header2", font=('arial', 12, 'bold'))
        text.config(state='disabled')

        text.pack(fill='both', expand=1, side=tk.BOTTOM)
        cmd_entry.pack(fill='x', side='left' , expand=1)
        run_btn.pack() 
Example #18
Source File: welds_gui.py    From Structural-Engineering with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def geometry_input_gui(self):
        tk.Label(self.tab_geometry, text="Weld Segment:", font=self.f_type_b).grid(row=0,column=0, sticky = tk.W)
        
        tk.Label(self.tab_geometry, text="Start x (in):", font=self.f_type).grid(row=1,column=0, sticky = tk.E)
        self.start_x_in = tk.StringVar()
        tk.Entry(self.tab_geometry, textvariable=self.start_x_in, width=10).grid(row=1,column=1, sticky = tk.W)
        
        tk.Label(self.tab_geometry, text="Start y (in):", font=self.f_type).grid(row=1,column=2, sticky = tk.E, padx=5)
        self.start_y_in = tk.StringVar()
        tk.Entry(self.tab_geometry, textvariable=self.start_y_in, width=10).grid(row=1,column=3, sticky = tk.W)
        
        tk.Label(self.tab_geometry, text="End x (in):", font=self.f_type).grid(row=2,column=0, sticky = tk.E)
        self.end_x_in = tk.StringVar()
        tk.Entry(self.tab_geometry, textvariable=self.end_x_in, width=10).grid(row=2,column=1, sticky = tk.W)
        
        tk.Label(self.tab_geometry, text="End y (in):", font=self.f_type).grid(row=2,column=2, sticky = tk.E, padx=5)
        self.end_y_in = tk.StringVar()
        tk.Entry(self.tab_geometry, textvariable=self.end_y_in, width=10).grid(row=2,column=3, sticky = tk.W)
        
        self.add_segment_button = tk.Button(self.tab_geometry,text = "Add Weld Segment", command = self.add_segment, font=self.f_type_b)
        self.add_segment_button.grid(row=1,column=4, padx=5)
        
        self.remove_last_segment_button = tk.Button(self.tab_geometry,text = "Remove Last\nWeld Segment", command = self.remove_last_segment, font=self.f_type_b)
        self.remove_last_segment_button.grid(row=2,column=4, padx=5)
        
        self.remove_all_segment_button = tk.Button(self.tab_geometry,text = "Remove All\nWeld Segments", command = self.remove_all, font=self.f_type_b)
        self.remove_all_segment_button.grid(row=3,column=4, padx=5)
        
        tk.Label(self.tab_geometry, text="Weld Segment List:", font=self.f_type_b).grid(row=3,column=0, sticky = tk.W)
        self.segment_list_scrollbar = tk.Scrollbar(self.tab_geometry, orient="vertical", command=self.segment_list_scroll)
        self.segment_list_scrollbar.grid(row=4, column=6, sticky='wns', pady=10)
        
        self.segment_list = tk.Listbox(self.tab_geometry, height = 30, width = 130, font=self.f_type, yscrollcommand=self.segment_list_scrollbar.set)
        self.segment_list.grid(row=4, column=0, columnspan=6, sticky='nsew', pady=10)
        
        segment_label_key = """i = weld start coord.  j = segment end coord.  A = segment area = segment length\nIxo = x-axis moment of inertia about segment center   Iyo = y-axis moment of inertia about segment center\nCenter = segment center coords.   Cx = x distance to group centroid   Cy = y distance to group centroid\nIx = x-axis moment of inertia about  group center   Iy = y-axis moment of inertia about group center"""
                                   
        tk.Label(self.tab_geometry, text=segment_label_key, font=self.f_type, justify=tk.LEFT).grid(row=5,column=0,columnspan=6, sticky = tk.W, padx=5)
        
        self.add_circle_button = tk.Button(self.tab_geometry, text='Add a Circular Weld', command = self.add_circle_function, font=self.f_type_b)
        self.add_circle_button.grid(row=0,column=5, sticky = tk.W, padx=5)
        tk.Label(self.tab_geometry, text='center x (in):',font=self.f_type).grid(row=1,column=5, sticky = tk.E, padx=5)
        tk.Label(self.tab_geometry, text='center y (in):',font=self.f_type).grid(row=2,column=5, sticky = tk.E, padx=5)
        tk.Label(self.tab_geometry, text='radius (in):',font=self.f_type).grid(row=3,column=5, sticky = tk.E, padx=5)
        tk.Label(self.tab_geometry, text='start (deg.):',font=self.f_type).grid(row=1,column=7, sticky = tk.E, padx=5)
        tk.Label(self.tab_geometry, text='end (deg.):',font=self.f_type).grid(row=2,column=7, sticky = tk.E, padx=5)
        
        self.add_circle_ins = [tk.StringVar(),tk.StringVar(),tk.StringVar(),tk.StringVar(),tk.StringVar()]
        
        i=0
        for circle_info in self.add_circle_ins:
            r = 1+i
            if r<4:
                tk.Entry(self.tab_geometry, textvariable=circle_info, width=10).grid(row=r,column=6, sticky = tk.W)
            else:
                tk.Entry(self.tab_geometry, textvariable=circle_info, width=10).grid(row=r-3,column=8, sticky = tk.W)
            i+=1 
Example #19
Source File: recipe-580770.py    From code with MIT License 4 votes vote down vote up
def _build_listbox(self, values):
        listbox_frame = Frame()

        self._listbox = Listbox(listbox_frame, background="white", selectmode=SINGLE, activestyle="none", exportselection=False)
        self._listbox.grid(row=0, column=0,sticky = N+E+W+S)

        self._listbox.bind("<ButtonRelease-1>", self._update_entry_from_listbox)
        self._listbox.bind("<Return>", self._update_entry_from_listbox)
        self._listbox.bind("<Escape>", lambda event: self.unpost_listbox())
        
        self._listbox.bind('<Control-n>', self._next)
        self._listbox.bind('<Control-p>', self._previous)

        if self._use_vscrollbar:
            vbar = Scrollbar(listbox_frame, orient=VERTICAL, command= self._listbox.yview)
            vbar.grid(row=0, column=1, sticky=N+S)
            
            self._listbox.configure(yscrollcommand= lambda f, l: autoscroll(vbar, f, l))
            
        if self._use_hscrollbar:
            hbar = Scrollbar(listbox_frame, orient=HORIZONTAL, command= self._listbox.xview)
            hbar.grid(row=1, column=0, sticky=E+W)
            
            self._listbox.configure(xscrollcommand= lambda f, l: autoscroll(hbar, f, l))

        listbox_frame.grid_columnconfigure(0, weight= 1)
        listbox_frame.grid_rowconfigure(0, weight= 1)

        x = -self.cget("borderwidth") - self.cget("highlightthickness") 
        y = self.winfo_height()-self.cget("borderwidth") - self.cget("highlightthickness")

        if self._listbox_width:
            width = self._listbox_width
        else:
            width=self.winfo_width()

        listbox_frame.place(in_=self, x=x, y=y, width=width)
        
        height = min(self._listbox_height, len(values))
        self._listbox.configure(height=height)

        for item in values:
            self._listbox.insert(END, item) 
Example #20
Source File: recipe-580771.py    From code with MIT License 4 votes vote down vote up
def _build_listbox(self, values):
        listbox_frame = Frame()

        self._listbox = Listbox(listbox_frame, background="white", selectmode=SINGLE, activestyle="none", exportselection=False)
        self._listbox.grid(row=0, column=0,sticky = N+E+W+S)

        self._listbox.bind("<ButtonRelease-1>", self._update_entry_from_listbox)
        self._listbox.bind("<Return>", self._update_entry_from_listbox)
        self._listbox.bind("<Escape>", lambda event: self.unpost_listbox())
        
        self._listbox.bind('<Control-n>', self._next)
        self._listbox.bind('<Control-p>', self._previous)

        if self._use_vscrollbar:
            vbar = Scrollbar(listbox_frame, orient=VERTICAL, command= self._listbox.yview)
            vbar.grid(row=0, column=1, sticky=N+S)
            
            self._listbox.configure(yscrollcommand= lambda f, l: autoscroll(vbar, f, l))
            
        if self._use_hscrollbar:
            hbar = Scrollbar(listbox_frame, orient=HORIZONTAL, command= self._listbox.xview)
            hbar.grid(row=1, column=0, sticky=E+W)
            
            self._listbox.configure(xscrollcommand= lambda f, l: autoscroll(hbar, f, l))

        listbox_frame.grid_columnconfigure(0, weight= 1)
        listbox_frame.grid_rowconfigure(0, weight= 1)

        x = -self.cget("borderwidth") - self.cget("highlightthickness") 
        y = self.winfo_height()-self.cget("borderwidth") - self.cget("highlightthickness")

        if self._listbox_width:
            width = self._listbox_width
        else:
            width=self.winfo_width()

        listbox_frame.place(in_=self, x=x, y=y, width=width)
        
        height = min(self._listbox_height, len(values))
        self._listbox.configure(height=height)

        for item in values:
            self._listbox.insert(END, item) 
Example #21
Source File: gui_widgets.py    From SVPV with MIT License 4 votes vote down vote up
def __init__(self, parent, header, width=10, selectmode=tk.BROWSE):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.num_f = len(header)
        self.headers = []
        self.lbs = []
        self.c = 0
        self.sel_idxs = []

        self.scroll = tk.Scrollbar(self, orient=tk.VERTICAL)
        for i in range(0, self.num_f):
            self.headers.append(tk.Label(self, text=header[i]))
            self.headers[-1].grid(row=0, column=self.c, sticky=tk.EW)
            self.lbs.append(tk.Listbox(self, width=width, selectmode=selectmode, yscrollcommand=self.yscroll, bg='white'))
            self.lbs[-1].grid(row=1, column=self.c, sticky=tk.EW)
            self.lbs[-1].bind("<<ListboxSelect>>", self.select)
            self.c += 1

        self.scroll.config(command=self.lbs[0].yview)
        self.scroll.grid(row=1, column=self.c, sticky=tk.NS) 
Example #22
Source File: Select.py    From PyKinectTk with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):

        # init

        self._root = tk.Tk()

        # Load initial data from database

        self._db = Database(DATABASE)
        
        tbl_PerformanceName = self._db[PERFORMANCE_NAME_TABLE]
        tbl_AudioPath       = self._db[AUDIO_PATH_TABLE]

        # Create widget to display selector
        self._listbox = tk.Listbox(self._root)
        self._listbox.pack()
        self._performances = []
        for i, name in tbl_PerformanceName:
            self._listbox.insert(tk.END, name)
            self._performances.append(i)

        # Add Audio Button
        self._addAudio = tk.Button(self._root, text="Add Audio Files", command=self.add_audio)
        self._addAudio.pack()

        # Playback Button
        self._playback = tk.Button(self._root, text="Play", command=self.start_playback)
        self._playback.pack()

        # Save to video Button
        self._toVideo = tk.Button(self._root, text="Save as Video", command=self.to_video)
        self._toVideo.pack()

        # Radio buttons for selecting stream to play/store
        self._streams = {}
        self._streams['body']  = tk.IntVar(value=1)
        self._streams['video'] = tk.IntVar(value=1)
        self._streams['audio'] = tk.IntVar(value=0)
        self._streams['depth'] = tk.IntVar(value=0)

        for stream in self._streams:
            button = tk.Checkbutton(self._root,
                                    text=stream,
                                    variable=self._streams[stream],
                                    offvalue=False,
                                    onvalue=True,
                                    anchor=tk.W)
            button.pack()        

        # Location of videos
        self._video_fp_root = "%s.avi"

        # Run
        self._root.mainloop() 
Example #23
Source File: check_log_gui.py    From nekros with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def size_(self):
        sz = tk.Listbox.size(self)
        return sz 
Example #24
Source File: check_log_gui.py    From nekros with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def __init__(self, master, **kw):
        tk.Listbox.__init__(self, master, **kw)
        AutoScroll.__init__(self, master) 
Example #25
Source File: demo.py    From OpenCV-Python-Tutorial with MIT License 3 votes vote down vote up
def __init__(self):
        root = tk.Tk()
        root.title('OpenCV Demo')

        self.win = win = tk.PanedWindow(root, orient=tk.HORIZONTAL, sashrelief=tk.RAISED, sashwidth=4)
        self.win.pack(fill=tk.BOTH, expand=1)

        left = tk.Frame(win)
        right = tk.Frame(win)
        win.add(left)
        win.add(right)

        scrollbar = tk.Scrollbar(left, orient=tk.VERTICAL)
        self.demos_lb = demos_lb = tk.Listbox(left, yscrollcommand=scrollbar.set)
        scrollbar.config(command=demos_lb.yview)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        demos_lb.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)

        self.samples = {}
        for fn in glob('*.py'):
            name = splitfn(fn)[1]
            if fn[0] != '_' and name not in exclude_list:
                self.samples[name] = fn

        for name in sorted(self.samples):
            demos_lb.insert(tk.END, name)

        demos_lb.bind('<<ListboxSelect>>', self.on_demo_select)

        self.cmd_entry = cmd_entry = tk.Entry(right)
        cmd_entry.bind('<Return>', self.on_run)
        run_btn = tk.Button(right, command=self.on_run, text='Run', width=8)

        self.text = text = ScrolledText(right, font=('arial', 12, 'normal'), width = 30, wrap='word')
        self.linker = linker = LinkManager(text, self.on_link)
        self.text.tag_config("header1", font=('arial', 14, 'bold'))
        self.text.tag_config("header2", font=('arial', 12, 'bold'))
        text.config(state='disabled')

        text.pack(fill='both', expand=1, side=tk.BOTTOM)
        cmd_entry.pack(fill='x', side='left' , expand=1)
        run_btn.pack()