1

I'm creating a file explorer using tkinter in python for my homework. when my program adds more the 634 files to my frame it won't show them

I've tried changing the size of the frame. but it doesn't works.

the below is the code of my frame in a canvas:

canvas = Canvas(bottomframe, width=935, height=1000)    
frame = Frame(canvas, width=canvas.winfo_height(), 
                      height=canvas.winfo_width()) #}

and this is the code to add the files of a directory:

for num,files in enumerate(listdir(dir_path)):
    path_var=dir_path+files
    if path.isfile(path_var):
        filename, file_extension = path.splitext(path_var)
        if button==6:
             window.label(root,frame,r)
             buttons.clear()
             button=0
             r+=2
             c=0

        folder_button = Button(frame, text=files,
            command=lambda buttonName=files:button_check(buttonName), 
            width=120, height=120, image=some_img])

        button+=1
        folder_button.grid(row=r,column=c)
        buttons.append(files)
        c+=1

    window.label(root,frame,r)

I expect a for that dynamically adds the all files of a directory in a form but it doesn't it only scrolls till the 634th file and the files after that are some thing like below picture: http://s8.picofile.com/file/8360209018/err.png

if all code is needed its on github: https://github.com/BahramiAlireza/FileExplorer/tree/master/source I'll be appreciated if you pay attention to my question.

aa aab
  • 9
  • 6
  • You didn't show the relevant part: **How did you** layout the `frame` and **how did you** `configure` the `scrollregion`. As it stands you have **fixed size** of `canvas` and `frame` . Read [Adding a scrollbar to a group of widgets in Tkinter](https://stackoverflow.com/a/3092341/7414759) – stovfl May 12 '19 at 11:04
  • If I had to guess I would say you are hitting the max height of your canvas, try increasing the height dynamically – Helder Sepulveda May 12 '19 at 13:20
  • See [tkinter maximum canvas size?](https://stackoverflow.com/questions/42830037/tkinter-maximum-canvas-size) – Bryan Oakley May 12 '19 at 15:35
  • no i dont mean that. my canvas scrolls till 634th file but after that files appear like the uploaded picture. – aa aab May 12 '19 at 19:41

0 Answers0