Hello i have designed a maze and i want to draw a path between the cells as the 'person' moves from one cell to the next. So each time i move the cell a line is drawn Also i am using the graphics module
The graphics module is an object oriented library
Im importing - from graphics import*
-
from maze import*
my circle which is my cell -
center = Point(15, 15)
-
c = Circle(center, 12)
-
c.setFill('blue')
-
c.setOutline('yellow')
-
c.draw(win)
-
-
p1 = Point(c.getCenter().getX(), c.getCenter().getY())
-
this is my loop
-
-
if mazez.blockedCount(cloc)> 2:
-
mazez.addDecoration(cloc, "grey")
-
mazez[cloc].deadend = True
-
c.move(-25, 0)
-
p2 = Point(p1.getX(), p1.getY())
-
line = graphics.Line(p1, p2)
-
cloc.col = cloc.col - 1
Now it says getX not defined every time i press a key is this because of p2???
ive found this in the module about Point - class Point(GraphicsObject)
-
Method resolution order:
-
Point
-
GraphicsObject
-
builtins.object
-
-
Methods defined here:
-
-
__init__(self, x, y)
-
-
clone(self)
-
-
getX(self)
-
-
getY(self)
9 1705 bvdet 2,851
Recognized Expert Moderator Specialist
Without seeing your code for "Circle", I have no way of knowing what your problem is other than you did not define a method "center()".
@bvdet
ey ive just shown u the code for circle its right there lol andi have edited my question of my post and my code
# c is my circle
bvdet 2,851
Recognized Expert Moderator Specialist
You are calling getX() as though it is a stand-alone function when it is actually a Point object method. Try this: - p2 = Point(c.getCenter().getX(), c.getCenter().getY())
@bvdet
thanx bvdet i did what u said but now i get another error which is - Exception in Tkinter callback
-
Traceback (most recent call last):
-
File "C:\Python31\lib\tkinter\__init__.py", line 1399, in __call__
-
return self.func(*args)
-
File "C:\Python31\mazefiddle.py", line 38, in handleKeys
-
p2 = Point(c.getCenter.getX(), c.getCenter().getY())
-
AttributeError: 'function' object has no attribute 'getX'
Any ideas why still a getX error whys dat?
bvdet 2,851
Recognized Expert Moderator Specialist
Look carefully: - p2 = Point(c.getCenter().getX(), c.getCenter().getY())
You are not calling getCenter().
@bvdet
what you mean iam not calling getCenter? it is in my p1 and p2 shouldnt it be called already?
how do i call something then?
I also changed my code for the p2 bit
bvdet 2,851
Recognized Expert Moderator Specialist @lightning18
Take a look at this code, and tell me if you see any difference between "p.uv" and "p.uv()". - >>> p = Pt3D(1,2,3)
-
>>> p.uv
-
<bound method Pt3D.uv of Pt3D(1.000000, 2.000000, 3.000000)>
-
>>> p.uv()
-
Pt3D(0.267261, 0.534522, 0.801784)
-
>>>
"p.uv" returns the method bound to instance "p" and "p.uv()" calls method "uv()". The difference is the parentheses.
@bvdet
so is this what you are saying ?
if i have
( - p1 = Point(c.getcenter().getX(), c.getcenter.getY())
-
p2 = Point(p1.getcenter().getX(), p1.getcenter().getY()
or you saying
something like that
i understand it but do not know whot to implement it with my code bit confused how mine needs to be like that
thanks
bvdet 2,851
Recognized Expert Moderator Specialist
p2 = Point(c.getCenter.getX(), c.getCenter().getY())
The line of code above should be - p2 = Point(c.getCenter().getX(), c.getCenter().getY())
You left out the parentheses after "c.getCenter".
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: cain |
last post by:
Hi,
I'm new to ASP so bare with me here.
I just coded a page and I'm getting an error on line 3, which is the
attach line. According to the references I have, this is the correct
way to do...
|
by: ding feng |
last post by:
I have got formatted files. All of these file takes this form:
obj1 method1 obj2 string1 obj3 string2 argument.
Of course, each file can have maximum fields as shown above, or
minimun fields...
|
by: nukiboy |
last post by:
========= test.js ===================
function Test()
{
this.temp = "hehehehe" ;
this.method1 = method1 ;
|
by: t2581 |
last post by:
I want to run single script that will attach to instance and restore db
example file restore_on_dev1.txt
-- file restore_on_dev1.txt
attach to DEV1 user bamboo using 123456;
restote database...
|
by: andrewcw |
last post by:
( excuse earlier bad post, I was attemptingt to use tab
key which sent message ).
I am using a class genereated by XSD. From data I will
collect I plan to build the object & serialize as XMl...
| |
by: Steve Amey |
last post by:
Hi all
At the moment I am using the following code to check to see if the
oTempDataSet is not nothing and that it has tables in it:
If Not oTempDataSet Is Nothing Then
If...
|
by: Steve Long |
last post by:
Hello,
I'm trying to create an object at runtime. The way I used to do this in the
COM (vb6) world was to use the ProgID such as:
PublicWorksPlugin.PWPlug
I kind of know how to do this in .NET...
|
by: kujtim |
last post by:
i have problem using ajaxlib.js i have includet as it should in the same directoryy the ajaxlib.js with my codee but i am reciving error "line 15 object required " .
here is my...
|
by: zjs |
last post by:
class CChatSocket : public CSocket
{
....
}
void CChatSocket::OnReceive(int nErrorCode)
{
CSocket::OnReceive(nErrorCode);//Here I insert a breakpoint,
m_pDoc->ProcessPendingRead();
}
|
by: EJaques |
last post by:
(Using Access 2003)
I have a an Object OLE field in a table where users can insert Excel sheets, Word Docs, Pdfs etc.
I need to create a button on a formulaire that allows the user to browse...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |