Hi Liam,
Liam Clarke wrote on 06.11.2005:
>Hi Jan,
>
>Won't this
>
>site_id = property(GetSiteID, SetSiteID)
>
>and this
>
>site_id = 1
>
>collide?
>
Yup. After writing my message, I thought about it again: the property function
gets never executed when I use the class attribute.
So I changed
Am Samstag, den 05.11.2005, 22:30 +0100 schrieb Jan Eden:
> Hi,
>
> I use the following construction to make sure the data attribute site_id is
> set only once for each object:
>
> def GetSiteID(self):
> return self._site_id
>
> def SetSiteID(self, value):
> if not (hasattr(self, '_site
I am try to write a code that turn codes to html file
I do it like this,(It is take out from example code form sourceforge):
re_lead=re.compile(r"[\f\t]")
re_space=re.compile(r"[ ]{2,}")
src = re_lead.sub(r" ",src)
src = re_lead.sub(r" ",src)
src is the code string!
why the following code report error?
"""
Is given point in polygon?
"""
def pointInPoly(point, pointsList):
"Return True if point is contained in polygon (defined by
given list of points.)"
assert len(pointsList) >= 3, 'Not enough points to define a
polygon (I require 3 or more.)
why the following code does not work?
# determine if a point is inside a given polygon or not
# Polygon is a list of (x,y) pairs.
def point_inside_polygon(x,y,poly):
n = len(poly)
inside =False
p1x,p1y = poly[0]
for i in range(n+1):
p2x,p2y = poly[i % n]
if y > m
why the following code does not work?
"""
Tkinter Color Vector Objects
Just the bare minimum to create re-sizable
and re-usable color icons in tkinter.
"""
import Tkinter as Tk
import math
""" Get points for a unit regular-polygon with n sides. """
def getregpoly(sides):
points = []
ang
> why the following code does not work?
> [snip script]
Give us an error message, please.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
just return the
"Simple pointInPoly() test..."
no return from point_inside_polygon(3,10,poly)
On 11/6/05, Glen Wheeler <[EMAIL PROTECTED]> wrote:
> > why the following code does not work?
> > [snip script]
>
> Give us an error message, please.
> ___
> T
Interfaces and abstract classes - I know they don't exist per se in
Python. But what are the closest analogues? I've found a few examples,
e.g. for an abstract class the following page has a fairly common
suggestion:
http://www.norvig.com/python-iaq.html
thanks!
alex
_
Shi,
I've just seen 3 queries from you all along the lines of -
why the following code does not work?
If English is not your first language, I can understand you're not
going to write us a novel.
However, you'll get a better response if you copy and paste the error
message (the traceback) that
there is no error message but in the console
I just see Simple pointInPoly() test...
On 11/6/05, Liam Clarke <[EMAIL PROTECTED]> wrote:
> Shi,
>
> I've just seen 3 queries from you all along the lines of -
>
> why the following code does not work?
>
>
>
> If English is not your first language, I
This is why -
if __name__ == '__main__':
print 'Simple pointInPoly() test...'
poly = [(-1,-1), (6,-1), (5,6), (0,5)]
point_inside_polygon(3,10,poly)
And you were expecting to see a True/False as to whether or not the
point was inside the polygon right, as point_inside_polygon()
Missed the rest of the list with this.
Still sent to Shi however.
From: "Shi Mu" <[EMAIL PROTECTED]>
> why the following code report error?
>
> [..]
>assert pointInPoly(pointA, poly)
>assert not pointInPoly(pointB, poly)
Assuming your function is correct, the asserts are fa
Is there any sample code to calculate the overlaid area between two polygons?
Thanks!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I would do this by clipping the two polygons together, and then
calculating the area of the resultant polygon.
You can do that using the Weiler-Atherton polygon clipping algorithm,
which is rather common.
Glen
From: "Shi Mu" <[EMAIL PROTECTED]>
> Is there any sample code to calculate th
铁石 wrote:
> I am try to write a code that turn codes to html file
You might be interested in existing solutions. Here is an old list, there are
probably more now:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/904b11321e07460a/fc9a13cf4baf3b05%23fc9a13cf4baf3b05?sa=X&oi=gro
Shi Mu wrote:
> why the following code report error?
What error does it report? If you show us the error message and the full stack
trace it will be easier to answer your question.
Kent
___
Tutor maillist - Tutor@python.org
http://mail.python.org/ma
Shi Mu wrote:
> why the following code does not work?
In what way does it not work?
Kent
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
> just return the "Simple pointInPoly() test..."
> no return from point_inside_polygon(3,10,poly)
if __name__ == '__main__':
print 'Simple pointInPoly() test...'
poly = [(-1,-1), (6,-1), (5,6), (0,5)]
point_inside_polygon(3,10,poly)
-
You nee
> Interfaces and abstract classes - I know they don't exist per se in
> Python.
First you need to define what you mean by the terms.
Every class has an interface - it is the set of messages to which
it responds.
An Abstract class is one which is not intended to be instantiated.
class Abstract
Hi! I'm on the version 2.4, going through Beginning Python (Wrox), and I'm
getting the above error. I'm trying to do this:
menu_specials._contains_("test")
Any ideas on what I'm doing wrong? Thanks!
___
Tutor maillist - Tutor@python.org
http://mai
hi everyone,
Firstly I am a new programmer on python. I am using Python 2.4.1
with IDLE 1.1.1
I can't save my poject in my computer. how can I save my projects and
in which format I must save my projects.
thanks a lot.
___
Tutor maillist
Alex Hunsley wrote:
> Interfaces and abstract classes - I know they don't exist per se in
> Python. But what are the closest analogues? I've found a few examples,
> e.g. for an abstract class the following page has a fairly common
> suggestion:
>
> http://www.norvig.com/python-iaq.html
Interfa
Trent Rigsbee wrote:
> Hi! I'm on the version 2.4, going through Beginning Python (Wrox), and I'm
> getting the above error. I'm trying to do this:
>
> menu_specials._contains_("test")
>
> Any ideas on what I'm doing wrong? Thanks!
The name of the method is __contains__ (note *double* leading
| From: Shi Mu
| Is there any sample code to calculate the overlaid area between two
| polygons?
| Thanks!
|
The polygon module at (
http://www.dezentral.de/warp.html?http://www.dezentral.de/soft/Polygon/ ) was
found by googling for "polygon module python". If by "overlay" you mean the
area
> Hi! I'm on the version 2.4, going through Beginning Python (Wrox), and
> I'm getting the above error. I'm trying to do this:
>
> menu_specials._contains_("test")
>
> Any ideas on what I'm doing wrong? Thanks!
It looks like you may be reading the wrong book!
Why they would suggest you ever exec
>Firstly I am a new programmer on python. I am using Python 2.4.1
> with IDLE 1.1.1
Welcome to the tutor list!
> I can't save my poject in my computer. how can I save my projects and
> in which format I must save my projects.
Provided you have typed your code into a new editor wind
> But you normally shouldn't call this directly, you should write
> "test" in menu_specials
Now howzabout that! Yet another new trick learnt.
When did 'in' start working with dictionaries?
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.p
Alan Gauld wrote:
>> But you normally shouldn't call this directly, you should write
>> "test" in menu_specials
>
>
> Now howzabout that! Yet another new trick learnt.
> When did 'in' start working with dictionaries?
Oh, about four years ago :-) in Python 2.2
You really should read the "What's
I believe around Python 2.2...
I used to want that syntax when I started, now I stick to for x in y.keys()
- The 'explicit > implicit' concept has become important to me; probably
because I do most of my coding after midnight and the "should really be in
bed" mistakes are bad enough, but adding im
I have a list of random points:
[[x0,y0],[x1,y1],...,[xn,yn]]
how can I use Tkinter to draw lines to connect them one by one based
on the order in the list?
Thanks a lot!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tuto
On 07/11/05, Shi Mu <[EMAIL PROTECTED]> wrote:
> I have a list of random points:
> [[x0,y0],[x1,y1],...,[xn,yn]]
> how can I use Tkinter to draw lines to connect them one by one based
> on the order in the list?
You need to use a Tkinter.Canvas.
Have a look at Fredrik Lundh's site: http://effbot.
On Sun, 6 Nov 2005, Shi Mu wrote:
> I have a list of random points: [[x0,y0],[x1,y1],...,[xn,yn]] how can I
> use Tkinter to draw lines to connect them one by one based on the order
> in the list?
Do you know how to draw a single line in Tkinter? Have you looked at the
Canvas widget documentat
Shi Mu wrote:
> I have a list of random points:
> [[x0,y0],[x1,y1],...,[xn,yn]]
> how can I use Tkinter to draw lines to connect them one by one based
> on the order in the list?
You can use a Canvas widget to draw lines. You will probably have to scale your
coordinates to match the coordinates o
> I used to want that syntax when I started, now I stick to for x in
> y.keys()
I knew you could do
for item in dictionary:
instead of
for item in dictionary.keys():
But I didn't realise it worked for a single item test too
if item in dictionary
instead of
if dictionary.has_key(item):
Whi
Hey all,
I have a question that I can't figure out, despite reading the help and
everything else. How do I use an image or images in a Graphic User Interface,
and link them to parts of my code i.e. a picture of a game piece to its
value?
Thanks in advance,
Nathan Pinno
___
> Oh, about four years ago :-) in Python 2.2
>
> You really should read the "What's New in Python x.x" docs ;)
:-)
Hmm, I usually skim them but pick up most of my info from this
list because I rarely upgrade to the latest version right away
- I only upgraded my XP box. to 2.4 a few weeks ago..
Title: Message
Depends on your GUI toolkit and
widget.
For instance, in wxPython's wx.BitmapButton widget, there's a
specific method to set the bitmap, and then the
underlying C++ code interfaces with the GDI portion of the Win32
API and draws it for you.
http://www.wxpython.org/docs/api/w
I had thought I was developing a clue regarding objects in Python, but I
ran across an oddity today that I didn't expect. It had seemed to me
that once an instance was created, it would have a separate data pool
from any other instance of the same object. It would share methods, of
course, but th
Hi DS,
I'm not sure what language you've dealt with before, but if it was Java or
C++, then you've run into Python's variant of static members.
class X(object):
classMember = True
def __init__(self):
self.instanceMember = True
Does that make it any clearer? As to the why, I'd
On 07/11/05, DS <[EMAIL PROTECTED]> wrote:
> So, I can see the error of my ways. I can also see that this behavior
> gives me an opportunity to globally change a value in all of the object
> instances, if I ever had to do something like that. I just don't have a
> clue as to why objects were desi
Title: Message
Liam,
I am using Pygame, but I am still don't know how to use it. I read it, and
it confused me.
- Original Message -
From: Liam
Clarke-Hutchinson
To: 'Nathan Pinno'
Cc: 'tutor@python.org'
Sent: November 6, 2005 3:47 PM
Subject: RE: [Tutor] How I use
I tried to write the follwoing code to draw lines on the anvas based
on the clicked points but retur the message:
>>> Traceback (most recent call last):
File "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
Hi Shi Mu,
Let's look at click():
##
def click(event):
print event.x, event.y
m1=event.x
n1=event.y
##
By default, variable names in functions are local. Do you know about
local vs global variables? The assignments to m1 and n1 won't
based on the following rewritten code, why the lines still can not be
drawn? (there is no error report and the canvas appears).
from Tkinter import *
root = Tk()
c = Canvas(root, bg='#0e2e0e', height=500, width=1000)
lastX=""
lastY=""
def click(event):
global lastX, lastY
if lastX != "":
it works now.
from Tkinter import *
root = Tk()
c = Canvas(root, bg='#0e2e0e', height=500, width=1000)
frame = c
lastX=""
lastY=""
def click(event):
global lastX, lastY
if lastX != "":
c.create_line(lastX,lastY,event.x,event.y,fill="white")
lastX = event.x
lastY = event.y
c.bind('
Title: Message
Hi Nathan,
Pygame is a little confusing at first, but
it makes sense one you can get the hang of the basics.
http://www.pygame.org/docs/tut/intro/intro.html is
a good example.
import sys, pygamepygame.init()size = width, height = (320, 240)speed = [2,
2]black = (0, 0, 0
>I had thought I was developing a clue regarding objects in Python, but I
> ran across an oddity today that I didn't expect. It had seemed to me
> that once an instance was created, it would have a separate data pool
> from any other instance of the same object.
And this is true...
> It would sh
> I'm not sure what language you've dealt with before, but if it was Java or
> C++, then you've run into Python's variant of static members.
>
> class X(object):
>classMember = True
>
>def __init__(self):
>self.instanceMember = True
>
>
> Does that make it any clearer? As to the why
On Sun, 6 Nov 2005, Shi Mu wrote:
> based on the following rewritten code, why the lines still can not be
> drawn? (there is no error report and the canvas appears).
It works for me.
> from Tkinter import *
>
> root = Tk()
>
> c = Canvas(root, bg='#0e2e0e', height=500, width=1000)
>
> last
frame = c needs to be put before the click function or the lines can
not be drawn.
On 11/6/05, Chris F.A. Johnson <[EMAIL PROTECTED]> wrote:
> On Sun, 6 Nov 2005, Shi Mu wrote:
>
> > based on the following rewritten code, why the lines still can not be
> > drawn? (there is no error report and the
On Sun, 6 Nov 2005, Shi Mu wrote:
> frame = c needs to be put before the click function or the lines can
> not be drawn.
Not at all. I have everything after the click function and it works.
This is my version (includes a small addition):
def click(event):
global lastX, lastY
when I read some python sample codes.
I found that several of them need "python -i" to run them or you will
not get any result though the program does not report any error.
I really can not understand it.
Thanks!
___
Tutor maillist - Tutor@python.org
ht
53 matches
Mail list logo