diff --git a/TermTk/TTkTestWidgets/logviewer.py b/TermTk/TTkTestWidgets/logviewer.py index 5347651e..4654d374 100644 --- a/TermTk/TTkTestWidgets/logviewer.py +++ b/TermTk/TTkTestWidgets/logviewer.py @@ -28,16 +28,19 @@ from TermTk.TTkCore.log import TTkLog from TermTk.TTkCore.color import TTkColor from TermTk.TTkCore.string import TTkString from TermTk.TTkCore.signal import pyTTkSlot +from TermTk.TTkWidgets.widget import TTkWidget from TermTk.TTkAbstract.abstractscrollarea import TTkAbstractScrollArea from TermTk.TTkAbstract.abstractscrollview import TTkAbstractScrollView class _TTkLogViewer(TTkAbstractScrollView): __slots__ = ('_messages', '_cwd', '_follow') - def __init__(self, *args, **kwargs): - TTkAbstractScrollView.__init__(self, *args, **kwargs) - self._messages = [TTkString()] + def __init__(self, *, + follow:bool=False, + **kwargs) -> None: self._cwd = os.getcwd() - self._follow = kwargs.get('follow' , False ) + self._messages = [TTkString()] + self._follow = follow + super().__init__(**kwargs) TTkLog.installMessageHandler(self.loggingCallback) self.viewChanged.connect(self._viewChangedHandler) @@ -78,10 +81,14 @@ class _TTkLogViewer(TTkAbstractScrollView): class TTkLogViewer(TTkAbstractScrollArea): __slots__ = ('_logView') - def __init__(self, *args, **kwargs): - TTkAbstractScrollArea.__init__(self, *args, **kwargs) - kwargs.pop('parent',None) - kwargs.pop('visible',None) - self._logView = _TTkLogViewer(*args, **kwargs) + def __init__(self, *, + # TTkWidget init + parent:TTkWidget=None, + visible:bool=True, + # TTkLogViewer init + follow:bool=False, + **kwargs) -> None: + self._logView = _TTkLogViewer(follow=follow) + super().__init__(parent=parent, visible=visible, **kwargs) self.setFocusPolicy(TTkK.ClickFocus) self.setViewport(self._logView) diff --git a/TermTk/TTkWidgets/TTkPickers/textpicker.py b/TermTk/TTkWidgets/TTkPickers/textpicker.py index 8f4884ad..62f59360 100644 --- a/TermTk/TTkWidgets/TTkPickers/textpicker.py +++ b/TermTk/TTkWidgets/TTkPickers/textpicker.py @@ -65,7 +65,7 @@ emoji = { class _emojiPickerView(TTkAbstractScrollView): __slots__ = ('_btns', '_labels', 'emojiClicked') - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: self.emojiClicked = pyTTkSignal(str) super().__init__(*args, **kwargs) self.viewChanged.connect(self._viewChangedHandler) @@ -121,7 +121,7 @@ class _emojiPickerView(TTkAbstractScrollView): class _emojiPickerArea(TTkAbstractScrollArea): __slots__ = ('_areaView') - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) kwargs.pop('parent',None) kwargs.pop('visible',None) @@ -131,14 +131,14 @@ class _emojiPickerArea(TTkAbstractScrollArea): class _emojiPicker(TTkResizableFrame): __slots__ = ('emojiClicked') - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs|{'layout':TTkGridLayout()}) self.layout().addWidget(epa := _emojiPickerArea()) self.emojiClicked = epa.viewport().emojiClicked class TTkTextDialogPicker(TTkWindow): __slots__ = ('_textEdit', '_autoSize') - def __init__(self, *, autoSize=False, multiLine=True, wrapMode=TTkK.WidgetWidth, **kwargs): + def __init__(self, *, autoSize=False, multiLine=True, wrapMode=TTkK.WidgetWidth, **kwargs) -> None: self._autoSize = autoSize super().__init__(**kwargs) fontLayout = TTkGridLayout(columnMinWidth=1) @@ -264,7 +264,7 @@ class TTkTextPicker(TTkContainer): And I've no idea what I am doing ''' __slots__ = ('_teButton','_textEdit', 'documentViewChanged', 'textChanged', '_autoSize') - def __init__(self, *, text='', autoSize=False, multiLine=True, wrapMode=TTkK.WidgetWidth, **kwargs): + def __init__(self, *, text='', autoSize=False, multiLine=True, wrapMode=TTkK.WidgetWidth, **kwargs) -> None: self.documentViewChanged = pyTTkSignal(int,int) self._autoSize = autoSize super().__init__(**kwargs|{'layout':TTkHBoxLayout()}) @@ -273,9 +273,10 @@ class TTkTextPicker(TTkContainer): self._textEdit.setReadOnly(False) self._textEdit.setLineWrapMode(wrapMode) self.textChanged = self._textEdit.textChanged - self._teButton = TTkButton(border=True, text='◉', borderColor=TTkColor.fg("#AAAAFF")+TTkColor.bg("#002244") , - pos=(self.width()-2,0), - size=(2,self.height()), minSize=(3,1),maxWidth=3) + self._teButton = TTkButton(border=True, text='◉', + addStyle={'default':{'borderColor':TTkColor.fg("#AAAAFF")+TTkColor.bg("#002244")}} , + pos=(self.width()-2,0), + size=(2,self.height()), minSize=(3,1),maxWidth=3) self.layout().addWidget(self._textEdit) self.layout().addWidget(self._teButton) diff --git a/TermTk/TTkWidgets/label.py b/TermTk/TTkWidgets/label.py index 8b72938f..a14eaf87 100644 --- a/TermTk/TTkWidgets/label.py +++ b/TermTk/TTkWidgets/label.py @@ -39,6 +39,7 @@ class TTkLabel(TTkWidget): __slots__ = ('_text', '_alignment') def __init__(self, *, text:TTkString="", + color:TTkColor=None, alignment:TTkK.Alignment=TTkK.LEFT_ALIGN, **kwargs) -> None: if issubclass(type(text), TTkString): @@ -49,6 +50,8 @@ class TTkLabel(TTkWidget): self.setDefaultSize(kwargs, max(t.termWidth() for t in self._text), len(self._text)) super().__init__(**kwargs) + if color: + self.setColor(color) self._textUpdated() def alignment(self): diff --git a/TermTk/TTkWidgets/lineedit.py b/TermTk/TTkWidgets/lineedit.py index 922b4228..0bdc42a4 100644 --- a/TermTk/TTkWidgets/lineedit.py +++ b/TermTk/TTkWidgets/lineedit.py @@ -44,10 +44,15 @@ class TTkLineEdit(TTkWidget): '''TTkLineEdit''' class EchoMode(int): - Normal = 0x00 # Display characters as they are entered. This is the default. - NoEcho = 0x01 # Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret. - Password = 0x02 # Display asterisks instead of the characters actually entered. - PasswordEchoOnEdit = 0x03 # Display characters as they are entered while editing otherwise display asterisks. + '''EchoMode''' + Normal = 0x00 + '''Display characters as they are entered. This is the default.''' + NoEcho = 0x01 + '''Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret.''' + Password = 0x02 + '''Display asterisks instead of the characters actually entered.''' + PasswordEchoOnEdit = 0x03 + '''Display characters as they are entered while editing otherwise display asterisks.''' classStyle = { 'default': {'color': TTkColor.fg("#dddddd")+TTkColor.bg("#222222"), diff --git a/TermTk/TTkWidgets/radiobutton.py b/TermTk/TTkWidgets/radiobutton.py index 738440e7..dc2c0701 100644 --- a/TermTk/TTkWidgets/radiobutton.py +++ b/TermTk/TTkWidgets/radiobutton.py @@ -49,6 +49,8 @@ class TTkRadioButton(TTkWidget): :type radiogroup: str, optional :param bool checked: Checked status, defaults to "False" :type checked: bool, optional + :param checkStatus: If defined, override the option defined in the 'checked' field otherwise defaults to :py:class:`TTkK.CheckState.Checked` or :py:class:`TTkK.CheckState.Unchecked` based on the checked status + :type checkStatus: :py:class:`TTkK.CheckState` , optional ''' clicked:pyTTkSignal @@ -77,6 +79,7 @@ class TTkRadioButton(TTkWidget): def __init__(self, *, radiogroup:str='DefaultGroup', checked:bool=False, + checkStatus:TTkK.CheckState = None, text:TTkString='', **kwargs) -> None: # Define Signals @@ -86,6 +89,10 @@ class TTkRadioButton(TTkWidget): self._radiogroup = radiogroup # self.checked = pyTTkSignal() self._checked = checked + if checkStatus != None : + self._checked = checkStatus==TTkK.Checked + else: + self._checked = checked self._text = TTkString(text) TTkWidget.__init__(self, **kwargs) diff --git a/TermTk/TTkWidgets/widget.py b/TermTk/TTkWidgets/widget.py index e0ebfa89..6361d7d4 100644 --- a/TermTk/TTkWidgets/widget.py +++ b/TermTk/TTkWidgets/widget.py @@ -63,31 +63,45 @@ class TTkWidget(TMouseEvents,TKeyEvents, TDragEvents): :param parent: the parent widget, defaults to None :type parent: :py:class:`TTkWidget`, optional - :param (int,int) pos: the [x,y] position (override the previously defined x, y), optional, default=(0,0) - :param int x: the x position, defaults to 0 - :param int y: the y position, defaults to 0 - - :param (int,int) size: the size [width, height] of the widget (override the previously defined sizes), optional, default=(0,0) - :param int width: the width of the widget, defaults to 0 - :param int height: the height of the widget, defaults to 0 - - :param int maxWidth: the maxWidth of the widget, optional, defaults to 0x10000 - :param int maxHeight: the maxHeight of the widget, optional, defaults to 0x10000 - :param (int,int) maxSize: the max [width,height] of the widget, optional, defaults to (maxWidth,maxHeight) - :param int minWidth: the minWidth of the widget, defaults to 0 - :param int minHeight: the minHeight of the widget, defaults to 0 - :param (int,int) minSize: the minSize [width,height] of the widget, optional, defaults to (minWidth,minHeight) + :param x: the x position, defaults to 0 + :type x: int, optional + :param y: the y position, defaults to 0 + :type y: int, optional + :param pos: the [x,y] position (override the previously defined x, y), defaults to (x,y) + :type pos: (int,int), optional + + :param width: the width of the widget, defaults to 0 + :type width: int, optional + :param height: the height of the widget, defaults to 0 + :type height: int, optional + :param size: the size [width, height] of the widget (override the previously defined sizes), defaults to (width,height) + :type size: (int,int), optional + + :param maxWidth: the maxWidth of the widget, defaults to 0x10000 + :type maxWidth: int, optional + :param maxHeight: the maxHeight of the widget, defaults to 0x10000 + :type maxHeight: int, optional + :param maxSize: the max [width,height] of the widget, optional, defaults to (maxWidth,maxHeight) + :type maxSize: (int,int), optional + :param minWidth: the minWidth of the widget, defaults to 0 + :type minWidth: int, optional + :param minHeight: the minHeight of the widget, defaults to 0 + :type minHeight: int, optional + :param minSize: the minSize [width,height] of the widget, optional, defaults to (minWidth,minHeight) + :type minSize: (int,int), optional :param toolTip: This property holds the widget's tooltip, defaults to '' - :type toolTip: :py:class:`TTkString` + :type toolTip: :py:class:`TTkString`, optional :param style: this field hold the custom style to be used by this widget - :type style: dict + :type style: dict, optional :param addStyle: this field is required to override/merge the new style on top of the current one, useful if only few params need to be changed - :type addStyle: dict + :type addStyle: dict, optional - :param bool,optional visible: the visibility, optional, defaults to True - :param bool,optional enabled: the ability to handle input events, optional, defaults to True + :param visible: the visibility, optional, defaults to True + :type visible: bool, optional + :param enabled: the ability to handle input events, optional, defaults to True + :type enabled: bool, optional ''' focusChanged:pyTTkSignal diff --git a/docs/source/index.rst b/docs/source/index.rst index e4278ce4..f24a0990 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -102,10 +102,20 @@ API Reference TTkWidgets.TTkPickers TTkWidgets.TTkTerminal -.. # .. autosummary:: -.. # :caption: Classes: -.. # :toctree: _autosummary -.. # :template: custom-class-template.01.rst +.. #.. autosummary:: +.. # :caption: Classes: +.. # :toctree: _autosummary +.. # :template: custom-class-template.01.rst +.. # +.. # TTkCore.TTkK +.. # TTkWidgets.TTkAppTemplate +.. # TTkWidgets.TTkMenuBar +.. # TTkWidgets.TTkMenuBarLayout +.. # TTkWidgets.TTkWidget +.. # TTkWidgets.TTkLineEdit +.. # TTkWidgets.TTkScrollBar +.. # TTkWidgets.TTkModelView.TTkTable + .. # .. # TTkCore.TTkK .. # TTkCore.TTkConstant diff --git a/tools/ttkDesigner/app/superobj/superwidgetradiobutton.py b/tools/ttkDesigner/app/superobj/superwidgetradiobutton.py index 4d65cb7b..1a703110 100644 --- a/tools/ttkDesigner/app/superobj/superwidgetradiobutton.py +++ b/tools/ttkDesigner/app/superobj/superwidgetradiobutton.py @@ -25,10 +25,21 @@ import ttkDesigner.app.superobj as so class SuperWidgetRadioButton(so.SuperWidget): def getSuperProperties(self): + def _setRadioGroup(_wid:ttk.TTkRadioButton, value:str): + _wid._radiogroup = value + _rl = ttk.TTkRadioButton._radioLists + for _rg in _rl: + if _wid in _rl[_rg]: + _rl[_rg].remove(_wid) + if value not in _rl: + _rl[value] = [_wid] + else: + _rl[value].append(_wid) + additions, exceptions, exclude = super().getSuperProperties() exceptions |= { 'RadioGroup' : { 'init': {'name':'radiogroup', 'type':str } , 'get': {'cb':ttk.TTkRadioButton.radioGroup, 'type':str } , - 'set': {'cb':lambda w,l: setattr(w,'_radiogroup',l), 'type':str } } } + 'set': {'cb':_setRadioGroup, 'type':str } } } return additions, exceptions, exclude \ No newline at end of file diff --git a/tools/ttkDesigner/app/treeinspector.py b/tools/ttkDesigner/app/treeinspector.py index 71c8e947..245bdead 100644 --- a/tools/ttkDesigner/app/treeinspector.py +++ b/tools/ttkDesigner/app/treeinspector.py @@ -30,10 +30,13 @@ from .superobj.superwidgetmenubutton import SuperWidgetMenuButton class _TTkTomTreeWidgetItem(ttk.TTkTreeWidgetItem): __slots__ = ('_tomWidget','_tomSuperWidget') - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self._tomWidget = kwargs.get('tomWidget') - self._tomSuperWidget = kwargs.get('tomSuperWidget') + def __init__(self, *argv, + tomWidget=None, + tomSuperWidget=None, + **kwargs) -> None: + super().__init__(*argv, **kwargs) + self._tomWidget = tomWidget + self._tomSuperWidget = tomSuperWidget def tomWidget(self): return self._tomWidget def tomSuperWidget(self):