question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

style(Pack(visibility=VISIBLE) does not work

See original GitHub issue

Expected Behavior

self.busy_label.style=Pack(visibility=VISIBLE) should work

Current Behavior

I had a label: self.busy_label = toga.Label('Fetching data...Please wait...', style=Pack(visibility=HIDDEN))

Later I tried to hide it: self.busy_label.style=Pack(visibility=VISIBLE)

This did not work. Resizing the window did not help.

This. did work: self.busy_label.style.visibility = VISIBLE

Steps to reproduce

If you click the 2nd or 3rd buttons, everything works fine, but as soon as you click the 1st button, everything is broken.

import toga
from toga.style import Pack
from toga.constants import ROW, COLUMN, HIDDEN, VISIBLE, CENTER

class BugApp(toga.App):

    def startup(self):
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(500, 500))

        self.busy_label = toga.Label('Fetching data...Please wait...', style=Pack(visibility=HIDDEN))

        self.button1 = toga.Button(label='style=Pack(visibility=VISIBLE)', on_press=self.clicked)
        self.button2 = toga.Button(label='style.visibility = VISIBLE', on_press=self.clicked)
        self.button3 = toga.Button(label='Hide Label', on_press=self.clicked)
        button_box = toga.Box(children=[self.button1, self.button2, self.button3], style=Pack(direction=ROW, padding=20, alignment=CENTER))
        label_box = toga.Box(children=[self.busy_label], style=Pack(direction=COLUMN, padding=20, alignment=CENTER))
        box = toga.Box(children=[button_box, label_box], style=Pack(direction=COLUMN, padding=20))

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

    def clicked(self, button):
        if 'Pack' in button.label:
            self.busy_label.style=Pack(visibility=VISIBLE)
        elif 'Hide' in button.label:
            self.busy_label.style.visibility = HIDDEN
        else:
            self.busy_label.style.visibility = VISIBLE

        self.busy_label.refresh()

def main():
    # App name and namespace
    return BugApp('BugApp', 'mybugapp')


if __name__ == '__main__':
    app = main()
    app.main_loop()

Your Environment

  • Python Version: 3.7.7

  • Operating System and Version (select from the following and list the specific version number; if your OS is not listed, list that as well)

    • macOS - version: 10.15.5
  • Toga Version: 0.2.15

  • Toga Target (the type of app you are trying to generate)

    • cocoa

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
freakboy3742commented, Sep 25, 2020

@swapniljha001 We need to establish a patch that does trigger the application of the style change, but doesn’t require removal of the overall optimization. I’m not sure if @Vipul-Cariappa is still looking at this problem (it’s been a few months since the last update); any investigation/exploration you want to do would be helpful.

0reactions
swapniljha001commented, Sep 25, 2020

What can I do to help resolve this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Style Visibility not behaving as expected - Stack Overflow
My problem is that if I change the visibility of an element inside one of the tab content divs to 'hidden', then back...
Read more >
style.visibility = 'visible' or style.display = 'block' does not work ...
I found that div1.style.visibility = 'visible' or div.style.display = 'block' works in IE 6.x but NOT in Netscape 8.x. Anyone knows how I...
Read more >
toBeVisible not working as expected with visibility property #209
My code has a checkbox that must be visible when the user checks it. The visibility property is perfect for this because it...
Read more >
Top 3 Examples of JavaScript Style visibility - eduCBA
One can set visibility in styling by using values like visible, hidden, ... It's made possible to do animation using visibility property which...
Read more >
CSS Visibility - Quasar Framework
Set display to none . Compare with below - the class hidden means the element will not show and will not take up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found