''' import os
import tkinter as tk
from tkinter import filedialog
import ctypes
import shutil
ctypes.windll.shcore.SetProcessDpiAwareness(True)
global current_path
def path_change(*event):
directory = os.listdir(current_path)
list.delete(0, tk.END)
for file in directory:
list.insert(tk.END, file)
def change_path_by_click(event=None):
global current_path
picked = list.get(list.curselection()[0])
path = os.path.join(current_path, picked)
if os.path.isdir(path):
current_path = path
path_change()
elif os.path.isfile(path):
os.startfile(path)
def go_back():
global current_path
current_path = os.path.dirname(current_path)
path_change()
def window_new_file():
global new_window
new_window = tk.Toplevel(root)
new_window.geometry('250x150')
new_window.resizable(0,0)
new_window.title('Новый файл/папка')
new_window.columnconfigure(0, weight=1)
tk.Label(new_window, text='Введите название нового файла/папки').grid()
tk.Entry(new_window, textvariable=new_file_name).grid(column = 0, pady = 10, sticky = tk.NSEW)
tk.Button(new_window, text='Создать', command=new_or_folder).grid(pady=10, sticky=tk.NSEW)
def new_or_folder():
if len(new_file_name.get().split('.')) !=1:
open(os.path.join(current_path, new_file_name.get()), 'w').close()
else:
os.mkdir(os.path.join(current_path, new_file_name.get()))
new_window.destroy()
path_change()
def upload_file():
filename = filedialog.askopenfilename(initialdir="/", title="Выберите файл")
if filename:
destination_path = filedialog.askdirectory(initialdir=current_path, title="Выберите папку для загрузки")
if destination_path:
shutil.copy(filename, os.path.join(destination_path, os.path.basename(filename)))
path_change()
def upload_multiple_files(event=None):
filenames = filedialog.askopenfilenames(initialdir="/", title="Выберите файлы")
if filenames:
destination_path = filedialog.askdirectory(initialdir=current_path, title="Выберите папку для загрузки")
for filename in filenames:
if destination_path:
shutil.copy(filename, os.path.join(destination_path, os.path.basename(filename)))
path_change()
def download_file():
picked = list.get(list.curselection()[0])
source_path = os.path.join(current_path, picked)
if os.path.isfile(source_path):
destination_path = filedialog.asksaveasfilename(initialdir="/", title="Выберите путь для выгрузки файла", initialfile=picked)
if destination_path:
shutil.copy(source_path, destination_path)
path_change()
def consolidate_files():
filenames = filedialog.askopenfilenames(initialdir=current_path, title="Выберите файлы для консолидации")
if filenames:
destination_path = filedialog.askdirectory(initialdir=current_path, title="Выберите папку для сохранения консолидированного файла")
consolidated_filename = "consolidated.txt"
if destination_path:
with open(os.path.join(destination_path, consolidated_filename), 'wb') as outfile:
for filename in filenames:
with open(filename, 'rb') as infile:
shutil.copyfileobj(infile, outfile)
path_change()
def exit_program():
root.destroy()
f = ('Times', 14)
root = tk.Tk()
root.title('Озеро Данных')
root.config(bg='#0B5A81')
p1 = tk.PhotoImage(file="../Avtorizacia/IkonkaOzeroDanih3.png")
root.iconphoto(False, p1)
root.geometry('700x500')
x_position, y_position = 680, 260
root.geometry(f'700x500+{x_position}+{y_position}')
root.grid_columnconfigure(0, weight=1)
root.grid_rowconfigure(1, weight=1)
new_window = ''
new_file_name = tk.StringVar(root, "Блокнот.txt", 'new_name')
current_path = 'C:\\Отчеты'
# Кнопки
tk.Button(root, text='Создать', command=window_new_file).grid(sticky=tk.NSEW, column=0, row=0)
tk.Button(root, text='Загрузить', command=upload_file).grid(sticky=tk.NSEW, column=1, row=0)
tk.Button(root, text='Скопировать', command=download_file).grid(sticky=tk.NSEW, column=2, row=0)
tk.Button(root, text='Консолидатор', command=consolidate_files).grid(sticky=tk.NSEW, column=3, row=0)
tk.Button(root, text='Назад', command=go_back).grid(sticky=tk.NSEW, column=4, row=0)
tk.Button(root, text='Выход', command=exit_program).grid(sticky=tk.NSEW, column=5, row=0)
list = tk.Listbox(root, selectmode=tk.MULTIPLE) # Устанавливаем режим выбора EXTENDED
list.grid(sticky = tk.NSEW, column=0, row=1, columnspan=6, ipady=10, ipadx=10)
list.bind('<Double-1>', change_path_by_click)
list.bind('<Return>', change_path_by_click)
path_change('')
root.mainloop()
'''