Tkinter filedialog to read upload and adjust height width to resize multiple images to display

plus2net
plus2net
7.9 هزار بار بازدید - 3 سال پیش - 2:22
2:22  file types to be allowed using option filetypes
3:24 filedialog askopenfilename to select files
5:12 display image
8:11 Resize image
9:53 option multiple=True  to select multiple files
15:45 Resize images to maintain aspect ratio

Read more about filedialog to select files with options :  Displaying file browser to upload rea...
Filedialog & Treeview :  Displaying data in Treeview by using ...

We can use filedialog askopenfilename to show the file browser window and user can select the image they want to copy or display. Here we have restricted to JPG and PNG files only for selection by using the option filetypes.
Before displaying the image we will reduce the size to 100 width and 100 height to accommodate more images in our window.
By using multiple option and setting it to True we can allow user to select multiple files by holding the Ctrl ( Control ) key.
Once the multiple selection is set to True then the askopenfilename will return a Tuple with all selected files with path as element.
We will use one for loop to read each tuple element and display the same as image after resizing it.
The full code to download is available here.
https://www.plus2net.com/python/tkint...
Basics about file open dialog box
https://www.plus2net.com/python/tkint...

#filetypes , #askopenfilename #tkinterSelectFile #imageThumbnail #multipleImageSelection #creatingThumbnail #plus2net #python #imagegallery
3 سال پیش در تاریخ 1400/07/24 منتشر شده است.
7,982 بـار بازدید شده
... بیشتر