How to make my ttk widgets up to date?

I have a problem with tkinter.ttk on mac. I am using macports and python3.1. When I try to use tkinter.ttk, I get very old gui elements.

for example: I get this enter image description here
instead:
enter image description here

The code I use is:

from tkinter import *
from tkinter import ttk
root = Tk()
button = ttk.Button(root, text="Hello World").grid()
root.mainloop()

I would be happy to provide any information from my computer necessary to answer this question. Since I am a newbie programmer, tell me where to find the specified information.

I have a Macbook 5.2 with Snow Leopard. Any help would be appreciated. Thanks Marlene

Question update:
I installed tk @ 8.5.9_0 + quartz since schlenk only suggested getting this error:

TclMacOSXNotifierAddRunLoopMode: Tcl not built with CoreFoundation support Abort trap

https://trac.macports.org/ticket/22954. ( ):

$ cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/tcl
$ sudo patch < ~/Downloads/tcl.2.patch 
$ sudo port install tcl 

, :

Traceback (most recent call last):
  File "hello.py", line 5, in <module>
    root = Tk()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/tkinter/__init__.py", line 1632, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable tk.tcl in the following directories: 
    /opt/local/lib/tcl8.5/tk8.5 /opt/local/lib/tcl8.5/tk8.5/Resources/Scripts /opt/local/lib/tk8.5 /opt/local/lib/tk8.5/Resources/Scripts /opt/local/Library/Frameworks/Python.framework/Versions/3.1/Resources/Python.app/Contents/lib/tk8.5 /opt/local/Library/Frameworks/Python.framework/Versions/3.1/Resources/Python.app/Contents/lib/tk8.5/Resources/Scripts /opt/local/Library/Frameworks/Python.framework/Versions/3.1/Resources/Python.app/lib/tk8.5 /opt/local/Library/Frameworks/Python.framework/Versions/3.1/Resources/Python.app/Contents/library

/opt/local/lib/tk8.5/tk.tcl: version conflict for package "Tk": have 8.5.7, need exactly 8.5.9
version conflict for package "Tk": have 8.5.7, need exactly 8.5.9
    while executing
"package require -exact Tk  8.5.9"
    (file "/opt/local/lib/tk8.5/tk.tcl" line 20)
    invoked from within
"source /opt/local/lib/tk8.5/tk.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list source $file]"


This probably means that tk wasn't installed properly.
+3
3

macports. Tk, ttk. X11 Tk, Tk. 1. Tk X11. 2. Tk, Carbon 'windowingsystem -aqua' 3. Tk, Cocoa

, "" Tk macports, (, ActiveStates), .

, :

sudo port build tk @8.5.9+quartz

, : http://www.tkdocs.com/tutorial/install.html#installmac

+3

style = ttk.Style()
print(style.theme_names())
style.theme_use('default') # change 'default' to something better
+2

I have not played with ttk, however I have decent experience with tkinter. I believe you need to fill out the style keyword argument.

I think it will look something like this.

from tkinter import *
from tkinter import ttk
root = Tk()
button = ttk.Button(root, text="Hello World", style="somestyle").grid()
root.mainloop()

Link to some relevant documentation: http://docs.python.org/release/3.1.3/library/tkinter.ttk.html

-1
source

Source: https://habr.com/ru/post/1793764/


All Articles