Python 窗体(tkinter)按钮 位置实例

yipeiwu_com6年前Python基础

如下所示:

import tkinter
 
def go(): #函数
  print("go函数")
 
win=tkinter.Tk() #构造窗体
win.title("hello zhaolin")#标题
win.geometry("800x800+300+0")#800宽度,800高度,x,y坐标,左上角
button=tkinter.Button(win,text="有种点我",command=go) #收到消息执行go函数
button.pack()#加载到窗体,
button1=tkinter.Button(win,text="有种点",command= lambda :print("hello world"),width=20,height=10) 
button1.pack()#加载到窗体,
#button.place(10,10)
win.mainloop() #进入消息循环机制
 
 

以上这篇Python 窗体(tkinter)按钮 位置实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python中使用PyQt把网页转换成PDF操作代码实例

代码很简单,功能也很简单 =w= webpage2pdf #!/usr/bin/env python3 import sys try: from PyQt4 import...

浅谈插入排序算法在Python程序中的实现及简单改进

Python实现插入排序的一般范例为: #coding=cp936 #coding=cp936 #插入排序算法 def InsertionSort(A): for j in r...

Python中执行存储过程及获取存储过程返回值的方法

本文实例讲述了Python中执行存储过程及获取存储过程返回值的方法。分享给大家供大家参考,具体如下: 在Pathon中如何执行存储过程呢?可以使用如下方法: 存储过程定义基本如下:...

Pytorch保存模型用于测试和用于继续训练的区别详解

保存模型 保存模型仅仅是为了测试的时候,只需要 torch.save(model.state_dict, path) path 为保存的路径 但是有时候模型及数据太多,难以一次性训...

两个命令把 Vim 打造成 Python IDE的方法

两个命令把 Vim 打造成 Python IDE的方法

运行下面两个命令,即可把 Vim(含插件)配置成 Python IDE。目前支持 MAC 和 Ubuntu。 curl -O https://raw.githubuserconten...