font=("Arial", 14, "bold"))修改為藍色字體
时间: 2023-07-02 17:10:38 浏览: 54
可以使用如下代码将字体颜色修改为蓝色:
```python
from tkinter import *
root = Tk()
label = Label(root, text="Hello World!", font=("Arial", 14, "bold"), fg="blue")
label.pack()
root.mainloop()
```
其中,fg参数用于设置字体颜色,将其设置为blue即可。
相关问题
self.textbox.tag_configure("center", justify="center", font=("Arial", 14, "bold"))將這句代碼中添加設置為藍色字體
你可以使用下面的代码将字体设置为蓝色:
```
self.textbox.tag_configure("center", justify="center", font=("Arial", 14, "bold"), foreground="blue")
```
其中`foreground`参数用于设置字体颜色,这里设置为蓝色。你也可以根据需要更改颜色值。
button = tk.Button(self.panel_left, text=sheet_name, command=lambda name=sheet_name: self.show_sheet(name), bg='#D3D3D3', fg='white', font=('Arial', 10, 'bold')) 修改字體為藍色
您可以将`fg`属性设置为蓝色,例如`fg='blue'`,这将使按钮的字体颜色变为蓝色。下面是示例代码:
```
for i, sheet_name in enumerate(self.sheet_names):
button = tk.Button(self.panel_left, text=sheet_name, command=lambda name=sheet_name: self.show_sheet(name), bg='#D3D3D3', fg='blue', font=('Arial', 10, 'bold'))
button.used = False
button.grid(row=i, column=0, sticky="ew", padx=2, pady=2)
button.bind("<Enter>", lambda event, button=button: button.config(relief="sunken"))
button.bind("<Leave>", lambda event, button=button: button.config(relief="raised"))
button.bind("<Button-1>", lambda event, button=button: mark_used(button))
```
在这段代码中,我们将按钮的`fg`属性设置为蓝色,这是蓝色的十六进制表示。这样就可以将按钮的字体颜色设置为蓝色了。
相关推荐
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)