In Dave Angel
writes:
> > The problem is that change() isn't being executed here; instead it's being
> > executed from within root.mainloop(), whenever the user presses button-1.
> >
> > And within root.mainloop(), there is no variable called isWhite.
> >
> Actually that's irrelevant. Whether
On 06/24/2013 04:12 PM, John Gordon wrote:
In
pablobarhamal...@gmail.com writes:
isWhite = True
def change(event):
if event.x > x1 and event.x < x2 and event.y > y1 and event.y < y2:
if isWhite:
w.itemconfig(rect, fill="blue")
isWhite = False
On 24 June 2013 21:19, wrote:
> Thank's to you all!
>
> Setting isWhite as global worked fine.
> I'll probably be back soon with another silly question, see you then :)
By the way, it's normally bad to use globals like this. When you're
learning it's something you just do, though; it's fine for
On 24 June 2013 21:12, John Gordon wrote:
> Since you're new to programming, this might be a bit tricky to explain,
> but I'll do my best. :-)
>
> The problem is that change() isn't being executed here; instead it's being
> executed from within root.mainloop(), whenever the user presses button-1.
Here's a little test to make sure you understand (this is one of the
most confusing parts of Python's closures in my opinion):
foo = "I'm foo!"
def working():
print(foo)
def broken():
print(foo)
if False: # There's no way this could cause a problem!
foo = "This will *never*
Thank's to you all!
Setting isWhite as global worked fine.
I'll probably be back soon with another silly question, see you then :)
--
http://mail.python.org/mailman/listinfo/python-list
In
pablobarhamal...@gmail.com writes:
> isWhite = True
>
> def change(event):
> if event.x > x1 and event.x < x2 and event.y > y1 and event.y < y2:
> if isWhite:
> w.itemconfig(rect, fill="blue")
> isWhite = False
> else:
> w.itemc
Op 24-06-13 21:47, pablobarhamal...@gmail.com schreef:
Hi there! I'm quite new to programming, even newer in python (this is actually
the first thing I try on it), and every other topic I've seen on forums about
my problem doesn't seem to help.
So, the following lines are intended to draw a wh
pablobarhamal...@gmail.com wrote:
> Hi there! I'm quite new to programming, even newer in python (this is
> actually the first thing I try on it), and every other topic I've seen on
> forums about my problem doesn't seem to help.
>
> So, the following lines are intended to draw a white square (wh
Just before anyone says, the reason I bind to the Canvas instead of binding
directly to the rectangle is because I plan to add more squares in the future.
Cheers.
--
http://mail.python.org/mailman/listinfo/python-list
Hi there! I'm quite new to programming, even newer in python (this is actually
the first thing I try on it), and every other topic I've seen on forums about
my problem doesn't seem to help.
So, the following lines are intended to draw a white square (which it does),
turn it to blue when you cl
Le 08/06/2010 10:03, ch1zra a écrit :
import os, time, re, pyodbc, Image, sys
from datetime import datetime, date, time
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttf
ch1zra a écrit :
On Jun 8, 10:59 am, Bryan wrote:
Python doesn't have one global namespace. Each module (file) has its
own namespace, which is a Python dict, and 'global' means defined in
the containing module's dict. Put the import:
from reportlab.pdfgen import canvas
in the mkTable.py fil
Peter Otten wrote:
> Chris Rebert wrote:
[...]
> > The only global variable defined in mkTable.py is the "mkTable"
> > function (partly since you don't import anything). So the reference to
> > the global variable "canvas" on the right-hand side of this expression
> > is completely undefined, resul
Chris Rebert wrote:
> On Tue, Jun 8, 2010 at 2:00 AM, ch1zra wrote:
>> On Jun 8, 10:29 am, Richard Thomas wrote:
>>> On Jun 8, 9:03 am, ch1zra wrote:
>>> > I have following code :
>>>
>>> > import os, time, re, pyodbc, Image, sys
>>> > from datetime import datetime, date, time
>>> > from report
On Jun 8, 10:59 am, Bryan wrote:
> ch1zra wrote:
> > I have following code :
>
> > import os, time, re, pyodbc, Image, sys
> > from datetime import datetime, date, time
> > from reportlab.lib.pagesizes import A4
> > from reportlab.lib.units import cm
> > from reportlab.pdfgen import canvas
> > fro
On Tue, Jun 8, 2010 at 2:00 AM, ch1zra wrote:
> On Jun 8, 10:29 am, Richard Thomas wrote:
>> On Jun 8, 9:03 am, ch1zra wrote:
>> > I have following code :
>>
>> > import os, time, re, pyodbc, Image, sys
>> > from datetime import datetime, date, time
>> > from reportlab.lib.pagesizes import A4
>>
On Jun 8, 10:29 am, Richard Thomas wrote:
> On Jun 8, 9:03 am, ch1zra wrote:
>
>
>
>
>
> > I have following code :
>
> > import os, time, re, pyodbc, Image, sys
> > from datetime import datetime, date, time
> > from reportlab.lib.pagesizes import A4
> > from reportlab.lib.units import cm
> > from
ch1zra wrote:
> I have following code :
>
> import os, time, re, pyodbc, Image, sys
> from datetime import datetime, date, time
> from reportlab.lib.pagesizes import A4
> from reportlab.lib.units import cm
> from reportlab.pdfgen import canvas
> from reportlab.pdfbase import pdfmetrics
> from repor
On Jun 8, 9:03 am, ch1zra wrote:
> I have following code :
>
> import os, time, re, pyodbc, Image, sys
> from datetime import datetime, date, time
> from reportlab.lib.pagesizes import A4
> from reportlab.lib.units import cm
> from reportlab.pdfgen import canvas
> from reportlab.pdfbase import pdf
I have following code :
import os, time, re, pyodbc, Image, sys
from datetime import datetime, date, time
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTF
On Mon, 05 Apr 2010 10:08:51 -0700, John Nagle wrote:
> Alf P. Steinbach wrote:
>
>> Best is however to recognize that you have some state (your variable)
>> and some operations on that state (your callback), and that that is
>> what objects are all about. I.e. wrap your logic in a class. Then
>>
On 2010-04-05 10:08:51 -0700, John Nagle said:
Yes. Functions with persistent state are generally a bad idea.
Unfortunately, the "signal" module requires a callback parameter
which is a plain function. So you have to send it a function,
closure, or lambda. Here, it's being sent a clos
On 2010-04-05 12:08 PM, John Nagle wrote:
Alf P. Steinbach wrote:
Best is however to recognize that you have some state (your variable)
and some operations on that state (your callback), and that that is
what objects are all about. I.e. wrap your logic in a class. Then
'lastModifiedTime' become
Alf P. Steinbach wrote:
Best is however to recognize that you have some state (your variable)
and some operations on that state (your callback), and that that is what
objects are all about. I.e. wrap your logic in a class. Then
'lastModifiedTime' becomes an instance attribute, and 'handler' be
* Stephen Hansen:
On 2010-04-04 15:22:48 -0700, Alf P. Steinbach said:
* johngilbrough:
I cannot make sense of what's happening here ... I'm getting the
following error:
(1)
At least in Py3 you can declare the variable as 'global', like this:
global lastModifiedTime
within the function
On 2010-04-04 15:22:48 -0700, Alf P. Steinbach said:
* johngilbrough:
I cannot make sense of what's happening here ... I'm getting the
following error:
(1)
At least in Py3 you can declare the variable as 'global', like this:
global lastModifiedTime
within the function.
Actually, what
* johngilbrough:
I cannot make sense of what's happening here ... I'm getting the
following error:
initializing last modified time
/home/john/Dropbox/Projects/python/scripts/src 29
referencing last modified time
/home/john/Dropbox/Projects/python/scripts/src 29
referencing last modified time
Tr
I cannot make sense of what's happening here ... I'm getting the
following error:
initializing last modified time
/home/john/Dropbox/Projects/python/scripts/src 29
referencing last modified time
/home/john/Dropbox/Projects/python/scripts/src 29
referencing last modified time
Traceback (most recen
Wells Oliver wrote:
Writing a class which essentially spiders a site and saves the files
locally. On a URLError exception, it sleeps for a second and tries again (on
404 it just moves on). The relevant bit of code, including the offending
method:
class Handler(threading.Thread):
def __in
On Fri, 19 Jun 2009 11:16:38 -0500
Wells Oliver wrote:
> def save(self, uri, location):
> try:
> handler = urllib2.urlopen(uri)
> except urllib2.HTTPError, e:
> if e.code == 404:
>
Wells Oliver schrieb:
Writing a class which essentially spiders a site and saves the files
locally. On a URLError exception, it sleeps for a second and tries again
(on 404 it just moves on). The relevant bit of code, including the
offending method:
class Handler(threading.Thread):
def
On Jun 19, 10:16 am, Wells Oliver wrote:
> Writing a class which essentially spiders a site and saves the files
> locally. On a URLError exception, it sleeps for a second and tries again (on
> 404 it just moves on). The relevant bit of code, including the offending
> method:
>
> [snip]
>
> But wha
Writing a class which essentially spiders a site and saves the files
locally. On a URLError exception, it sleeps for a second and tries again (on
404 it just moves on). The relevant bit of code, including the offending
method:
class Handler(threading.Thread):
def __init__(self, url):
Pete Bartonly wrote:
>
> Quick question, probably quite a simple matter. Take the follow start of
> a method:
>
>
> def review(filesNeedingReview):
>
> for item in filesNeedingReview:
> (tightestOwner, logMsg) = item
>
> if (logMsg != None):
> for logInfo in lo
Peter Otten wrote:
> Pete Bartonly wrote:
>
>> Quick question, probably quite a simple matter. Take the follow start of
>> a method:
>>
>>
>> def review(filesNeedingReview):
>>
>> for item in filesNeedingReview:
>> (tightestOwner, logMsg) = item
>>
>> if (logMsg != None):
>
A.T.Hofkamp wrote:
> On 2007-10-25, Pete Bartonly <[EMAIL PROTECTED]> wrote:
>> Quick question, probably quite a simple matter. Take the follow start of
>> a method:
> With respect to compactness and style, you can move your multi-assignment
> statement in the for loop, as in
[snip]
Btw, thanks
A.T.Hofkamp wrote:
> On 2007-10-25, Pete Bartonly <[EMAIL PROTECTED]> wrote:
>> Quick question, probably quite a simple matter. Take the follow start of
>> a method:
>>
>>
>> def review(filesNeedingReview):
>>
>> for item in filesNeedingReview:
>> (tightestOwner, logMsg) = item
>>
>>
On 2007-10-25, Tim Williams <[EMAIL PROTECTED]> wrote:
> On 25/10/2007, A.T.Hofkamp <[EMAIL PROTECTED]> wrote:
>> On 2007-10-25, Pete Bartonly <[EMAIL PROTECTED]> wrote:
>> >
>> Also, brackets around conditions (in the if) are not needed, and comparing
>> against None is usually done with 'is' or '
On 25/10/2007, A.T.Hofkamp <[EMAIL PROTECTED]> wrote:
> On 2007-10-25, Pete Bartonly <[EMAIL PROTECTED]> wrote:
> >
> Also, brackets around conditions (in the if) are not needed, and comparing
> against None is usually done with 'is' or 'is not' instead of '==' or '!='.
> The result is then
>
> if
On Oct 25, 10:02 am, Pete Bartonly <[EMAIL PROTECTED]> wrote:
> Quick question, probably quite a simple matter. Take the follow start of
> a method:
>
> def review(filesNeedingReview):
>
> for item in filesNeedingReview:
> (tightestOwner, logMsg) = item
>
> if (logMsg != None
Pete Bartonly wrote:
> Quick question, probably quite a simple matter. Take the follow start of
> a method:
>
>
> def review(filesNeedingReview):
>
> for item in filesNeedingReview:
> (tightestOwner, logMsg) = item
>
> if (logMsg != None):
> for logInfo in
On 2007-10-25, Pete Bartonly <[EMAIL PROTECTED]> wrote:
>
> Quick question, probably quite a simple matter. Take the follow start of
> a method:
>
>
> def review(filesNeedingReview):
>
> for item in filesNeedingReview:
> (tightestOwner, logMsg) = item
>
> if (logMsg != None)
Quick question, probably quite a simple matter. Take the follow start of
a method:
def review(filesNeedingReview):
for item in filesNeedingReview:
(tightestOwner, logMsg) = item
if (logMsg != None):
for logInfo in logMsg.changed_paths:
This generates the
44 matches
Mail list logo