Circular progress bar using Tkinter?
NickName:Atalanttore Ask DateTime:2017-01-31T03:21:14

Circular progress bar using Tkinter?

I want to add a Circular progress bar to my Python GUI using Tkinter, but I didn't find any documentation for Circular progress bars with Tkinter.

How can I create a Circular progress bar in Tkinter or is this not possible?

Copyright Notice:Content Author:「Atalanttore」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/41943823/circular-progress-bar-using-tkinter

Answers
Atzin 2018-12-27T09:53:25

I dont have enough rep to add a comment but the code that martineau put up as is, does not currently work and you need to change\n\n if self.running:\n self.cur_extent = (self.cur_extent + delta) % 360\n self.canvas.itemconfigure(self.arc_id, extent=self.cur_extent)\n\n\nto \n\n if self.running:\n self.extent = (self.extent + delta) % 360\n self.cur_extent = (self.extent + delta) % 360\n self.canvas.itemconfigure(self.arc_id, extent=self.cur_extent)\n",


martineau 2017-01-31T06:28:12

There's none built-in, but you can create one of your own. Here's an example of one way of doing it that manually draws and updates the graphics on a Canvas:\ntry:\n import Tkinter as tk\n import tkFont\n import ttk\nexcept ImportError: # Python 3\n import tkinter as tk\n import tkinter.font as tkFont\n import tkinter.ttk as ttk\n\n\nclass CircularProgressbar(object):\n def __init__(self, canvas, x0, y0, x1, y1, width=2, start_ang=0, full_extent=360.):\n self.custom_font = tkFont.Font(family="Helvetica", size=12, weight='bold')\n self.canvas = canvas\n self.x0, self.y0, self.x1, self.y1 = x0+width, y0+width, x1-width, y1-width\n self.tx, self.ty = (x1-x0) / 2, (y1-y0) / 2\n self.width = width\n self.start_ang, self.full_extent = start_ang, full_extent\n # draw static bar outline\n w2 = width / 2\n self.oval_id1 = self.canvas.create_oval(self.x0-w2, self.y0-w2,\n self.x1+w2, self.y1+w2)\n self.oval_id2 = self.canvas.create_oval(self.x0+w2, self.y0+w2,\n self.x1-w2, self.y1-w2)\n self.running = False\n\n def start(self, interval=100):\n self.interval = interval # Msec delay between updates.\n self.increment = self.full_extent / interval\n self.extent = 0\n self.arc_id = self.canvas.create_arc(self.x0, self.y0, self.x1, self.y1,\n start=self.start_ang, extent=self.extent,\n width=self.width, style='arc')\n percent = '0%'\n self.label_id = self.canvas.create_text(self.tx, self.ty, text=percent,\n font=self.custom_font)\n self.running = True\n self.canvas.after(interval, self.step, self.increment)\n\n def step(self, delta):\n """Increment extent and update arc and label displaying how much completed."""\n if self.running:\n self.extent = (self.extent + delta) % 360\n self.canvas.itemconfigure(self.arc_id, extent=self.extent)\n # Update percentage value displayed.\n percent = '{:.0f}%'.format(\n round(float(self.extent) / self.full_extent * 100))\n self.canvas.itemconfigure(self.label_id, text=percent)\n self.canvas.after(self.interval, self.step, delta)\n\n\n def toggle_pause(self):\n self.running = not self.running\n\n\nclass Application(tk.Frame):\n def __init__(self, master=None):\n tk.Frame.__init__(self, master)\n self.grid()\n self.createWidgets()\n\n def createWidgets(self):\n self.canvas = tk.Canvas(self, width=200, height=200, bg='white')\n self.canvas.grid(row=0, column=0, columnspan=2)\n\n self.progressbar = CircularProgressbar(self.canvas, 0, 0, 200, 200, 20)\n\n self.pauseButton = tk.Button(self, text='Pause', command=self.pause)\n self.pauseButton.grid(row=1, column=0)\n self.quitButton = tk.Button(self, text='Quit', command=self.quit)\n self.quitButton.grid(row=1, column=1)\n\n def start(self):\n self.progressbar.start()\n self.mainloop()\n\n def pause(self):\n self.progressbar.toggle_pause()\n\nif __name__ == '__main__':\n app = Application()\n app.master.title('Sample application')\n app.start()\n\nHere's some screenshots of it running:\n",


More about “Circular progress bar using Tkinter?” related questions

Circular progress bar using Tkinter?

I want to add a Circular progress bar to my Python GUI using Tkinter, but I didn't find any documentation for Circular progress bars with Tkinter. How can I create a Circular progress bar in Tkint...

Show Detail

Circular Progress Bar using PySide

Hello friends iam trying to implement circular progress bar using PySide. Iam already downloaded the program from Any PyQt circular progress bar?. I try to convert the PyQt4 code to PySide code.But...

Show Detail

Using circular progress bar with masked image?

I am working on a circular progress bar for custom game center achievements view and I have kind of "hit the wall". I am struggling with this for over two hours and still cannot get it to work. The

Show Detail

How to change the circular progress bar Spinner Speed?

As mentioned (How To Make Circle Custom Progress Bar in Android am using https://github.com/Todd-Davies/ProgressWheel lib in my project. I am developing the game app which has different set of leve...

Show Detail

How to Program a Circular Progress Bar

I am programming a video game using LibGDX and I can't for the life of me figure out how to program a circular progress bar. This is not where the progress bar spins. This is where it will start ou...

Show Detail

Circular progress bar with circular UILabel

So I found this cool UI design on dribble https://dribbble.com/shots/1021040-UI-User-Profile-Page and I want to use that header section (profile picture, level, and right info). The problem I'm stu...

Show Detail

Scrolling Progress Bar in Tkinter

I have been trying to set up a progress bar in a python tkinter gui that shows that a process is running. The process is long and I have no way to really measure the progress, so I need to use an

Show Detail

Edit size CSS in this Circular progress bar

I use the following code: bootstrap Circular progress bar using custom CSS and JS To get a beautiful circular progress bar, but the problem, I want to make it bigger, it appears small, and when tr...

Show Detail

Segmented circular progress bar in android

How to create segmented circular progress bar in android like the one given below? segmented circular progress bar I am not able to find a solution

Show Detail

tkinter progress bar with joblib parallel

I would like to make a GUI progress bar to show the progress of Joblib. Here below is what I have done now: import tkinter as tk from tkinter import ttk from tqdm import tqdm from joblib import Par...

Show Detail