Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 883751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:38:41+00:00 2026-05-15T12:38:41+00:00

Hello i have designed a maze and i want to draw a path between

  • 0

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???

This is the most important bits in the module for this part

def __init__(self, title="Graphics Window",
             width=200, height=200, autoflush=True):
    master = tk.Toplevel(_root)
    master.protocol("WM_DELETE_WINDOW", self.close)
    tk.Canvas.__init__(self, master, width=width, height=height)
    self.master.title(title)
    self.pack()
    master.resizable(0,0)
    self.foreground = "black"
    self.items = []
    self.mouseX = None
    self.mouseY = None
    self.bind("<Button-1>", self._onClick)
    self.height = height
    self.width = width
    self.autoflush = autoflush
    self._mouseCallback = None
    self.trans = None
    self.closed = False
    master.lift()
    if autoflush: _root.update()

def __checkOpen(self):
    if self.closed:
        raise GraphicsError("window is closed")
def setCoords(self, x1, y1, x2, y2):
    """Set coordinates of window to run from (x1,y1) in the
    lower-left corner to (x2,y2) in the upper-right corner."""
    self.trans = Transform(self.width, self.height, x1, y1, x2, y2)
def plot(self, x, y, color="black"):
    """Set pixel (x,y) to the given color"""
    self.__checkOpen()
    xs,ys = self.toScreen(x,y)
    self.create_line(xs,ys,xs+1,ys, fill=color)
    self.__autoflush()

def plotPixel(self, x, y, color="black"):
    """Set pixel raw (independent of window coordinates) pixel
    (x,y) to color"""
    self.__checkOpen()
    self.create_line(x,y,x+1,y, fill=color)
    self.__autoflush()
    def draw(self, graphwin):
    if self.canvas and not self.canvas.isClosed(): raise GraphicsError(OBJ_ALREADY_DRAWN)
    if graphwin.isClosed(): raise GraphicsError("Can't draw to closed window")
    self.canvas = graphwin
    self.id = self._draw(graphwin, self.config)
    if graphwin.autoflush:
        _root.update()
    def move(self, dx, dy):

    """move object dx units in x direction and dy units in y
    direction"""

    self._move(dx,dy)
    canvas = self.canvas
    if canvas and not canvas.isClosed():
        trans = canvas.trans
        if trans:
            x = dx/ trans.xscale 
            y = -dy / trans.yscale
        else:
            x = dx
            y = dy
        self.canvas.move(self.id, x, y)
        if canvas.autoflush:
            _root.update()
    class Point(GraphicsObject):
def __init__(self, x, y):
    GraphicsObject.__init__(self, ["outline", "fill"])
    self.setFill = self.setOutline
    self.x = x
    self.y = y

def _draw(self, canvas, options):
    x,y = canvas.toScreen(self.x,self.y)
    return canvas.create_rectangle(x,y,x+1,y+1,options)

def _move(self, dx, dy):
    self.x = self.x + dx
    self.y = self.y + dy

def clone(self):
    other = Point(self.x,self.y)
    other.config = self.config.copy()
    return other

def getX(self): return self.x
def getY(self): return self.y
def __init__(self, p1, p2, options=["outline","width","fill"]):
    GraphicsObject.__init__(self, options)
    self.p1 = p1.clone()
    self.p2 = p2.clone()

def _move(self, dx, dy):
    self.p1.x = self.p1.x + dx
    self.p1.y = self.p1.y + dy
    self.p2.x = self.p2.x + dx
    self.p2.y = self.p2.y  + dy

def getP1(self): return self.p1.clone()

def getP2(self): return self.p2.clone()

def getCenter(self):
    p1 = self.p1
    p2 = self.p2
    return Point((p1.x+p2.x)/2.0, (p1.y+p2.y)/2.0)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:38:41+00:00Added an answer on May 15, 2026 at 12:38 pm

    You might try this from an interactive Python shell:

    >>> import graphics
    >>> help(graphics.Circle)
    

    That should tell you what attributes Circle does have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following regexp: (?P<question>.+(?<!\[\[)) It is designed to match hello world! in
Hello i have 2 arrays and and i want to put them in a
Hello I have next function, what always return null as result, but service calling
Hello I have a wordpress site than I want to upgrade to HTML5 code
Hello only have a few hours with Java. (from Python) I am trying to
Hello I'm completely new to using Jaspersoft iReport Designer. I want to have a
Hello I have this webiste www.liiklusinfo.ee and it's basically designed to work on web
Hello have to start a new Activity from the BroascastReceiver or the Service, but
Hello people can someone help. I have designed a dialog in which I would
Hello I have like this 2 tables class User public int UserId{get;set;} { ....

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.