Skip to content

Commit

Permalink
Merge pull request #2710 from btbest/restyle-label-table
Browse files Browse the repository at this point in the history
* Restyle label list GUI to use the available width, ellipsis for long label names, minus icon instead of drawing a cross-icon
* Unify setting the "Size:" label text for the brush size
* Remove some unused icon files
  • Loading branch information
btbest committed Jun 12, 2023
2 parents d3d28f7 + de0d0fe commit fccb7dc
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 59 deletions.
2 changes: 1 addition & 1 deletion ilastik/applets/counting/countingDrawer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<item>
<widget class="QLabel" name="brushSizeCaption">
<property name="text">
<string>brush size:</string>
<string>Size:</string>
</property>
</widget>
</item>
Expand Down
7 changes: 0 additions & 7 deletions ilastik/applets/counting/countingGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,14 +927,7 @@ def _gui_setNavigation(self):
self._labelControlUi.arrowToolButton.setChecked(True)

def _gui_setBrushing(self):
# self._labelControlUi.brushSizeComboBox.setEnabled(False)
# self._labelControlUi.brushSizeCaption.setEnabled(False)
# Make sure the paint button is pressed
self._labelControlUi.paintToolButton.setChecked(True)
# Show the brush size control and set its caption
self._labelControlUi.brushSizeCaption.setText("Size:")
# Make sure the GUI reflects the correct size
# self._labelControlUi.brushSizeComboBox.setCurrentIndex(0)

def _gui_setBox(self):
self._labelControlUi.brushSizeComboBox.setEnabled(False)
Expand Down
6 changes: 0 additions & 6 deletions ilastik/applets/labeling/labelingGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,23 +625,17 @@ def _gui_setErasing(self):
self._labelControlUi.brushSizeComboBox.setEnabled(True)
self._labelControlUi.brushSizeCaption.setEnabled(True)
self._labelControlUi.eraserToolButton.setChecked(True)
self._labelControlUi.brushSizeCaption.setText("Size:")
self._labelControlUi.brushSizeComboBox.setCurrentIndex(self.eraserSizeIndex)

def _gui_setNavigation(self):
self._labelControlUi.brushSizeComboBox.setEnabled(False)
self._labelControlUi.brushSizeCaption.setEnabled(False)
self._labelControlUi.arrowToolButton.setChecked(True)
# self._labelControlUi.arrowToolButton.setChecked(True) # why twice?

def _gui_setBrushing(self):
self._labelControlUi.brushSizeComboBox.setEnabled(True)
self._labelControlUi.brushSizeCaption.setEnabled(True)
# Make sure the paint button is pressed
self._labelControlUi.paintToolButton.setChecked(True)
# Show the brush size control and set its caption
self._labelControlUi.brushSizeCaption.setText("Size:")
# Make sure the GUI reflects the correct size
self._labelControlUi.brushSizeComboBox.setCurrentIndex(self.paintBrushSizeIndex)

def _gui_enableLabeling(self, enable):
Expand Down
2 changes: 1 addition & 1 deletion ilastik/applets/neuralNetwork/nnClass.ui
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<item>
<widget class="QLabel" name="brushSizeCaption">
<property name="text">
<string>brush size:</string>
<string>Size:</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion ilastik/applets/objectClassification/labelingDrawer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
<item>
<widget class="QLabel" name="brushSizeCaption">
<property name="text">
<string>brush size:</string>
<string>Size:</string>
</property>
</widget>
</item>
Expand Down
Binary file removed ilastik/applets/pixelClassification/icons/arrow.jpg
Binary file not shown.
Binary file removed ilastik/applets/pixelClassification/icons/arrow.png
Binary file not shown.
Binary file removed ilastik/applets/pixelClassification/icons/eraser.png
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion ilastik/applets/pixelClassification/labelingDrawer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<item>
<widget class="QLabel" name="brushSizeCaption">
<property name="text">
<string>brush size:</string>
<string>Size:</string>
</property>
</widget>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<item>
<widget class="QLabel" name="brushSizeCaption">
<property name="text">
<string>brush size:</string>
<string>Size:</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -175,4 +175,4 @@
</customwidgets>
<resources/>
<connections/>
</ui>
</ui>
25 changes: 4 additions & 21 deletions ilastik/widgets/listModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# on the ilastik web site at:
# http://ilastik.org/license.html
###############################################################################
from PyQt5.QtGui import QColor, QPixmap, QIcon, QPainter, QPen, QImage
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QObject, QAbstractTableModel, QItemSelectionModel, Qt, QModelIndex, pyqtSignal
from ilastik.shell.gui.iconMgr import ilastikIcons

import logging

Expand Down Expand Up @@ -129,7 +130,7 @@ def selectedIndex(self):
def rowCount(self, parent=None):
return len(self._elements)

def columnCount(self, parent):
def columnCount(self, parent=None):
return self.ColumnID.ncols

def _getToolTipSuffix(self, row):
Expand Down Expand Up @@ -221,25 +222,7 @@ def data(self, index, role):
if index.row() in self.unremovable_rows:
return

row = index.row()
pixmap = QPixmap(_NPIXELS, _NPIXELS)
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
painter.setRenderHint(QPainter.Antialiasing)
painter.setBrush(QColor("red"))
painter.drawEllipse(1, 1, _NPIXELS - 2, _NPIXELS - 2)
pen = QPen(QColor("black"))
pen.setWidth(2)
painter.setPen(pen)

x = _XSTART
y = _NPIXELS - x
painter.drawLine(x, x, y, y)
painter.drawLine(y, x, x, y)

painter.end()
icon = QIcon(pixmap)
icon = QIcon(ilastikIcons.RemSel)
return icon

def flags(self, index):
Expand Down
33 changes: 16 additions & 17 deletions ilastik/widgets/listView.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# http://ilastik.org/license.html
###############################################################################
from builtins import range
import os
from PyQt5.QtWidgets import QTableView, QAbstractItemView, QHeaderView, QStackedWidget, QLabel, QSizePolicy
from PyQt5.QtCore import Qt

Expand Down Expand Up @@ -61,38 +60,38 @@ def tableViewCellClicked(self, modelIndex):
:param modelIndex:
"""

# if (modelIndex.column() == self.model.ColumnID.Delete and
# not self._table.model().flags(modelIndex) == Qt.NoItemFlags):
# self._table.model().removeRow(modelIndex.row())
#
def tableViewCellDoubleClicked(self, modelIndex):
"""
Reimplement this function to get interaction when single click
:param modelIndex:
"""

# if modelIndex.column() == self.model.ColumnID.Color:
# self._colorDialog.setBrushColor(self._table.model()[modelIndex.row()].brushColor())
# self._colorDialog.setPmapColor (self._table.model()[modelIndex.row()].pmapColor())
# self._colorDialog.exec_()
# #print "brush color = {}".format(self._colorDialog.brushColor().name())
# #print "pmap color = {}".format(self._colorDialog.pmapColor().name())
# self._table.model().setData(modelIndex, (self._colorDialog.brushColor(),
# self._colorDialog.pmapColor ()))

def rowMovedTest(self, logicalIndex, oldVisualIndex, newVisualIndex):
logger.debug("{} {} {}".format(logicalIndex, oldVisualIndex, newVisualIndex))

def _setListViewLook(self):
if self.model.columnCount() < 3:
raise NotImplementedError("_setListViewLook can only be used for label tables with >=3 columns")
table = self._table
# table.setDragEnabled(True)
table.setStyleSheet(
"""
QTableView { padding-left: 3px; background-color: white; }
QTableView::item { padding: 4px; }
"""
) # item.padding does not affect all four sides of table cells
table.setAcceptDrops(True)
table.setFocusPolicy(Qt.NoFocus)
table.setShowGrid(False)
table.horizontalHeader().hide()
table.verticalHeader().hide()
# table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
table.horizontalHeader().setMinimumSectionSize(1)
sectionResizeModes = {
self.model.ColumnID.Color: QHeaderView.ResizeToContents,
self.model.ColumnID.Name: QHeaderView.Stretch,
self.model.ColumnID.Delete: QHeaderView.ResizeToContents,
}
for column, mode in sectionResizeModes.items():
table.horizontalHeader().setSectionResizeMode(column, mode)

table.setSelectionMode(QAbstractItemView.SingleSelection)
table.setSelectionBehavior(QAbstractItemView.SelectRows)
Expand Down
2 changes: 1 addition & 1 deletion ilastik/workflows/carving/carvingDrawer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<item row="1" column="0">
<widget class="QLabel" name="brushSizeCaption">
<property name="text">
<string>brush size:</string>
<string>Size:</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion ilastik/workflows/voxelSegmentation/labelingDrawer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<item>
<widget class="QLabel" name="brushSizeCaption">
<property name="text">
<string>brush size:</string>
<string>Size:</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit fccb7dc

Please sign in to comment.