Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter/ttk themed Message Box?

I started making a GUI with Tkinter and I added the module tkMessageBox as well. But recently I discovered that importing the module ttk gives more 'up-to-date' results: buttons and texts boxes appear with the actual style of the current OS. This is: Windows 10 buttons are plain and blue-lighted, and not those shaded gray blocky buttons from previous versions.

But unfortunately, I can't find a way to use this ttk themed widgets on the common Dialog Boxes (the ones which I imported from tkMessageBox). So OK/Cancel dialogs (for instance) still appear with a theme that doesn't belongs to Windows 10.

All the documentation I check brings me to Tkinter.

like image 758
Xesa Avatar asked Nov 18 '15 22:11

Xesa


People also ask

Is TTK better than tkinter?

ttk supports a variety of widgets as compared to tkinter widgets. Tkinter. ttk doesn't support Place, Pack() and Grid(), thus it is recommended to use tkinter widget with ttk. Ttk has many features and configurations that extend the functionality of a native application and make it look more modern.

What is Tk and TTK in tkinter?

The tkinter. ttk module provides access to the Tk themed widget set, introduced in Tk 8.5. If Python has not been compiled against Tk 8.5, this module can still be accessed if Tile has been installed.

How do I show a pop up message in Python?

Steps to create a Simple GUI in Python using Tkinter: Import Tkinter package and all of its modules. Create a GUI application root window (root = Tk()) and widgets will be inside the main window. Use mainloop() to call the endless loop of the window. If you forget to call this nothing will appear to the user.

What is Tkinter messagebox in Python?

Tkinter Messagebox is a module in python which provides a different set of dialogues that are used to display message boxes, showing errors or warnings, widgets to select files or change colors which is a pop-up box with a relevant message being displayed along with a title based on the requirement in python applications with an icon ...

What is the Tkinter TTK module?

The tkinter.ttk module contains all the new ttk widgets. It’s a good practice to always use themed widgets whenever they’re available. The following statements import the classic and the new Tk themed widgets:

How to create a TK messagebox on Windows?

The Tk messagebox on Windows is the system provided messagebox. Tk does not create a messagebox using Tk buttons and frames but shows the stock dialog provided by the Windows API. To check your report here I ran up Tcl/Tk 8.6, Python 3.4 and Powershell and got each to show a messagebox.

How to create pop-up message In Tkinter?

Popup message occurs on the user window. In the following code, we create a window inside the window we also create a button with the text “Click Me”. After clicking on them a Popup window will be open. import tkinter.messagebox importing this library for showing the message on the Popup screen.


1 Answers

From the docs:

Starting with Tk 8.5, the ttk module became available. This module replaces much (but not all) of the original Tkinter machinery. Use this module to gain these advantages:
  • Platform-specific appearance. In releases before Tk 8.5, one of the commonest complaints about Tk applications was that they did not conform to the style of the various platforms.

  • The ttk module allows you to write your application in a generic way, yet your application can look like a Windows application under Windows, like a MacOS app under MacOS, and so on, without any change to your program.

  • Each possible different appearance is represented by a named ttk theme. For example, the classic theme gives you the appearance of the original Tkinter widgets described in the previous sections.

ttk uses the system styles to represent something. Tkinter does not. It is its own style.

like image 189
R4PH43L Avatar answered Nov 09 '22 23:11

R4PH43L