1

I'm working on a GUI with tkinter and i have a problem. When i add a scrollbar to my app, the frame on my canvas overlaps the outlines (see image)

Screenshot of my app

Here is the code:

from tkinter import * window = Tk() window.geometry("400x225") scrollbar1 = Scrollbar(window, orient=VERTICAL) canvas1 = Canvas(window, bg="#003333", yscrollcommand=scrollbar1.set) frame1 = Frame(canvas1, bg="#003333") scrollbar1.config(command=canvas1.yview) scrollbar1.pack(side=RIGHT, fill=Y) canvas1.pack(fill=BOTH, expand=True) canvas1.create_window((0, 0), window=frame1, anchor="nw") for x in range(20): string = "line " + str(x) label1 = Label(frame1, fg="white", bg="#003333", text=string, font=("Calibri Bold", 14)) label1.pack(pady=5) window.update() canvas1.config(scrollregion=canvas1.bbox("all")) window.mainloop() 

I don't know if it's possible but i want the frame to fit within the canvas and keeping the outlines as well. I hope you get my problem and can probably help me out! Thanks in advance.

1 Answer 1

2

The highlightthickness

Specifies a non-negative value indicating the width of the highlight rectangle to draw around the outside of the widget when it has the input focus.

So, this is not really the "border" that you want. It is a part of the drawing space within the canvas, when you use window_create to draw a window, the parent of that window is the canvas, which begins before the highlight and so the window slides over it.

A solution, as also suggested by @martineau would be to make this 0 by specifying highlightthickness=0 and as you suggested that you need the "border" around the whole thing, you can either create a container frame and specify the bd parameter, or just set the bd of the window window.config(bd=2).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks man! That window.config(bd=2) was what I needed!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.