forked from 2572724988/Pandora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filePicklist.py
155 lines (129 loc) · 6.01 KB
/
filePicklist.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
from login import hoofdMenu
from sys import platform
import os
from PyQt5.QtCore import Qt, QRegExp
from PyQt5.QtGui import QFont, QPixmap, QIcon, QRegExpValidator
from PyQt5.QtWidgets import QDialog, QGridLayout, QLabel, QMessageBox,\
QComboBox, QPushButton, QLineEdit
def windowSluit(self, m_email):
self.close()
hoofdMenu(m_email)
def geenMenu():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Warning)
msg.setText('Geen bestandsnaam gekozen!')
msg.setWindowTitle('Geen keuze')
msg.exec_()
def printFile(filename, m_email, path):
if platform == 'win32':
os.startfile(path+filename, "print")
else:
os.system("lpr "+path+filename)
def printing():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Information)
msg.setText('Ogenblik afdrukken wordt gestart!')
msg.setWindowTitle('Printen diverse formulieren')
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.exec_()
def fileList(m_email, path):
filelist = os.listdir(path)
class combo(QDialog):
def __init__(self, parent=None):
super(combo, self).__init__(parent)
self.setWindowTitle("Printen van lijsten")
self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
self.setFont(QFont("Arial", 10))
grid = QGridLayout()
grid.setSpacing(20)
logo = QLabel()
pixmap = QPixmap('./images/logos/logo.jpg')
logo.setPixmap(pixmap)
grid.addWidget(logo , 0, 2, 1, 1, Qt.AlignRight)
plbl = QLabel()
plbl = QLabel('Printen\nLijsten')
plbl.setStyleSheet("color:rgba(45, 83, 115, 255); font: 20pt Comic Sans MS")
grid.addWidget(plbl, 0, 1)
lbl = QLabel()
pixmap = QPixmap('./images/logos/verbinding.jpg')
lbl.setPixmap(pixmap)
grid.addWidget(lbl, 0, 0, 1, 1)
self.cb = QComboBox()
self.cb.setFixedWidth(420)
self.cb.setFont(QFont("Arial",10))
if platform == 'win32':
self.cb.setStyleSheet("color: black; background-color: #F8F7EE")
else:
self.cb.setStyleSheet("combobox-popup: 0;")
self.Keuze = QLabel()
self.cb.addItem(' Kies bestand')
grid.addWidget(self.cb, 1, 0, 1, 3, Qt.AlignRight)
for item in range(len(filelist)):
self.cb.addItem(filelist[item])
self.cb.model().sort(0)
grid.addWidget(self.cb, 1, 0, 1, 3, Qt.AlignRight)
self.cb.activated[str].connect(self.cbChanged)
self.aantal = QLabel()
aantalEdit = QLineEdit('1')
aantalEdit.setStyleSheet("background: #F8F7EE")
aantalEdit.setFixedWidth(30)
aantalEdit.setFont(QFont("Arial",10))
aantalEdit.textChanged.connect(self.aantalChanged)
reg_ex = QRegExp("^[0-9]{1,2}$")
input_validator = QRegExpValidator(reg_ex, aantalEdit)
aantalEdit.setValidator(input_validator)
grid.addWidget(QLabel('Aantal kopieën te printen'), 3, 1, 1, 2)
grid.addWidget(aantalEdit, 3, 2, 1, 1, Qt.AlignRight)
plbl = QLabel()
pmap = QPixmap('./images/thumbs/MG3650.jpg')
plbl.setPixmap(pmap)
grid.addWidget(plbl , 3, 0, 2, 1, Qt.AlignCenter)
cancelBtn = QPushButton('Sluiten')
cancelBtn.clicked.connect(lambda: windowSluit(self, m_email))
grid.addWidget(cancelBtn, 4, 1, 1, 1, Qt.AlignRight)
cancelBtn.setFont(QFont("Arial",10))
cancelBtn.setFixedWidth(90)
cancelBtn.setStyleSheet("color: black; background-color: gainsboro")
printBtn = QPushButton('Printen')
printBtn.clicked.connect(self.accept)
grid.addWidget(printBtn, 4, 2)
printBtn.setFont(QFont("Arial",10))
printBtn.setFixedWidth(90)
printBtn.setStyleSheet("color: black; background-color: gainsboro")
grid.addWidget(QLabel('\u00A9 2017 all rights reserved [email protected]'), 5, 0, 1, 3, Qt.AlignCenter)
self.setLayout(grid)
self.setGeometry(550, 300, 150, 150)
def cbChanged(self, text):
self.Keuze.setText(text)
def aantalChanged(self, text):
self.aantal.setText(text)
def returncb(self):
return self.Keuze.text()
def returnaant(self):
return self.aantal.text()
@staticmethod
def getData(parent=None):
dialog = combo(parent)
dialog.exec_()
return [dialog.returncb(), dialog.returnaant()]
win = combo()
data = win.getData()
if data[0] == '' or data[0][0] == ' ':
geenMenu()
fileList(m_email, path)
elif data[0]:
if not data[1]:
mhoev = '1'
else:
mhoev = data[1]
filename = data[0]
for x in range(0, int(mhoev)):
printFile(filename, m_email, path)
printing()
fileList(m_email, path)
else:
fileList(m_email, path)