Tkinter 插入图片背景

Tkinter 插入图片背景

#!/usr/bin/python
# -*- coding: utf-8 -*-

from Tkinter import *
from PIL import ImageTk,Image

app = Tk()
app.title("Welcome")
image2 =Image.open(r'C:\Python27\tcl\tk8.5\demos\images\earth.gif')
background_image = ImageTk.PhotoImage(image2)
w = background_image.width()
h = background_image.height()
app.geometry('%dx%d+0+0' % (w,h))

background_label = Label(app, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)

for x in ('button1','button2','button3'):
    btn=Button(app,text=x)
    btn.pack()
    
app.mainloop()

转自: https://www.cnblogs.com/buchizaodian/p/7076964.html

你可能感兴趣的:(Python随笔)