Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'exit': 0.07; 'pixels': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rows': 0.09; 'def': 0.13; 'columns': 0.16; 'email name:news': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'refreshing': 0.16; 'why,': 0.16; 'wrote:': 0.16; 'odd': 0.18; 'runs': 0.18; 'number)': 0.22; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'skip:# 10': 0.27; 'idea': 0.28; '---': 0.28; 'loop,': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'code': 0.30; "i'd": 0.31; 'scanned': 0.32; 'getting': 0.33; 'displayed': 0.33; 'wrap': 0.33; 'except': 0.34; 'running': 0.34; 'something': 0.35; 'problem.': 0.35; 'step': 0.36; 'but': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'missing': 0.37; 'progress': 0.38; 'button': 0.38; 'skip:p 20': 0.38; 'to:addr:python.org': 0.40; 'some': 0.40; 'ten': 0.60; 'avoid': 0.61; 'charset:windows-1252': 0.62; 'complete': 0.63; 'within': 0.64; 'our': 0.64; 'here': 0.66; 'day': 0.67; 'completion': 0.79; 'photo': 0.81; 'received:12': 0.81; 'subject:get': 0.81; 'photo.': 0.84; 'yours': 0.89 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Emile van Sebille Subject: Re: 2.7.9: PhotoImage get/put Date: Tue, 20 Oct 2015 15:25:14 -0700 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: www.westernstatesglass.com User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list 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: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1445379941 news.xs4all.nl 23770 [2001:888:2000:d::a6]:50156 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4700 X-Received-Body-CRC: 3457704659 Xref: csiph.com comp.lang.python:97847 On 10/20/2015 3:05 PM, Randy Day wrote: > I'm writing a simple image manipulation > on a PhotoImage (tkinter), and running > into an odd problem. The code below works, > except for one thing: > > As the image is scanned, I'd like to > observe the pixels getting inverted on > the image (as a kind of progress bar). > What happens is that the code runs the > complete loop before refreshing the > photo. I have no idea why, but here are some ideas I'd try out. So is it refreshing upon completion of the loop, or upon exit from process()? What happens if you put an outer loop around yours to process hght in ten (pick a number) steps? Emile > I've tried various forms of > refresh(), update(), etc., within the > loop, but so far no luck. Am I > missing something simple? > > def process(): # Ordinarily this would be process(photo,wdth,hgt) > global wdth # but I ran into problems calling it from a button > global hgt #command with parameters... > global photo # the PhotoImage displayed by the calling code > > # indents set to 1 to avoid word wrap > > # Loop through rows and columns of the image > v=wdth > z=0 > a=-1 > for y in range (0,hgt): > w=v > v=z # swap v and z so rows are scanned l/r r/l l/r > z=w > a=-a # set our inc/dec step for lr->rl scan > > for x in range(v,z,a): > pix = photo.get(x,y) if pix == u'0 0 0' : > #pixel_turn_on() > photo.put("#%02x%02x%02x" % (255,255,255), (x,y)) > else: > #pixel_turn_off() > photo.put("#%02x%02x%02x" % (0,0,0), (x,y)) > > --- news://freenews.netfront.net/ - complaints: news@netfront.net --- >