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)

18th Dec 2019, 9:22 PM
Roxana
9 Answers
+ 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)
19th Dec 2019, 3:47 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
from tkinter import * root = Tk() canv = Canvas(root) canv.pack() canv.create_line (x1,y1,x2,y2)
18th Dec 2019, 10:51 PM
Qasem
+ 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.
19th Dec 2019, 3:45 AM
Qasem
0
Can you share you code here ?
18th Dec 2019, 9:31 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
I mean that i want x1,y1,x2,y2 to choose from values of 4 lists with for loops
19th Dec 2019, 3:36 AM
Roxana
0
Roxana Haghgoo provide an example please, because there are many ways you can loop throught a list
19th Dec 2019, 3:37 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
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)
19th Dec 2019, 3:44 AM
Roxana
0
Thanks
19th Dec 2019, 6:50 AM
Roxana
0
Np
19th Dec 2019, 8:09 AM
Aymane Boukrouh
Aymane Boukrouh - avatar