python - tkinter create_window erases previous window -


for reason, when go create_window in tkinter canvas, erases in said window, , jams window in top left corner (even though set somewhere else.

canvas.create_window(30, height - 40, anchor = nw, width = 40,     window = canvas.data.buildsquarebutton) 

precedes

canvas.create_rectangle(0,0,width, 40, fill = "#888888888",                         outline = "#888888888") canvas.create_rectangle(0, height, width, (height-40), fill = "#888888888",                         outline = "#888888888") canvas.create_rectangle(0, 40, width, (height - 40), fill = "#fffffffff",                         outline = "#fffffffff") 

and image.

i put in 1 second time.sleep after create_window, , see button put in right place. after time.sleep over, button threw in top right corner , rectangle never appeared. commented out window, , rectangles appeared fine.

am doing wrong when call window, or there tkinter glitch?

there's not enough information in question know sure. however, guess packing or griding widget in canvas, , that's causing canvas shrink fit contents. or, you're doing else cause canvas shrink.

to compound problem, canvas has same background color main window, think contents being erased, in reality you're looking @ widget canvas in rather canvas itself.

to prove or disprove theory, give canvas garish background color, such bright red. run code , see happens red part of screen.

bottom line: there no bug in tkinter cause behavior describe. there bug in code aren't showing us.

the best thing create smallest possible program reproduces problem. mere act of trying may expose bug in code. if able reproduce in dozen or 2 lines of code, update question , can spot error.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -