Add import paths to audio files. Add error dialog. Add checking extension of audio file(.mp3).

This commit is contained in:
Jarosław Wieczorek 2020-12-18 19:53:04 +01:00
parent 0f1d8e3c6c
commit d93dd450dc
5 changed files with 175 additions and 78 deletions

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM alpine:3.9 AS build
WORKDIR /opt/app/MagicPodcast
# Install Python and external dependencies, including headers and GCC
RUN apk add --no-cache python3 python3-dev py3-pip libffi libffi-dev musl-dev gcc
# Install Pipenv
RUN pip3 install pipenv
# Create a virtual environment and activate it
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH" VIRTUAL_ENV="/opt/venv"
# Install dependencies into the virtual environment with Pipenv
COPY Pipfile Pipfile.lock /opt/app/MagicPodcast
RUN pipenv install --deploy
FROM alpine:3.9
WORKDIR /opt/app/MagicPodcast
# Install Python and external runtime dependencies only
RUN apk add --no-cache python3 libffi
# Copy the virtual environment from the previous image
COPY --from=build /opt/venv /opt/venv
# Activate the virtual environment
ENV PATH="/opt/venv/bin:$PATH" VIRTUAL_ENV="/opt/venv"
# Copy your application
COPY . /opt/app/MagicPodcast

View File

@ -1,10 +1,10 @@
from src.python.classes.mainwindow import MainWindow
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication
import sys
if __name__=='__main__':
app = QtWidgets.QApplication(sys.argv)
app = QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())

View File

@ -18,67 +18,85 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
<item>
<widget class="QSlider" name="range_silder">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QVBoxLayout" name="vertical_layout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Początek fragmentu</string>
<widget class="QGraphicsView" name="graphics_view"/>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Koniec fragemntu</string>
<widget class="QSlider" name="range_silder">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>start</string>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>stop</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontal_layout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Początek fragmentu</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="line_edit"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Koniec fragemntu</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="line_edit_2"/>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>zakończ</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontal_layout_3">
<item>
<widget class="QPushButton" name="push_button">
<property name="text">
<string>start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="push_button_2">
<property name="text">
<string>stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="push_button_3">
<property name="text">
<string>zakończ</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>

View File

@ -6,6 +6,48 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent=parent)
self.setupUi(self)
self.setup_logic()
def setup_logic(self):
self.push_button_audio1.clicked.connect(lambda: self.open_audio_import(audio_number=1))
self.push_button_audio2.clicked.connect(lambda: self.open_audio_import(audio_number=2))
def setup_detail(self):
pass
def create_custom_dialog(self, title: str, msg: str):
dialog = QDialog()
dialog.setWindowTitle(title)
label = QLabel()
label.setText(msg)
buttons = QDialogButtonBox.Ok
button_box = QDialogButtonBox(buttons)
button_box.accepted.connect(dialog.accept)
layout = QVBoxLayout()
layout.addWidget(label)
layout.addWidget(button_box)
dialog.setLayout(layout)
return dialog
def open_audio_import(self, audio_number: int):
dialog = QFileDialog()
dialog.setOption(dialog.DontUseNativeDialog, True)
dialog.setFileMode(QFileDialog.ExistingFile)
file, _ = dialog.getOpenFileName(self, "QFileDialog.getOpenFileName()", "", "All Files (*);;mp3 (*.mp3);;wav (*.wav)", options=dialog.options())
if not file.endswith('.mp3'):
print(F"[!] Plik {file} nie jest plikiem mp3.")
dialog = self.create_custom_dialog(title='Error', msg=F"[!] Plik {file} nie jest plikiem mp3.")
dialog.exec_()
else:
if audio_number == 1:
self.line_edit_audio1.setText(file)
elif audio_number == 2:
self.line_edit_audio2.setText(file)
print(F"[*] Zaimportowano ścieżkę {audio_number} pliku: '{file}'.")

View File

@ -18,42 +18,55 @@ class Ui_dialog(object):
dialog.resize(782, 356)
self.verticalLayout = QtWidgets.QVBoxLayout(dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.graphicsView = QtWidgets.QGraphicsView(dialog)
self.graphicsView.setObjectName("graphicsView")
self.verticalLayout.addWidget(self.graphicsView)
self.vertical_layout = QtWidgets.QVBoxLayout()
self.vertical_layout.setObjectName("vertical_layout")
self.graphics_view = QtWidgets.QGraphicsView(dialog)
self.graphics_view.setObjectName("graphics_view")
self.vertical_layout.addWidget(self.graphics_view)
self.line = QtWidgets.QFrame(dialog)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.vertical_layout.addWidget(self.line)
self.range_silder = QtWidgets.QSlider(dialog)
self.range_silder.setOrientation(QtCore.Qt.Horizontal)
self.range_silder.setTickPosition(QtWidgets.QSlider.TicksBothSides)
self.range_silder.setTickInterval(1)
self.range_silder.setObjectName("range_silder")
self.verticalLayout.addWidget(self.range_silder)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.vertical_layout.addWidget(self.range_silder)
self.line_2 = QtWidgets.QFrame(dialog)
self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.vertical_layout.addWidget(self.line_2)
self.horizontal_layout_2 = QtWidgets.QHBoxLayout()
self.horizontal_layout_2.setObjectName("horizontal_layout_2")
self.label = QtWidgets.QLabel(dialog)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.lineEdit = QtWidgets.QLineEdit(dialog)
self.lineEdit.setObjectName("lineEdit")
self.horizontalLayout_2.addWidget(self.lineEdit)
self.horizontal_layout_2.addWidget(self.label)
self.line_edit = QtWidgets.QLineEdit(dialog)
self.line_edit.setObjectName("line_edit")
self.horizontal_layout_2.addWidget(self.line_edit)
self.label_2 = QtWidgets.QLabel(dialog)
self.label_2.setObjectName("label_2")
self.horizontalLayout_2.addWidget(self.label_2)
self.lineEdit_2 = QtWidgets.QLineEdit(dialog)
self.lineEdit_2.setObjectName("lineEdit_2")
self.horizontalLayout_2.addWidget(self.lineEdit_2)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.pushButton = QtWidgets.QPushButton(dialog)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.pushButton_2 = QtWidgets.QPushButton(dialog)
self.pushButton_2.setObjectName("pushButton_2")
self.horizontalLayout.addWidget(self.pushButton_2)
self.pushButton_3 = QtWidgets.QPushButton(dialog)
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalLayout.addWidget(self.pushButton_3)
self.verticalLayout.addLayout(self.horizontalLayout)
self.horizontal_layout_2.addWidget(self.label_2)
self.line_edit_2 = QtWidgets.QLineEdit(dialog)
self.line_edit_2.setObjectName("line_edit_2")
self.horizontal_layout_2.addWidget(self.line_edit_2)
self.vertical_layout.addLayout(self.horizontal_layout_2)
self.horizontal_layout_3 = QtWidgets.QHBoxLayout()
self.horizontal_layout_3.setObjectName("horizontal_layout_3")
self.push_button = QtWidgets.QPushButton(dialog)
self.push_button.setObjectName("push_button")
self.horizontal_layout_3.addWidget(self.push_button)
self.push_button_2 = QtWidgets.QPushButton(dialog)
self.push_button_2.setObjectName("push_button_2")
self.horizontal_layout_3.addWidget(self.push_button_2)
self.push_button_3 = QtWidgets.QPushButton(dialog)
self.push_button_3.setObjectName("push_button_3")
self.horizontal_layout_3.addWidget(self.push_button_3)
self.vertical_layout.addLayout(self.horizontal_layout_3)
self.verticalLayout.addLayout(self.vertical_layout)
self.retranslateUi(dialog)
QtCore.QMetaObject.connectSlotsByName(dialog)
@ -63,9 +76,9 @@ class Ui_dialog(object):
dialog.setWindowTitle(_translate("dialog", "Dialog"))
self.label.setText(_translate("dialog", "Początek fragmentu"))
self.label_2.setText(_translate("dialog", "Koniec fragemntu"))
self.pushButton.setText(_translate("dialog", "start"))
self.pushButton_2.setText(_translate("dialog", "stop"))
self.pushButton_3.setText(_translate("dialog", "zakończ"))
self.push_button.setText(_translate("dialog", "start"))
self.push_button_2.setText(_translate("dialog", "stop"))
self.push_button_3.setText(_translate("dialog", "zakończ"))
if __name__ == "__main__":