Windows progress bar in python's Tkinter - python

Is there any way in python's Tkinter, bwidget or anything similar to show a Windwos' default progress bar?
I already know the bwidget.ProgressBar, but it produces an ugly progress bar while I mean showing a valid windows progress bar - the green, glowing one:
http://imageshack.us/photo/my-images/853/unledtph.png/
I need it because that way Windows will automatically show the progress of my program in the task bar. Plus, it looks better.

If you are using a modern (2.7+) version of Tkinter you can try the ttk.ProgressBar which is part of Tkinter.

You can install the pyttk module separately.
from Tkinter import *
import ttk
root = Tk()
progressbar = ttk.Progressbar(orient=HORIZONTAL, length=200, mode='determinate')
progressbar.pack(side="bottom")
progressbar.start()
root.mainloop()
As far as the taskbar functionality, that is not available in Tkinter yet (at least to the best of my knowledge). You'll need to make use of the Windows API for that. Although this question is for PyQt, the answers should prove helpful. Hope it gets you started.

The simplest solution would appear to be to use themed Tk with the tkinter.ttk module included in Python 2.7 and 3.1. The Progressbar widget is what you want.
Since you appear to be considering other frameworks you might look at Qt or wxWidgets which look native and have excellent Python bindings.

Related

Add Widget to Tkinter colorchooser

As far as I understand, it is not possible to modify the tkinter.colorchooser.askcolor as it uses the systems colorpicker dialog. Is this true?
from the source code: https://github.com/python/cpython/blob/3.9/Lib/tkinter/colorchooser.py
# this module provides an interface to the native color dialogue
# available in Tk 4.2 and newer.
The reason being is I wish to add an entry box to the dialog so that I would get the color code and user-entered text returned. Maybe it is possible to embed the dialog within a larger window? Is something like this possible, without using multiple windows?
I cannot find previous discussion anywhere else so I guess it is not a simple issue.
As far as I understand, it is not possible to modify the tkinter.colorchooser.askcolor as it uses the systems colorpicker dialog. Is this true?
Yes, that is true. At least on Windows and OSX. On Linux it's a custom dialog written in tcl/tk. You could start with that code and then make modifications to it, then write a tkinter wrapper around it. That wouldn't be particularly difficult if you know tcl/tk, but it's not exactly trivial either.
Maybe it is possible to embed the dialog within a larger window?
No, it's not.

Parallel functions in python

I have these functions in my python script the top three of them being related to tkinter and the bottom one being a process not related to the Tk window , how can i execute the pixels() function parallel to the tkinter functions ?
top.mainloop()
C.pack()
colors()
pixels()
Try tkinter's after method. Documentation here.
I see a lot of people who are looking for "running function along side tkinter mainloop" but cannot find after while researching. I guess it just isn't talked about much in documentation to show up on searches (besides SO questions).

How to make a simple GUI in python without using any tools such as Tkinter, Eclipse etc?

I'm making an app using python. I want a very simple user interface just to read a query. It should contain a text box where to type the query and a submit button. Can I make such an interface without using any drag and drop softwares, i.e just by using the code?
Well simply you can't do that with pure python
BTW start with Tkinter as its more easy to learn than any other gui framework
Your expected code would look like in Tkinter:
import Tkinter as Tk
root = Tk.Tk()
def submit():
print "entered text were " + entry.get()
entry = Tk.Entry(root)
entry.pack()
button = Tk.Button(root,text='submit',command=submit)
button.pack()
root.mainloop()
By the way Tkinter is open source so feel free to look how the module is made
Well, there isn't really anything to say other than: no, you can't.
Unlike some other languages, Python cannot do too much without importing modules/libraries.
Meaning, to make a user-interface of any kind, you must first import a GUI development library such as Tkinter, wxPython, etc.

How to use the "native" GUI look with Tkinter?

By default Tkinter still uses the old Windows 2000-style widgets (random example):
but I want it to use the Windows XP/Vista/7-style widgets instead:
How can I do this? I would prefer to use the latest style version, so Windows 7 > Vista > XP > 2000.
On Windows, use tkinter.ttk to get the the themed version of Tk.
The ttk themed widgets are what you are looking for. Be sure to use the 'vista' theme to get native appearance on Vista/Win7.

Python 2.7: Themed "common dialog" tkinter interfaces via Ttk?

Python 2.7 (32-bit) Windows: We're experimenting with Python 2.7's support for themed Tkinter (ttk) for simple GUI's and have come away very impressed!! The one area where the new theme support seems to have come up short is how OS specific common dialogs are wrapped.
Corrected: In other words, the MessageBox and ColorChooser common dialogs have "ugly" looking Win 95 style blocky looking buttons vs. the themed (rounded/gradient) buttons that normally show up on these common dialogs under XP, Vista, and Windows 7. (I'm testing on all 3 platforms with identical, un-themed results).
Note: The filedialog common dialogs (askopenfilename, askopenfilenames, asksaveasfilename, askdirectory) are all properly themed.
import tkMessageBox as messagebox
messagebox.showinfo()
import tkColorChooser as colorchooser
color = colorchooser.askcolor( parent=root, title='Customize colors' )
Any ideas on what's required to get Tkinter's MessageBox and ColorChooser common dialogs to be OS theme compatible (at least under Windows XP or higher)?
Your observation is mainly correct. I do see what you are referring to in the messagebox and the colorchooser. However, my filedialogs all seem to have properly rounded buttons, etc.
My recommendation for you on making the messagebox is to create your own messagebox using the TopLevel widget, and then define what you need on it and the appropriate behavior for the different buttons (it's definitely a bit harder than just using a messagebox, but if you really need the new style buttons, it'll work).
I don't think you can hack together a solution for the colorchooser problem, however.
I though for a minute that perhaps Python 3.1 had fixed this problem, but sadly, I tried and that isn't the case. I suppose if you need the user to pick a color, the buttons will have to be ugly.
An option to get better looking dialog boxes is to compile your script to an executable using pyinstaller. I explain this more thouroughly here.
tl;dr, it appears that compiling with pyinstaller allows you to have dialog boxes with the style of the currently running OS, but not custom styles.

Categories