Re: Unusable outer edge of Tkinter canvases?



Dave Opstad wrote:

> When drawing rectangles in Tkinter canvases I've noticed the outer edges
> (say 3-5 pixels) don't always draw. For instance, try typing this in an
> interactive session (Terminal in OS X or Command Prompt in Windows XP):
>
> >>> import Tkinter as T
> >>> root = T.Tk()
> >>> f = T.Frame(root)
> >>> f.grid()
> >>> c = T.Canvas(f, width = 300, height = 300)
> >>> c.grid()
> >>> c.create_rectangle(1, 1, 299, 299)
> >>> c.create_rectangle(3, 3, 297, 297)
> >>> c.create_rectangle(5, 5, 295, 295)
>
> On the Mac, the first two rectangles only partly show up (two sides for
> the first one and three for the second), while the third one draws
> completely. On Windows the first rectangle appears partially and the
> final two appear completely.
>
> Is there some simple setting I'm missing? I've tried gridding the canvas
> with padx, pady and also ipadx, ipady values but nothing seems to help
> make the whole rectangle (1, 1, 299, 299) appear.

by default, the coordinate system is aligned with the widget's upper
left corner, which means that things you draw will be covered by the
inner border.

to fix this, you can either set the border width to zero, add scrollbars
to the widget (this fixes the coordinate system), or explicitly reset the
coordinate system:

w.xview_moveto(0)
w.yview_moveto(0)

</F>



.



Relevant Pages

  • Re: On the light-like interval
    ... There are no coordinates in the underlying space time. ... Draw two orthogonal lines one up and the other ... So the light-like object is at the origin. ... Notice how the coordinate system says ...
    (sci.physics.relativity)
  • Re: C#- coordinate system, drawing
    ... code can be written to actually draw the cross marking the point and the label. ... There are at least a couple of ways to _draw_ the cross and the name of the point. ... you can just draw the lines defining the intervals of the coordinate system. ... void MapMillimetersToPixels(Graphics gfx, Rectangle rectPixels, Rectangle rectMm) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to draw to the screen not the form?
    ... this on Vista with Aero enabled, dragging those rectangles around ... on XP (or Vista with the standard, ... draw my rectangles on the overlay. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Draw Rectangle directly to client (ie - without bitmap?)
    ... Perhaps you should draw your rectangles to an image in memory and then ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: 3d question
    ... > I was asked to draw 3d points in a coordinate system to describe a ... > psychological experiment. ... it's probably not the most intuitive way to just draw dots ...
    (comp.lang.java.gui)

Loading