Open PSMusicalRoc opened 4 years ago
Hmmm, that's bizarre. It shouldn't be necessary for Form
to implement do_regroup_children()
, because it uses a Stack
to organize the its background and label widgets, and the stack should take care of setting up the ordered groups. But that doesn't explain why you're getting the label behind the background sometimes.
If you can create a minimal working example that exhibits the label intermittently appearing behind the background (admittedly, I know it can be hard to create MWEs of intermittent problems), I'd be interested in looking into that.
I haven't gotten a minimal example of it yet, however, I have gotten a video example of it happening in my original code, before adding in the do_regroup_children
function. It occurred after about 3 or 4 resets of the program. All the points where the cursor is over a text input, I'm spam-clicking the input to show that it's selected, but behind the background.
Interesting development, but one of the times that I loaded the program up WITH the fix that I made, the text was behind the form again! So now we definitely know that it doesn't have to do with do_regroup_children
... I have no idea what could be causing this odd bug.
So I've run into this problem myself, and to help debug it, I wrote a quick tree printer. It may be unrelated, but it looks like it may have something to do with the discrepency between _children in containers, and _Widget__children in widgets.
If I use this tree printer:
def tree_print(self, item=None, depth=0):
if not item:
item = self.gui
print(f"{' '*(depth*4)}{self.printer(item)}")
children = list(getattr(item, '_children', []))
if not children:
children = list(getattr(item, '_Widget__children', []))
for child in children:
self.tree_print(child, depth+1)
def printer(self, item):
order_type = getattr(item, '_Widget__group', 'NullGroup')
return f"[{order_type}] {str(item)}"
Then the tree always prints appropriately as:
[OrderedGroup(1)] Gui(id=2220)
[OrderedGroup(0)] Frame(id=2250)
[OrderedGroup(2)] Box(id=2280)
[OrderedGroup(2)] VBox(id=2d00)
[OrderedGroup(2)] Label(id=05e0, "Server...")
[OrderedGroup(2)] LoginForm(id=23d0)
[OrderedGroup(2)] Stack(id=1280)
[OrderedGroup(0)] Label(id=8e80, "localhost")
[OrderedGroup(-1)] Base(id=8df0)
[OrderedGroup(2)] Label(id=8e20, "Server...")
[OrderedGroup(2)] LoginForm(id=ec10)
[OrderedGroup(2)] Stack(id=7f40)
[OrderedGroup(0)] Label(id=c220, "9123")
[OrderedGroup(-1)] Base(id=ce50)
[OrderedGroup(2)] Spacer(id=c820)
[OrderedGroup(2)] Button(id=cdc0)
[OrderedGroup(1)] Rollover(id=c9a0)
[OrderedGroup(1)] Image(id=9610)
[OrderedGroup(1)] Image(id=58b0)
[OrderedGroup(1)] Image(id=56d0)
[OrderedGroup(1)] Image(id=9af0)
[OrderedGroup(2)] Label(id=c4c0, "Connect")
[OrderedGroup(1)] Decoration(id=2b80)
even when 'Connect' does not show on the button, like so:
However, when I use THIS tree printer:
def tree_print(self, item=None, depth=0):
if not item:
item = self.gui
print(f"{' '*(depth*4)}{self.printer(item)}")
children = list(getattr(item, '_Widget__children', []))
for child in children:
self.tree_print(child, depth+1)
Then something interesting happens: I get the same printed tree as the above when 'Connect' is shown.... but when it's not i get a different tree, specifically something like this:
[OrderedGroup(1)] Gui(id=2220)
[OrderedGroup(0)] Frame(id=2250)
[OrderedGroup(2)] Box(id=2280)
[OrderedGroup(2)] VBox(id=2d00)
[OrderedGroup(2)] Label(id=05e0, "Server...")
[OrderedGroup(2)] Label(id=8e20, "Server...")
[OrderedGroup(2)] Spacer(id=c820)
[OrderedGroup(2)] LoginForm(id=23d0)
[OrderedGroup(2)] Stack(id=1280)
[OrderedGroup(0)] Label(id=8e80, "localhost")
[OrderedGroup(-1)] Base(id=8df0)
[OrderedGroup(2)] Button(id=cdc0)
[OrderedGroup(1)] Rollover(id=c9a0)
[OrderedGroup(1)] Image(id=9610)
[OrderedGroup(1)] Image(id=58b0)
[OrderedGroup(1)] Image(id=56d0)
[OrderedGroup(1)] Image(id=9af0)
[OrderedGroup(2)] Label(id=c4c0, "Connect")
[OrderedGroup(2)] LoginForm(id=ec10)
[OrderedGroup(2)] Stack(id=7f40)
[OrderedGroup(0)] Label(id=c220, "9123")
[OrderedGroup(-1)] Base(id=ce50)
[OrderedGroup(1)] Decoration(id=2b80)
This may be a complete coincidence, but it's very, very consistent.
So I noticed while playing around with
Form
that in some cases its text (itsLabel
) was behind the background, resulting in text not being shown. I also noticed that itsdo_regroup_children
function wasn't defined. Placing the following code in my customForm
class (that always has aBase
and aLabel
) seemed to mitigate this problem, leading me to believe it was a bug:Perhaps the
do_regroup_children
function should be defined in theForm
in the base module?