1
我試圖使用滾動條與我的項目。我有一個代碼,在一個框架內的一個畫布內創建一個框架,以便將標籤放到框架上,然後滾動。這是一些代碼:place_configure()失蹤1個人需要的位置參數:「自我」
statWindow = Tk()
statWindow.title("View Statistics")
statWindow.config(bg = "grey")
statWindow.geometry('600x700')
myframe =Frame(statWindow, relief=GROOVE, width=550, height=400, bd=1)
myframe.place(x=20, y=90)
canvas = Canvas(myframe)
frame = Frame(canvas)
myscrollbar = Scrollbar(myframe, orient="vertical", command=canvas.yview)
canvas.configure(width=530, height=400, yscrollcommand=myscrollbar.set)
myscrollbar.pack(side="right", fill="y")
canvas.pack(side="left")
canvas.create_window((0, 0), window=frame, anchor='nw')
frame.bind("<Configure>", myfunction)
def myfunction(event):
global canvas
canvas.configure(scrollregion=canvas.bbox("all"),width=530,height=400)
然後我有代碼:
Label(frame,text="hello", height=1, width=14, bg="white").grid(row=1, column=1)
這工作完全,但我真的需要使用.place() Allthough當我改變標籤代碼到:
Label(frame,text="hello", height=1, width=14, bg="white").place(x=10, y=10)
沒有任何反應,因爲在屏幕上沒有標籤,並且沒有錯誤發生。 然而,當我的代碼更改爲:
Label(frame,text="hello", height=1, width=14, bg="white")
Label.place(x=10, y=10)
我得到的錯誤:
TypeError: place_configure() missing 1 required positional argument: 'self'
爲什麼我不是一個標籤放置到機架,以及如何解決這個問題? 謝謝
他們不調用類'place'。他們在一個實例上調用它。 –
'Label.place(x = 10,y = 10)'這個確實看起來像是在一個類中調用它。這個標籤(frame,text =「hello」,height = 1,width = 14,bg =「white」)。place(x = 10,y = 10)'在另一方面調用它,這正在按預期工作。 – Fejs
好的,你是對的。我很抱歉。在一個地方,他們做錯了,在一個地方他們做對了。這回答標題中的問題。 –