Skip to content

Commit 62c3c62

Browse files
New improvements. (#5)
## New Features: - The option to choose multiple files in the 'Merge PDF' window has been implemented. - Reduction of imports in the code.
2 parents 271893a + 5a9d789 commit 62c3c62

12 files changed

+112
-34
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
## Install via deb package
2424
To install pdfgui_tools, you will first need to download the **Debian package**, which can be found at the following link:
2525

26-
<a href="https://github.com/TheWatcherMultiversal/pdfgui_tools/releases/download/v1.0.3/pdfgui_tools_stable-release_1.0.3_all.deb" target="_blank">📦 Download deb package</a>
26+
<a href="https://github.com/TheWatcherMultiversal/pdfgui_tools/releases/download/v1.0.4/pdfgui_tools_stable-release_1.0.4_all.deb" target="_blank">📦 Download deb package</a>
2727

2828
Once we have our **Debian package** installed, simply execute the following command, and it will be downloaded to our system:
2929

30-
sudo dpkg -i pdfgui_tools_stable-release_1.0.3_all.deb
30+
sudo dpkg -i pdfgui_tools_stable-release_1.0.4_all.deb
3131

3232
- Note: If we find any missing dependencies, it's just a matter of installing them with the `sudo apt install -f` command
3333

Screenshots/Screenshot_1.png

175 KB
Loading

code/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def retranslateUi(self, MainWindow):
8888
_translate = QtCore.QCoreApplication.translate
8989
MainWindow.setWindowTitle(_translate("MainWindow", "About"))
9090
self.label.setText(_translate("MainWindow", "PDF GUI Tools"))
91-
self.label_3.setText(_translate("MainWindow", "Version 1.0.3"))
91+
self.label_3.setText(_translate("MainWindow", "Version 1.0.4"))
9292
self.label_2.setText(_translate("MainWindow", "PDF GUI Tools is a graphical user interface tool that integrates the features of poppler-utils."))
9393
self.label_4.setText(_translate("MainWindow", "© Angel M 2021 - 2023"))
9494
self.label_5.setText(_translate("MainWindow", "GNU GENERAL PUBLIC LICENSE v3"))

code/pdfgui_pdfseparate.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
from PyQt5 import QtCore, QtGui, QtWidgets
15+
from PyQt5.QtWidgets import QMessageBox, QFileDialog
1516
import subprocess
1617
import os
1718

@@ -169,7 +170,6 @@ def retranslateUi(self, MainWindow):
169170

170171
# Function to add a file to 'self.listWidget'
171172
def click_add(self):
172-
from PyQt5.QtWidgets import QFileDialog, QMessageBox
173173
if self.listWidget.count() == 1:
174174
print("One file permited")
175175
QMessageBox.critical(MainWindow, "Error", 'Only one file at a time.', QMessageBox.Ok)
@@ -196,20 +196,17 @@ def click_delete(self):
196196
def viewpdf(self):
197197

198198
if self.listWidget.count() < 1:
199-
from PyQt5.QtWidgets import QMessageBox
200199
print("you need to add file")
201200
QMessageBox.critical(MainWindow, "Error", 'You need to add file', QMessageBox.Ok)
202201
else:
203202
try:
204203
item = self.listWidget.item(0)
205204
subprocess.run([f'xdg-open "{item.text()}"'], check=True, shell=True)#------> Use xdg-open to open the default PDF viewer
206205
except subprocess.CalledProcessError:
207-
from PyQt5.QtWidgets import QMessageBox
208206
QMessageBox.critical(MainWindow, "Error", 'The PDF file could not be viewed', QMessageBox.Ok)
209207

210208
# Separate PDF
211209
def separate_pdf(self):
212-
from PyQt5.QtWidgets import QMessageBox
213210

214211
if self.listWidget.count() < 1:
215212
print("you need to add file")
@@ -240,7 +237,6 @@ def separate_pdf(self):
240237
print(f'File {row}:', item.text())
241238
self.command += ' "' + item.text() + '"'
242239

243-
from PyQt5.QtWidgets import QFileDialog
244240
options = QFileDialog.Options()
245241
options |= QFileDialog.ShowDirsOnly
246242
options |= QFileDialog.DontUseNativeDialog
@@ -274,7 +270,6 @@ def _about(self):
274270
os.system('python3 /usr/share/pdfgui_tools/about.py')
275271

276272
def _help(self):
277-
from PyQt5.QtWidgets import QMessageBox
278273

279274
# Help Message ------------------------------------------------------
280275
QMessageBox.about(MainWindow, "Help", """Controls:

code/pdfgui_pdftocairo.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# -----------------------------------------------------------------------------------
1212

1313
from PyQt5 import QtCore, QtGui, QtWidgets
14+
from PyQt5.QtWidgets import QMessageBox, QFileDialog
1415
import subprocess
1516
import os
1617

@@ -166,7 +167,6 @@ def retranslateUi(self, MainWindow):
166167

167168
# Function to add a file to 'self.listWidget'
168169
def click_add(self):
169-
from PyQt5.QtWidgets import QFileDialog, QMessageBox
170170
if self.listWidget.count() == 1:
171171
print("One file permited")
172172
QMessageBox.critical(MainWindow, "Error", 'Only one file at a time.', QMessageBox.Ok)
@@ -192,7 +192,6 @@ def click_delete(self):
192192

193193
# Convert PDF
194194
def convert(self):
195-
from PyQt5.QtWidgets import QMessageBox
196195

197196
if self.listWidget.count() < 1:
198197
print("you need to add file")
@@ -218,7 +217,6 @@ def convert(self):
218217
print(f'File {row}:', item.text())
219218
self.command += ' "' + item.text() + '"'
220219

221-
from PyQt5.QtWidgets import QFileDialog
222220
options = QFileDialog.Options()
223221

224222
# Asks where to save and how to name the file, obtains the path
@@ -246,7 +244,6 @@ def _about(self):
246244

247245
# Function Help
248246
def _help(self):
249-
from PyQt5.QtWidgets import QMessageBox
250247

251248
# Help Message ------------------------------------------------------
252249
QMessageBox.about(MainWindow, "Help", """Controls:

code/pdfgui_pdftohtml.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
from PyQt5 import QtCore, QtGui, QtWidgets
15+
from PyQt5.QtWidgets import QMessageBox, QFileDialog
1516
import os
1617
import subprocess
1718

@@ -136,7 +137,6 @@ def retranslateUi(self, MainWindow):
136137

137138
# Function to add a file to 'self.listWidget'
138139
def click_add(self):
139-
from PyQt5.QtWidgets import QFileDialog, QMessageBox
140140
if self.listWidget.count() == 1:
141141
print("One file permited")
142142
QMessageBox.critical(MainWindow, "Error", 'Only one file at a time.', QMessageBox.Ok)
@@ -162,7 +162,6 @@ def click_delete(self):
162162

163163
# Convert PDF to Html
164164
def convert_html(self):
165-
from PyQt5.QtWidgets import QMessageBox
166165

167166
if self.listWidget.count() < 1:
168167
print("you need to add file")
@@ -181,7 +180,6 @@ def convert_html(self):
181180
print(f'File {row}:', item.text())
182181
self.command += ' "' + item.text() + '"'
183182

184-
from PyQt5.QtWidgets import QFileDialog
185183
options = QFileDialog.Options()
186184

187185
# Asks where to save and how to name the file, obtains the path
@@ -207,7 +205,6 @@ def _about(self):
207205

208206
# Function Help
209207
def _help(self):
210-
from PyQt5.QtWidgets import QMessageBox
211208

212209
# Help Message ------------------------------------------------------
213210
QMessageBox.about(MainWindow, "Help", """Controls:

code/pdfgui_pdftotext.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
from PyQt5 import QtCore, QtGui, QtWidgets
15+
from PyQt5.QtWidgets import QMessageBox, QFileDialog
1516
import os
1617
import subprocess
1718

@@ -139,7 +140,6 @@ def retranslateUi(self, MainWindow):
139140

140141
# Function to add a file to 'self.listWidget'
141142
def click_add(self):
142-
from PyQt5.QtWidgets import QFileDialog, QMessageBox
143143
if self.listWidget.count() == 1:
144144
print("One file permited")
145145
QMessageBox.critical(MainWindow, "Error", 'Only one file at a time.', QMessageBox.Ok)
@@ -164,7 +164,6 @@ def click_delete(self):
164164

165165
# Convert PDF to Text
166166
def convert_text(self):
167-
from PyQt5.QtWidgets import QMessageBox
168167

169168
if self.listWidget.count() < 1:
170169
print("you need to add file")
@@ -183,7 +182,6 @@ def convert_text(self):
183182
print(f'File {row}:', item.text())
184183
self.command += ' "' + item.text() + '"'
185184

186-
from PyQt5.QtWidgets import QFileDialog
187185
options = QFileDialog.Options()
188186

189187
# Asks where to save and how to name the file, obtains the path
@@ -207,7 +205,6 @@ def _about(self):
207205
os.system('python3 /usr/share/pdfgui_tools/about.py')
208206

209207
def _help(self):
210-
from PyQt5.QtWidgets import QMessageBox
211208

212209
# Help Message ------------------------------------------------------
213210
QMessageBox.about(MainWindow, "Help", """Controls:

code/pdfgui_pdfunite.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313

1414
from PyQt5 import QtCore, QtGui, QtWidgets
15+
from PyQt5.QtWidgets import QMessageBox, QFileDialog
1516
import subprocess
1617
import os
1718

19+
1820
class Ui_MainWindow(object):
1921
def setupUi(self, MainWindow):
2022
MainWindow.setObjectName("MainWindow")
@@ -166,13 +168,15 @@ def retranslateUi(self, MainWindow):
166168

167169
# Function to add a file to 'self.listWidget'
168170
def click_add(self):
169-
from PyQt5.QtWidgets import QFileDialog
171+
170172
options = QFileDialog.Options()
171-
file_name, _ = QFileDialog.getOpenFileName(MainWindow, "Select File", "", "PDF Files (*.pdf)", options=options)
172-
if file_name:
173-
print("Add file:", file_name)
174-
new_element = file_name
175-
self.listWidget.addItem(new_element)
173+
options |= QFileDialog.DontUseNativeDialog
174+
files, _ = QFileDialog.getOpenFileNames(MainWindow, "Select PDF Files", "", "PDF Files (*.pdf);;All Files (*)", options=options)
175+
if files:
176+
for file_name in files:
177+
print("Add file:", file_name)
178+
new_element = file_name
179+
self.listWidget.addItem(new_element)
176180
else:
177181
print("Cancel...")
178182

@@ -206,7 +210,6 @@ def move_down(self):
206210

207211
# Merge PDFs
208212
def merge_pdf(self):
209-
from PyQt5.QtWidgets import QMessageBox
210213

211214
if self.listWidget.count() < 2:
212215
print("Add more files")
@@ -225,7 +228,6 @@ def merge_pdf(self):
225228
print(f'File {row}:', item.text())
226229
self.command += ' "' + item.text() + '"'
227230

228-
from PyQt5.QtWidgets import QFileDialog
229231
options = QFileDialog.Options()
230232

231233
# Asks where to save and how to name the file, obtains the path
@@ -251,7 +253,6 @@ def _about(self):
251253

252254
# Function Help
253255
def _help(self):
254-
from PyQt5.QtWidgets import QMessageBox
255256

256257
# Help Message ------------------------------------------------------
257258
QMessageBox.about(MainWindow, "Help", """Controls:

code/pdfgui_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def setupUi(self, MainWindow):
3535
self.label.setAlignment(QtCore.Qt.AlignCenter)
3636
self.label.setObjectName("label")
3737
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
38-
self.verticalLayoutWidget.setGeometry(QtCore.QRect(100, 70, 181, 211))
38+
self.verticalLayoutWidget.setGeometry(QtCore.QRect(65, 70, 251, 211))
3939
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
4040
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
4141
self.verticalLayout.setContentsMargins(0, 0, 0, 0)

designer/pdfgui_tools.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file 'pdfgui_tools.ui'
4+
#
5+
# Created by: PyQt5 UI code generator 5.15.9
6+
#
7+
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
8+
# run again. Do not edit this file unless you know what you are doing.
9+
10+
11+
from PyQt5 import QtCore, QtGui, QtWidgets
12+
13+
14+
class Ui_MainWindow(object):
15+
def setupUi(self, MainWindow):
16+
MainWindow.setObjectName("MainWindow")
17+
MainWindow.resize(381, 339)
18+
MainWindow.setMinimumSize(QtCore.QSize(381, 339))
19+
MainWindow.setMaximumSize(QtCore.QSize(381, 362))
20+
self.centralwidget = QtWidgets.QWidget(MainWindow)
21+
self.centralwidget.setObjectName("centralwidget")
22+
self.label = QtWidgets.QLabel(self.centralwidget)
23+
self.label.setGeometry(QtCore.QRect(80, 10, 221, 61))
24+
font = QtGui.QFont()
25+
font.setPointSize(20)
26+
font.setBold(True)
27+
font.setWeight(75)
28+
self.label.setFont(font)
29+
self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
30+
self.label.setAlignment(QtCore.Qt.AlignCenter)
31+
self.label.setObjectName("label")
32+
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
33+
self.verticalLayoutWidget.setGeometry(QtCore.QRect(60, 70, 251, 211))
34+
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
35+
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
36+
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
37+
self.verticalLayout.setObjectName("verticalLayout")
38+
self.pdfunite_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
39+
self.pdfunite_button.setObjectName("pdfunite_button")
40+
self.verticalLayout.addWidget(self.pdfunite_button)
41+
self.pdfseparate_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
42+
self.pdfseparate_button.setObjectName("pdfseparate_button")
43+
self.verticalLayout.addWidget(self.pdfseparate_button)
44+
self.pdftocairo_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
45+
self.pdftocairo_button.setObjectName("pdftocairo_button")
46+
self.verticalLayout.addWidget(self.pdftocairo_button)
47+
self.pdftohtml_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
48+
self.pdftohtml_button.setObjectName("pdftohtml_button")
49+
self.verticalLayout.addWidget(self.pdftohtml_button)
50+
self.pdftotext_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
51+
self.pdftotext_button.setObjectName("pdftotext_button")
52+
self.verticalLayout.addWidget(self.pdftotext_button)
53+
MainWindow.setCentralWidget(self.centralwidget)
54+
self.menubar = QtWidgets.QMenuBar(MainWindow)
55+
self.menubar.setGeometry(QtCore.QRect(0, 0, 381, 24))
56+
self.menubar.setObjectName("menubar")
57+
self.menuHelp = QtWidgets.QMenu(self.menubar)
58+
self.menuHelp.setObjectName("menuHelp")
59+
MainWindow.setMenuBar(self.menubar)
60+
self.statusbar = QtWidgets.QStatusBar(MainWindow)
61+
self.statusbar.setObjectName("statusbar")
62+
MainWindow.setStatusBar(self.statusbar)
63+
self.actionAbout = QtWidgets.QAction(MainWindow)
64+
self.actionAbout.setObjectName("actionAbout")
65+
self.menuHelp.addAction(self.actionAbout)
66+
self.menubar.addAction(self.menuHelp.menuAction())
67+
68+
self.retranslateUi(MainWindow)
69+
QtCore.QMetaObject.connectSlotsByName(MainWindow)
70+
71+
def retranslateUi(self, MainWindow):
72+
_translate = QtCore.QCoreApplication.translate
73+
MainWindow.setWindowTitle(_translate("MainWindow", "PDF GUI Tools"))
74+
self.label.setText(_translate("MainWindow", "PDF gui Tools"))
75+
self.pdfunite_button.setText(_translate("MainWindow", "Merge PDFs"))
76+
self.pdfseparate_button.setText(_translate("MainWindow", "Separate PDF"))
77+
self.pdftocairo_button.setText(_translate("MainWindow", "PDF to multimedia file"))
78+
self.pdftohtml_button.setText(_translate("MainWindow", "PDF to html"))
79+
self.pdftotext_button.setText(_translate("MainWindow", "PDF to text"))
80+
self.menuHelp.setTitle(_translate("MainWindow", "Help"))
81+
self.actionAbout.setText(_translate("MainWindow", "About"))
82+
83+
84+
if __name__ == "__main__":
85+
import sys
86+
app = QtWidgets.QApplication(sys.argv)
87+
MainWindow = QtWidgets.QMainWindow()
88+
ui = Ui_MainWindow()
89+
ui.setupUi(MainWindow)
90+
MainWindow.show()
91+
sys.exit(app.exec_())

0 commit comments

Comments
 (0)