Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97851
| References | <MPG.309076b1693d9388989686@freenews.netfront.net> <n06f0k$r6g$1@ger.gmane.org> |
|---|---|
| Date | 2015-10-20 18:44 -0700 |
| Subject | Re: 2.7.9: PhotoImage get/put |
| From | C Smith <illusiontechniques@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.66.1445391898.878.python-list@python.org> (permalink) |
>> def process(): # Ordinarily this would be process(photo,wdth,hgt)
>> global wdth # but I ran into problems calling it from a button
If you want to pass arguments to a command called when a button is
clicked, you have to use 'lambda' in tkinter.
>> 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))
You can't expect a delay to happen during the mainloop() of the
program. To interrupt the mainloop(), use: parent.after(n,someCommand)
Where 'n' is some amount of milliseconds. Just have the parent widget
or the root frame call it.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
2.7.9: PhotoImage get/put Randy Day <randy.day@sasktel.netx> - 2015-10-20 16:05 -0600
Re: 2.7.9: PhotoImage get/put Emile van Sebille <emile@fenx.com> - 2015-10-20 15:25 -0700
Re: 2.7.9: PhotoImage get/put Randy Day <randy.day@sasktel.netx> - 2015-10-20 23:59 -0600
Re: 2.7.9: PhotoImage get/put C Smith <illusiontechniques@gmail.com> - 2015-10-20 18:44 -0700
Re: 2.7.9: PhotoImage get/put Randy Day <randy.day@sasktel.netx> - 2015-10-20 23:50 -0600
Re: 2.7.9: PhotoImage get/put Terry Reedy <tjreedy@udel.edu> - 2015-10-21 03:51 -0400
Re: 2.7.9: PhotoImage get/put Randy Day <randy.day@sasktel.netx> - 2015-10-21 09:31 -0600
csiph-web