2
我正在設置背景圖像,並在該圖像添加標籤,按鈕和所有。一切都來了,但不是背景圖像上,它是這樣的:如何使用Tkinter設置背景圖像到窗口python 2.7
而且我的代碼是:
from Tkinter import Tk, Frame, BOTH
import Tkinter
from PIL import Image, ImageTk
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("PISE")
self.pack(fill=BOTH, expand=1)
root = Tk()
root.geometry("1111x675+300+300")
app = Example(root)
im = Image.open('wood.png')
tkimage = ImageTk.PhotoImage(im)
Tkinter.Label(root,image = tkimage).pack()
custName = StringVar(None)
yourName = Entry(app, textvariable=custName)
yourName.pack()
relStatus = StringVar()
relStatus.set(None)
labelText = StringVar()
labelText.set('Accuracy Level')
label1 = Label(app, textvariable=labelText, height=2)
label1.pack()
radio1 = Radiobutton(app, text='100%', value='1', variable = relStatus, command=beenClicked1).pack()
radio2 = Radiobutton(app, text='50%', value='5', variable = relStatus, command=beenClicked5).pack()
root.mainloop()
如何正確適合的背景圖像?
在此先感謝!
我認爲你應該嘗試[地方](http://effbot.org/tkinterbook/place.htm),而不是包() – Gogo
檢查此:同樣的問題:http://stackoverflow.com/questions/10158552/如何把圖像作爲背景在python – sshashank124
@shaktimaan,它的工作,但只有背景正在顯示,並沒有其他小工具正在顯示 –