wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.34k stars 516 forks source link

Help string is not showing in PropertyGrid #1722

Open LumaRay opened 4 years ago

LumaRay commented 4 years ago

Hello. I have previously opened this issue: https://github.com/wxWidgets/Phoenix/issues/1714 You have suggested that I upgrade wxPython to the newer dev version 4.1.1a1. So did I, and that problem was solved. But now I have another problem: help strings in PropertyGrid are not showing in this dev alpha version. They do though after I downgrade the version to 4.1.0 using pip3 install --upgrade wxpython=4.1.0

import wx
import wx.propgrid

class MyFrame(wx.Frame):
    S_NORMAL_FACE_DETECTION_ALGORITHM = "NormalFaceDetectionAlgorithm"
    S_NORMAL_FACE_DETECTION_ALGORITHM_OPENCV = 0
    S_NORMAL_FACE_DETECTION_ALGORITHM_TENSORFLOW = 1
    S_WINDOW_WIDTH = "WindowWidth"

    def __init__(self, *args, **kwds):
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((400, 450))
        self.pane_1 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(400, 450))

        self.property_grid_1 = wx.propgrid.PropertyGridManager(self.pane_1, wx.ID_ANY,
                                                               style=wx.propgrid.PG_BOLD_MODIFIED | wx.propgrid.PG_DESCRIPTION | wx.propgrid.PG_SPLITTER_AUTO_CENTER | wx.propgrid.PG_TOOLBAR | wx.propgrid.PG_TOOLTIPS)
        self.property_grid_1.AddPage("Test page")
        pr = wx.propgrid.EnumProperty(label="Face detection algorithm", name=self.S_NORMAL_FACE_DETECTION_ALGORITHM,
                                      value=self.S_NORMAL_FACE_DETECTION_ALGORITHM_TENSORFLOW)
        pr.SetHelpString("Description: Face detection algorithm")
        pr.AddChoice(label="OpenCV HaarCascade", value=self.S_NORMAL_FACE_DETECTION_ALGORITHM_OPENCV)
        pr.AddChoice(label="Tensorflow FCNN Yolo", value=self.S_NORMAL_FACE_DETECTION_ALGORITHM_TENSORFLOW)
        pr.SetChoiceSelection(self.S_NORMAL_FACE_DETECTION_ALGORITHM_TENSORFLOW)
        self.property_grid_1.Append(pr)

        pr = wx.propgrid.IntProperty(label="Window width", name=self.S_WINDOW_WIDTH, value=800)
        pr.SetEditor("SpinCtrl")
        pr.SetHelpString("Description: Window width")
        self.property_grid_1.Append(pr)

        pgv = self.property_grid_1.GetPropertyValues(inc_attributes=True)

        self.property_grid_1.SetPropertyValues(pgv, autofill=True)

        self.label_alg = wx.TextCtrl(self.pane_1, id=wx.ID_ANY, size=(50, 50))
        self.label_alg.SetLabel("Test")

        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_1.Add(self.property_grid_1, 1, wx.EXPAND, 0)
        sizer_1.Add(self.label_alg, 1, wx.EXPAND, 0)
        self.pane_1.SetSizer(sizer_1)
        self.SetSizer(sizer_1)

        self.timer = wx.Timer(self)
        self.timer.Start(1000. / 15)

        self.Bind(wx.EVT_TIMER, self.TimerJob)

    def TimerJob(self, evt):
        algProp = self.property_grid_1.GetProperty(self.S_NORMAL_FACE_DETECTION_ALGORITHM)
        alg = algProp.GetChoiceSelection()
        self.label_alg.SetLabel("Choice is: " + str(alg))

class MyApp(wx.App):
    def OnInit(self):
        self.frame = MyFrame(None, wx.ID_ANY, "")
        self.SetTopWindow(self.frame)
        self.frame.Show()
        return True

# end of class MyApp

if __name__ == "__main__":
    app = MyApp(0)
    app.MainLoop()
swt2c commented 4 years ago

What OS? I see the help string on GTK so it may be OS-specific.

LumaRay commented 4 years ago

Windows 10 x64

swt2c commented 4 years ago

This doesn't seem like it would be a problem in wxPython itself. Can you compile wxWidgets master branch and see if you observe the problem in the propgrid sample? If so, then I would suggest opening a trac ticket.

LumaRay commented 4 years ago

@swt2c, I'm not very familiar with installations by compiling, so I just tried to follow instructions from this page: https://docs.wxwidgets.org/trunk/plat_msw_install.html In particular I have compiled wxWidgets using Visual Studio 2019 compiler: > nmake /f makefile.vc BUILD=release SHARED=1 TARGET_CPU=X64 But what should I do next? How to tell Python3 to use this compiled version?

swt2c commented 4 years ago

There should be a propgrid sample in the samples/propgrid directory. You may have to compile it separately. Once you do that, you can run it and see if you observe the same behavior with the missing help string.

LumaRay commented 4 years ago

I have found and compiled that example, but it is missing dlls, where do I find them?

swt2c commented 4 years ago

They should be somewhere down the build tree - you compiled them earlier. (Sorry, I'm not very familiar with how Windows builds work.)

LumaRay commented 4 years ago

Ok, I have searched for *.dll and fould them here: wxWidgets\lib\vc_x64_dll\ I have run the sample and it doesn't show the help string for any property selected: https://www.screencast.com/t/qJ0sGnRdoQ

swt2c commented 4 years ago

In that case, you should file a wxWidgets bug at https://trac.wxwidgets.org/.

LumaRay commented 4 years ago

Ok, posted that: https://trac.wxwidgets.org/ticket/18825#ticket

LumaRay commented 4 years ago

I can see devs replied already: "This issue is not related to wxPropertyGrid itself. It is about measuring empty text extent" Actually I don't understand what that means and what to do to fix that, and you? And also how do I manage that ticket? Should I close it or say something else there?

swt2c commented 4 years ago

He's saying it's a regression in wxWidgets, but not just in PropertyGrid itself. You don't need to respond to it yet. Someone will hopefully respond and fix it.

LumaRay commented 4 years ago

Ok, thank you for bearing with me.

swt2c commented 4 years ago

I would leave this ticket open here because once they fix the problem in wxWidgets, we'll have to update wxPython to pick up the fix.

LumaRay commented 4 years ago

Ah, allright, reopening...

swt2c commented 4 years ago

I think this should supposedly be fixed in the latest snapshots (as wxWidgets was updated). Can you give them a try?

LumaRay commented 4 years ago

Do you mean I can checkout and compile wxWidgets? Or how do I use the snapshots?

swt2c commented 4 years ago

For Windows, you should be able to use the precompiled wheels and not have to compile anything. See the instructions here: https://wxpython.org/Phoenix/snapshot-builds/README.txt. Make sure you install the one with 75f1081f in the name as that's the latest one.

LumaRay commented 4 years ago

Ok, and for Debian 10.4 x64?

swt2c commented 4 years ago

Do you see this particular issue on Debian? I don't see it on Linux so I assumed it was probably Windows-only.

LumaRay commented 4 years ago

Well, on Windows 10 x64 I have upgraded wxPython to your latest snapshot: pip3 install --upgrade https://wxpython.org/Phoenix/snapshot-builds/wxPython-4.1.1a1.dev4892+33fa9afd-cp37-cp37m-win_amd64.whl After that the help strings in PropertyGrid did start showing. However now enum dropdowns are not opening anymore. You can take and try the sample code I posted above.

Regarding Debian, right, I have forgotten that it is just Windows issue. Checked in Debian - help strings are showing and dwopdowns work.

swt2c commented 4 years ago

Well, on Windows 10 x64 I have upgraded wxPython to your latest snapshot: pip3 install --upgrade https://wxpython.org/Phoenix/snapshot-builds/wxPython-4.1.1a1.dev4892+33fa9afd-cp37-cp37m-win_amd64.whl After that the help strings in PropertyGrid did start showing. However now enum dropdowns are not opening anymore. You can take and try the sample code I posted above.

Sigh, one thing fixed and another thing breaks. The wxWidgets trunk has been rather busy lately as they are preparing for a release. It should hopefully be fixed soon.

LumaRay commented 4 years ago

I can change dropdown values with arrow keys, but the problem is, the set events are not firing.

LumaRay commented 4 years ago

Actually set events are not firing even in 4.1.1a1.dev4867 version. I use it like this: pr.OnSetValue = self.onPropertyInfraredDisplayPaletteChanged This is a problem, because I need to perform actions based on that event :(

swt2c commented 4 years ago

I think it's been fixed in wxWidgets. Robin just needs to update the ref in wxPython.

LumaRay commented 4 years ago

I have just installed the latest snapshot: pip3 install --upgrade https://wxpython.org/Phoenix/snapshot-builds/wxPython-4.1.1a1.dev4919+57702fa7-cp37-cp37m-win_amd64.whl Still PG dropdowns are not expanding...