天天看点

python tkinter text改变文本字体颜色_Python3 tkinter基础 Button text,fg 按钮上显示的文字 文字的颜色...

?

python : 3.7.0

OS : Ubuntu 18.04.1 LTS

IDE : PyCharm 2018.2.4

conda : 4.5.11

type setting : Markdown

?

code

"""

@Author : 行初心

@Date : 18-10-1

@Blog : www.cnblogs.com/xingchuxin

@GitHub : github.com/GratefulHeartCoder

"""

import tkinter as tk

# 面向对象的编程思想

class APP:

def __init__(self, master):

self.frame = tk.Frame(master)

self.frame.pack()

# 新建一个按钮 上面的显示:佛手柑 前景色(字体颜色):蓝色

self.hi_there = tk.Button(frame, text="佛手柑", fg="blue")

self.hi_there.pack()

def main():

root = tk.Tk()

app = APP(root)

root.mainloop()

if __name__ == ‘__main__‘:

main()

?

result

python tkinter text改变文本字体颜色_Python3 tkinter基础 Button text,fg 按钮上显示的文字 文字的颜色...

?

reference

[文档] https://docs.python.org/3/library/tkinter.html

?

resource

[文档] https://docs.python.org/3/

[规范] https://www.python.org/dev/peps/pep-0008/

[规范] https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules/

[源码] https://www.python.org/downloads/source/

[ PEP ] https://www.python.org/dev/peps/

[平台] https://www.cnblogs.com/

?

Python具有开源、跨平台、解释型和交互式等特性,值得学习。 Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。 GUI可以选择PyQt5、PySide2、wxPython、PyGObject、wxWidgets等进行创作。 代码的书写要遵守规范,这样有助于沟通和理解。 每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。