码迷,mamicode.com
首页 > 编程语言 > 详细

python Tkinter 基础添加一个按钮,在按钮上显示文字,并设置文字颜色

时间:2018-01-24 21:59:34      阅读:2693      评论:0      收藏:0      [点我收藏+]

标签:text   python   roo   ima   tkinter   test   root   编程   理解   

code;

# Tkinter 基础添加一个按钮,在按钮上显示文字,并设置文字颜色

import tkinter as tk
# 面向对象编程
class App():
    def __init__(self, master):
        frame = tk.Frame(master)  # 框架??不是很理解
        frame.pack()
        # 创建一个按钮,fg前景色:蓝色
        self.testButton = tk.Button(frame, text = "hello", fg = "blue")
        self.testButton.pack()

root = tk.Tk()
app = App(root)
root.mainloop()

结果:

技术分享图片

 

python Tkinter 基础添加一个按钮,在按钮上显示文字,并设置文字颜色

标签:text   python   roo   ima   tkinter   test   root   编程   理解   

原文地址:https://www.cnblogs.com/wilson-wu/p/8343266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!