Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'canvas': 0.07; 'tkinter': 0.07; '(self,': 0.09; '__init__': 0.09; 'canvas.': 0.09; 'pixel': 0.09; 'pixels': 0.09; 'subject:skip:t 10': 0.09; 'width': 0.09; 'def': 0.12; 'random': 0.14; '(0,': 0.16; '250)': 0.16; 'idea:': 0.16; 'script,': 0.16; 'self.y': 0.16; 'subject:Lines': 0.16; 'url:py': 0.16; 'y):': 0.16; 'thursday,': 0.16; 'all.': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'differ': 0.19; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'this?': 0.23; 'specify': 0.24; '(or': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'point': 0.28; 'resolution': 0.29; "doesn't": 0.30; 'code': 0.31; 'lines': 0.31; 'that.': 0.31; 'dimensions': 0.31; 'horizontal': 0.31; 'pa,': 0.31; 'file': 0.32; 'class': 0.32; 'another': 0.32; 'url:python': 0.33; '-----': 0.33; 'level.': 0.33; 'skip:# 10': 0.33; 'could': 0.34; 'display': 0.35; 'board': 0.35; 'point.': 0.35; 'prepare': 0.35; 'but': 0.35; 'there': 0.35; 'format.': 0.36; 'height': 0.36; 'method': 0.36; 'shows': 0.36; 'should': 0.36; 'application': 0.37; 'too': 0.37; 'turn': 0.37; 'email addr:python.org': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'subject:': 0.39; '12,': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'received:bf1.yahoo.com': 0.60; 'received:mail.bf1.yahoo.com': 0.60; 'color': 0.61; 'show': 0.63; 'high': 0.63; 're:': 0.63; 'email name:python-list': 0.65; 'here': 0.66; 'header:Reply-To:1': 0.67; 'received:98.139.212': 0.68; 'therefore': 0.72; 'received:bullet.mail.bf1.yahoo.com': 0.74; 'blow': 0.84; 'draws': 0.84; 'everything.': 0.84; 'otten': 0.84; 'received:98.139.212.152': 0.84 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 279152.3557.bm@omp1008.mail.bf1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1402604268; bh=09QIR83IMg7wkGR7KmUhED40V5OsdbryJlSA9VeL2yk=; h=References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=P53W104HuNKJvZLaLST5HrV9IgfWxbKSyWSd7jec8YOrYqWg1TZw/GEtlOuEp9tCKwF02txhXd6trEFCL9n/uJsIwyy6Q6bfotGCkD/ZNwDU9IFD284o1Uj5d0kyU+0RVIr1DAJ9ubEaguvgExlozaus0IOWfhhtXmcA6+SGMyA= X-YMail-OSG: 7bgho0sVM1lOVTAbBy4EdpbxYST6O6EJD3J2BHOGdwXwPEY MfTcn6MZDeuJWSSWq5iOgMc.mumiOypyhpbIBKlZC5uoyCKUpDLqEDGx7Nuq C02iDEB1u6fPa4osli72JsOfhPRQOAcPYrh7menLRnKN6y3pFLOfZWLOYqHh 0gz03BIseCgdjRw7umEq36k8lwsM4DHGgUjCK_7uheChixXSjwimY5JVhro9 lDYzZjNkVZT1qYRNzr3kQETDN8hQBfPHeO8gbykMfiJTlysjkPGvIDrcQTSr csOcAMnP.X88LgwB_z3uQYMJeaVSFg09Q.6TjAeEnoWDibw8k93jc4r7jE2H T64nJCAARY1aHu9k_IXy_Z7p97fcGVYd7dpzPpzyCTudAZzd9uxV_Cwar.f. Wwat3NiTeZjM3aHehltp_8tYBCX_0Ydqa9ZTL3H22hUIBKMVCZbWapAyxM9U eKD1lp.91InZQEFx2T6GTs7WOoJILnnZzisl53ScS6ogrpO1TnVW6Z0xK.Tn Du.jCVO.lPvmRNBIf0oVWwo6H8xr1QnwyVhMQwg9HWAJuKIpB5CugXkbJivr Czl_UphdoVAJgoUNq2XSXPNf3AnQ4M49w71Bhkliv6PVKd9mrcZ.dXZQHRQn axRjaCh42MxVEWi9ntTwsFHDAaooeXiw.v215vlcWCIj3O_e4gQTtrk5P X-Rocket-MIMEInfo: 002.001, wqAgQXMgUGV0ZXIgT3R0ZW4gZGlkIG5vdCBzZWUgdGhlIHNhbWUgcmVzdWx0IHRoYXQgSSBzYXcsIEkgcHJlcGFyZWQgYW4gaW1hZ2UgdGhhdCBzaG93cyB0aGUgcmVzdWx0IG9uIG15IG5vdGVib29rOgpodHRwOi8vaXplY2tzb2huLmNvbS9wZWRyby9weXRob24vY2FudmFzL3RrX3dpbmRvdy54Y2YKwqAgRm9yIHRob3NlIHRoYXQgbWlnaHQgbm90IGtub3c6IHhjZiBpcyB0aGUgR2ltcCdzIGZpbGUgZm9ybWF0LgoKCi0tLS0tIE9yaWdpbmFsIE1lc3NhZ2UgLS0tLS0KPiBGcm9tOiBQZXRlciBPdHRlbgo.IFQBMAEBAQE- X-Mailer: YahooMailWebService/0.8.190.668 References: <1402538245.73470.YahooMailNeo@web140102.mail.bf1.yahoo.com> Date: Thu, 12 Jun 2014 13:17:48 -0700 (PDT) From: Pedro Izecksohn Subject: Re: Lines on a tkinter.Canvas To: "python-list@python.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Thu, 12 Jun 2014 22:28:41 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Pedro Izecksohn List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1402604922 news.xs4all.nl 2899 [2001:888:2000:d::a6]:51489 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73237 =A0 As Peter Otten did not see the same result that I saw, I prepared an im= age that shows the result on my notebook:=0Ahttp://izecksohn.com/pedro/pyth= on/canvas/tk_window.xcf=0A=A0 For those that might not know: xcf is the Gim= p's file format.=0A=0A=0A----- Original Message -----=0A> From: Peter Otten= =0A> To: python-list@python.org=0A> Sent: Thursday, June 12, 2014 4:02 AM= =0A> Subject: Re: Lines on a tkinter.Canvas=0A> =0A> Pedro Izecksohn wrote:= =0A> =0A>> The code available from:=0A>> http://izecksohn.com/pedro/pytho= n/canvas/testing.py=0A>> draws 2 horizontal lines on a Canvas. Why the 2 l= ines differ on thickness=0A>> and length?=0A>> =0A>> The Canvas' method c= reate_line turns on at least 2 pixels. But I want =0A> to=0A>> turn on man= y single pixels on a Canvas. How should I do this? Canvas has=0A>> no meth= od create_pixel or create_point.=0A> =0A>> #!/usr/bin/python3=0A>> =0A>> = import tkinter as tk=0A>> =0A>> class Point ():=0A>> =A0 def __init__ (se= lf, x, y):=0A>> =A0 =A0 self.x =3D x=0A>> =A0 =A0 self.y =3D y=0A>> =0A>>= class Board (tk.Frame):=0A>> =A0 def __init__ (self, bg, dimensions):=0A= >> =A0 =A0 tk.Frame.__init__ (self, tk.Tk())=0A>> =A0 =A0 self.pack()=0A>= > =A0 =A0 self.canvas =3D tk.Canvas (self, bd =3D 0, bg =3D bg, width =3D = dimensions.x, =0A> height =3D dimensions.y)=0A>> =A0 =A0 self.canvas.pack = (side =3D "top")=0A>> =A0 def drawLine (self, pa, pb, color):=0A>> =A0 =A0= self.canvas.create_line (pa.x, pa.y, pb.x, pb.y, fill =3D color)=0A>> =A0= def drawPoint (self, p, color):=0A>> =A0 =A0 self.canvas.create_line (p.= x, p.y, p.x, p.y, fill =3D color)=0A>> =0A>> dimensions =3D Point (500, 50= 0)=0A>> board =3D Board ('black', dimensions)=0A>> color =3D 'red'=0A>> = p =3D Point (0, 250)=0A>> while (p.x < dimensions.x):=0A>> =A0 board.draw= Point (p, color)=0A>> =A0 p.x +=3D 1=0A>> pa =3D Point (0, 350)=0A>> pb = =3D Point (499, 350)=0A>> board.drawLine (pa, pb, color)=0A>> board.mainl= oop()=0A> =0A> I just tried your script, and over here the line drawn with= =0A> =0A>> =A0 def drawLine (self, pa, pb, color):=0A>> =A0 =A0 self.canv= as.create_line (pa.x, pa.y, pb.x, pb.y, fill =3D color)=0A> =0A> has a widt= h of 1 pixel and does not include the end point. Therefore the =0A> "line" = drawn with=0A> =0A>> =A0 def drawPoint (self, p, color):=0A>> =A0 =A0 sel= f.canvas.create_line (p.x, p.y, p.x, p.y, fill =3D color)=0A> =0A> does not= show up at all. You could try to specify the line width explicitly:=0A> = =0A> =A0 def drawPoint (self, p, color):=0A> =A0 =A0 self.canvas.create_l= ine (p.x, p.y, p.x+1, p.y, fill=3Dcolor, width=3D1)=0A> =0A> If that doesn'= t work (or there's too much overhead) use pillow to =0A> prepare an =0A> im= age and show that.=0A> =0A> Another random idea: if you have a high resolut= ion display your OS might =0A> blow up everything. In that case there would= be no fix on the application =0A> level.=0A>