Apr-01-2019, 10:01 AM
Hi DT2000
Put your listbox in a Frame and add with padx & pady some border to the listbox. For instance:
Put your listbox in a Frame and add with padx & pady some border to the listbox. For instance:
import tkinter as tk class Application(object): INTERIOR_BORDER = 10 def __init__(self, mainm_win): self.main_win = main_win self.build() def build(self): main_frame = tk.Frame(self.main_win, relief='sunken', bd=1, bg='white') main_frame.pack(fill='both', expand=True, padx=5, pady=5) main_frame.columnconfigure(0, weight=1) main_frame.rowconfigure(0, weight=1) list_item_values = ["one", "two", "three", "four", "five"]*5 listbox = tk.Listbox(main_frame, width=42, height=20, bd=0, highlightthickness=0) listbox.grid(row=0, column=0, padx=self.INTERIOR_BORDER, pady=self.INTERIOR_BORDER, sticky='news') listbox.insert('end', *list_item_values) yscroll1 = tk.Scrollbar(main_frame, command=listbox.yview, orient=tk.VERTICAL) yscroll1.grid(row=0, column=1, sticky='ns') listbox.configure(yscrollcommand=yscroll1.set) listbox.bind('<ButtonRelease-1>', self.get_recipe) def get_recipe(self, event=None): print("Get Recipe") if __name__ == "__main__": main_win = tk.Tk() main_win.title("Listbox with internal border") app = Application(main_win) main_win.mainloop()Greetings wuf :-)