Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
LETG
Rename bands
Commits
9346e020
Commit
9346e020
authored
Sep 14, 2021
by
PIERSON Julie
Browse files
removing add button for adding a row in table
parent
3f5aba9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
27 deletions
+16
-27
BandTableWidget.py
BandTableWidget.py
+11
-17
bandtablewidgetbase.ui
bandtablewidgetbase.ui
+5
-10
No files found.
BandTableWidget.py
View file @
9346e020
...
...
@@ -56,7 +56,6 @@ class BandTableWidget(BASE, WIDGET):
self
.
cmbLayers
.
setFilters
(
QgsMapLayerProxyModel
.
RasterLayer
)
self
.
cmbLayers
.
layerChanged
.
connect
(
self
.
layerChanged
)
self
.
btnAdd
.
setIcon
(
QgsApplication
.
getThemeIcon
(
'/symbologyAdd.svg'
))
self
.
btnRemove
.
setIcon
(
QgsApplication
.
getThemeIcon
(
'/symbologyRemove.svg'
))
self
.
btnUp
.
setIcon
(
QgsApplication
.
getThemeIcon
(
'/mActionArrowUp.svg'
))
self
.
btnDown
.
setIcon
(
QgsApplication
.
getThemeIcon
(
'/mActionArrowDown.svg'
))
...
...
@@ -75,28 +74,23 @@ class BandTableWidget(BASE, WIDGET):
# for each band
for
band_number
in
range
(
nbands
):
band
=
input_raster
.
GetRasterBand
(
band_number
+
1
)
# add band name to table in first column
self
.
_addBandData
(
band
.
GetDescription
())
# add band name and number to table
bandnumber
=
'bande '
+
str
(
band_number
+
1
)
bandname
=
band
.
GetDescription
()
self
.
_addBandData
(
bandnumber
,
bandname
)
# add selected raster band names to table
def
_addBandData
(
self
,
bandname
):
# add selected raster band
number and
names to table
def
_addBandData
(
self
,
bandnumber
,
bandname
):
item
=
QTreeWidgetItem
()
item
.
setText
(
0
,
bandname
)
item
.
setText
(
1
,
''
)
item
.
setText
(
0
,
bandnumber
)
item
.
setText
(
1
,
bandname
)
#item.setText(2, '')
self
.
bandClassTree
.
addTopLevelItem
(
item
)
# remove all rows from table
def
_removeBandData
(
self
,):
self
.
bandClassTree
.
clear
()
@
pyqtSlot
()
def
on_btnAdd_clicked
(
self
):
item
=
QTreeWidgetItem
()
item
.
setText
(
0
,
'0.00'
)
item
.
setText
(
1
,
'0.00'
)
# item.setBackground(2, QBrush(QColor(127, 127, 127)))
self
.
bandClassTree
.
addTopLevelItem
(
item
)
@
pyqtSlot
()
def
on_btnRemove_clicked
(
self
):
selectedItems
=
self
.
bandClassTree
.
selectedItems
()
...
...
@@ -129,13 +123,13 @@ class BandTableWidget(BASE, WIDGET):
if
not
item
:
return
if
column
==
1
:
if
column
==
2
:
d
,
ok
=
QInputDialog
.
getText
(
None
,
self
.
tr
(
'Band name'
),
self
.
tr
(
'Enter new band name'
)
)
if
ok
:
item
.
setText
(
1
,
str
(
d
))
item
.
setText
(
2
,
str
(
d
))
def
reliefColors
(
self
):
colors
=
[]
...
...
bandtablewidgetbase.ui
View file @
9346e020
...
...
@@ -36,6 +36,11 @@
</item>
<item
row=
"1"
column=
"0"
colspan=
"2"
>
<widget
class=
"QTreeWidget"
name=
"bandClassTree"
>
<column>
<property
name=
"text"
>
<string>
Band number
</string>
</property>
</column>
<column>
<property
name=
"text"
>
<string>
Band name
</string>
...
...
@@ -50,16 +55,6 @@
</item>
<item
row=
"1"
column=
"3"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QToolButton"
name=
"btnAdd"
>
<property
name=
"toolTip"
>
<string>
Add row
</string>
</property>
<property
name=
"text"
>
<string>
…
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"btnRemove"
>
<property
name=
"toolTip"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment