Hi,

Python v2.7
Tkinter
Windows 7

I am having some troubles drawing a line. I have called create_line inside a for loop, in which I gave it coordinates that are returned from another function. However, instead of drawing separate lines, it joins the lines together. Here is a snippet of my code:

from Tkinter import *

class App(object):
 
    def __init__(self, master):
        self.canvas = Canvas(width = 50, height = 30, bg = white)
        self.canvas.pack()

    def create_lines(self):
        self.p = Plot
       
        for line in self.lines:
           for (x,y) in self.p.coord(line):
               self.canvas.create_line((x,y), fill = self.colour)
     
       
class Plot(Frame):

    def __init__(self, master):

        Frame.__init__(self, master)
       <Entry boxes, labels and buttons here>

    def coords(self, line):
        <a function here is used to generate coords based on line input>

How do I make it draw individual lines? Any help would be greatly appreciated. Thanks!

Solved. My co-ordinates weren't outputting correctly

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.