如何将 theme/style 添加到 GUIZERO python3 包

How to add theme/style to GUIZERO python3 package

所以我正在尝试构建一个小应用程序,我真的很喜欢 Guizero 包,它很简单,是事件驱动的编程。

它似乎唯一缺少的是实现主题更改的方法,因此目前看起来确实过时了。有没有办法应用 Tkinter 包之类的?

下面是我试过的一些代码,它甚至可以正确打印 'vista',但它似乎没有实现实际的主题更改。

from tkinter import *
from guizero import *
import tkinter.ttk as ttk

app = App(title="Application Name", layout="grid", height=200, width=600)  # Random app name
app.tk.iconbitmap("someicon.ico")  # I got this to work

s=ttk.Style()

#app.ttk.Style().theme_use('default')

print(s.theme_names())  # loads themes
print(s.theme_use())  # shows potential theme names ('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')

s.theme_use('vista')
print(s.theme_use())  # prints 'vista'

app.style = s

print(app.style.theme_use()) # prints 'vista'

app.display()

这不是 ttk,但您仍然可以设置您想要的样式。

from guizero import *

app = App()
#app.icon="images/Icon.ico"
#Changes in version 1.2.0
#https://lawsie.github.io/guizero/changelog/



#.icon does not work on Window()
#you will need to use WindowsName.tk.iconbitmap("Icon.ico")
#when creating a second window or more 

def do_nothing():
    print("Button was pressed")
    
#tkinter  widget Properties
#https://www.tutorialspoint.com/python/python_gui_programming.htm        
def elementsName(Name):
    #example of Guizero property
    #Name.bg='green'
    #these are button widget properties 
    Name.tk.config(width=5,
                   height=1,
                   borderwidth=0,
                   relief="groove",
                   activeforeground='darkgray',
                   activebackground='green',
                   highlightthickness=0,
                   #highlightcolor="blue",
                   bg='blue',
                   fg='orange'
                   )



button1 = PushButton(app,text='button', command=do_nothing)
button1.text_size=15
button2 = PushButton(app,text='button2', command=do_nothing)
button2.text_size=15

#do no use '' or "" inside this tuple.
buttonsNames=(button1,button2)


#works for group of elements doesn't
#work on single elements/widgets
for x in buttonsNames:
    elementsName(x)



#How to style just one elements/widget
'''
using tkinter config
WidgetsName.tk.config(property1,
                      property2,
                      property3,
                      )
                      
                      
                      
Using Guizero to list each property separately
WidgetsName.text_size=12
WidgetsName.text_color= 'gray'
'''

app.display()