More information on this interesting problem. It seems when running in the PyInstaller exe, wxPython gets different (and confusing) information regarding the size of a wx.Dialog window. Here’s my test results of various methods on the wx.Dialog window comparing command-line execution vs. PyInstaller execution of my code:
Command Line Results
self.GetSize() returns (400,399)
self.GetWindowBorderSize returns (0,0)
self.GetClientSize() returns (384,360)
``
``
PyInstaller Results
self.GetSize() returns (390,389)
self.GetWindowBorderSize returns (0,0)
self.GetClientSize() returns (384,360)
``
Note: GetSize returns the entire size of the window, including borders, title bar, menu bar, scrollbars, etc. GetClientSize returns the part of the window for placing user controls, panels, etc. In my case, the wx.Dialog has no scrollbars, no menubar; only a title bar (which is thinner in the PyInstaller case) and various controls, buttons, etc.
As can be seen by the above numbers, in the PyInstaller case, the Dialog full window size is reported as exactly 10 pixels smaller in both dimensions, however the ClientSize IS REPORTED AS EXACTLY THE SAME !?? How can the full window be smaller but the client area be the same??
And to make it even more interesting, when I visually compare the x-dimension of the command-line dialog window with the PyInstaller dialog window, they are rendered exactly the same on my display !! (The y-dimension is still different though because of the thinner title bar in the PyInstaller version). Something clearly doesn’t add up here.
Regarding os.environ: The only difference I see is that the following is removed from my PATH variable when running via PyInstaller:
C:\Users\dave\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pywin32_system32;
C:\Users\dave\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\.libs
So I am still no closer to understanding where the problem is at this point. wxPython is clearly getting different (and non-sensical) sizing information when run under PyInstaller, but I don’t know if this is a problem with wxPython or PyInstaller. I tried installing the latest DEV version of PyInstaller but it did not affect anything. I’m reluctant to upgrade to wxPython 4.0.3 at this point but may have to cave in and try it anyway. (CAUTION: Uninstalling PyInstaller requires MORE than just doing “pip uninstall”…it took me quite a while to figure this out after trying to re-install the current stable release)
Can anyone recommend some next steps for figuring out if we have a wxPython problem or a PyInstaller problem?
Thanks,
Dave
···
On Wednesday, August 29, 2018 at 6:41:53 PM UTC-4, Datro wrote:
Thanks again for another good suggestion. It is encouraging to know that you are not having similar problems in your environment.
To get a further idea of whether the OS is at play, I installed the PyInstaller exe bundle on a separate “virgin” Windows 10 machine I have here, and also a Windows 7 machine. I get the exact same behavior on the separate Windows 10 machine, i.e. thinner wx.Dialog title bar and incorrect positioning. Interestingly, on the Windows 7 machine the wx.Dialog title bar is NOT thinner, but the positioning alignment problem still persists. So perhaps I am dealing with two separate issues here. I should also mention that my PyInstaller app bundle of identical code works correctly and as expected on macOS 10.13.6.
Next I will have a look at os.environ differences, if any.
Dave
On Wednesday, August 29, 2018 at 12:39:43 PM UTC-4, efahl wrote:
Ok, just to give you some more data to churn…
We switched from py2exe to PyInstaller about 18 months ago. Our distributions are run on Win 7 and 10 machines (all x64), some with font scaling, some without (most notably, my primary dev workstation has a 32" main monitor set to 125%). We run Python 3.6.6, wxPython 4.0.3 (moving to latest stable a few days after they are released and we’ve tested them). Our in-dev code running via ‘python main.py’ looks identical in every regard to our bundled ‘main.exe’, all the windows, frames and title bars stay the same size. We use AUI to manage a tiled collection of “top-level” widgets (model tree, property editor, graphics window, task manager, task dialog, etc). We even tear off windows programmatically (when we record animations in the graphics window, we tear off the control panel so we can reposition and resize the graphics window without moving the start/stop controls), then redock them, all with no apparent differences between .py and .exe…
I’d suspect local environment settings, LOCALE(???) or something? Maybe dump os.environ in both dev and .exe to see if anything jumps out?