mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-10 15:26:34 +03:00
update file view
This commit is contained in:
parent
82b1206541
commit
46755b3f9f
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tkinter
|
import tkinter
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from PIL import ImageTk, Image
|
from PIL import ImageTk, Image
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ print("started loading files")
|
||||||
for dirpath, _, filenames in os.walk(file_path):
|
for dirpath, _, filenames in os.walk(file_path):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
files.append(os.path.abspath(os.path.join(dirpath, f)))
|
files.append(os.path.abspath(os.path.join(dirpath, f)))
|
||||||
|
files = sorted(files, key=os.path.getsize, reverse=True)
|
||||||
print("files loaded")
|
print("files loaded")
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,16 +59,19 @@ class Window:
|
||||||
|
|
||||||
def show_file(self, f):
|
def show_file(self, f):
|
||||||
self.img = Image.open(f)
|
self.img = Image.open(f)
|
||||||
self.img = self.img.resize((self.img.width, self.img.height), Image.ANTIALIAS)
|
x = self.img.height / 1080
|
||||||
|
self.img = self.img.resize((int(self.img.width / x), 1080), Image.LANCZOS)
|
||||||
|
|
||||||
self.img = ImageTk.PhotoImage(self.img)
|
self.img = ImageTk.PhotoImage(self.img)
|
||||||
|
|
||||||
self.label = tkinter.Label(self.master, image=self.img)
|
self.label = tkinter.Label(self.master, image=self.img)
|
||||||
self.label.pack(expand=True, fill=tkinter.BOTH)
|
self.label.pack_propagate(0)
|
||||||
|
self.label.pack(side=tkinter.TOP, expand=True, fill=tkinter.X)
|
||||||
|
|
||||||
def next(self, event):
|
def next(self, event):
|
||||||
self.cur += 1
|
self.cur += 1
|
||||||
self.show_file(self.files[self.cur])
|
self.show_file(self.files[self.cur])
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
def real(self, event):
|
def real(self, event):
|
||||||
self.label.destroy()
|
self.label.destroy()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user