from Tkinter import *
root=Tk()
root.title('我是root窗口!')
L=Label(root,text='我属于root')
L.pack() f=Toplevel(root,width=30,height=20)
f.title('我是toplevel')
Lf=Label(f,text='我是toplevel')
Lf.pack() root.mainloop() ==============================
from Tkinter import *
time1=0
time2=0
def xin1():
global t,c1,time1
if time1%2==0:
time1+=1
t['text']='西瓜被选中'
else:
time1+=1
t['text']='西瓜被取消'
def xin2():
global t,c2,time2
if time2%2==0:
time2+=1
t['text']='芒果被选中'
else:
time2+=1
t['text']='芒果被取消'
root=Tk()
c1=Checkbutton(root,text='西瓜',command=xin1)
c1.pack()
c2=Checkbutton(root,text='芒果',command=xin2)
c2.pack()
t=Label(root,text='')
t.pack()
root.mainloop()
================================
 import Tkinter  as tk

 def get_screen_size(window):
return window.winfo_screenwidth(),window.winfo_screenheight() def get_window_size(window):
return window.winfo_reqwidth(),window.winfo_reqheight() def center_window(root, width, height):
screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
size = '%dx%d+%d+%d' % (width, height, (screenwidth - width)/2, (screenheight - height)/2)
print(size)
root.geometry(size) root = tk.Tk()
root.title('测试窗口')
center_window(root, 300, 240)
root.maxsize(600, 400)
root.minsize(300, 240)
Tkinter.Label(root, relief = tk.FLAT, text = '屏幕大小(%sx%s)\n窗口大小(%sx%s)' % (get_screen_size(root) + get_window_size(root))).pack(expand = tk.YES)
tk.mainloop()

 

===========================

from Tkinter import *

class CanvasDemo:
def __init__(self):
window = Tk()
window.title("CanvasDemo") self.canvas = Canvas(window, width = 200, height = 100, bg = "White")
self.canvas.pack() frame = Frame(window)
frame.pack() btRectangle = Button(frame, text = "长方形", command = self.displayRect)
btOval = Button(frame, text="椭 圆", command=self.displayOval)
btArc = Button(frame, text = "圆 弧", command = self.displayArc)
btPolygon = Button(frame, text="多边形", command=self.displayPolygon)
btLine = Button(frame, text=" 线 ", command=self.displayLine)
btString = Button(frame, text="文 字", command=self.displayString)
btClear = Button(frame, text="清 空", command=self.clearCanvas) btRectangle.grid(row = 1, column = 1)
btOval.grid(row=1, column=2)
btArc.grid(row=1, column=3)
btPolygon.grid(row=1, column=4)
btLine.grid(row=1, column=5)
btString.grid(row=1, column=6)
btClear.grid(row=1, column=7) window.mainloop() def displayRect(self):
self.canvas.create_rectangle(10, 10, 190, 90, tags = "rect")
def displayOval(self):
self.canvas.create_oval(10, 10, 190, 90, tags = "oval", fill = "red")
def displayArc(self):
self.canvas.create_arc(10, 10, 190, 90, start = -90, extent = 90, width = 5, fill = "red", tags = "arc")
def displayPolygon(self):
self.canvas.create_polygon(10, 10, 190, 90, 30, 50, tags = "polygon")
def displayLine(self):
self.canvas.create_line(10, 10, 190, 90, fill = 'red', tags = "line")
self.canvas.create_line(10, 90, 190, 10, width = 9, arrow = "last", activefill = "blue", tags = "line")
def displayString(self):
self.canvas.create_text(60, 40, text = "Hi,i am a string", font = "Tine 10 bold underline", tags = "string")
def clearCanvas(self):
self.canvas.delete("rect", "oval", "arc", "polygon", "line", "string") CanvasDemo()

  

import Tkinter as tk      #引入Tkinter模块
window = tk.Tk() def checkPassword(): #密码接收与检验
password = "Pass"
enteredPassword = passwordEntry.get()
if password == enteredPassword:
confirmLabel.config(text="Correct")
else:
confirmLabel.config(text="Incorrrect") passwordLabel = tk.Label(window,text="Password:") #创建密码标签控件与密码输入框
passwordEntry = tk.Entry(window,show="*") button = tk.Button(window,text="Enter",command=checkPassword) #添加按钮
confirmLabel = tk.Label(window)
#控件布局
passwordLabel.pack()
passwordEntry.pack()
button.pack()
confirmLabel.pack() window.mainloop()

python window窗口的更多相关文章

  1. python 利用tkinter模块设计出window窗口(搞笑版)

    代码如下 from tkinter import * import tkinter from tkinter import messagebox #定义了一个函数,当关闭window窗口时将会弹出一个 ...

  2. Python初学——窗口视窗Tkinter

    此篇文章是跟着沫凡小哥的视频学习的,附上学习网址:https://morvanzhou.github.io/tutorials/python-basic/ 什么是 tkinter 窗口1.1 什么是 ...

  3. Python之窗口操作之find_window,set_foreground等

    在自动化测试过程中,常常需要模拟按键的操作,比如像窗口发送一个按键,实现鼠标点击的功能,在上一篇文章中,我和大家讨论了python文件生成为不依赖与python库的exe文件的方式(需要了解的朋友戳这 ...

  4. python 前置程序窗口,还原最小化的窗口

    python 前置程序窗口,还原最小化的窗口 在网上找了比较久,大多是: win32gui.FindWindow(class_name, window_name) win32gui.SetForegr ...

  5. [转载]ExtJs4 笔记(9) Ext.Panel 面板控件、 Ext.window.Window 窗口控件、 Ext.container.Viewport 布局控件

    作者:李盼(Lipan)出处:[Lipan] (http://www.cnblogs.com/lipan/)版权声明:本文的版权归作者与博客园共有.转载时须注明本文的详细链接,否则作者将保留追究其法律 ...

  6. JavaScript:window窗口对象

    在JavaScript中,window表示的就是一个窗口对象.所以在整个处理过程之中,所有的操作都是以弹框为主 的.范例1:使用警告框 <script type="text/javas ...

  7. (转载)JavaScript中的Window窗口对象

    (转载)http://www.ijavascript.cn/jiaocheng/javascript-window-65.html 例子: <html> <head> < ...

  8. ExtJs4 笔记(9) Ext.Panel 面板控件、 Ext.window.Window 窗口控件、 Ext.container.Viewport 布局控件

    本篇讲解三个容器类控件. 一.面板控件 Ext.Panel 一个面板控件包括几个部分,有标题栏.工具栏.正文.按钮区.标题栏位于最上面,工具栏可以在四个位置放置,围绕中间部分正文,按钮区位于最小方.下 ...

  9. easyUi弹出window窗口传值与调用父页面的方法,子页面给父页面赋值

    <!-- 父页面 --> <!DOCTYPE html PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN" "ht ...

随机推荐

  1. [JAVASCRIPT][EXTJS]直接用JSON创建树形控件(Ext.tree.TreePanel )(转)

    直接用JSON创建树形控件(Ext.tree.TreePanel ) 1.创建多个根节点的树形 2.直接使用JsonList创建树形 <!DOCTYPE HTML PUBLIC "-/ ...

  2. web中cookie和session_转

    转自:Python爬虫番外篇之Cookie和Session  python修行路 关于cookie和session估计很多程序员面试的时候都会被问到,这两个概念在写web以及爬虫中都会涉及,并且两者可 ...

  3. sqoop 导入增量数据到hive

    版本 hive:apache-hive-2.1.0 sqoop:sqoop-1.4.6 hadoop:hadoop-2.7.3 导入方式 1.append方式 2.lastmodified方式,必须要 ...

  4. 2013.6.21 - OpenNER第一天

    下午去实验室继续写实验报告,跟伟杰要了一个实验报告,然后大师兄叫我,我们在走廊唠了一会儿. 大 师兄想做Open NE,他说这个会比较难,目前没有人做,因为还没有发现相关的文章,大家研究的都是指定了哪 ...

  5. 【转】java.io.Closeable接口

    说到java.io.Closeable接口就避不开java.lang.AutoCloseable接口,因为在java版本7.0时引入了java.lang.AutoCloseable接口,同时java. ...

  6. nginx 配置文件详解(转)

    #运行用户 #user nobody; #启动进程,通常设置成和cpu的数量相等或者2倍于cpu的个数(具体结合cpu和内存).默认为1 worker_processes 1; #全局的错误日志和日志 ...

  7. UVA816 Abbott's Revenge (三元组BFS)

    题目描述: 输入输出: 输入样例: SAMPLE 3 1 N 3 3 1 1 WL NR * 1 2 WLF NR ER * 1 3 NL ER * 2 1 SL WR NF * 2 2 SL WF ...

  8. 手写Java的字符串简单匹配方法IndexOf()

    简单的字符串模式匹配算法,可使用KMP进行优化 /** * @param s1 母串 * @param s2 子串 * @return */ public static int myIndexOf(S ...

  9. 为什么将项目托管到Apache,浏览器输入http://127.0.0.1会跳转到http://127.0.0.1//dashboard/?

    找到xampp安装的根目录下htdocs文件夹下的index.php文件 <?php if (!empty($_SERVER['HTTPS']) && ('on' == $_SE ...

  10. 评估预测函数(3)---Model selection(选择多项式的次数) and Train/validation/test sets

    假设我们现在想要知道what degree of polynomial to fit to a data set 或者 应该选择什么features 或者 如何选择regularization par ...