diff --git a/TermTk/TTkCore/string.py b/TermTk/TTkCore/string.py index b0c2a6ea..86785ffe 100644 --- a/TermTk/TTkCore/string.py +++ b/TermTk/TTkCore/string.py @@ -279,7 +279,7 @@ class TTkString(): ''' Return the ascii representation of the string ''' return self._text - def toAnsi(self): + def toAnsi(self, strip=False): ''' Return the ansii (terminal colors/events) representation of the string ''' out = "" color = None @@ -288,6 +288,14 @@ class TTkString(): color = col out += str(TTkColor.RST) + str(color) out += ch + if strip: + rstCh = "\u001b[0m" + lenRst = len(rstCh) + while out.startswith(rstCh): + out = out[lenRst:] + while out.endswith(rstCh): + out = out[:-lenRst] + return out return out+str(TTkColor.RST) def align(self, width=None, color=TTkColor.RST, alignment=TTkK.NONE): diff --git a/ttkDesigner/app/superobj/superobj.py b/ttkDesigner/app/superobj/superobj.py index c7a8b37e..a2e4674f 100644 --- a/ttkDesigner/app/superobj/superobj.py +++ b/ttkDesigner/app/superobj/superobj.py @@ -28,7 +28,7 @@ class SuperObject(): def _dumpPrimitive(val): return val def _dumpTTkString(val): - return val.toAnsi() + return val.toAnsi(True) def _dumpTTkColor(val): return str(val) def _dumpTTkLayout(val): diff --git a/ttkDesigner/app/superobj/superwidgetframe.py b/ttkDesigner/app/superobj/superwidgetframe.py index 62fe930f..798a150c 100644 --- a/ttkDesigner/app/superobj/superwidgetframe.py +++ b/ttkDesigner/app/superobj/superwidgetframe.py @@ -43,8 +43,8 @@ class SuperWidgetFrame(so.SuperWidget): ret = {'params': { 'Name': _mbi.name(), - 'ToolTip': _mbi.toolTip().toAnsi(), - 'Text': _mbi.text().toAnsi(), + 'ToolTip': _mbi.toolTip().toAnsi(True), + 'Text': _mbi.text().toAnsi(True), 'Checkable': _mbi.isCheckable(), 'Checked': _mbi.isChecked(), } diff --git a/ttkDesigner/tui/menuBarEditor.tui.json b/ttkDesigner/tui/menuBarEditor.tui.json index ed4d8e8f..0b5240eb 100644 --- a/ttkDesigner/tui/menuBarEditor.tui.json +++ b/ttkDesigner/tui/menuBarEditor.tui.json @@ -25,9 +25,9 @@ "Layout": "TTkGridLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", + "ToolTip": "", "Border": true, - "Title": "\u001b[0m\u001b[0mMenuBar Editor\u001b[0m", + "Title": "MenuBar Editor", "Window Flags": 134217728 }, "layout": { @@ -66,8 +66,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": false, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mEdit\u001b[0m", + "ToolTip": "", + "Text": "Edit", "Border": true, "Checkable": true, "Checked": false @@ -114,8 +114,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0m MenuBar Top\u001b[0m", + "ToolTip": "", + "Text": " MenuBar Top", "Tristate": false, "Checked": false, "Check State": 0 @@ -162,8 +162,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": false, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mEdit\u001b[0m", + "ToolTip": "", + "Text": "Edit", "Border": true, "Checkable": true, "Checked": false @@ -210,8 +210,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0m MenuBar Bottom\u001b[0m", + "ToolTip": "", + "Text": " MenuBar Bottom", "Tristate": false, "Checked": false, "Check State": 0 @@ -257,7 +257,7 @@ ], "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", + "ToolTip": "", "Border": true, "Orientation": 3 }, diff --git a/ttkDesigner/tui/newWindow.tui.json b/ttkDesigner/tui/newWindow.tui.json index b722dce6..d4dece54 100644 --- a/ttkDesigner/tui/newWindow.tui.json +++ b/ttkDesigner/tui/newWindow.tui.json @@ -25,9 +25,9 @@ "Layout": "TTkGridLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", + "ToolTip": "", "Border": true, - "Title": "\u001b[0m\u001b[0mNew Form - TTk Designer \ud83d\ude0e\u001b[0m", + "Title": "New Form - TTk Designer \ud83d\ude0e", "Window Flags": 134250496 }, "layout": { @@ -66,8 +66,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": false, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mLayout\u001b[0m", + "ToolTip": "", + "Text": "Layout", "Border": true, "Checkable": false, "Checked": false @@ -114,8 +114,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0m\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\n\u2551 Window \u001b[0m\u001b[0;38;2;255;255;0;48;2;0;0;255m[\u001b[0m\u001b[0;38;2;255;95;0;48;2;0;0;255mx\u001b[0m\u001b[0;38;2;255;255;0;48;2;0;0;255m]\u001b[0m\u001b[0m\u2551\n\u255f\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2562\n\u2551 \u2551\n\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u001b[0m", + "ToolTip": "", + "Text": "\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\n\u2551 Window \u001b[0m\u001b[0;38;2;255;255;0;48;2;0;0;255m[\u001b[0m\u001b[0;38;2;255;95;0;48;2;0;0;255mx\u001b[0m\u001b[0;38;2;255;255;0;48;2;0;0;255m]\u001b[0m\u001b[0m\u2551\n\u255f\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2562\n\u2551 \u2551\n\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255d", "Border": true, "Checkable": false, "Checked": false @@ -162,8 +162,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mWidget\u001b[0m", + "ToolTip": "", + "Text": "Widget", "Border": true, "Checkable": false, "Checked": false @@ -210,8 +210,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": false, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mGrid Layout\u001b[0m", + "ToolTip": "", + "Text": "Grid Layout", "Border": true, "Checkable": false, "Checked": false @@ -258,8 +258,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": false, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mVBox Layout\u001b[0m", + "ToolTip": "", + "Text": "VBox Layout", "Border": true, "Checkable": false, "Checked": false @@ -306,8 +306,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": false, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mHBox Layout\u001b[0m", + "ToolTip": "", + "Text": "HBox Layout", "Border": true, "Checkable": false, "Checked": false @@ -354,8 +354,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mNew Widget\u001b[0m", + "ToolTip": "", + "Text": "New Widget", "Color": "\u001b[0m", "Alignment": 4 }, @@ -401,8 +401,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mNew Layout\u001b[0m", + "ToolTip": "", + "Text": "New Layout", "Color": "\u001b[0m", "Alignment": 4 }, @@ -448,8 +448,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mNew Window\u001b[0m", + "ToolTip": "", + "Text": "New Window", "Color": "\u001b[0m", "Alignment": 4 }, diff --git a/ttkDesigner/tui/quickExport.tui.json b/ttkDesigner/tui/quickExport.tui.json index 4916b0e8..6fce6c62 100644 --- a/ttkDesigner/tui/quickExport.tui.json +++ b/ttkDesigner/tui/quickExport.tui.json @@ -25,9 +25,9 @@ "Layout": "TTkGridLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", + "ToolTip": "", "Border": true, - "Title": "\u001b[0m\u001b[0mMr Export \ud83c\udf81\u001b[0m", + "Title": "Mr Export \ud83c\udf81", "Window Flags": 134250496 }, "layout": { @@ -66,8 +66,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0m\ud83d\udcbe\u001b[0m", + "ToolTip": "", + "Text": "\ud83d\udcbe", "Border": true, "Checkable": false, "Checked": false, @@ -119,8 +119,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mNormal\u001b[0m", + "ToolTip": "", + "Text": "Normal", "Border": true, "Checkable": false, "Checked": false @@ -167,8 +167,8 @@ "Layout": "TTkLayout", "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", - "Text": "\u001b[0m\u001b[0mCompressed\u001b[0m", + "ToolTip": "", + "Text": "Compressed", "Border": true, "Checkable": false, "Checked": false @@ -214,7 +214,7 @@ ], "Visible": true, "Enabled": true, - "ToolTip": "\u001b[0m", + "ToolTip": "", "Line Number": true, "Read Only": false, "Multi Line": true