0
내 최상위 메뉴 중 하나에서 목록 상자에 스크롤바를 연결하려고합니다. 그러나, 내 목록 상자에 연결하는 대신 자체를 최상위에 연결합니다. 나는 여기서 완전히 잃어 버렸다. 내가 뭘 잘못하고 있는지에 대한 아이디어가 있습니까? 누구나 필요하면 전체 프로그램 코드를 제공 할 수 있습니다. 목록 상자 및 스크롤 막대 :Tkinter 스크롤 막대에 문제가 있습니다.
def onNewRecipe(self):
self.top = Toplevel()
self.top.title("New Recipe")
quantity = StringVar()
#Center the window
w = 600
h = 600
sw = self.top.winfo_screenwidth()
sh = self.top.winfo_screenheight()
x = (sw - w)/2
y = (sh - h)/2
self.top.geometry('%dx%d+%d+%d' % (w, h, x, y))
#Add quantity label
addQuantity = Label(self.top, text="Add Quantity:")
addQuantity.place(x=0,y=0)
quantityAdd = Entry(self.top, textvariable=quantity)
quantityAdd.place(x=150, y=0)
#Add ingredient label
addIngredient = Label(self.top, text="Add Ingredients:")
addIngredient.place(x=0,y=30)
ingredientAdd = Entry(self.top)
ingredientAdd.place(x=150, y=30)
#Select measurements label
selectMeasurement = Label(self.top, text="Select Measurements:")
selectMeasurement.place(x=0, y=60)
measurement = StringVar()
measurement.set("ounce")
measurementSelect = OptionMenu(self.top, measurement, "ounce", "pound", "gallon", "quart", "fl oz", "pint", "cup", "table spoon", "teaspoon")
measurementSelect.place(x=150, y=60)
#Add measurements label
addMeasurement = Label(self.top, text="Amount:")
addMeasurement.place(x=0, y=100)
measurementAdd = Entry(self.top)
measurementAdd.place(x=150, y=100)
#Add the textwidget
recipeText = Text(self.top)
recipeText.place(x=0,y=200)
#Cooking direction label
cookingDirection = Label(self.top, text="Cooking Direction")
cookingDirection.place(x=0,y=175)
def onNewIngredient():
qVar = quantity.get()
print(qVar)
#Add the Add Button
addButton = Button(self.top, text="Add", command= onNewIngredient)
addButton.place(x=0, y=130)
#Add Ingredients listbox
ingredScroll = Scrollbar(self.top, orient=VERTICAL)
ingredientListbox = Listbox(self.top, yscrollcommand=ingredScroll.set)
ingredScroll.config(command=ingredientListbox.yview)
ingredScroll.pack(side=RIGHT, fill=Y)
ingredientListbox.place(x=450, y=0)
그랬습니다! 고마워요. 튜토리얼에서 프레임 부분을 보았습니다. 두 개와 두 개를 맞추지 않았을 것입니다. 다시 한 번 감사드립니다! – unlikelysyntax