例1:创建按钮

import tkinter as tk
class App:
def __init__(self,root):
frame = tk.Frame(root)
frame.pack()
self.hi_there = tk.Button(frame,text='hello',fg='blue',\
command=self.say_hi)
self.hi_there.pack(side=tk.LEFT)
def say_hi(self):
print("大家好") root = tk.Tk()
app = App(root)
root.mainloop()

例2:

 1 import tkinter as tk
2
3 T = [1,2,3]
4 class App:
5 def __init__(self,root):
6 frame = tk.Frame(root)
7 frame.pack()
8 self.hi_there = tk.Button(frame,text='hello',fg='blue',command=lambda:self.say_hi(T))
9 self.hi_there.pack(side=tk.LEFT)
10 def say_hi(self,t):
11 t.append(4)
12 print(t)
13
14 root = tk.Tk()
15 app = App(root)
16 root.mainloop()

参考:

https://www.cnblogs.com/shwee/p/9427975.html

https://blog.csdn.net/vevenlcf/article/details/82226531

http://www.17python.com/blog/23

https://blog.csdn.net/ahilll/article/details/81531587

https://www.zhihu.com/question/30665278

[Python] Tkinter command的更多相关文章

  1. Python Tkinter基础控件入门实例

    分享一个Python Tkinter基础控件用法的入门例子,包括窗口的显示.显示内置图片.弹出窗口.菜单等. 例子,Python Tkinter基础控件的用法 # -*- coding: utf-8 ...

  2. Python Tkinter 学习成果:点歌软件music

    笔者工作业余时间也没什么爱好,社交圈子也小,主要娱乐就是背着自己带电瓶的卖唱音响到住地附近找个人多的位置唱唱KtV. 硬件上点歌就用笔记本电脑,歌曲都是网上下载的mkv格式的含有两个音轨的视频.因此点 ...

  3. Python Tkinter Entry(文本框)

    Python学习记录--关于Tkinter Entry(文本框)的选项.方法说明,以及一些示例. 属性(Options) background(bg) borderwidth(bd) cursor e ...

  4. python tkinter Listbox用法

    python tkinter组件的Listbox的用法,见下面代码的演示: from tkinter import * root=Tk() v=StringVar() #Listbox与变量绑定' l ...

  5. python Tkinter之Button

    Button小部件是一个标准的Tkinter的部件,用于实现各种按钮.按钮可以包含文本或图像,您可以调用Python函数或方法用于每个按钮. Tkinter的按钮被按下时,会自动调用该函数或方法. 该 ...

  6. python gui tkinter快速入门教程 | python tkinter tutorial

    本文首发于个人博客https://kezunlin.me/post/d5c57f56/,欢迎阅读最新内容! python tkinter tutorial Guide main ui messageb ...

  7. Python tkinter模块弹出窗口及传值回到主窗口操作详解

    这篇文章主要介绍了Python tkinter模块弹出窗口及传值回到主窗口操作,结合实例形式分析了Python使用tkinter模块实现的弹出窗口及参数传递相关操作技巧,需要的朋友可以参考下 本文实例 ...

  8. Python tkinter 实现简单登陆注册 基于B/S三层体系结构,实现用户身份验证

    Python tkinter 实现简单登陆注册 最终效果 开始界面 ​ 注册 登陆 ​ 源码 login.py # encoding=utf-8 from tkinter import * from ...

  9. Python Tkinter 文本框(Entry)

    Python Tkinter 文本框用来让用户输入一行文本字符串. 你如果需要输入多行文本,可以使用 Text 组件. 你如果需要显示一行或多行文本且不允许用户修改,你可以使用 Label 组件. 语 ...

随机推荐

  1. 「Leetcode-算法_MId1006」从单栈到双栈

    Mid 1006 笨阶乘 栈/后缀 运算优化 + 栈 思路描述 每四个数一组 这四个数中前三个会进行乘.除 然后与最后一个相加 Stack 入前三个之和 与 最后一个数 以 4 举例 运算式 4 * ...

  2. 使用sysbench测试mysql及postgresql(完整版)

    使用sysbench测试mysql及postgresql(完整版) 转载请注明出处https://www.cnblogs.com/funnyzpc/p/14592166.html 前言 使用sysbe ...

  3. Filebeat配置文件解析-转载

    转载地址:https://dongbo0737.github.io/2017/06/13/filebeat-config/ Filebeat配置文件解析 filebeat 一个ELK架构中,专门用来收 ...

  4. ELK查询命令详解总结

    目录 ELK查询命令详解 倒排索引 倒排索引原理 分词器介绍及内置分词器 使用ElasticSearch API 实现CRUD 批量获取文档 使用Bulk API 实现批量操作 版本控制 什么是Map ...

  5. B. 【例题2】雷达装置

    B . [ 例 题 2 ] 雷 达 装 置 B. [例题2]雷达装置 B.[例题2]雷达装置 题目解析 求最少所需的雷达数,考虑贪心算法. 以这张图为例.以一个城市为中心,作一个半径为 d d d的圆 ...

  6. Dynamics CRM分享记录后出现关联记录被共享的问题

    Dynamics CRM的权限配置有许多的问题,其中分享功能也是未来解决标准功能分配的权限不满足需求而设计的.但是这个功能使用的时候也要注意,否则会出现其他记录被共享的问题导致数据泄露可能会对项目的安 ...

  7. 深入学习spring cloud gateway 限流熔断

    前言 Spring Cloud Gateway 目前,Spring Cloud Gateway是仅次于Spring Cloud Netflix的第二个最受欢迎的Spring Cloud项目(就GitH ...

  8. Docker下MySQL的安装

    1 概述 本文讲述了如何利用Docker去安装MySQL,以及MySQL自定义配置文件的相关设置. 2 安装Docker 首先安装Docker并开启服务: systemctl start docker ...

  9. 005-Java中的控制语句

    目录 一.控制语句 一.作用 二.分类 二.选择语句(分支语句) 一.if 语句 二.switch语句 三.循环语句 一.for循环 二.while循环(while循环的循环次数是:0~n次) 三.d ...

  10. Compound Words UVA - 10391

      You are to find all the two-word compound words in a dictionary. A two-word compound word is a wor ...