# -*- coding: utf-8 -*-
from Tkinter import * def btn_click():
b2['text'] = 'clicked'
evalue = e.get()
print 'btn Click and Entry value is %s' % evalue def btn_click_bind(event):
print 'enter b2' def show_toplevel():
top = Toplevel()
top.title('2号窗体')
Label(top, text='这是2号窗体').pack() root = Tk()
root.title('1号窗体')
# 显示内置图片
# x = Label(root, bitmap='warning')
l = Label(root, fg='red', bg='blue',text='wangwei', width=34, height=10)
l.pack() # command 指定button调用的函数
b = Button(root, text='clickme', command=btn_click)
b['width'] = 10
b['height'] = 2
b.pack()
# 使用bind 方式关联button和函数
b2 = Button(root, text = 'clickme2')
b2.configure(width = 10, height = 2, state = 'disabled')
b2.bind("<Enter>", btn_click_bind)
b2.pack()
# 弹出Toplevel窗体
b3 = Button(root, text = 'showToplevel', command=show_toplevel)
b3.pack() # 输入框
e = Entry(root, text = 'input your name')
e.pack()
# password框
epwd = Entry(root, text = 'input your pwd', show = '*')
epwd.pack() # 菜单
def menu_click():
print 'I am menu' xmenu = Menu(root)
submenu = Menu(xmenu, tearoff = 0)
for item in ['java', 'cpp', 'c', 'php']:
xmenu.add_command(label = item, command = menu_click) for item in ['think in java', 'java web', 'android']:
submenu.add_command(label = item, command = menu_click)
xmenu.add_cascade(label = 'progame', menu = submenu) # 弹出菜单
def pop(event):
submenu.post(event.x_root, event.y_root) # 获取鼠标左键点击的坐标
def get_clickpoint(event):
print event.x, event.y # frame
for x in ['red', 'blue', 'yellow']:
Frame(height = 20, width = 20, bg = x).pack() root['menu'] = xmenu
root.bind('<Button-3>', pop)
root.bind('<Button-1>', get_clickpoint)
root.mainloop()

Python Tkinter 基础控件学习的更多相关文章

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

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

  2. Python Tkinter Text控件

    原文地址: http://blog.csdn.net/bemorequiet/article/details/54743889 这篇博客主要是简单的说一下Tkinter中的Text控件的相关知识. T ...

  3. [Python] wxPython 菜单栏控件学习总结(原创)

    1.总结 1.大体创建过程 1.创建一个 菜单栏  : menuBar = wx.MenuBar() 相当于这个白色地方,没有File这个菜单 2.创建 菜单 : fileMenu = wx.Menu ...

  4. iOS界面设计之基础控件的学习 --- UITextField

    学习iOS界面设计也有段时间了,每次写到一些基础控件(如:UILable . UITextField)的时候就深觉应该总结一个函数来实现这些基础控件的属性设置,所以下面就是我对UITextField的 ...

  5. React Native环境搭建以及几个基础控件的使用

    之前写了几篇博客,但是没有从最基础的开始写,现在想了想感觉不太合适,所以现在把基础的一些东西给补上,也算是我从零开始学习RN的经验吧! 一.环境搭建 首先声明一下,本人现在用的编辑器是SublimeT ...

  6. MFC 之ActiveX控件学习

    本文将介绍ActiveX控件的应用与工作原理,读者可以把ActiveX控件看成一个极小服务器的应用程序,它不能独立运行,必须要嵌入到容器程序中与容器一起运行,就像电脑主机中的显卡,它自己在电脑硬件系统 ...

  7. Cocos2d-JS项目之二:studio基础控件的使用

    在studio里把几个基础控件往场景文件一拖,然后导出json格式的资源文件 逻辑代码如下: var HelloWorldLayer = cc.Layer.extend({ sprite:null, ...

  8. [iOS基础控件 - 5.5] 代理设计模式 (基于”APP列表"练习)

    A.概述      在"[iOS基础控件 - 4.4] APP列表 进一步封装,初见MVC模式”上进一步改进,给“下载”按钮加上效果.功能      1.按钮点击后,显示为“已下载”,并且不 ...

  9. IOS学习笔记(四)之UITextField和UITextView控件学习

    IOS学习笔记(四)之UITextField和UITextView控件学习(博客地址:http://blog.csdn.net/developer_jiangqq) Author:hmjiangqq ...

随机推荐

  1. shiro + maven 的web配置(不整合spring)

    本文采用的是1.4.0版本的shiro 官方中说的1.2之前,和之后的shiro配置分别为: 1.2之前: <filter> <filter-name>iniShiroFilt ...

  2. UVA 11404 Palindromic Subsequence

    Palindromic Subsequence Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA ...

  3. ZOJ 3640

    很简单的概率题了 设dp[x]为能力值 为x时出去的期望 天数 #include <iostream> #include <cstdio> #include <cmath ...

  4. C++实现页码数字统计

    #include<iostream> #include<iomanip> #include<cstdlib> #include<ctime> #incl ...

  5. IIS身份验证的配置

    前4者配置:localhost applicationHost.config <location path=""> 后2者配置:web.config 要点: 这6项尽管 ...

  6. C/S和B/S交互

    近期一直在做C/S的项目,每天都超忙,抽个时间写篇博客,之前一直做C/S项目就是各种窗口.各种控件,拖来拖去,然后点进去写方法,做BS的时候呢,由于一直使用的是mvc,所以就是常常手写代码.或者拖引用 ...

  7. 智课雅思词汇---十二、vent是什么意思

    智课雅思词汇---十二.vent是什么意思 一.总结 一句话总结:词根:ven, vent = come, 表示“来” 词根:vent = wind 风 1.tact是什么意思? 词根:-tact-, ...

  8. .Net垃圾回收和大对象处理

    本文引自:http://www.cnblogs.com/yukaizhao/archive/2011/11/21/dot_net_gc_large_object_heap.html CLR垃圾回收器根 ...

  9. bower 代理

    bower 设置: 修改 .bowerrc 文件(如无则新增): { "proxy": "http://proxy.mysite.com:8080", &quo ...

  10. swift中高阶函数map、flatMap、filter、reduce

    Swift相比于Objective-C又一个重要的优点,它对函数式编程提供了很好的支持,Swift提供了map.filter.reduce这三个高阶函数作为对容器的支持. 1 map:可以对数组中的每 ...