pyfa-org / Pyfa

Python fitting assistant, cross-platform fitting tool for EVE Online
GNU General Public License v3.0
1.59k stars 403 forks source link

wx.BusyInfo not showing last word if it ends with ... #2245

Open m-sasha opened 3 years ago

m-sasha commented 3 years ago

For some unfathomable reason,

wx.BusyInfo("Loading previous fits...", parent=self)

is showing like this:

Screen Shot 2020-07-29 at 15 35 37

Simply adding a space after the ... fixes it.

blitzmann commented 3 years ago

image

Is this macOS? The windows one on mine has a slightly different feel, so I'm assuming this is mac. I don't have a mac to test with unfortunately.

Wild guess: I'm assuming it's calculating the incorrect boundaries for the text and thus hiding the full string. You might find some hints if you're able to open the inspector tool (available under Help menu when running with -d) while that's open, find the widget, and see what boundaries there are. Otherwise, yeah, it's an odd issue.

If simply adding a space at the end "solves" it, then we can always do that. But would be interested to have an idea as to the actual cause of it

m-sasha commented 3 years ago

Here is the parent and the text widgets with the regular text:

Widget:
    name = 'panel'
    class = <class 'wx._core.Panel'>
    bases = (<class 'wx._core.Window'>,)
    module = <module 'wx._core' from '/Users/sasha/Development/Projects/PyfaAT/.venv/lib/python3.7/site-packages/wx/_core.cpython-37m-darwin.so'>
    id = -31562
    style = 2621440
    pos = (0, 0)
    size = (400, 80)
    minsize = (-1, -1)
    bestsize = (270, 48)
    client size = (400, 80)
    virtual size = (400, 80)
    IsEnabled = True
    IsShown = True
    IsFrozen = False
    fg color = (0, 0, 0, 255)
    bg color = (236, 236, 236, 255)
    label = ''
    child count = 1 (direct)  1 (recursive)  1 (include TLWs)

Widget:
    name = 'staticText'
    class = <class 'wx._core.StaticText'>
    bases = (<class 'wx._core.Control'>,)
    module = <module 'wx._core' from '/Users/sasha/Development/Projects/PyfaAT/.venv/lib/python3.7/site-packages/wx/_core.cpython-37m-darwin.so'>
    id = -31561
    style = 0
    pos = (129, 32)
    size = (141, 16)
    minsize = (-1, -1)
    bestsize = (141, 16)
    client size = (141, 16)
    virtual size = (141, 16)
    IsEnabled = True
    IsShown = True
    IsFrozen = False
    fg color = (0, 0, 0, 255)
    bg color = (236, 236, 236, 255)
    label = 'Loading previous fits...'
    child count = 0 (direct)  0 (recursive)  0 (include TLWs)

Here it with a space after the ...:

Widget:
    name = 'panel'
    class = <class 'wx._core.Panel'>
    bases = (<class 'wx._core.Window'>,)
    module = <module 'wx._core' from '/Users/sasha/Development/Projects/PyfaAT/.venv/lib/python3.7/site-packages/wx/_core.cpython-37m-darwin.so'>
    id = -31562
    style = 2621440
    pos = (0, 0)
    size = (400, 80)
    minsize = (-1, -1)
    bestsize = (272, 48)
    client size = (400, 80)
    virtual size = (400, 80)
    IsEnabled = True
    IsShown = True
    IsFrozen = False
    fg color = (0, 0, 0, 255)
    bg color = (236, 236, 236, 255)
    label = ''
    child count = 1 (direct)  1 (recursive)  1 (include TLWs)

Widget:
    name = 'staticText'
    class = <class 'wx._core.StaticText'>
    bases = (<class 'wx._core.Control'>,)
    module = <module 'wx._core' from '/Users/sasha/Development/Projects/PyfaAT/.venv/lib/python3.7/site-packages/wx/_core.cpython-37m-darwin.so'>
    id = -31561
    style = 0
    pos = (127, 32)
    size = (145, 16)
    minsize = (-1, -1)
    bestsize = (145, 16)
    client size = (145, 16)
    virtual size = (145, 16)
    IsEnabled = True
    IsShown = True
    IsFrozen = False
    fg color = (0, 0, 0, 255)
    bg color = (236, 236, 236, 255)
    label = 'Loading previous fits... '
    child count = 0 (direct)  0 (recursive)  0 (include TLWs)
m-sasha commented 3 years ago

and yes, it's on Mac OS X.

m-sasha commented 3 years ago

Ok, this is a larger problem:

Screen Shot 2020-07-30 at 0 05 23

If I change the line that creates this label to:

box.Add(wx.StaticText(parent, wx.ID_ANY, damageType.capitalize() + ' '), 0, wx.ALIGN_LEFT)

Then it looks correct:

Screen Shot 2020-07-30 at 0 06 28
m-sasha commented 3 years ago

The stats panel is full of these, by the way:

Screen Shot 2020-07-30 at 0 08 12
m-sasha commented 3 years ago

Updating to wxPython 4.1.0 fixes this, and also makes PyFa use Mac OS X's Dark Mode:

Screen Shot 2020-07-30 at 0 16 11
m-sasha commented 3 years ago

Unfortunately, it appears that

bmp.SetSize((bmp.GetWidth() // scale, bmp.GetHeight() // scale))

fails on wxPython 4.1.0 with:

pyfa v2.24.1
EVE Data Version: 1777281 (2020-07-28 11:14:33)

OS version: Darwin-19.5.0-x86_64-i386-64bit
Python version: 3.7.7 (default, Mar 10 2020, 15:43:33) 
[Clang 11.0.0 (clang-1100.0.33.17)]
wxPython version: 4.1.0 (wxWidgets 3.1.4)
SQLAlchemy version: 1.3.18
Logbook version: 1.5.3
Requests version: 2.24.0
Dateutil version: 2.8.1

####################

Traceback (most recent call last):
  File "pyfa.py", line 143, in <module>
    mf = MainFrame(options.title)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/mainFrame.py", line 172, in __init__
    self.additionsPane = AdditionsPane(self.fitting_additions_split, self)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/additionsPane.py", line 64, in __init__
    self.drone = DroneView(self.notebook)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/builtinAdditionPanes/droneView.py", line 73, in __init__
    Display.__init__(self, parent, style=wx.BORDER_NONE)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/display.py", line 44, in __init__
    self.insertColumnBySpec(i, colName)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/display.py", line 123, in insertColumnBySpec
    col = ViewColumn.getColumn(colSpec)(self, None)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/builtinViewColumns/maxRange.py", line 45, in __init__
    self.imageId = fittingView.imageList.GetImageIndex(iconFile, "icons")
  File "/Users/sasha/Development/Projects/PyfaAT/gui/cachingImageList.py", line 34, in GetImageIndex
    bitmap = BitmapLoader.getBitmap(*loaderArgs)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/bitmap_loader.py", line 74, in getBitmap
    bmp = cls.loadBitmap(name, location)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/bitmap_loader.py", line 108, in loadBitmap
    bmp.SetSize((bmp.GetWidth() // scale, bmp.GetHeight() // scale))
wx._core.wxAssertionError: C++ assertion "GetHeight() == h" failed at /Users/robind/projects/bb2/dist-osx-py37/build/ext/wxWidgets/src/osx/core/bitmap.cpp(1380) in SetHeight(): Changing the bitmap height is not supported

I tried to replace Bitmap.SetSize with Bitmap.CreateScaled, but then it fails with:

Traceback (most recent call last):
  File "pyfa.py", line 143, in <module>
    mf = MainFrame(options.title)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/mainFrame.py", line 172, in __init__
    self.additionsPane = AdditionsPane(self.fitting_additions_split, self)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/additionsPane.py", line 64, in __init__
    self.drone = DroneView(self.notebook)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/builtinAdditionPanes/droneView.py", line 73, in __init__
    Display.__init__(self, parent, style=wx.BORDER_NONE)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/display.py", line 44, in __init__
    self.insertColumnBySpec(i, colName)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/display.py", line 123, in insertColumnBySpec
    col = ViewColumn.getColumn(colSpec)(self, None)
  File "/Users/sasha/Development/Projects/PyfaAT/gui/builtinViewColumns/maxRange.py", line 45, in __init__
    self.imageId = fittingView.imageList.GetImageIndex(iconFile, "icons")
  File "/Users/sasha/Development/Projects/PyfaAT/gui/cachingImageList.py", line 37, in GetImageIndex
    id_ = self.map[loaderArgs] = wx.ImageList.Add(self, bitmap)
wx._core.wxAssertionError: C++ assertion "bitmapSize == m_size" failed at /Users/robind/projects/bb2/dist-osx-py37/build/ext/wxWidgets/src/generic/imaglist.cpp(85) in Add(): All bitmaps in wxImageList must have the same size
m-sasha commented 3 years ago

Maybe this can be of use: https://groups.google.com/forum/#!topic/wxpython-users/EV5rOSohRCE I'll try and see whether that helps.

blitzmann commented 3 years ago

Yeah, I believe @DarkFenX is well versed in issues with 4.1.0. I think there was an attempt to upgrade to it a while back, but there's too many issues atm. (see https://github.com/pyfa-org/Pyfa/issues/2179)

The text thing is bizarre tho. Is this something that you just noticed with recent versions? Would it be possible to try older 2.* versions to see if they have the same issue? (you're going to want to backup your saveddata.db file if you want to try to run older versions, just to be safe)

m-sasha commented 3 years ago

The last version I know worked (about two years ago) is 4.0.0b2, but now I can't even get it to install. It fails with

    checking if C++ compiler (g++ -mmacosx-version-min=10.5) works with SDK/version options... configure: error: in `/private/var/folders/cb/8d5j43cd4l30xjdbr6s980_h0000gp/T/pip-install-sbfdl2yo/wxPython/build/wxbld':
    configure: error: no.  Try a different SDK
    See `config.log' for more details
    Error running configure
    ERROR: failed building wxWidgets
    Traceback (most recent call last):
      File "build.py", line 1269, in cmd_build_wx
        wxbuild.main(wxDir(), build_options)
      File "/private/var/folders/cb/8d5j43cd4l30xjdbr6s980_h0000gp/T/pip-install-sbfdl2yo/wxPython/buildtools/build_wxwidgets.py", line 376, in main
        "Error running configure")
      File "/private/var/folders/cb/8d5j43cd4l30xjdbr6s980_h0000gp/T/pip-install-sbfdl2yo/wxPython/buildtools/build_wxwidgets.py", line 85, in exitIfError
        raise builder.BuildError(msg)

I'll try complete older PyFa versions. It could be a Mac OS X change which triggers this issue, and they fixed/worked around it in wxPython 4.1.0

m-sasha commented 3 years ago

I went back as far as 2.9.1 and it has the same bug. I think it's a combination of latest Mac OS X and old(er) wxPython.

m-sasha commented 3 years ago

When running with wxPython 4.0.6, but not 4.1.0, I get this printed to the console a bunch of times:

2020-07-30 09:56:10.157 Python[12064:648175] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

I suspect it's relevant.

blitzmann commented 3 years ago

That would be a good place to start looking. I wonder if it expected a certain font, and is calculating sizes with that font in mind, but instead gets a different one that doesn't match the size.

XygenSS commented 3 years ago

Hi, sorry if I'm making unnecessary noise, but is this issue getting any attention? Have been having the exact same problem for the entire time I've been using Pyfa. 2015 macbook pro, Catalina 10.15.7 (and older). I'm wondering if there's any info I could provide to help or if there is any DIY fixes I could do.

Screen Shot 2021-03-24 at 4 58 06 PM
DarkFenX commented 3 years ago

I suspect it is a bug on wxpython/wxwidgets side. Since it is fixed in 4.1.0, switching to that would resolve it. However, there are multiple issues related to this upgrade, see #2179

Vertux commented 2 years ago

I run into the same issue, that's why I wanted to ask, if you could solve this issue already - I have seen wxPython 4.1.1 is out, maybe they have fixed the other issues mentioned in #2179