问题描述
所以我想给我的tkinter应用一个主题。但是,我不确定如何将其实现为像标准tkinter一样的类。这是我的代码:
import tkinter as tk
from tkinter import ttk
from ttkthemes import ThemedTk
class Gui(tk.Tk): # where do I put ThemedTk
def __init__(self):
super().__init__()
self.title('TThack')
self.geometry('200x440')
self.type = tk.StringVar()
self.status_message = tk.StringVar()
self.coins_message = tk.StringVar()
self.school_label = tk.Label(text="School",justify="left")
self.school_entry = tk.Entry()
self.username_label = tk.Label(text="Username")
self.username_entry = tk.Entry()
self.password_label = tk.Label(text="Password")
self.password_entry = tk.Entry()
self.rounds_label = tk.Label(text="Number Of Rounds")
self.rounds_entry = tk.Entry()
self.type_label = tk.Label(text="Game Mode")
self.name_entry = tk.Entry(self)
self.type_entry_one = tk.Radiobutton(text="Garage",value="garage",variable=self.type,command=self.disable_entry)
self.type_entry_two = tk.Radiobutton(text="Festival",value="festival",command=self.disable_entry)
self.type_entry_three = tk.Radiobutton(text="Studio",value="studio",command=self.disable_entry)
self.type_entry_five = tk.Radiobutton(text="Soundcheck",value="soundcheck",command=self.disable_entry)
self.type_entry_six = tk.Radiobutton(text="Arena",value="arena",command=self.disable_entry)
self.type_entry_four = tk.Radiobutton(text="Rockslam",value="rockslam",command=self.enable_entry)
self.type.set('garage')
self.submit = tk.Button(text="Start Hack",command=self.send_values)
self.end = tk.Button(text="End Hack",command=bot.end)
self.coins = tk.Label(textvariable=self.coins_message)
self.coins_message.set('Coins Earned So Far: 0')
self.status = tk.Label(textvariable=self.status_message)
self.status_message.set('Waiting...')
self.school_label.pack(anchor="w")
self.school_entry.pack(anchor="w")
self.username_label.pack(anchor="w")
self.username_entry.pack(anchor="w")
self.password_label.pack(anchor="w")
self.password_entry.pack(anchor="w")
self.rounds_label.pack(anchor="w")
self.rounds_entry.pack(anchor="w")
self.type_label.pack(anchor="w")
self.type_entry_one.pack(anchor="w")
self.type_entry_two.pack(anchor="w")
self.type_entry_three.pack(anchor="w")
self.type_entry_five.pack(anchor="w")
self.type_entry_six.pack(anchor="w")
self.type_entry_four.pack(anchor="w")
self.submit.pack(anchor="w")
self.end.pack(anchor="w")
self.coins.pack(anchor="w")
self.status.pack(anchor="w")
#there are more functions below,however I won't show them just to make this shorter.
from tkinter import ttk # normal Tkinter.* widgets are not themed!
from ttkthemes import ThemedTk
window = ThemedTk(theme="arc")
ttk.Button(window,text="Quit",command=window.destroy).pack()
window.mainloop()
那么我将如何在课堂上做到这一点?甚至有可能吗?
编辑:this post对我没有帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)