1

I want to create a pie chart in tkinter and fill the arcs with part of an image. It doesn't really matter what part of the image that is shown since the pictures will be uniform with a geometric patterns. I'm using the code below to create the pie chart, so i want to set the "fill"-variables to an image (for example, fill="image1"). Is this possible or can i do this some other way? I'm not an experienced programmer btw.

import Tkinter
def frac(n): return 360.0 * n / 500
c = Tkinter.Canvas(width=700, height=700, bg='black');
c.pack()
c.create_arc((100,100,500,500), fill="red", start=frac(0), extent = frac(100))
c.create_arc((100,100,500,500), fill="blue", start=frac(100), extent = frac(400))
c.create_arc((100,100,500,500), fill="green", start=frac(400), extent = frac(100))
c.mainloop()
Krupip
  • 4,404
  • 2
  • 32
  • 54
ronaldfisher
  • 21
  • 1
  • 6
  • Fix your semi colon at the end of your third line, you don't use ; in python. This post may help you in your endeavors. http://stackoverflow.com/questions/33072200/filling-a-tkinter-canvas-element-with-an-image – Krupip Apr 20 '17 at 13:41
  • @snb it's perfectly acceptable to use `;` in Python. It may not be standard practice, but it won't break anything. – Delioth Apr 20 '17 at 20:46
  • @Delioth You can use it, that doesn't mean you should. However in this case I edited his comment and I'd never used semicolons in python for anything, I think they origionally had c.pack() on the same line as the line above, hence the need for the semicolon ([allows multiple statements on the same line](http://stackoverflow.com/questions/12335358/python-what-does-a-semi-colon-do)), I didn't realize they were doing that in the edit since it was all in one line when i looked at the source – Krupip Apr 20 '17 at 20:56
  • Alright thank you! – ronaldfisher Apr 21 '17 at 08:34

0 Answers0