Skip to content

Commit

Permalink
added select all/none to clear LWT dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
jziolkowski committed Nov 21, 2019
1 parent 9735af4 commit b09e341
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions GUI/ClearLWT.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyQt5.QtCore import QSize, Qt
from PyQt5.QtWidgets import QDialog, QPushButton, QDialogButtonBox, QListWidget, QListWidgetItem, QLabel
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QListWidget, QListWidgetItem, QLabel

from GUI import VLayout, GroupBoxV, HLayout, GroupBoxH
from GUI import VLayout


class ClearLWTDialog(QDialog):
Expand All @@ -14,18 +14,29 @@ def __init__(self, env, *args, **kwargs):

vl = VLayout()

sel_btns = QDialogButtonBox()
sel_btns.setCenterButtons(True)
btnSelAll = sel_btns.addButton("Select all", QDialogButtonBox.ActionRole)
btnSelNone = sel_btns.addButton("Select none", QDialogButtonBox.ActionRole)

self.lw = QListWidget()

for lwt in self.env.lwts:
itm = QListWidgetItem(lwt)
itm.setCheckState(Qt.Checked)
itm.setCheckState(Qt.Unchecked)
self.lw.addItem(itm)

btnSelAll.clicked.connect(lambda: self.select(Qt.Checked))
btnSelNone.clicked.connect(lambda: self.select(Qt.Unchecked))

btns = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close)
btns.accepted.connect(self.accept)
btns.rejected.connect(self.reject)

vl.addWidgets([QLabel("Select LWTs to be cleared:"), self.lw, btns])
vl.addWidgets([sel_btns, self.lw, btns])
self.setLayout(vl)


def select(self, state):
for row in range(self.lw.count()):
itm = self.lw.item(row)
itm.setCheckState(state)

0 comments on commit b09e341

Please sign in to comment.