Python的tkinter和tkinter.messagebox应用-鼠标和键盘命令绑定
__author__ = 'Administrator'
from tkinter import *
import tkinter.messagebox class MainWindow: def buttonListener1(self,event):
tkinter.messagebox.showinfo("messagebox","this is button 1 dialog")
def buttonListener2(self,event):
tkinter.messagebox.showinfo("messagebox","this is button 2 dialog")
def buttonListener3(self,event):
tkinter.messagebox.showinfo("messagebox","this is button 3 dialog")
def buttonListener4(self,event):
tkinter.messagebox.showinfo("messagebox","this is button 4 dialog") def __init__(self):
self.frame = Tk() self.button1 = Button(self.frame,text = "button1",width = 10,height = 5)
self.button2 = Button(self.frame,text = "button2",width = 10,height = 5)
self.button3 = Button(self.frame,text = "button3",width = 10,height = 5)
self.button4 = Button(self.frame,text = "button4",width = 10,height = 5) self.button1.grid(row = 0,column = 0,padx = 5,pady = 5)
self.button2.grid(row = 0,column = 1,padx = 5,pady = 5)
self.button3.grid(row = 1,column = 0,padx = 5,pady = 5)
self.button4.grid(row = 1,column = 1,padx = 5,pady = 5) #bind代替command命令
self.button1.bind("<Enter>",self.buttonListener1)#绑定回车
self.button2.bind("<ButtonRelease-1>",self.buttonListener2)#绑定鼠标左键释放
self.button3.bind("<Button-1>",self.buttonListener3)#绑定鼠标左键按下
self.button4.bind("<ButtonRelease-1>",self.buttonListener4) self.frame.mainloop() window = MainWindow()
程序退出命令的应用
__author__ = 'Administrator'
from tkinter import *
root = Tk()
root.title("顶层窗口")
Button(root,text ="顶层窗口")
Button(root,text ="禁用",state = DISABLED).pack(side = LEFT)
Button(root,text = "确定").pack(side = LEFT)
Button(root,text = "退出",command=root.quit).pack(side = RIGHT) root.mainloop()
Python的tkinter和tkinter.messagebox应用-鼠标和键盘命令绑定的更多相关文章
- Python+Selenium笔记(十四)鼠标与键盘事件
(一) 前言 Webdriver高级应用的API,允许我们模拟简单到复杂的键盘和鼠标事件,如拖拽操作.快捷键组合.长按以及鼠标右键操作,都是通过使用webdriver的Python API 中的Ac ...
- Python:GUI库tkinter(一)
学习自: Python GUI 编程(Tkinter) | 菜鸟教程 TkDocs_官方文档 1.几个常用的Python GUI库 tkinter:Python的标准Tk GUI工具包的接口. wxP ...
- python--DenyHttp项目(1)--GUI:tkinter☞ module 'tkinter' has no attribute 'messagebox'
AttributeError: module 'tkinter' has no attribute 'messagebox' improt tkinter from tkinter import * ...
- python之GUI编程-tkinter学习
推荐几个学习网址:https://www.cnblogs.com/shwee/p/9427975.html https://cloud.tencent.com/developer/section/13 ...
- Python基础之用tkinter写界面
参考链接:https://blog.csdn.net/qq_37482202/article/details/84201259 Tkinter介绍 Tkinter(也叫Tk接口)是Tk图形用户界面工具 ...
- Python:GUI库tkinter(三)
这一章是对前两章的总结: Python:GUI库tkinter(一) Python:GUI库tkinter(二) 前两章是对控件的介绍,第一章可以知道各控件使用时的具体参数,第二章以具体的例子展示了每 ...
- python学习笔记(Tkinter编程利用Treeview实现表格自动更新)
博主今天总结这段时间抽空写的一个GUI编程项目 功能是查看本地打印机队列,可选择指定队列重新打印 直接上图 UI设计包括3个区域左上方,右上方和下方列表区域 使用网格grid方法来分配位置 下面是界面 ...
- tkinter中鼠标与键盘事件(十五)
鼠标与键盘事件 import tkinter wuya = tkinter.Tk() wuya.title("wuya") wuya.geometry("300x200+ ...
- Python在线聊天软件(Tkinter)
1.python2.7下安装 apt-get install python-tk 主要功能是实现客户端与服务器端的双向通信,这个小东西用到的主要知识点: 1.Python Socket:2.Pytho ...
随机推荐
- vs2010中socket链接错误LINK2019
解决方法参考下面链接: http://blog.163.com/strive_only/blog/static/893801682009225112354746/
- 显示查询记录的前n条 mysql limit用法
按时间倒序出所有的数据 mysql order by createtime desc ; +----+------------------+ | id | id_no | +----+-------- ...
- JOSN的stringify()和parse()方法
JOSN的stringify()和parse()方法使用,stringify()把对象序列化,parse()把JSON字符串解析为js对象 <script> var book = { ti ...
- JuPyter(IPython) Notebook中通过pip安装第三方Python Module
JuPyter(IPython) Notebooks中使用pip安装Python的模块 刚开始接触JuPyter Notebook的时候觉得这是个不错的写技术博客的工具,可以很直观的把代码和结果结合在 ...
- 异常处理与调试 - 零基础入门学习Delphi50
异常处理与调试 让编程改变世界 Change the world by program 异常处理与调试 在应用程序开发中如何检测.处理程序的运行错误是一个很重要的问题. 有些错误是无法控制的. 如何处 ...
- sql server 表连接
本文主要列举两张和三张表来讲述多表连接查询. 新建两张表: 表1:student 截图如下: SQL多表连接查询(详细实例)_新客网 表2:course 截图如下: SQL多表连接查询(详细实例)_新 ...
- 利用raspberry pi搭建typecho笔记(三) typecho nginx sqlite FAQ
前言 这是一个汇总文,用来总结我在整个配置过程中遇到的各种问题.因为我在解决这些问题的过程中发现,typecho被部署在这种需要完全自己配置的平台上的情况是比较少的,相关的资料也比较少,所以我的解决过 ...
- [WPF]ListView点击列头排序功能实现
[转] [WPF]ListView点击列头排序功能实现 这是一个非常常见的功能,要求也很简单,在Column Header上显示一个小三角表示表示现在是在哪个Header上的正序还是倒序就可以了. ...
- 【Xamarin挖墙脚系列:代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧(转)】
正愁如何选择构建项目中的视图呢,现在官方推荐画板 Storybord...但是好像 xib貌似更胜一筹.以前的老棒子总喜欢装吊,用代码写....用代码堆一个HTML页面不知道你们尝试过没有.等页面做出 ...
- (?m)使用实例
示例sql: # User@Host: zjzc_app[zjzc_app] @ [10.22.18.164] Id: 6069153 # Query_time: 153.908486 Lock_ti ...