Reputation: 127
so recently i have gotten into Tkinter and been using the docs so far. I ran into this problem where make a visible seperator between my "toolbar buttons", example below:
Home | Insert | PC | Etc..
How could i go about making that seperator, becuase i tried ttk seperator but didnt help me.
Thanks in advance.
Upvotes: 0
Views: 1580
Reputation: 385980
The ttk library has a Separator
widget which is specifically designed for this. You can also use a frame with a width of 1 or two pixels.
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
toolbar = tk.Frame(root)
toolbar.pack(side="top", fill="x", padx=20, pady=20)
button1 = tk.Button(toolbar, text="Home")
button2 = tk.Button(toolbar, text="Insert")
sep = ttk.Separator(toolbar)
button1.pack(side="left")
sep.pack(side="left", fill="y", padx=4, pady=4)
button2.pack(side="left")
root.mainloop()
Upvotes: 2