Python tkinter create_line problem : | Sololearn: Learn to code for FREE!

0

Python tkinter create_line problem :

How can I create line with values of 4 list x1,y1,x2,y2 on python's tkinter ??(I want to use for loop to create line between all points)

12/18/2019 9:22:18 PM

Roxana

9 Answers

New Answer

+1

Roxana Haghgoo it's like this: for x1, y1, x2, y2 in zip(X1_list, Y1_list, X2_list, Y2_list): Canv.create_line(x1, y1, x2, y2) or simply without zip: for (x1, y1, x2, y2) in (X1_list, Y1_list, X2_list, Y2_list): Canv.create_line(x1, y1, x2, y2)

+1

from tkinter import * root = Tk() canv = Canvas(root) canv.pack() canv.create_line (x1,y1,x2,y2)

+1

It depends on what the shape is going to be plotted. But to be an example: ... canv.pack (): x1=A y1=B for i, j in zip (list1,list2): canv.create_line (x1,y1,i,j) x1=i y1=j List1 and list 2 are those you want to be the shape coordinates.

0

Can you share you code here ?

0

I mean that i want x1,y1,x2,y2 to choose from values of 4 lists with for loops

0

Roxana Haghgoo provide an example please, because there are many ways you can loop throught a list

0

X1_list=[ ] Y1_list=[ ] X2_list=[ ] Y2_list=[ ] #I want to create lines between every indexes of this 4 list For ?????????? : Canv.creat_line(x1,y1,x2,y2)

0

Thanks

0