- 论坛徽章:
- 0
|
本帖最后由 whitelotus19 于 2014-12-11 20:41 编辑
这有个帖子,你看看是不是这样:
stackoverflow.com/questions/10158552/how-to-put-a-image-as-a-background-in-tkinter-in-python
随便瞄了两眼写了下:- #!/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()
复制代码 |
|