forked from luisCartoGeo/QGIS_Dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQGISDashboardDialog.py
More file actions
1415 lines (1351 loc) · 74.4 KB
/
QGISDashboardDialog.py
File metadata and controls
1415 lines (1351 loc) · 74.4 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
/***************************************************************************
QGISDashboard
A QGIS plugin
This plugin allows the construction and management of Dashboards on screen.
-------------------
begin : 2021-06-14
git sha : https://github.com/luisCartoGeo/QGIS_Dashboard
copyright : (C) 2021 by Luis Eduardo Perez https://www.linkedin.com/in/luisedpg/
email : luis3176@yahoo.com
***************************************************************************/
"""
from qgis.PyQt import uic
import os
from qgis import PyQt
from qgis.PyQt import*
from qgis.PyQt import QtWidgets
from qgis.PyQt.QtWidgets import *
from qgis.PyQt.QtGui import *
from qgis.PyQt.QtCore import *
from qgis.core import *
from qgis.gui import QgsSvgSelectorWidget
from .panels.stylesIndicadorPanel import styleIndicadorPanel
from .panels.stylesTextPanel import styleTextPanel
from .panels.stylesBarPanel import styleBarPanel
from .panels.operations import operations
from .panels.textPanel import textPanel
from .panels.indicadorPanel import indicadorPanel
from .panels.seriesPanel import seriesPanel
from .panels.barrasPanel import barrasPanel
#from .panels.groupPanel6 import groupPanel
from .myUtils.dashColors import dashColors
from .panels.adminPanel import adminPanel
from .calculations import *
from .register import logControl
DialogUi, DialogType=uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'QGIS_Dashboard_dialog_base.ui'))
class dashDialog(DialogUi, DialogType):
"""Construction and management of the panel creation wizard """
def __init__(self,iface,manager):
"""Constructor.
:param mapCanvas Represents a drawing window, it is where the
layers are displayed (raster, vector, ..)..
:type canvas: QgsMapCanvas
"""
super().__init__()
self.setupUi(self) #initializes everything done in QtDesigner
self.dir = os.path.dirname(__file__)
self.posicion='topLeft'
self.setWindowTitle("-----Builder of Dashboard----")
self.npaneles=0
#gestor de paneles
self.manager=manager
self.listaPaneles=[]
#Predefined panel sizes
self.sizesPanels={'Medium':(40,30),'Small':(35,25),'Large':(45,35)}
#iface
self.iface=iface
#MapCanvas
self.canvas=self.iface.mapCanvas()
# self.adminDash=groupPanel(canvas)
#REFERENCE TO THE PROJECT
self.pry=QgsProject.instance()
#MAXIMIZE AND MINIMIZE BUTTON
self.setWindowFlag(Qt.WindowMinimizeButtonHint, True)
self.setWindowFlag(Qt.WindowMaximizeButtonHint, False)
#VARIABLES ICON
self.icono=False
self.ruta_icono=''
#septup dialog Box
#updates the label when changing the number of panels
self.cbnPaneles.currentTextChanged.connect(self.cambioNPaneles)
self.labelNp.textChanged.connect(self.cambioLabel)
#---------------------------------------
self.paginador.setCurrentIndex(0)
self.siguiente.setFlat(False)
self.siguiente.clicked.connect(self.cambiarPagina)
#Set up the Series field list for multiple selections.
self.listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.listWidget2.setSelectionMode(QAbstractItemView.ExtendedSelection)
#LOADING LOGOS AND ICONS
icoTop= QtGui.QPixmap(os.path.join(self.dir,'images','iconTop.png'))
self.l0.setPixmap(icoTop)
self.l0.resize(icoTop.width(),icoTop.height())
self.l0.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
icoBar= QtGui.QPixmap(os.path.join(self.dir,'images','barras.png'))
self.lbar.setPixmap(icoBar)
self.lbar.resize(icoBar.width(),icoBar.height())
self.lbar.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
icoIndi= QtGui.QPixmap(os.path.join(self.dir,'images','indicador.png'))
self.lindicador.setPixmap(icoIndi)
self.lindicador.resize(icoIndi.width(),icoIndi.height())
# self.lindicador.setSizePolicy(QtWidgets.QSizePolicy\
# (QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
icoPanel= QtGui.QPixmap(os.path.join(self.dir,'images','panel.png'))
self.lpanel.setPixmap(icoPanel)
self.lpanel.resize(icoPanel.width(),icoPanel.height())
icoSerie= QtGui.QPixmap(os.path.join(self.dir,'images','serie.png'))
self.lserie.setPixmap(icoSerie)
self.lserie.resize(icoSerie.width(),icoSerie.height())
self.lserie.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
icoCenter= QtGui.QPixmap(os.path.join(self.dir,'images','iconCenter.png'))
# self.lcenter.setPixmap(icoCenter)
# self.lcenter.resize(icoCenter.width(),icoCenter.height())
# self.lcenter.setSizePolicy(QtWidgets.QSizePolicy\
# (QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
#error log
self.log=logControl()
self.logAcces=self.log.canWriteLog()
#GENERAL DASHBOARD SETTINGS
self.checkBoxToolTip.setChecked(False)
self.checkBoxMarco.setChecked(True)
#SETTINGS checkbox of bar, line
self.optColor.setChecked(True)
self.opPalette.setChecked(False)
self.splitTextBar.setChecked(False)
self.opLineStyle.setChecked(True)
self.opAreaStyle.setChecked(False)
self.splitTextLine.setChecked(False)
#Initializing predefined panel sizes
self.cbSizePanel.addItems(self.sizesPanels.keys())
#TOOLBOX BAR PANEL SETTINGS
self.barToolBox.setCurrentIndex(0)
self.modBarras.clear()
self.modBarras.addItems(['Values of a field (Attribute)','Multiple fields'])
self.colorBar.setColor(QColor(111,158,235))
self.colorTitleBar.setColor(QColor('black'))
self.colorLabelBar.setColor(QColor('black'))
self.spTitleSizeBar.setValue(12)
self.spLabelSizeBar.setValue(9)
self.paletteBar.addItems(dashColors.returnPalette())
self.paletteBar.setEnabled(False)
if self.optColor.isChecked()==False:
self.optColor.setChecked(True)
#CONECT EVENTS
self.optColor.toggled.connect(self.cambiarColorBar)
self.opPalette.toggled.connect(self.cambiarColorBar)
#TOOLBOX LINE PANEL SETTINGS
self.lineToolBox.setCurrentIndex(0)
self.colorTitleline.setColor(QColor('black'))
self.labelColorLine.setColor(QColor('black'))
self.spTitleSizeLine.setValue(12)
self.spLabelSizeLine.setValue(9)
if self.opLineStyle.isChecked()==False:
self.opLineStyle.setChecked(True)
#TOOLBOX OF TEXTPANEL SETTINGS
self.tptoolBox.setCurrentIndex(0)#colocamos en modalidad de calculo
self.cbTextPestilo.clear()
self.cbTextPestilo.addItems(styleTextPanel.getTypeStyles())
self.cbTextPestilo.setCurrentIndex(0)
#colores de panel text. Fondos
self.ctitPanelText.setColor(QColor("black"))
self.cconPanelText.setColor(QColor(254,196,79))
#colores de panel text. Textos
self.cTextTitPT.setColor(QColor("white"))
self.cTextConPT.setColor(QColor("black"))
#Colocar icono en panel-------
self.checkBoxIcono.setChecked(False)
self.ubiIcono.setCurrentIndex(0)#por defecto ubica el icono en el centro
self.color_icono.setCurrentIndex(1)#por defecto color invertido
#UBICAR Y CONFIGURAR EL SELECTOR DE ICONOS SVG
self.svg_selector_widget = QgsSvgSelectorWidget()
#EVENTO AL SELECCIONAR UN ICONO
self.svg_selector_widget.svgSelected.connect(self.svg_seleccionado)
self.scrollArea.setWidget(self.svg_selector_widget)
self.svg_selector_widget.show()
#Configuraciones dependiendo del estilo seleccionado
self.cbTextPestilo.currentTextChanged.connect(self.cambioPanelTextEstilo)
self.cbTextPestilo.setCurrentIndex(0)
self.cambioPanelTextEstilo()
#EVENTO CAMBIO CAPA SECUNDARIA
self.cap2PanelTexto.currentTextChanged.connect(self.cambioCapaSecundTextP)
#TOOLBOX INDICATOR PANEL SETTINGS
self.indToolBox.setCurrentIndex(0)
self.cbIndEstilo.clear()
self.cbIndEstilo.addItems(styleIndicadorPanel.getTypeStyles())
self.cbIndEstilo.setCurrentIndex(0)
self.indTitleColor.setColor(QColor("black"))
self.indBaseColor.setColor(QColor("lightGray"))
self.indLineColor.setColor(QColor("red"))
self.indFinalColor.setColor(QColor("darkGray"))
self.indMarkColor.setColor(QColor("red"))
self.indBarColor.setColor(QColor("blue"))
self.indBackColor.setColor(QColor("white"))
self.indColorValue.setColor(QColor("black"))
#BOTONES PARA DEFINIR POSICION
self.posi1=QPushButton('')
self.posi2=QPushButton('')
self.posi3=QPushButton('')
self.posi4=QPushButton('')
self.posi5=QPushButton('')
self.posi6=QPushButton('')
self.configurarPosiciones()
self.cargarCapasCampos()
self.capaSecundariaInd()
self.iniciarModalidad()
self.iniciarModalidadInd()
self.iniciarModalidadBarras()
#Capa secudnaria text panel
self.capaSecundariaTextP()
#---------------------
#EVENTO PROCESAR PANEL
self.procPanelT.clicked.connect(self.procesarTextPanel)
#EVENTO PROCESAR INDICADOR
self.procIndicador.clicked.connect(self.procesarIndicador)
#EVENTO PROCESAR BARRAS
self.procBarras.clicked.connect(self.procesarBarras)
#EVENTO PROCESAR SERIES
self.procSeries.clicked.connect(self.procesarSeries)
#EVENTO ACEPTAR CANCELAR
self.accepted.connect(self.aceptar)
self.rejected.connect(self.cancelar)
#EVENTOS DEL PROYECTO
self.pry.layersWillBeRemoved.connect(self.capaRemovida)
self.pry.layersAdded.connect(self.capaAdicionada)
#TEXT PANEL: configuracion de los tool dependiendo del estilo
def cambioPanelTextEstilo(self):
if self.cbTextPestilo.currentText()=='Separate frames':
self.checkBoxIcono.setEnabled(False)
self.ubiIcono.setEnabled(False)
self.color_icono.setEnabled(False)
self.svg_selector_widget.setEnabled(False)
self.roundFrame.setEnabled(True)
self.cTextTitPT.setEnabled(True);self.cconPanelText.setEnabled(True);self.cTextConPT.setEnabled(True)
elif self.cbTextPestilo.currentText()=='One frame':
self.cTextTitPT.setEnabled(True);self.cconPanelText.setEnabled(False);self.cTextConPT.setEnabled(False)
self.checkBoxIcono.setEnabled(True)
self.ubiIcono.setEnabled(True)
self.color_icono.setEnabled(True)
self.roundFrame.setEnabled(False)
self.svg_selector_widget.setEnabled(True)
elif self.cbTextPestilo.currentText()=='United frames':
self.checkBoxIcono.setEnabled(True)
self.ubiIcono.setEnabled(True)
self.svg_selector_widget.setEnabled(True)
self.color_icono.setEnabled(True)
self.roundFrame.setEnabled(False)
self.cTextTitPT.setEnabled(True);self.cconPanelText.setEnabled(True);self.cTextConPT.setEnabled(True)
#ALMACENA LA RUTA DEL ICONO SELECCIONADO
def svg_seleccionado(self,path):
self.ruta_icono=path
#CUANDO EL NUMERO DE PANELES SEA 0, BLOQUEA PROCESAR
def cambioLabel(self,e):
if int(e)==0:
self.procPanelT.setEnabled(False)
self.procIndicador.setEnabled(False)
self.procBarras.setEnabled(False)
self.procSeries.setEnabled(False)
def aceptar(self):
if len(self.listaPaneles) >0:
try:
self.manager.posicion=self.posicion
self.manager.init(self.canvas)
ancho= self.sizesPanels[self.cbSizePanel.currentText()][0]
alto= self.sizesPanels[self.cbSizePanel.currentText()][1]
self.manager.initPlacePanels(ancho,alto)
self.manager.addPanels(self.listaPaneles)
#Verificamos si el check del borde esta checkeado o no
if self.checkBoxMarco.isChecked()==False:
self.manager.globalBordeMarco=False
if self.checkBoxToolTip.isChecked()==True:
self.manager.globalToolTip=True
self.manager.placePanels()
except Exception as e:
if self.logAcces:
self.log.writeLog(str(e))
def cancelar(self):
self.listaPaneles.clear()
# print('cancelar')
def procesarSeries(self):
#CREAMOS EL GRAFICO
titulo=self.lineEdit.text()
if titulo=='':
titulo='Serie of data'
items=self.listWidget.selectedItems()
camposn=[i.text() for i in items]
campox=self.camXSeries.currentText()
ancho= self.sizesPanels[self.cbSizePanel.currentText()][0]
alto= self.sizesPanels[self.cbSizePanel.currentText()][1]
if len(camposn)>1:
#Disminuimos el numero de paneles disponibles
np=int(self.labelNp.text())-1
self.labelNp.setText(str(np))
if self.opLineStyle.isChecked():
fill=False
else:
fill=True
if self.splitTextLine.isChecked():
wordBreak=True
else:
wordBreak=False
# try:
tp=seriesPanel(self.capa,[camposn,campox],title=titulo,fill=fill,wordBreak=wordBreak,\
widthline=self.widthLine.value(),colorTit=self.colorTitleline.color(),\
sizeTitle=self.spTitleSizeLine.value(),colorLabels=self.labelColorLine.color(),\
sizeLabels=self.spLabelSizeLine.value(),anchoP=ancho,altoP=alto)
# except Exception as e:
# if self.logAcces:
# self.log.writeLog(str(e))
# try:
self.listaPaneles.append(tp)
# except Exception as e:
# print(str(e))
# if self.logAcces:
# self.log.writeLog(str(e))
def procesarBarras(self):
#CREAMOS EL GRAFICO
titulo=self.lineEdit.text()
if self.opPalette.isChecked():
typeColor='palette'
else:
typeColor='unicolor'
if self.splitTextBar.isChecked():
wordBreak=True
else:
wordBreak=False
if titulo=='':
titulo='Bar Graphic'
#Dimensiones
ancho= self.sizesPanels[self.cbSizePanel.currentText()][0]
alto= self.sizesPanels[self.cbSizePanel.currentText()][1]
try:
if self.modBarras.currentText()=='Values of a field (Attribute)':
campox=self.camXBar.currentText()
campoy=self.camYBar.currentText()
print('value a field',campox,campoy)
if len(campox)>0 and len(campoy)>0:
tp=barrasPanel(self.capa,'atributo-sum',titulo,[campox,campoy],\
colorBar=self.colorBar.color(),colorTit=self.colorTitleBar.color(),typeColor=typeColor,\
wordBreak=wordBreak,sizeTitle=self.spTitleSizeBar.value(),sizeLabels=self.spLabelSizeBar.value(),\
colorLabels=self.colorLabelBar.color(),palette=self.paletteBar.currentText(),\
anchoP=ancho,altoP=alto)
elif self.modBarras.currentText()=='Multiple fields':
items=self.listWidget2.selectedItems()
campos=[i.text() for i in items]
print('en multiple fields',campos)
if len(campos)>1:
tp=barrasPanel(self.capa,'multiple_fields',titulo,[campos],\
colorBar=self.colorBar.color(),colorTit=self.colorTitleBar.color(),typeColor=typeColor,\
wordBreak=wordBreak,sizeTitle=self.spTitleSizeBar.value(),sizeLabels=self.spLabelSizeBar.value(),\
colorLabels=self.colorLabelBar.color(),palette=self.paletteBar.currentText(),\
anchoP=ancho,altoP=alto)
except Exception as e:
print(str(e))
if self.logAcces:
self.log.writeLog(str(e))
try:
self.listaPaneles.append(tp)
#Disminuimos el numero de paneles disponibles
np=int(self.labelNp.text())-1
self.labelNp.setText(str(np))
except Exception as e:
if self.logAcces:
self.log.writeLog(str(e))
def cambiarColorBar(self):
if self.sender()==self.optColor:
self.colorBar.setEnabled(True)
self.paletteBar.setEnabled(False)
elif self.sender()==self.opPalette:
self.colorBar.setEnabled(False)
self.paletteBar.setEnabled(True)
def procesarTextPanel(self):
#CREAMOS EL PANEL
titulo=self.lineEdit.text()
if titulo=='':
titulo='Text Panel'
capa=self.capa.name()
modo=self.cbModoPanelT.currentText()
estilot=self.cbTextPestilo.currentText()
#Verifcamos el icono
if self.ubiIcono.currentText()=='Right':
direcIcono='right'
elif self.ubiIcono.currentText()=='Left':
direcIcono='left'
else:
direcIcono='center'
if self.color_icono.currentText()=='Normal':
self.colorIcono=0
else:
self.colorIcono=1
#Dimensiones
ancho= self.sizesPanels[self.cbSizePanel.currentText()][0]
alto= self.sizesPanels[self.cbSizePanel.currentText()][1]
try:
if modo=='Total selected entities':
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa, 'entid_seleccionadas', titulo,[],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono),anchoP=ancho,altoP=alto)
else:
tp=textPanel(self.capa, 'entid_seleccionadas', titulo,[],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Percentage':
campo=self.cam1PanelTexto.currentText()
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'Porcentaje',titulo,[campo],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono),anchoP=ancho,altoP=alto)
else:
tp=textPanel(self.capa,'Porcentaje',titulo,[campo],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Sum of an attribute':
campo=self.cam1PanelTexto.currentText()
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'atributo',titulo,[campo],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono),anchoP=ancho,altoP=alto)
else:
tp=textPanel(self.capa,'atributo',titulo,[campo],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Statistics. Selected entities':
campo=self.cam1PanelTexto.currentText()
operador=self.operadorPanelT.currentText()
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'math-atributo',titulo,[campo,operador],
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono),anchoP=ancho,altoP=alto)
else:
tp=textPanel(self.capa,'math-atributo',titulo,[campo,operador],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Statistics. Selection that coincides with':
campo=self.cam1PanelTexto.currentText()
operador=self.operadorPanelT.currentText()
campos=self.cam2PanelTexto.currentText()
atrib=self.lineE1.text()
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(capa,'math-atributo',titulo,[campo,operador,campos,atrib],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono),anchoP=ancho,altoP=alto)
else:
tp=textPanel(self.capa,'math-atributo',titulo,[campo,operador,campos,atrib],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Entities contained in selection':
capa2=self.cap2PanelTexto.currentText()
if self.capa==self.cap2PanelTexto.currentData():
self.iface.messageBar().pushMessage('ERROR',\
'Select a different layer than the main layer', level=Qgis.Warning, duration=7)
else:
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa, 'entid-selec-intersect', titulo,[capa2],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono),anchoP=ancho,altoP=alto)
else:
tp=textPanel(self.capa, 'entid-selec-intersect', titulo,[capa2],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Entities contained. count by attribute that coincides with':
capa2=self.cap2PanelTexto.currentText()
campo2=self.cam3PanelTexto.currentText()
valor=self.lineE1.text()
if self.capa==self.cap2PanelTexto.currentData():
self.iface.messageBar().pushMessage('ERROR',\
'Select a different layer than the main layer', level=Qgis.Warning, duration=7)
else:
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'entid-selec-intersect-atrib', titulo,\
[capa2,campo2,valor],fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,anchoP=ancho,altoP=alto,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono))
else:
tp=textPanel(self.capa, 'entid-selec-intersect-atrib', titulo,[capa2,campo2,valor],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Number of entities in the area. Density':
capa2=self.cap2PanelTexto.currentText()
crs=self.capa.crs()
if self.capa==self.cap2PanelTexto.currentData():
self.iface.messageBar().pushMessage('ERROR',\
'Select a different layer than the main layer', level=Qgis.Warning, duration=7)
else:
if crs.isGeographic():
self.iface.messageBar().pushMessage('Layer in geographic coordinates',\
'The main layer is in geographic coordinates. Lat/Long The value will be processed in degrees', level=Qgis.Info, duration=7)
unidad=1
else:
if crs.mapUnits() != QgsUnitTypes.DistanceMeters:
self.iface.messageBar().pushMessage('Coordinate units will be considered in meters',\
'For now, only units of the coordinate system in meters are considered', level=Qgis.Info, duration=7)
unidad=self.tpUnit.currentText()
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'densidad', titulo,\
[capa2,unidad],fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,anchoP=ancho,altoP=alto,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono))
else:
tp=textPanel(self.capa, 'densidad', titulo,[capa2,unidad],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Sum of attribute between area. Density':
capa2=self.cap2PanelTexto.currentText()
campo2=self.cam3PanelTexto.currentText()
crs=self.capa.crs()
if self.capa==self.cap2PanelTexto.currentData():
self.iface.messageBar().pushMessage('ERROR',\
'Select a different layer than the main layer', level=Qgis.Warning, duration=7)
else:
if crs.isGeographic():
self.iface.messageBar().pushMessage('Layer in geographic coordinates',\
'The main layer is in geographic coordinates. Lat/Long The value will be processed in degrees', level=Qgis.Info, duration=7)
unidad=1
else:
if crs.mapUnits() != QgsUnitTypes.DistanceMeters:
self.iface.messageBar().pushMessage('Coordinate units will be considered in meters',\
'For now, only units of the coordinate system in meters are considered', level=Qgis.Info, duration=7)
unidad=self.tpUnit.currentText()
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'densidad valor', titulo,\
[capa2,unidad,campo2],fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,anchoP=ancho,altoP=alto,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono))
else:
tp=textPanel(self.capa, 'densidad valor', titulo,[capa2,unidad,campo2],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Entities contained at a distance. Buffer':
capa2=self.cap2PanelTexto.currentText()
dist=self.bufferDistance.value()
crs=self.capa.crs()
if self.capa==self.cap2PanelTexto.currentData():
self.iface.messageBar().pushMessage('ERROR',\
'Select a different layer than the main layer', level=Qgis.Warning, duration=7)
else:
if crs.isGeographic():
self.iface.messageBar().pushMessage('Layer in geographic coordinates',\
'The main layer is in geographic coordinates. Lat/Long The value will'+\
'be processed in degrees', level=Qgis.Info, duration=7)
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'buffer-contains', titulo,\
[capa2,dist],fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,anchoP=ancho,altoP=alto,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono))
else:
tp=textPanel(self.capa, 'buffer-contains', titulo,[capa2,dist],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Entities contained at a distance that coincides with':
capa2=self.cap2PanelTexto.currentText()
dist=self.bufferDistance.value()
campo2=self.cam3PanelTexto.currentText()
valor=self.lineE1.text()
crs=self.capa.crs()
if self.capa==self.cap2PanelTexto.currentData():
self.iface.messageBar().pushMessage('ERROR',\
'Select a different layer than the main layer', level=Qgis.Warning, duration=7)
else:
if crs.isGeographic():
self.iface.messageBar().pushMessage('Layer in geographic coordinates',\
'The main layer is in geographic coordinates. Lat/Long The value will'+\
'be processed in degrees', level=Qgis.Info, duration=7)
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'buffer-contains-attrib', titulo,\
[capa2,dist,campo2,valor],fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,anchoP=ancho,altoP=alto,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono))
else:
tp=textPanel(self.capa,'buffer-contains-attrib', titulo,[capa2,dist,campo2,valor],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
elif modo=='Sum of attributes of entities contained at a distance':
capa2=self.cap2PanelTexto.currentText()
dist=self.bufferDistance.value()
campo2=self.cam3PanelTexto.currentText()
layer2=self.cap2PanelTexto.currentData()
fields=layer2.fields()
field=fields.field(campo2)
crs=self.capa.crs()
if self.capa==self.cap2PanelTexto.currentData():
self.iface.messageBar().pushMessage('ERROR',\
'Select a different layer than the main layer', level=Qgis.Warning, duration=7)
elif field.isNumeric() == False:
self.iface.messageBar().pushMessage('ERROR',\
'Select a numeric field', level=Qgis.Warning, duration=7)
else:
if crs.isGeographic():
self.iface.messageBar().pushMessage('Layer in geographic coordinates',\
'The main layer is in geographic coordinates. Lat/Long The value will'+\
'be processed in degrees', level=Qgis.Info, duration=7)
if self.checkBoxIcono.isChecked()==True and os.path.exists(self.ruta_icono) and\
self.cbTextPestilo.currentText()!='Separate frames':
tp=textPanel(self.capa,'buffer-contains-sum', titulo,\
[capa2,dist,campo2,''],fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
estilo=estilot,icono=True,rutaIcono=self.ruta_icono,anchoP=ancho,altoP=alto,\
direccionIcono=direcIcono,colorIcono=str(self.colorIcono))
else:
tp=textPanel(self.capa,'buffer-contains-sum', titulo,[capa2,dist,campo2,''],\
fondTit=self.ctitPanelText.color(),colorTextTit=self.cTextTitPT.color(),\
fondVal=self.cconPanelText.color(),colorTextVal=self.cTextConPT.color(),\
suavizado=self.roundFrame.value(),estilo=estilot,anchoP=ancho,altoP=alto)
if type(tp)==textPanel:
self.listaPaneles.append(tp)
#Disminuimos el numero de paneles disponibles
np=int(self.labelNp.text())-1
self.labelNp.setText(str(np))
except Exception as e:
print(str(e))
if self.logAcces:
self.log.writeLog(str(e))
#Modalidades en PANEL TEXT: Total entidades seleccionadas,
#Suma de un atributo,Estadistica. Entidades seleccionadas,
#Estadistica selección que coincide con
def iniciarModalidad(self):
indice=self.cbModoPanelT.findText('Total selected entities')
self.cbModoPanelT.setCurrentIndex(indice)
self.cam1PanelTexto.setEnabled(False)
self.cam2PanelTexto.setEnabled(False)
self.cam3PanelTexto.setEnabled(False)
self.cap2PanelTexto.setEnabled(False)
self.lineE1.setEnabled(False)
self.operadorPanelT.setEnabled(False)
self.bufferDistance.setEnabled(False)
self.tpUnit.setEnabled(False)
#EVENTOS
self.cbModoPanelT.currentTextChanged.connect(self.cambioModo)
#INICIAR Modalidades en GRAFICO BARRAS
def iniciarModalidadBarras(self):
indice=self.modBarras.findText('Values of a field (Attribute)')
self.modBarras.setCurrentIndex(indice)
self.listWidget2.setEnabled(False)
#EVENTOS
self.modBarras.currentTextChanged.connect(self.cambioModoBarras)
#Evento cambio de modalidad Grafico de Barras
def cambioModoBarras(self):
modo=self.modBarras.currentText()
if modo=='Values of a field (Attribute)':
self.listWidget2.setEnabled(False)
self.camXBar.setEnabled(True)
self.camYBar.setEnabled(True)
elif modo=='Multiple fields':
self.listWidget2.setEnabled(True)
self.camXBar.setEnabled(False)
self.camYBar.setEnabled(False)
def cargarCapasCampos(self):
#Cargamos las capas presentes en el mapa
listacapas= self.pry.mapLayers().values() #Lista de capas
#------Filtramos y guardamos solo las capas Vector--------
#------Utilizaremos las listas para cargar los combo Box--------
self.listC=[] #Lista de capas vectoriales
for i in listacapas:
try:
if i.type()==QgsMapLayer.VectorLayer or isinstance(i,QgsVectorLayer):
if i.featureCount()>0:
self.listC.append(i)
except Exception as e:
if self.logAcces:
self.log.writeLog(e)
#Si no hay capas cerrar
if len(self.listC)==0:
self.cierre()
else:
for i in self.listC:
self.lc.addItem(i.name(),i)
#Llenamos las listas de campos
self.capa= self.lc.currentData()
qfields=self.capa.fields()
if qfields.count()>0:
for i in qfields.toList():
if i.isNumeric():
self.cam1Ind.addItem(i.name()) #indicador
self.cam1PanelTexto.addItem(i.name())#panel texto
self.camYBar.addItem(i.name()) #campo categorico grafico barras
self.listWidget.addItem(i.name())#lista de campos numericos para grafico series
self.listWidget2.addItem(i.name())#lista de campos numericos para grafico Barras
else:
self.cam2Ind.addItem(i.name())#campo2 indicador
self.cam2PanelTexto.addItem(i.name())#panel texto
self.camXBar.addItem(i.name())
self.camXSeries.addItem(i.name())#campo categorico grafico series
#CONECTAR EVENTOS
self.lc.currentTextChanged.connect(self.cambioCapa)
self.updateOperations()
def cambioCapa(self):
if self.lc.count()==0 or self.lc.currentText()is "":
self.cierre()
else:
self.capa=self.lc.currentData()
self.cam1PanelTexto.clear()#vaciamos el listado de campos principal
self.cam2PanelTexto.clear()#vaciamos el listado de campos secundario
self.listWidget.clear()
self.listWidget2.clear()
self.camXSeries.clear()
self.cam1Ind.clear()
self.cam2Ind.clear()
self.camYBar.clear()
self.camXBar.clear()
qfields=self.capa.fields()
if qfields.count()>0:
for i in qfields.toList():
if i.isNumeric():
self.cam1PanelTexto.addItem(i.name())#indicador
self.cam1Ind.addItem(i.name())#panel texto
self.camYBar.addItem(i.name())
self.listWidget.addItem(i.name())
self.listWidget2.addItem(i.name())
else:
self.cam2Ind.addItem(i.name())#campo2 indicador
self.cam2PanelTexto.addItem(i.name())
self.camXBar.addItem(i.name())
self.camXSeries.addItem(i.name())
self.updateOperations()
#ACTUALIZAMOS EL LISTADO DE OPERACIONES DE TEXT PANEL DEACUERDO AL TIPO DE CAPA
def updateOperations(self):
capa=self.capa
tipoGeom=capa.geometryType()
try:
if capa.isSpatial()==False:
self.cbModoPanelT.clear()
self.cbModoInd.clear()
listaFunciones=operations.getOperation('no spatial')
self.cbModoPanelT.addItems(listaFunciones)
listaFunInd=operations.getOperation('ind no spatial')
self.cbModoInd.addItems(listaFunInd)
else:
if tipoGeom==QgsWkbTypes.PointGeometry or tipoGeom==QgsWkbTypes.LineGeometry:
self.cbModoPanelT.clear()
self.cbModoInd.clear()
listaFunciones=operations.getOperation('line or point')
self.cbModoPanelT.addItems(listaFunciones)
listaFunInd=operations.getOperation('ind line or point')
self.cbModoInd.addItems(listaFunInd)
elif tipoGeom==QgsWkbTypes.PolygonGeometry:
self.cbModoPanelT.clear()
self.cbModoInd.clear()
listaFunciones=operations.getOperation('polygon')
self.cbModoPanelT.addItems(listaFunciones)
listaFunInd=operations.getOperation('ind polygon')
self.cbModoInd.addItems(listaFunInd)
except Exception as e:
if self.logAcces:
self.log.writeLog(e)
#enviar un message bar capa no reconocida
#DEFINIMOS LA CAPA SECUNDARIA DE TEXT PANEL. LA CAPA QUE INTERSECTA
def capaSecundariaTextP(self):
if self.lc.count()>0 or self.lc.currentText()!= "":
self.cap2PanelTexto.clear()
capaPrincipal=self.lc.currentData()
for i in self.listC:
# if i!=capaPrincipal:
try:
if i.isSpatial():
self.cap2PanelTexto.addItem(i.name(),i)
except:
pass
capa2=self.cap2PanelTexto.currentData()
qfields=capa2.fields()
self.cam3PanelTexto.clear()
if qfields.count()>0:
for i in qfields.toList():
self.cam3PanelTexto.addItem(i.name())
#Evento cuando seleccionamos otra capa secundaria.Text Panel
def cambioCapaSecundTextP(self):
if self.cap2PanelTexto.count()>0:
# print('n lista capas2 ',self.cap2PanelTexto.count())
capa2=self.cap2PanelTexto.currentData()
# print(capa2)
qfields=capa2.fields()
self.cam3PanelTexto.clear()
if qfields.count()>0:
for i in qfields.toList():
self.cam3PanelTexto.addItem(i.name())
#DEFINIMOS LA CAPA SECUNDARIA DE INDICADOR. LA CAPA QUE INTERSECTA
def capaSecundariaInd(self):
if self.lc.count()>0 or self.lc.currentText()!= "":
self.capa2ind.clear()
for i in self.listC:
# if i!=capaPrincipal:
try:
if i.isSpatial():
self.capa2ind.addItem(i.name(),i)
except:
pass
#Llenamos las listas de campos
capa2=self.capa2ind.currentData()
qfields=capa2.fields()
self.cam2Ind.clear()
if qfields.count()>0:
for i in qfields.toList():
self.cam2Ind.addItem(i.name())
self.capa2ind.currentTextChanged.connect(self.cambioCapaSecund)
#Evento cuando seleccionamos otra capa secundaria.indicador
def cambioCapaSecund(self):
if self.capa2ind.count()>0:
capa=self.capa2ind.currentData()
self.cam2Ind.clear()#vaciamos el listado de campos principal
qfields=capa.fields()
if qfields.count()>0:
for i in qfields.toList():
self.cam2Ind.addItem(i.name())#indicador
def nombreCapaCambio(self):
pass
def cierre(self):
self.close()
def cambiarPagina(self,e):
self.paginador.setCurrentIndex(1)
self.npaneles=self.cbnPaneles.currentText()
self.labelNp.setText(str(self.npaneles))
def cambioNPaneles(self):
self.npaneles=self.cbnPaneles.currentText()
self.labelNp.setText(str(self.npaneles))
def configurarPosiciones(self):
css = """
QGroupBox{
color:white;}"""
self.posiciones.setStyleSheet(css)
grid = QGridLayout()
grid.setContentsMargins(2,2,2,2)
self.iupposi1=QIcon(os.path.join(self.dir,'images','b1.png'))
self.idposi1=QIcon(os.path.join(self.dir,'images','b1a.png'))
self.posi1.setIcon(self.idposi1)
self.posi1.setIconSize(QSize(100,70))
self.posi1.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
grid.addWidget(self.posi1,0,0)
self.iupposi2=QIcon(os.path.join(self.dir,'images','b2.png'))
self.idposi2=QIcon(os.path.join(self.dir,'images','b2a.png'))
self.posi2.setIcon(self.iupposi2)
self.posi2.setIconSize(QSize(100,70))
self.posi2.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
grid.addWidget(self.posi2,0,1)
self.iupposi3=QIcon(os.path.join(self.dir,'images','b3.png'))
self.idposi3=QIcon(os.path.join(self.dir,'images','b3a.png'))
self.posi3.setIcon(self.iupposi3)
self.posi3.setIconSize(QSize(100,70))
self.posi3.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
grid.addWidget(self.posi3,1,0)
self.iupposi4=QIcon(os.path.join(self.dir,'images','b4.png'))
self.idposi4=QIcon(os.path.join(self.dir,'images','b4a.png'))
self.posi4.setIcon(self.iupposi4)
self.posi4.setIconSize(QSize(100,70))
self.posi4.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
grid.addWidget(self.posi4,1,1)
self.iupposi5=QIcon(os.path.join(self.dir,'images','b5.png'))
self.idposi5=QIcon(os.path.join(self.dir,'images','b5a.png'))
self.posi5.setIcon(self.iupposi5)
self.posi5.setIconSize(QSize(100,70))
self.posi5.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
grid.addWidget(self.posi5,2,0)
self.iupposi6=QIcon(os.path.join(self.dir,'images', 'b6.png'))
self.idposi6=QIcon(os.path.join(self.dir,'images', 'b6a.png'))
self.posi6.setIcon(self.iupposi6)
self.posi6.setIconSize(QSize(100,70))
self.posi6.setSizePolicy(QtWidgets.QSizePolicy\
(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding))
grid.addWidget(self.posi6,2,1)
self.posiciones.setLayout(grid)
self.posiciones.setAutoFillBackground(True)
palette = self.posiciones.palette()
palette.setColor(QPalette.Window, QColor('black'))
self.posiciones.setPalette(palette)
#EVENTOS DE LOS BOTONES
self.posi1.clicked.connect(self.defPosi1)
self.posi2.clicked.connect(self.defPosi2)
self.posi3.clicked.connect(self.defPosi3)
self.posi4.clicked.connect(self.defPosi4)
self.posi5.clicked.connect(self.defPosi5)
self.posi6.clicked.connect(self.defPosi6)
def defPosi1(self,e):
if self.posicion!='topLeft':
self.posicion='topLeft'
self.posi1.setIcon(self.idposi1)
self.posi2.setIcon(self.iupposi2)
self.posi3.setIcon(self.iupposi3)
self.posi4.setIcon(self.iupposi4)
self.posi5.setIcon(self.iupposi5)
self.posi6.setIcon(self.iupposi6)
def defPosi2(self,e):
if self.posicion!='topRight':
self.posicion='topRight'
self.posi1.setIcon(self.iupposi1)
self.posi2.setIcon(self.idposi2)
self.posi3.setIcon(self.iupposi3)
self.posi4.setIcon(self.iupposi4)
self.posi5.setIcon(self.iupposi5)
self.posi6.setIcon(self.iupposi6)
def defPosi3(self,e):
if self.posicion!='bottomLeft':
self.posicion='bottomLeft'
self.posi1.setIcon(self.iupposi1)
self.posi2.setIcon(self.iupposi2)
self.posi3.setIcon(self.idposi3)
self.posi4.setIcon(self.iupposi4)
self.posi5.setIcon(self.iupposi5)
self.posi6.setIcon(self.iupposi6)
def defPosi4(self,e):
if self.posicion!='bottomRight':
self.posicion='bottomRight'
self.posi1.setIcon(self.iupposi1)
self.posi2.setIcon(self.iupposi2)
self.posi3.setIcon(self.iupposi3)
self.posi4.setIcon(self.idposi4)
self.posi5.setIcon(self.iupposi5)
self.posi6.setIcon(self.iupposi6)
def defPosi5(self,e):
if self.posicion!='horizontalTop':
self.posicion='horizontalTop'
self.posi1.setIcon(self.iupposi1)
self.posi2.setIcon(self.iupposi2)
self.posi3.setIcon(self.iupposi3)
self.posi4.setIcon(self.iupposi4)
self.posi5.setIcon(self.idposi5)
self.posi6.setIcon(self.iupposi6)
def defPosi6(self,e):
if self.posicion!='horizontalBottom':