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

setting value in several controls when the value is not a str #73

Open
typemytype opened this issue May 11, 2018 · 2 comments
Open

setting value in several controls when the value is not a str #73

typemytype opened this issue May 11, 2018 · 2 comments

Comments

@typemytype
Copy link
Member

(in py3)

When the value is not a string, cocoa/pyObjc tries to localise somehow, fe numbers. This is not nice and different behaviour.

import vanilla

def callback(sender):
    v = sender.get()
    print(v, type(v))

w = vanilla.Window((400, 400))

w.t1 = vanilla.EditText((10, 10, -10, 22), "1000", callback=callback)
w.t2 = vanilla.EditText((10, 40, -10, 22), 1000, callback=callback)

w.open()

get() and set() are not symmetrical as the output get() is not getting localised.

This behaviour has changed in cocoa and maybe the best advice is to stringify before setting any data in a control, so maybe vanilla should warn if this is happening.

@typemytype
Copy link
Member Author

objectValue is maybe not the best option...

To be valid object value, the cell must have a formatter capable of converting the object to and from its textual representation. The value of this property is nil if an object has not been assigned to the cell.

but the cell.formatter() is None, tried to look for a default formatter... but there isn't one

see https://developer.apple.com/documentation/appkit/nscell/1530936-objectvalue?language=objc

@typesupply
Copy link
Member

The EditText documentation now says that the value should be a string if no formatter is defined. Do you still think we should raise a warning if the value is not a string and there is no formatter? I'm worried about that being very noisy.

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

2 participants