Skip to content

Commit

Permalink
Added list of files in selected directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fincap committed Jun 24, 2021
1 parent 850b03e commit fc2c4e8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion png-to-jpeg/view.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from PyQt5 import QtWidgets, QtCore

from convert import get_file_list_from_folder, convert_png_to_jpeg
Expand All @@ -9,7 +11,7 @@ def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.setWindowTitle("png-to-jpeg")

self.file_list = None
self.file_list = []

# Create central widget
central_widget = QtWidgets.QWidget()
Expand Down Expand Up @@ -63,14 +65,33 @@ def __init__(self):
layout_left_panel.addWidget(widget_output_location)
layout_left_panel.addWidget(button_convert)

# Create right panel
right_panel = QtWidgets.QWidget()
layout_right_panel = QtWidgets.QVBoxLayout(right_panel)
layout_right_panel.setAlignment(QtCore.Qt.AlignTop)

# Found items listview
label_found_files = QtWidgets.QLabel("Files to convert")
self.list_found_files = QtWidgets.QListWidget()

# Add widgets to right panel
layout_right_panel.addWidget(label_found_files)
layout_right_panel.addWidget(self.list_found_files)

central_layout.addWidget(left_panel)
central_layout.addWidget(right_panel)
self.setCentralWidget(central_widget)

def on_browse_clicked(self):
filepath = QtWidgets.QFileDialog.getExistingDirectory(self, "Open Directory")
if filepath != '':
self.file_list = get_file_list_from_folder(filepath)

# Update list of files loaded
self.list_found_files.clear()
entries = [os.path.basename(img) for img in self.file_list] # Only show filenames
self.list_found_files.addItems(entries)

def on_slider_updated(self, value):
self.label_quality.setText(str(value))

Expand Down

0 comments on commit fc2c4e8

Please sign in to comment.