Browse Source

Merge pull request #287 from ceccopierangiolieugenio/286-ttkdesigner-fix-glitch-that-prevent-some-widgets-to-be-displayed

#286 : Fixed ttkDesigner glitch
pull/289/head
Pier CeccoPierangioliEugenio 1 year ago committed by GitHub
parent
commit
f1d0fd7e11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 26
      .vscode/launch.json
  2. 2
      tools/ttkDesigner/app/superobj/supercontrol.py
  3. 4
      tools/ttkDesigner/app/superobj/superwidgetcontainer.py
  4. 27
      tools/ttkDesigner/app/widgetbox.py

26
.vscode/launch.json vendored

@ -4,16 +4,17 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
},{
"name": "Python: Test Player",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
@ -21,18 +22,25 @@
"args": ["-p", "tmp/test.input.bin"]
},{
"name": "Python: TTk Designer",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "ttkDesigner",
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"PYTHONPATH": "./tools"
}
},{
"name": "Python: TTk Designer Quick",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "ttkDesigner",
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"PYTHONPATH": "./tools"
},
"args": ["ttkDesigner/tui/newWindow.tui.json"]
},{
"name": "Python: DumbPaintTool",
@ -40,7 +48,10 @@
"request": "launch",
"program": "tools/dumbPaintTool.py",
"console": "integratedTerminal",
"justMyCode": true
"justMyCode": true,
"env": {
"PYTHONPATH": "./tools"
}
},{
"name": "Python: DumbPaintTool File",
"type": "debugpy",
@ -48,6 +59,9 @@
"program": "tools/dumbPaintTool.py",
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"PYTHONPATH": "./tools"
},
"args":["experiments/untitled.DPT.json"]
},{
"name": "Python: Demo",
@ -58,7 +72,7 @@
"justMyCode": true
},{
"name": "Python: Demo Mouse tracking",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "demo/demo.py",
"console": "integratedTerminal",

2
tools/ttkDesigner/app/superobj/supercontrol.py

@ -101,7 +101,7 @@ class SuperControlWidget(ttk.TTkResizableFrame):
def paintEvent(self, canvas):
w,h = self.size()
self._wid.paintEvent(canvas)
self._wid.paintEvent(self._wid.getCanvas())
self._wid.paintChildCanvas()
canvas.paintCanvas(
self._wid.getCanvas(),

4
tools/ttkDesigner/app/superobj/superwidgetcontainer.py

@ -114,7 +114,11 @@ class SuperWidgetContainer(so.SuperWidget):
# canvas.fill(color=self._layoutColor)
# canvas.fill(pos=(l,t), size=(w-r-l,h-b-t), color=self._layoutPadColor)
else:
for child in self._wid.rootLayout().iterWidgets():
child.getCanvas().updateSize()
child.paintEvent(child.getCanvas())
self._wid.getCanvas().updateSize()
self._wid.paintChildCanvas()
self._wid.paintEvent(self._wid.getCanvas())
canvas.paintCanvas(
self._wid.getCanvas(),

27
tools/ttkDesigner/app/widgetbox.py

@ -25,6 +25,17 @@ import TermTk as ttk
from .cfg import *
from .about import *
_dummyTextSingle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
_dummyTextMulti = (
"Lorem ipsum dolor sit amet, consectetur adipiscing elit,\n"
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"
"Ut enim ad minim veniam,\n"
"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n"
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n"
"Excepteur sint occaecat cupidatat non proident,\n"
"sunt in culpa qui officia deserunt mollit anim id est laborum.\n")
dWidgets = {
'Layouts':{
"Layout" : { "class":ttk.TTkLayout , "params":{'size':(30,10)}},
@ -47,9 +58,9 @@ dWidgets = {
},
'Input Widgets':{
"ComboBox" : { "class":ttk.TTkComboBox, "params":{'size':(20,1)} },
"LineEdit" : { "class":ttk.TTkLineEdit, "params":{'size':(20,1)} },
"TextEdit" : { "class":ttk.TTkTextEdit, "params":{'size':(25,8), 'readOnly':False, 'multiline':True } },
"TextEditLine": { "class":ttk.TTkTextEdit, "params":{'size':(20,1), 'readOnly':False, 'multiLine':False, 'maxHeight':1 } },
"LineEdit" : { "class":ttk.TTkLineEdit, "params":{'size':(20,1), 'text':_dummyTextSingle } },
"TextEdit" : { "class":ttk.TTkTextEdit, "params":{'size':(25,8), 'document':ttk.TTkTextDocument(text=_dummyTextMulti), 'readOnly':False, 'multiline':True } },
"TextEditLine": { "class":ttk.TTkTextEdit, "params":{'size':(20,1), 'document':ttk.TTkTextDocument(text=_dummyTextSingle), 'readOnly':False, 'multiLine':False, 'maxHeight':1 } },
"SpinBox" : { "class":ttk.TTkSpinBox, "params":{'size':(20,1)} },
"H ScrollBar" : { "class":ttk.TTkScrollBar, "params":{'size':(10,1), "orientation":ttk.TTkK.HORIZONTAL} },
"V ScrollBar" : { "class":ttk.TTkScrollBar, "params":{'size':(1,5), "orientation":ttk.TTkK.VERTICAL} },
@ -126,7 +137,15 @@ class DragDesignItem(ttk.TTkWidget):
drag = ttk.TTkDrag()
data = wc['class'](**(wc['params']|{'name':name}))
if issubclass(wc['class'], ttk.TTkWidget):
if issubclass(wc['class'], ttk.TTkContainer):
for child in data.rootLayout().iterWidgets():
child.getCanvas().updateSize()
child.paintEvent(child.getCanvas())
data.getCanvas().updateSize()
data.paintChildCanvas()
data.paintEvent(data.getCanvas())
drag.setPixmap(data)
elif issubclass(wc['class'], ttk.TTkWidget):
drag.setPixmap(data)
else:
w,h = wc['params']['size']

Loading…
Cancel
Save