天天看點

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等進行創作。 代碼的書寫要遵守規範,這樣有助于溝通和了解。 每種語言都有獨特的思想,初學者需要轉變思維、踏實踐行、堅持積累。