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

New Widget Does Not Get Added #989

Closed
3 of 15 tasks
Vipul-Cariappa opened this issue Jul 27, 2020 · 3 comments
Closed
3 of 15 tasks

New Widget Does Not Get Added #989

Vipul-Cariappa opened this issue Jul 27, 2020 · 3 comments
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.

Comments

@Vipul-Cariappa
Copy link
Contributor

Vipul-Cariappa commented Jul 27, 2020

Expected Behavior

A new Label Widget needs to get added.

Current Behavior

New Label Widget does not get added.

Steps to reproduce

from toga import Box, Button, Label, App, MainWindow
from toga.style import Pack
from toga.constants import COLUMN

class BugApp(App):

    def startup(self):
        self.main_window = MainWindow(title=self.name)

        self.label1 = Label('Some Text...')
        self.button1 = Button(label='Add New Label', on_press=self.add_widget)

        self.box = Box(children=[self.label1, self.button1], style=Pack(direction=COLUMN, padding=20))

        self.main_window.content = self.box
        self.main_window.show()

    def add_widget(self, button):
        x = Label("New Label")
        self.box.add(x)
        self.box.refresh()


if __name__ == '__main__':
    app = BugApp('BugApp', 'mybugapp')
    app.main_loop()

Your Environment

  • Python Version 3.7

  • Operating System and Version

    • macOS - version:
    • Linux - distro: - version:
    • Windows - Windows 10
    • Other - name: - version:
  • Toga Version

    • 0.3.0.dev23
  • Toga Target

    • android
    • cocoa
    • django
    • gtk
    • iOS
    • tvOS
    • watchOS
    • winforms
    • win32
    • Other (please specify)
@Vipul-Cariappa
Copy link
Contributor Author

If we replace

self.main_window.content = self.box

with

self.main_window.content = Box(children=[self.box])

it works as expected.

@tut949
Copy link

tut949 commented Aug 21, 2020

I have reproduced this issue (and the suggested workaround) on winforms. Also, it appears a similar issue exists on Android - although that seems to have another related bug as well. I don't understand the code well enough yet to be confident on an appropriate fix, but I can make it work by changing two lines in Widget.add_child() in toga_android:
Screen Shot 2020-08-21 at 5 11 37 PM

By making those changes (in combination with @Vipul-Cariappa 's suggested workaround for winforms), I can get it working on Android.

@freakboy3742 freakboy3742 added bug A crash or error in behavior. up-for-grabs windows The issue relates to Microsoft Windows support. labels Mar 29, 2022
@freakboy3742
Copy link
Member

I believe these issues have been addressed, and are now formally tested with #1834.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.
Projects
None yet
Development

No branches or pull requests

3 participants