ttkbootstrap widget demo
时间: 2023-09-15 08:18:07 浏览: 147
Sure! Here's a demo of a ttkbootstrap widget:
```python
import tkinter as tk
from ttkbootstrap import Style
from ttkbootstrap.widgets import Button
# Create a new style instance
style = Style()
# Create a tkinter window
window = tk.Tk()
# Set the style for the window
style.theme_use('minty')
# Create a button widget using ttkbootstrap
button = Button(
window,
text="Click me!",
style="primary.Outline.TButton",
command=lambda: print("Button clicked!")
)
# Pack the button widget into the window
button.pack(padx=10, pady=10)
# Start the tkinter mainloop
window.mainloop()
```
This demo showcases the usage of the `Button` widget from `ttkbootstrap`. It creates a styled button with the label "Click me!" and binds a `print` statement to its `command` attribute. When the button is clicked, it will print "Button clicked!" to the console.
Make sure you have `ttkbootstrap` installed (`pip install ttkbootstrap`) before running this code.
阅读全文