-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI_Normal_OP.py
103 lines (81 loc) · 2.78 KB
/
GUI_Normal_OP.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python3
from PyQt5.QtWidgets import QApplication, QWidget, QLineEdit, QPushButton, QGridLayout, QLabel
from PyQt5.QtWidgets import QListWidget, QComboBox, QFileDialog, QMessageBox
from PIL import Image, ImageTk
import os.path
from Normal_OP import strength_normal_list
def popup_dialog(txt):
msg = QMessageBox()
msg.setText(txt)
msg.exec_()
def strength_normals(url_list, folder_dir):
normal_list = [ os.path.normpath(x.path()) for x in url_list ]
strength_normal_list(normal_list, folder_dir)
popup_dialog('Finished!')
'''
PyQt5 Line edit widget that adds drag n drop funcionality
'''
class DnDLineEdit(QLineEdit):
def __init__(self, folders = False):
# Basic widget config
super().__init__()
# For Drag n drops
print(self.setAcceptDrops(True))
self.file_url = ''
self.accept_folders = folders
def dropEvent(self, event):
# For the nature of the widget we just take the first
# element
self.setText(event.mimeData().urls()[0].path())
def dragEnterEvent(self, event):
print('drop')
event.accept()
return
if event.mimeData().hasUrls():
event.accept()
else:
event.ignore()
class DnDWindow(QWidget):
def __init__(self):
# Basic widget config
super().__init__()
# For Drag n drops
self.setAcceptDrops(True)
self.line_edit = None
def dropEvent(self, event):
# For the nature of the widget we just take the first
# element
strength_normals(event.mimeData().urls(), self.line_edit.text())
def dragEnterEvent(self, event):
if event.mimeData().hasUrls():
event.accept()
else:
event.ignore()
def options_dialog_GUI(app):
main_window = DnDWindow()
dir_edit = QLineEdit()
main_window.line_edit = dir_edit
grid = QGridLayout()
# Button events
def origin_search():
filename = QFileDialog.getExistingDirectory(None, "Open Folder", '.')
if filename:
dir_edit.setText(filename)
search_button = QPushButton('Search')
search_button.clicked.connect(origin_search)
grid.addWidget(QLabel('Origin Resource pack: '), 1, 0)
grid.addWidget(dir_edit, 2, 0)
grid.addWidget(search_button, 2, 1)
grid.addWidget(QLabel(' '), 2, 0)
grid.addWidget(QLabel(' '), 3, 0)
grid.addWidget(QLabel(' '), 4, 0)
grid.addWidget(QLabel(' Drag here the files '), 5, 0)
grid.addWidget(QLabel(' '), 6, 0)
grid.addWidget(QLabel(' '), 7, 0)
grid.addWidget(QLabel(' '), 8, 0)
main_window.setLayout(grid)
main_window.show()
app.exec()
if __name__ == '__main__':
app = QApplication([])
options_dialog_GUI(app)