Browse Source

fix(TTkTabBar): currentIndex <= highlighted TypeError (#593)

Co-authored-by: Parodi, Eugenio 🌶 <ceccopierangiolieugenio@googlemail.com>
pull/597/head
slook 4 weeks ago committed by GitHub
parent
commit
c743c492e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 15
      libs/pyTermTk/TermTk/TTkWidgets/tabwidget.py

15
libs/pyTermTk/TermTk/TTkWidgets/tabwidget.py

@ -96,7 +96,6 @@ class _TTkTabStatus():
@pyTTkSlot() @pyTTkSlot()
def _moveToTheLeft(self) -> None: def _moveToTheLeft(self) -> None:
self._setCurrentIndex(self.currentIndex-1) self._setCurrentIndex(self.currentIndex-1)
@pyTTkSlot() @pyTTkSlot()
def _andMoveToTheRight(self) -> None: def _andMoveToTheRight(self) -> None:
self._setCurrentIndex(self.currentIndex+1) self._setCurrentIndex(self.currentIndex+1)
@ -121,8 +120,12 @@ class _TTkTabStatus():
# index = self.tabButtons.index(button) # index = self.tabButtons.index(button)
# self._setCurrentIndex(index) # self._setCurrentIndex(index)
def _selectHighlighted(self) -> None:
if self.highlighted is not None:
self._setCurrentIndex(self.highlighted)
@pyTTkSlot(int) @pyTTkSlot(int)
def _setCurrentIndex(self, index) -> None: def _setCurrentIndex(self, index:int) -> None:
'''setCurrentIndex''' '''setCurrentIndex'''
if ( ( 0 <= index < len(self.tabButtons) ) and if ( ( 0 <= index < len(self.tabButtons) ) and
( self.currentIndex != index or ( self.currentIndex != index or
@ -133,12 +136,6 @@ class _TTkTabStatus():
self.currentChanged.emit(index) self.currentChanged.emit(index)
self.statusUpdated.emit() self.statusUpdated.emit()
@pyTTkSlot(int)
def _resetHighlighted(self) -> None:
if self.highlighted != -1:
self.highlighted = None
self.statusUpdated.emit()
def _insertButton(self, index:int, button:TTkTabButton) -> None: def _insertButton(self, index:int, button:TTkTabButton) -> None:
self.tabButtons.insert(index,button) self.tabButtons.insert(index,button)
self.statusUpdated.connect(button.update) self.statusUpdated.connect(button.update)
@ -865,7 +862,7 @@ class TTkTabBar(TTkContainer):
return True return True
if ( evt.type == TTkK.Character and evt.key==" " ) or \ if ( evt.type == TTkK.Character and evt.key==" " ) or \
( evt.type == TTkK.SpecialKey and evt.key == TTkK.Key_Enter ): ( evt.type == TTkK.SpecialKey and evt.key == TTkK.Key_Enter ):
self._tabStatus._setCurrentIndex(self._tabStatus.highlighted) self._tabStatus._selectHighlighted()
return True return True
return False return False

Loading…
Cancel
Save