{"action":"created","issue":{"url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/742","repository_url":"https://api.github.com/repos/wxWidgets/Phoenix","labels_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/742/labels{/name}","comments_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/742/comments","events_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/742/events","html_url":"https://github.com/wxWidgets/Phoenix/issues/742","id":295791581,"number":742,"title":"wxpg.PGEditor.GetValueFromControl & wxpg.PGProperty.StringToValue","user":{"login":"Lokla","id":6813414,"avatar_url":"https://avatars2.githubusercontent.com/u/6813414?v=4","gravatar_id":"","url":"https://api.github.com/users/Lokla","html_url":"https://github.com/Lokla","followers_url":"https://api.github.com/users/Lokla/followers","following_url":"https://api.github.com/users/Lokla/following{/other_user}","gists_url":"https://api.github.com/users/Lokla/gists{/gist_id}","starred_url":"https://api.github.com/users/Lokla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lokla/subscriptions","organizations_url":"https://api.github.com/users/Lokla/orgs","repos_url":"https://api.github.com/users/Lokla/repos","events_url":"https://api.github.com/users/Lokla/events{/privacy}","received_events_url":"https://api.github.com/users/Lokla/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-09T08:33:40Z","updated_at":"2018-05-15T15:06:54Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"**Operating system**: Windows 10 64 Bit\r\n**wxPython version**: 4.0.2a1 msw (phoenix)\r\n**Stock or custom build**: Stock\r\n**Python version**: 2.7.14\r\n**Stock or custom build**: Stock\r\n\r\nRelated with #394 \r\nReported in wxpython-users here: \r\nhttps://groups.google.com/forum/#!topic/wxpython-users/F5l-QrKQEfk\r\n\r\nI have two problems here when implementing a custom editor. I tried to fix it myself, but I am stuck along the way.\r\n\r\n**PGEditor Overload of GetValueFromControl crashes application**:\r\n\r\nFile to create the crash:\r\n[pgEditorCrash.zip](https://github.com/wxWidgets/Phoenix/files/1710135/pgEditorCrash.zip)\r\n\r\nAlso happens in demo (example is created mostly from demo code).\r\n\r\nSteps to reproduce:\r\n * Edit the label\r\n * Save the edited value\r\n\r\nI already managed to at least jump into the function by removing the third D in the format - I think it might be too much there. But I have no experience with sip, so it is just a guess.\r\n\r\n```python\r\nPyObject *sipResObj = sipCallMethod(0, sipMethod, \"DD\",\r\n                                            property, sipType_wxPGProperty, NULL,\r\n                                            ctrl, sipType_wxWindow, NULL);\r\n```\r\n\r\nMy code now reaches the Python function (yay), but the return value (once the second problem is avoided) will still report an error:\r\n\r\n```TypeError: invalid result from CustomEditor.GetValueFromControl(), a 'bool' is expected not 'tuple'```\r\n\r\nSo it seems that the sipParseResult is not executed correctly.\r\n\r\n\r\nBut I also ran into the following additional problem:\r\n\r\n**PGProperty function StringToValue returns boolean and not tuple of Boolean and String**:\r\n\r\n```python\r\nimport wx\r\nimport wx.propgrid as wxpg\r\napp = wx.App()\r\nframe = wx.Frame(None)\r\npg = wxpg.PropertyGrid(frame)\r\nprop = wxpg.StringProperty(\"Simple Property\", name=\"mine\", value=\"Change me!!\")\r\nprint(prop.StringToValue(wxpg.PG_EDITABLE_VALUE, 'My New Value'))\r\n```\r\n\r\n* This code returns just the boolean True which indicates that the result is valid, but not the result itself.\r\n* At the moment this function also cannot be overridden for custom Properties\r\n\r\nThis might also affect IntToValue.\r\n\r\nFor funtions like the GetValueFromControl, you really need both return values (the bool and the string), so the function should return a tuple.\r\n\r\nThanks,\r\nMichael"},"comment":{"url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/comments/389201612","html_url":"https://github.com/wxWidgets/Phoenix/issues/742#issuecomment-389201612","issue_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/742","id":389201612,"user":{"login":"jensgoe","id":6022600,"avatar_url":"https://avatars1.githubusercontent.com/u/6022600?v=4","gravatar_id":"","url":"https://api.github.com/users/jensgoe","html_url":"https://github.com/jensgoe","followers_url":"https://api.github.com/users/jensgoe/followers","following_url":"https://api.github.com/users/jensgoe/following{/other_user}","gists_url":"https://api.github.com/users/jensgoe/gists{/gist_id}","starred_url":"https://api.github.com/users/jensgoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jensgoe/subscriptions","organizations_url":"https://api.github.com/users/jensgoe/orgs","repos_url":"https://api.github.com/users/jensgoe/repos","events_url":"https://api.github.com/users/jensgoe/events{/privacy}","received_events_url":"https://api.github.com/users/jensgoe/received_events","type":"User","site_admin":false},"created_at":"2018-05-15T15:06:54Z","updated_at":"2018-05-15T15:06:54Z","author_association":"CONTRIBUTOR","body":"Ok, i fixed the crash by removing the virtualCatcherCode of GetValueFromControl in the etg script. After that i had the same issue like Lokla that StringToValue is not working properly. All the StringToValue functions that receives the result in the first argument are not marked as an out parameter in the sip code. I fixed this by modifying the sip file like this (adding /Out/):\r\n\r\n```\r\n    virtual\r\n    bool StringToValue(\r\n        wxPGVariant & variant   /Out/,\r\n        const wxString & text,\r\n        int argFlags = 0\r\n    ) const;\r\n```\r\n\r\nThis seems to be done in the etg script by:\r\n```\r\n    c = module.find('wxPGProperty')\r\n    tools.ignoreConstOverloads(c)\r\n    c.find('StringToValue.variant').out = True\r\n    c.find('IntToValue.variant').out = True\r\n```\r\nSomehow this does not work. I guess this seems not to consider all the derived subclasses."}}
{"actor":{"display_login":"jensgoe"}}