开发者

How to enable the use of the gui resources on mac

开发者 https://www.devze.com 2023-02-06 21:24 出处:网络
I am having 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 looking gui elements.

I am having 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 looking gui elements.

eg: I get this

How to enable the use of the gui resources on mac

Instead of this:

How to enable the use of the gui resources on mac

The code I used 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 needed to answer this question. As I am a novice programer please tell me where to find said information.

After a bit of digging I found this: Python 3.1.2 (r312:79147, Jan 16 2011, 08:02:01) [GCC 4.2.1 (Apple 开发者_如何学运维Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information.

->>> import tkinter.test.test_ttk.test_style

Traceback (most recent call last):

File "", line 1, in

File "/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/tkinter/test/test_ttk/test_style.py", line 8, in requires('gui') File "/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/test/support.py", line 215, in requires raise ResourceDenied(msg) test.support.ResourceDenied: Use of the gui' resource not enabled

->>> The error I have has something to do with the fact that "Use of thegui' resource is not enabled".

If two more people confirm that the code in blockquotes has nothing to do with the problem I will delete it from the question.

I have a Macbook 5,2 with Snow Leopard installed. Any help would be appreciated.

Thanks, Marlen


It's highly unlikely that this is related. You run the test from the Python command line, it needs to be enabled first, which is done by:

from test import support
support.use_resources = ['gui']

Then you can:

import tkinter.test.test_ttk.test_style

And see what it says (mine says nothing, but I'm on Ubuntu).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号