python界面设计模块_Python中Tk模块简单窗口设计

import tkinter #导入TKinter模块

from tkinter importStringVarfrom tkinter import *

from PIL importImageTk, Image

ytm= tkinter.Tk() #创建Tk对象

ytm.title("test_tool") #设置窗口标题

ytm.geometry("400x300") #设置窗口尺寸

canvas = tkinter.Canvas(ytm, width=400, height=400, bd=0, highlightthickness=0)

imgpath= './p1.jpg'img=Image.open(imgpath)

photo=ImageTk.PhotoImage(img)

canvas.create_image(200, 150, image=photo)

canvas.pack()#entry = tkinter.Entry(ytm, insertbackground='red', highlightthickness=2)#entry.pack()

ytm.resizable(False,False)#不允许改变窗口大小

l1 = tkinter.Label(ytm, text="欢")#标签

l1.place(x=40,y=20)#l1.pack() # 指定包管理器放置组件

user_text1 = tkinter.Entry() #创建文本框

user_text1.place(x=80,y=20)

l2= tkinter.Label(ytm, text="迎") #标签#l2.pack()

l2.place(x=40,y=60)

user_text2= tkinter.Entry() #创建文本框#user_text2.pack()

user_text2.place(x=80,y=60)

l3= tkinter.Label(ytm, text="来") #标签#l3.pack()

l3.place(x=40,y=100)

user_text3= tkinter.Entry() #创建文本框

user_text3.place(x=80,y=100)

l4= tkinter.Label(ytm, text="到") #标签

l4.place(x=40,y=140)

filename=StringVar()

filename02=StringVar()

filename03=StringVar()

user_text4= tkinter.Entry(ytm, textvariable = filename) #创建文本框

user_text4.place(x=80,y=140)

l5= tkinter.Label(ytm, text="这") #标签

l5.place(x=40,y=180)

user_text5= tkinter.Entry(ytm, textvariable = filename02) #创建文本框

user_text5.place(x=80,y=180)

l6= tkinter.Label(ytm, text="里") #标签

l6.place(x=40,y=220)

user_text6= tkinter.Entry(ytm, textvariable = filename03) #创建文本框

user_text6.place(x=80,y=220)

ytm.mainloop()

你可能感兴趣的:(python界面设计模块)