Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 未应用Tkinter样式_Python 3.x_Tkinter - Fatal编程技术网

Python 3.x 未应用Tkinter样式

Python 3.x 未应用Tkinter样式,python-3.x,tkinter,Python 3.x,Tkinter,我只是想换成“蛤蜊”风格,但什么都没变。我使用其他小部件编写了一个更为扩展的UI,因此我知道,当我尝试更改样式时,没有任何变化: 我在Linux Mint 19.2、Python 3.6.8和Pycharm中工作。我已经通过从终端运行来验证Pycharm不是问题所在 from tkinter import * from tkinter.ttk import Style class Window(Frame): def __init__(self, master=None):

我只是想换成“蛤蜊”风格,但什么都没变。我使用其他小部件编写了一个更为扩展的UI,因此我知道,当我尝试更改样式时,没有任何变化:

我在Linux Mint 19.2、Python 3.6.8和Pycharm中工作。我已经通过从终端运行来验证Pycharm不是问题所在

from tkinter import *
from tkinter.ttk import Style

class Window(Frame):

    def __init__(self, master=None):

        self.master = master
        self.add_widgets()



    def add_widgets(self, ):
        self.mainframe = Frame(self.master, border=3)
        self.mainframe.grid(columnspan=3, sticky='w', padx=5, pady=5)

        Label(self.mainframe, text="Directory Selection", font='Helvetica 12 bold italic underline').grid(column=0, sticky="w")
        self.pathframe = Frame(self.mainframe, relief=RIDGE, border=2)
        self.pathframe.grid(rowspan=3, columnspan=3, sticky='w', padx=0, pady=10)


        button_color="dark gray";

        Button(self.pathframe, text="Run Folder Path", bg=button_color).grid(sticky="w")
        Entry(self.pathframe, width=43).grid(row=0, column=1, sticky="w")



root = Tk()

style = Style()
style.theme_use("clam")


root.title('TestUI')
root.geometry("500x500")
app = Window(root)
root.mainloop()
我还尝试:

style = Style(root)
style.theme_use("clam")

仍然没有变化。

您没有使用任何ttk小部件。正常的tkinter小部件不受ttk样式的影响

通常,这是通过导入ttk,然后在小部件前面加上ttk来完成的

from tkinter import ttk
...
self.mainframe = ttk.Frame(self.master, border=3)
...