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

Allowing 'none' Values for a Choice #3

Closed
mcrowson opened this issue Jul 16, 2018 · 3 comments · Fixed by #33
Closed

Allowing 'none' Values for a Choice #3

mcrowson opened this issue Jul 16, 2018 · 3 comments · Fixed by #33

Comments

@mcrowson
Copy link

In Toga, possible choices are given for display and visibility of 'none'
https://github.com/pybee/toga/blob/master/src/core/toga/style/pack.py#L33

Entering a valid entry of 'none' for these however gets converted to the native Python None
https://github.com/pybee/travertino/blob/master/travertino/declaration.py#L51

Which causes a ValueError to be raised.
ValueError: Invalid value 'none' for property 'visibility'; Valid values are: hidden, none, visible

@mcrowson mcrowson changed the title Allowing None Values for Display Allowing None Values for a Choice Jul 16, 2018
@mcrowson mcrowson changed the title Allowing None Values for a Choice Allowing 'none' Values for a Choice Jul 16, 2018
@stantonxu
Copy link

@mcrowson , could you please list out the detailed reproduce steps? I don't have problem to use style=None for my toga GUI.

@mcrowson
Copy link
Author

mcrowson commented Jul 16, 2018 via email

@mcrowson
Copy link
Author

mcrowson commented Jul 17, 2018

To reproduce:

cookiecutter https://github.com/pybee/briefcase-template
# named the project bug_example
cd bug_example
python3 -m venv env
env/bin/pip install briefcase toga

Then I added a Box named some_content and set its visibility to 'none'. Here is the app.py file with those two lines added.

import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW


class BugExample(toga.App):
    def startup(self):
        # Create a main window with a name matching the app
        self.main_window = toga.MainWindow(title=self.name)

        some_content = toga.Box()
        some_content.style.visibility = 'none'

        # Create a main content box
        main_box = toga.Box()

        # Add the content on the main window
        self.main_window.content = main_box

        # Show the main window
        self.main_window.show()


def main():
    return BugExample('Bug Example', 'com.example.bug_example')

Next I ran setup for ios

env/bin/python setup.py ios

I opened the xcode project then in xcode. It builds successfully, The simulator launches and i see the following in the xcode console

2018-07-17 09:27:30.726154-0400 Bug Example[1038:14423]   File "/Users/matthew/Library/Developer/CoreSimulator/Devices/90E3F30B-408D-4D8C-81BE-48E2A139543D/data/Containers/Bundle/Application/5597D9C1-561C-4830-92C8-DAA6C2F3D45F/Bug Example.app/Library/Application Support/com.example.bug_example/app/bug_example/app.py", line 13, in startup
2018-07-17 09:27:30.726382-0400 Bug Example[1038:14423]     some_content.style.visibility = 'none'
2018-07-17 09:27:30.726500-0400 Bug Example[1038:14423]   File "/Users/matthew/Library/Developer/CoreSimulator/Devices/90E3F30B-408D-4D8C-81BE-48E2A139543D/data/Containers/Bundle/Application/5597D9C1-561C-4830-92C8-DAA6C2F3D45F/Bug Example.app/Library/Application Support/com.example.bug_example/app_packages/travertino/declaration.py", line 181, in setter
2018-07-17 09:27:30.726748-0400 Bug Example[1038:14423]     value, name, choices
2018-07-17 09:27:30.726944-0400 Bug Example[1038:14423] ValueError: Invalid value 'none' for property 'visibility'; Valid values are: hidden, none, visible
2018-07-17 09:27:30.731067-0400 Bug Example[1038:14423] App became active.

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

Successfully merging a pull request may close this issue.

2 participants