Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Include' hides re-appended objects even though destroy_old = False #370

Open
K3nn3th2 opened this issue Sep 10, 2019 · 4 comments
Open

Comments

@K3nn3th2
Copy link

as stated, i have an include object with the 'destroy_old' attribute set to false.
i can append and remove an object to/from the objects attribute and it gets shown/removed respectively.

when re-appending an object i previously had appended, it does not get shown. interestingly, upon appending more objects, i can see the re-appended one taking up some space in the list, yet without showing any of the widgets.

so the include object is hiding the re-appended object even though destroy_old = False

is this a bug?
ill try and make a minimal working example reproducing the error.

@sccolbert
Copy link
Member

sccolbert commented Sep 10, 2019 via email

@MatthieuDartiailh
Copy link
Member

From the top of my head, even if the Include does not destroy the widget it hides it. Show the widget when you add it back and you should be fine.

@MatthieuDartiailh
Copy link
Member

I also have a memory that this is related to qt behavior when a widget is unparented and not directly something enforced by enaml.

@K3nn3th2
Copy link
Author

K3nn3th2 commented Sep 10, 2019

Thank you @MatthieuDartiailh ! calling .show() after adding did the trick.

it is rather strange though, i'm using a further Include in my code (also with destroy_old = False) which works perfectly fine when fiddling with its objects attribute, no need to display anything after adding.

anyway, i attached a 'minimal' example.

please excuse the somewhat unusual structure, i tried to keep the example close to my use case in order to see if maybe the structure is causing the strange behaviour.

here is the content of the enaml file (sorry for the strange formatting, the "code" markup doesnt seem to work for enaml code ) :

`
from enaml.widgets.api import (
Window, FlowItem, FlowArea, Form, CheckBox, PushButton, ScrollArea, GroupBox, Label, MultilineField, Container,
)
from enaml.layout.api import vbox, hbox
from enaml.core.api import Include

class Release(object):
name = ''
def init(self, name):
super(Release, self).init()
self.name = name

enamldef DownloadListItem(Form):
attr release
Container:
Label: name:
text << release.name

enamldef ReleaseItem(FlowItem):
attr release
attr downloadList
attr downloadListItem = DownloadListItem(release = release)
preferred_size << (180,250)
Container:
constraints = [
height >= 200,
gBox.width == width,
gBox.height == height,
]
GroupBox: gBox:
constraints = [
info.height == .5 * self.height,
info.width == self.width,
contents_bottom == toDownload.bottom, contents_left == toDownload.left,
]
MultilineField: info:
read_only = True
# border =
resist_width = 'weak'
resist_height = 'weak'
text << release.name
CheckBox: toDownload:
checked << False if downloadListItem not in downloadList else True
toggled ::
if checked:
downloadList.append(downloadListItem)
print('appended downloadListitem. contents: ' + str(downloadList))
else:
downloadList.remove(downloadListItem)

enamldef Downloader(GroupBox):
title = 'Download'
alias downloads : downloads

ScrollArea:
    Container:
        Include: downloads:
            destroy_old = False
PushButton:
    text = 'print include objects "destroy_old" value'
    clicked :: print('includes destroy old: ' + str(downloads.destroy_old))

enamldef Main(Window):

func getItems():
    return [ReleaseItem(release=Release(name='Release ' + str(x)), downloadList = dl.downloads.objects) for x in range(5)]
        
Container:
    constraints=[
        vbox(flow, dl),
        dl.height == 0.5 * height,
        ]
    FlowArea: flow:
        Include: inc:
            destroy_old = False
            objects = getItems()
    Downloader: dl:
        pass

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants