How can I remove the light grey border around the Canvas widget?


Rectangle Rectangle:

I've been messing around with Tkinter Canvaswidgets to see if I can make some nice looking widgets, and I have a few questions.

First of all, why is there a light grey border around my Canvas widget and how do I get rid of it?

Second, why is the position of the top left corner in the canvas (2,2)? Seems like it should be (0,0).

My current script:

from Tkinter import *

master = Tk()
master.configure(bg='black')
master.wm_attributes("-topmost", 1)

w = Canvas(master, width=150, height=40, bd=0,relief='ridge',)
w.pack()

color = 100
x0 = 2
y0 = 2
x1 = 151
y1 = 2

while y0 < 20 :
    r = color
    g = color
    b = color
    rgb = r, g, b
    Hex = '#%02x%02x%02x' % rgb
    w.create_line(x0, y0, x1, y1,fill=str(Hex), width=1)
    color = color - 2
    y0 = y0 + 1
    y1 = y1 + 1

color = 10

while y0 < 40 :
    r = color
    g = color
    b = color
    rgb = r, g, b
    Hex = '#%02x%02x%02x' % rgb
    w.create_line(x0, y0, x1, y1,fill=str(Hex), width=1)
    color = color + 4
    y0 = y0 + 1
    y1 = y1 + 1

mainloop()
TP:

Section 6.8 Why does the canvas seem not to start at 0,0? The phenomenon described in the FAQ of Tk usage .

I made a small change to the published source to get rid of the border artifact...

Change this:

w = Canvas(master, width=150, height=40, bd=0, relief='ridge')
w.pack()

to:

w = Canvas(master, width=150, height=40, bd=0, highlightthickness=0, relief='ridge')
w.pack()

and this:

x0 = 2
y0 = 2
x1 = 151
y1 = 2

to:

x0 = 0
y0 = 0
x1 = 150
y1 = 0

Interestingly, "borderwidth"nothing has changed for that property, but I've kept it according to the FAQ .

w.config()Immediately after running the Canvasinitialization statement shows that the default is 2 pairs highlightthicknessand 0 's border width.

Related


How can I remove the light grey border around the Canvas widget?

Rectangle Rectangle: I've been messing around with Tkinter Canvaswidgets to see if I can make some nice looking widgets, and I have a few questions. First of all, why is there a light grey border around my Canvas widget and how do I get rid of it? Second, why

How can I add a border around the canvas?

Thomas I am now wondering how to add a border around the canvas . So just use CSS code border:black 3px solid; You will get the border in the canvas . And I don't want the border on the canvas. I want a border around the canvas . I want to use CSS. thanks for

How can I add a border around the canvas?

Thomas I am now wondering how to add a border around the canvas . So just use CSS code border:black 3px solid; You will get the border in the canvas . And I don't want the border on the canvas. I want a border around the canvas . I want to use CSS. thanks for

How can I add a border around the canvas?

Thomas I am now wondering how to add a border around the canvas . So just use CSS code border:black 3px solid; You will get border in canvas . And I don't want the border on the canvas. I want a border around the canvas . I want to use CSS. thanks for your he

How can I add a border around the canvas?

Thomas I am now wondering how to add a border around the canvas . So just use CSS code border:black 3px solid; You will get border in canvas . And I don't want the border on the canvas. I want a border around the canvas . I want to use CSS. thanks for your he

How can I remove the border around the toolbar?

Axl In my app I'm using the toolbar and it seems I want to get rid of the border around it: Then I create it like this: <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:bac

How can I remove the border around the toolbar?

Axl In my app I'm using the toolbar and it seems I want to get rid of the border around it: Then I create it like this: <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:bac

How can I remove the border around the image?

username How can I remove the border around the square? Exterior: my HTML: <input id="black" type="image" src="html5-canvas-drawing-app/images/color-swatch-brown.png" onClick="changeColorBlack()"> my css: #black{ border:none; outline:none; background:none; pa

How can I remove the border around the toolbar?

Axl In my app I'm using the toolbar and it seems I want to get rid of the border around it: Then I create it like this: <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:bac

How can I remove the border around each div?

ganhy99 I'm creating a sketch tool that allows the user to color "cells" after hovering over them. The problem I'm facing right now is that each cell has a white border around it, which I can't seem to remove. I've tried making border: none; border-style:none;

Remove grey border around pavucontrol in 16.04

Rovannon This problem is best illustrated with the following image: As you can see above, there is a grey border around the actual content of the app. So far I have tried modifying the contents of .config/gtk-3.0/gtk.css based on pointers given by possibly unr

Remove grey border around pavucontrol in 16.04

Rovannon This problem is best illustrated with the following image: As you can see above, there is a grey border around the actual content of the app. So far I have tried modifying the contents of .config/gtk-3.0/gtk.css based on pointers given by possibly unr

How can I create a white arrow with a grey border?

json2021 he I'm trying to create a left arrow but with a grey border. So far I only have a grey arrow. Will someone know how I can do this? I have attached a photo of what I mean. Thank you in advance! .tri { width: 0; height: 0; border-style: sol

How can I create a white arrow with a grey border?

json2021 he I'm trying to create a left arrow but with a grey border. So far I only have a grey arrow. Will someone know how I can do this? I have attached a photo of what I mean. Thank you in advance! .tri { width: 0; height: 0; border-style: sol

How to draw a border around the canvas

Valla Doharis I am drawing an image on a canvas with a white background color. I would like to draw a border around the canvas but am unable to do so. Here is my code: canvas.width = image.width; canvas.height = image.height; var context = canvas.getContext('2

How to draw a border around the canvas

Valla Doharis I am drawing an image on a canvas with a white background color. I would like to draw a border around the canvas but am unable to do so. Here is my code: canvas.width = image.width; canvas.height = image.height; var context = canvas.getContext('2

How to draw a border around the canvas

Valla Doharis I am drawing an image on a canvas with a white background color. I would like to draw a border around the canvas but am unable to do so. Here is my code: canvas.width = image.width; canvas.height = image.height; var context = canvas.getContext('2

Owl carousel tries to remove grey border around navbar

sorority In the owl carousel, I added: navigation:true, navigationText: ["<img src='img/leftarrow.png'>", "<img src='img/rightarrow.png'>"], The image is two arrows. But when I look at them they look like grey ovals around them? I want to remo

Owl carousel tries to remove grey border around navbar

sorority In the owl carousel, I added: navigation:true, navigationText: ["<img src='img/leftarrow.png'>", "<img src='img/rightarrow.png'>"], The image is two arrows. But when I look at them they look like grey ovals around them? I want to remo

Owl carousel tries to remove grey border around navbar

sorority In the owl carousel, I added: navigation:true, navigationText: ["<img src='img/leftarrow.png'>", "<img src='img/rightarrow.png'>"], The image is two arrows. But when I look at them they look like grey ovals around them? I want to remo

Owl carousel tries to remove grey border around navbar

sorority In the owl carousel, I added: navigation:true, navigationText: ["<img src='img/leftarrow.png'>", "<img src='img/rightarrow.png'>"], The image is two arrows. But when I look at them they look like grey ovals around them? I want to remo