Browse Source

fix(ttkDesigner): crash due to the flag integer handling (#540)

pull/544/head
Pier CeccoPierangioliEugenio 3 months ago committed by GitHub
parent
commit
c6d89550df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      apps/ttkDesigner/ttkDesigner/app/propertyeditor.py
  2. 17
      libs/pyTermTk/TermTk/TTkCore/constant.py

4
apps/ttkDesigner/ttkDesigner/app/propertyeditor.py

@ -79,11 +79,11 @@ class PropertyEditor(ttk.TTkGridLayout):
# • Password │[ ] 0x0004
def _processMultiFlag(name, prop, domw):
flags = prop['get']['flags']
ret = ttk.TTkTreeWidgetItem([name,f" - (0x{prop['get']['cb'](domw):04X})"],expanded=True)
ret = ttk.TTkTreeWidgetItem([name,f" - (0x{int(prop['get']['cb'](domw)):04X})"],expanded=True)
# value = ttk.TTkFrame(layout=ttk.TTkVBoxLayout(), height=len(flags), border=False)
for fl in flags:
if 'set' in prop:
fcb = ttk.TTkCheckbox(text=f" 0x{flags[fl]:04X}", checked=bool(prop['get']['cb'](domw)&flags[fl]), height=1)
fcb = ttk.TTkCheckbox(text=f" 0x{int(flags[fl]):04X}", checked=bool(prop['get']['cb'](domw)&flags[fl]), height=1)
fcb.stateChanged.connect(_boundFlags(
prop['set']['cb'], prop['get']['cb'],
domw, lambda v: v==ttk.TTkK.Checked, flags[fl]))

17
libs/pyTermTk/TermTk/TTkCore/constant.py

@ -60,7 +60,7 @@ class TTkConstant:
ColorModifier = 0x08
'''The :py:class:`TTkColor` include a color modifier based on :py:class:`TTkColorModifier`'''
class FocusPolicy(Flag):
class FocusPolicy(int, Flag):
'''
This Class type defines the various policies a widget
can have with respect to acquiring keyboard focus.
@ -423,7 +423,7 @@ class TTkConstant:
Cursor_Blinking_Bar = 0x0006
Cursor_Steady_Bar = 0x0007
class InputType(Flag):
class InputType(int, Flag):
'''
This enum type describes the input validation types for text input widgets.
@ -504,7 +504,7 @@ class TTkConstant:
AcceptSave = 1
'''Save'''
class TTkItemSelectionModel(Flag):
class TTkItemSelectionModel(int, Flag):
'''These values describes the way the selection model will be updated.
.. autosummary::
@ -584,7 +584,7 @@ class TTkConstant:
LayoutItem = LayoutItemTypes.LayoutItem
WidgetItem = LayoutItemTypes.WidgetItem
class WindowFlag(Flag):
class WindowFlag(int, Flag):
'''
Those flags are used to enable customization of the window controls.
@ -624,6 +624,15 @@ class TTkConstant:
# WindowStaysOnBottomHint = 0x04000000
# ''' Informs the window system that the window should stay on bottom of all other windows.'''
def __int__(self) -> int:
'''
Convert the flag to its integer value
:return: the integer representation of the flag
:rtype: int
'''
return self.value
class KeyType(int):
'''Input Key Types

Loading…
Cancel
Save