Is there any way to create a hanging indented list using the tkinter label widget? Note: Using propper standard bullets not * or -.
I have made a class that do what you want:
class BLabel(object):
b = "•"
def __init__(self,master):
import tkinter as tk
self.l = tk.Label(master)
def add_option(self,text):
if self.l.cget("text") == "":
self.l.config(text=self.b+" "+text)
else:
self.l.config(text=self.l.cget("text") +"\n"+ self.b + " "+text)
You can use it like:
lbal = BLabel(master=master)
lbal.add_option("Bullet1") #<-- adding item
lbal.add_option("Bullet2") #<-- adding item
lbal.l.pack() #<-- Packing
Here is an example code:
import tkinter as tk
root = tk.Tk()
class BLabel(object):
b = "•"
def __init__(self,master):
import tkinter as tk
self.l = tk.Label(master)
def add_option(self,text):
if self.l.cget("text") == "":
self.l.config(text=self.b+" "+text)
else:
self.l.config(text=self.l.cget("text") +"\n"+ self.b + " "+text)
lbal = BLabel(master=root)
lbal.add_option("Bullet1")
lbal.add_option("Bullet2")
lbal.l.pack()
Here is the output of above code:

In that way, you can use pack , place or grid. Example:
Grid:
lbal.l.grid(row=0,column=0)
Place:
lbal.l.place(x=0,y=0)
Pack:
lbal.l.pack()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With