This repository has been archived by the owner on Dec 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
70 lines (52 loc) · 2.04 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import threading
import time
import sys
import os
from PyQt5.QtWidgets import QMainWindow, QApplication, QInputDialog, QLineEdit, QFileDialog, QListWidgetItem
from PyQt5.QtCore import (QCoreApplication, Qt, QEvent)
from mainUI import Ui_MainWindow
from format_generator import Task
# https://stackoverflow.com/questions/50635881/pyinstaller-importerror-c-extension-no-module-named-np-datetime-not-built
class Qfile(QListWidgetItem):
def __init__(self, path, parent=None):
self.path = path
self.filename = os.path.basename(self.path)
super().__init__(self.filename)
class AppWindow(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.generate)
self.ui.actionOpenFIle.triggered.connect(self.openFileNameDialog)
self.task = Task()
self.task.start_thread()
def keyPressEvent(self, event):
key = event.key()
if key == Qt.Key_Escape:
QCoreApplication.quit()
elif key == Qt.Key_Delete:
self.ui.listWidget.takeItem(self.ui.listWidget.currentRow())
def openFileNameDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fileNames, _ = QFileDialog.getOpenFileNames(self,"Abrir Excel", "","Excel (*.xlsx)", options=options)
if fileNames:
#self.ui.listWidget.addItems([ntpath.basename(i) for i in fileNames])
for i in fileNames:
self.ui.listWidget.addItem(Qfile(i))
def generate(self):
if self.task.status and not self.task.task:
file_paths = []
for i in range(self.ui.listWidget.count()):
file_paths.append(self.ui.listWidget.item(i).path)
self.task.start_task(file_paths)
if not self.task.status:
self.task = Task()
self.task.start_thread()
app = QApplication(sys.argv)
w = AppWindow()
w.show()
sys.exit(app.exec_())
w.end()
w.task.stop_thread()