Merge pull request #297 from MikeTheWatchGuy/Dev-latest
Fix for Buttons not finding Target if within a Calumn or other contai…
This commit is contained in:
commit
c7af75ca78
|
@ -293,6 +293,7 @@ class Element():
|
||||||
self.TKImage = None
|
self.TKImage = None
|
||||||
|
|
||||||
self.ParentForm=None
|
self.ParentForm=None
|
||||||
|
self.ParentContainer=None # will be a Form, Column, or Frame element
|
||||||
self.TextInputDefault = None
|
self.TextInputDefault = None
|
||||||
self.Position = (0,0) # Default position Row 0, Col 0
|
self.Position = (0,0) # Default position Row 0, Col 0
|
||||||
self.BackgroundColor = background_color if background_color is not None else DEFAULT_ELEMENT_BACKGROUND_COLOR
|
self.BackgroundColor = background_color if background_color is not None else DEFAULT_ELEMENT_BACKGROUND_COLOR
|
||||||
|
@ -1023,7 +1024,7 @@ class Button(Element):
|
||||||
if not isinstance(target, str):
|
if not isinstance(target, str):
|
||||||
if target[0] < 0:
|
if target[0] < 0:
|
||||||
target = [self.Position[0] + target[0], target[1]]
|
target = [self.Position[0] + target[0], target[1]]
|
||||||
target_element = self.ParentForm._GetElementAtLocation(target)
|
target_element = self.ParentContainer._GetElementAtLocation(target)
|
||||||
else:
|
else:
|
||||||
target_element = self.ParentForm.FindElement(target)
|
target_element = self.ParentForm.FindElement(target)
|
||||||
try:
|
try:
|
||||||
|
@ -1324,7 +1325,7 @@ class Frame(Element):
|
||||||
self.DictionaryKeyCounter = 0
|
self.DictionaryKeyCounter = 0
|
||||||
self.ParentWindow = None
|
self.ParentWindow = None
|
||||||
self.Rows = []
|
self.Rows = []
|
||||||
self.ParentForm = None
|
# self.ParentForm = None
|
||||||
self.TKFrame = None
|
self.TKFrame = None
|
||||||
self.Title = title
|
self.Title = title
|
||||||
self.Relief = relief
|
self.Relief = relief
|
||||||
|
@ -1345,6 +1346,7 @@ class Frame(Element):
|
||||||
# ------------------------- Add the elements to a row ------------------------- #
|
# ------------------------- Add the elements to a row ------------------------- #
|
||||||
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
||||||
element.Position = (CurrentRowNumber, i)
|
element.Position = (CurrentRowNumber, i)
|
||||||
|
element.ParentContainer = self
|
||||||
CurrentRow.append(element)
|
CurrentRow.append(element)
|
||||||
if element.Key is not None:
|
if element.Key is not None:
|
||||||
self.UseDictionary = True
|
self.UseDictionary = True
|
||||||
|
@ -1355,15 +1357,20 @@ class Frame(Element):
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self.AddRow(*row)
|
self.AddRow(*row)
|
||||||
|
|
||||||
|
def _GetElementAtLocation(self, location):
|
||||||
|
(row_num,col_num) = location
|
||||||
|
row = self.Rows[row_num]
|
||||||
|
element = row[col_num]
|
||||||
|
return element
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
for row in self.Rows:
|
for row in self.Rows:
|
||||||
for element in row:
|
for element in row:
|
||||||
element.__del__()
|
element.__del__()
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
super().__del__()
|
super().__del__()
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
# Slider #
|
# Slider #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
|
@ -1498,7 +1505,7 @@ class Column(Element):
|
||||||
self.DictionaryKeyCounter = 0
|
self.DictionaryKeyCounter = 0
|
||||||
self.ParentWindow = None
|
self.ParentWindow = None
|
||||||
self.Rows = []
|
self.Rows = []
|
||||||
self.ParentForm = None
|
# self.ParentForm = None
|
||||||
self.TKFrame = None
|
self.TKFrame = None
|
||||||
self.Scrollable = scrollable
|
self.Scrollable = scrollable
|
||||||
bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
|
||||||
|
@ -1516,6 +1523,7 @@ class Column(Element):
|
||||||
# ------------------------- Add the elements to a row ------------------------- #
|
# ------------------------- Add the elements to a row ------------------------- #
|
||||||
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
||||||
element.Position = (CurrentRowNumber, i)
|
element.Position = (CurrentRowNumber, i)
|
||||||
|
element.ParentContainer = self
|
||||||
CurrentRow.append(element)
|
CurrentRow.append(element)
|
||||||
if element.Key is not None:
|
if element.Key is not None:
|
||||||
self.UseDictionary = True
|
self.UseDictionary = True
|
||||||
|
@ -1526,6 +1534,13 @@ class Column(Element):
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self.AddRow(*row)
|
self.AddRow(*row)
|
||||||
|
|
||||||
|
def _GetElementAtLocation(self, location):
|
||||||
|
(row_num,col_num) = location
|
||||||
|
row = self.Rows[row_num]
|
||||||
|
element = row[col_num]
|
||||||
|
return element
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
for row in self.Rows:
|
for row in self.Rows:
|
||||||
for element in row:
|
for element in row:
|
||||||
|
@ -1863,6 +1878,7 @@ class FlexForm:
|
||||||
# ------------------------- Add the elements to a row ------------------------- #
|
# ------------------------- Add the elements to a row ------------------------- #
|
||||||
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
||||||
element.Position = (CurrentRowNumber, i)
|
element.Position = (CurrentRowNumber, i)
|
||||||
|
element.ParentContainer = self
|
||||||
CurrentRow.append(element)
|
CurrentRow.append(element)
|
||||||
# ------------------------- Append the row to list of Rows ------------------------- #
|
# ------------------------- Append the row to list of Rows ------------------------- #
|
||||||
self.Rows.append(CurrentRow)
|
self.Rows.append(CurrentRow)
|
||||||
|
|
Loading…
Reference in New Issue