0
MacOS Mojave (10.14.5 (18F132))
Python 3.7.7 (default, Mar 10 2020, 15:43:03)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
PyQt version: 5.14.1
PyCharm 2019.1.3 (Community Edition)
Build #PC-191.7479.30, built on May 29, 2019
JRE: 11.0.2+9-b159.60 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

I generated an UI with QtDesigner (UI_LaserExpose.ui - see code at bottom of post), and I'm getting the desired looks when launching from the a bash terminal (python3 qt_test.py - see code at bottom of post):

UI running qt_test.py from MacOS terminal (bash)

However, if I run the same script (qt_test.py) from within PyCharm, accessing the same Python interpreter, not utilizing any virtual environment, and relying on the same PyQt5 installation, I'm getting this:

UI as produced when running qt_test.py from within PyCharm

Not sure why I'd get different results from within PyCharm?

Some things I already did:

  • Uninstalling all Python versions and re-installing only the one I'm using right now.
  • Deleting all library folders and re-installing only the ones I'm using right now.

Here are the currently installed libraries:

  • PyQt5 5.14.1
  • PyQt5-sip 12.7.1
  • PyYAML 5.3.1
  • future 0.18.2
  • iso8601 0.1.12
  • pip 20.0.2
  • pyserial 3.4 3.4
  • setuptools 46.0.0
  • wheel 0.34.2

Any pointers as to what's causing the layout screw-up from within PyCharm would be appreciated!

Thanks!

UI_LaserExpose.ui:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>471</width>
    <height>301</height>
   </rect>
  </property>
  <property name="minimumSize">
   <size>
    <width>5</width>
    <height>0</height>
   </size>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QPushButton" name="up_button">
    <property name="geometry">
     <rect>
      <x>60</x>
      <y>130</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="text">
     <string>Y+</string>
    </property>
   </widget>
   <widget class="QPushButton" name="down_button">
    <property name="geometry">
     <rect>
      <x>60</x>
      <y>210</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="text">
     <string>Y-</string>
    </property>
   </widget>
   <widget class="QPushButton" name="motor_off_button">
    <property name="geometry">
     <rect>
      <x>60</x>
      <y>170</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Motor
Off</string>
    </property>
   </widget>
   <widget class="QPushButton" name="right_button">
    <property name="geometry">
     <rect>
      <x>100</x>
      <y>170</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="text">
     <string>X+</string>
    </property>
   </widget>
   <widget class="QPushButton" name="left_button">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>170</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="text">
     <string>X-</string>
    </property>
   </widget>
   <widget class="QComboBox" name="serial_port_combobox">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>30</y>
      <width>221</width>
      <height>26</height>
     </rect>
    </property>
   </widget>
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>10</y>
      <width>81</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>Serial port</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_2">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>60</y>
      <width>81</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>Position</string>
    </property>
   </widget>
   <widget class="QLabel" name="posdisp_label">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>80</y>
      <width>221</width>
      <height>21</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">QLabel { background-color : #888888; color : #EEEE00; }</string>
    </property>
    <property name="text">
     <string>TextLabel</string>
    </property>
    <property name="alignment">
     <set>Qt::AlignCenter</set>
    </property>
   </widget>
   <widget class="QPushButton" name="zup_button">
    <property name="geometry">
     <rect>
      <x>160</x>
      <y>130</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="text">
     <string>Z+</string>
    </property>
   </widget>
   <widget class="QPushButton" name="zdown_button">
    <property name="geometry">
     <rect>
      <x>160</x>
      <y>210</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="text">
     <string>Z-</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_4">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>110</y>
      <width>121</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>Manual Controls</string>
    </property>
   </widget>
   <widget class="QProgressBar" name="progress_bar">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>270</y>
      <width>431</width>
      <height>23</height>
     </rect>
    </property>
    <property name="value">
     <number>24</number>
    </property>
   </widget>
   <widget class="QLabel" name="file_label">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>250</y>
      <width>461</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>Elapsed: na / Remaining: na</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_7">
    <property name="geometry">
     <rect>
      <x>340</x>
      <y>170</y>
      <width>31</width>
      <height>21</height>
     </rect>
    </property>
    <property name="text">
     <string>vG0:</string>
    </property>
   </widget>
   <widget class="QLineEdit" name="G0_speed_textbox">
    <property name="geometry">
     <rect>
      <x>380</x>
      <y>170</y>
      <width>71</width>
      <height>21</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
   </widget>
   <widget class="QLabel" name="label_8">
    <property name="geometry">
     <rect>
      <x>340</x>
      <y>210</y>
      <width>31</width>
      <height>21</height>
     </rect>
    </property>
    <property name="text">
     <string>vG1:</string>
    </property>
   </widget>
   <widget class="QLineEdit" name="G1_speed_textbox">
    <property name="geometry">
     <rect>
      <x>380</x>
      <y>210</y>
      <width>71</width>
      <height>21</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
   </widget>
   <widget class="QLineEdit" name="laser_power_textbox">
    <property name="geometry">
     <rect>
      <x>380</x>
      <y>130</y>
      <width>71</width>
      <height>21</height>
     </rect>
    </property>
    <property name="text">
     <string/>
    </property>
   </widget>
   <widget class="QLabel" name="label_9">
    <property name="geometry">
     <rect>
      <x>330</x>
      <y>130</y>
      <width>41</width>
      <height>21</height>
     </rect>
    </property>
    <property name="text">
     <string>Plaser</string>
    </property>
   </widget>
   <widget class="QComboBox" name="speed_combobox">
    <property name="geometry">
     <rect>
      <x>140</x>
      <y>170</y>
      <width>71</width>
      <height>31</height>
     </rect>
    </property>
   </widget>
   <widget class="QPushButton" name="spindle_on_button">
    <property name="geometry">
     <rect>
      <x>240</x>
      <y>130</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Laser
On</string>
    </property>
   </widget>
   <widget class="QPushButton" name="spindle_off_button">
    <property name="geometry">
     <rect>
      <x>280</x>
      <y>130</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Laser
Off</string>
    </property>
   </widget>
   <widget class="QPushButton" name="home_button">
    <property name="geometry">
     <rect>
      <x>280</x>
      <y>70</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Home
XYZ</string>
    </property>
   </widget>
   <widget class="QPushButton" name="xyzero_button">
    <property name="geometry">
     <rect>
      <x>320</x>
      <y>70</y>
      <width>31</width>
      <height>31</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Set
Zero</string>
    </property>
   </widget>
   <widget class="QPushButton" name="goto_zzero_button">
    <property name="geometry">
     <rect>
      <x>280</x>
      <y>210</y>
      <width>31</width>
      <height>31</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Goto
Z0</string>
    </property>
   </widget>
   <widget class="QPushButton" name="goto_xyzero_button">
    <property name="geometry">
     <rect>
      <x>240</x>
      <y>210</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Goto
XY0</string>
    </property>
   </widget>
   <widget class="QPushButton" name="file_dialog_button">
    <property name="geometry">
     <rect>
      <x>280</x>
      <y>30</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Open
File</string>
    </property>
   </widget>
   <widget class="QPushButton" name="play_button">
    <property name="geometry">
     <rect>
      <x>320</x>
      <y>30</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Play</string>
    </property>
   </widget>
   <widget class="QPushButton" name="stop_button">
    <property name="geometry">
     <rect>
      <x>360</x>
      <y>30</y>
      <width>31</width>
      <height>32</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <pointsize>9</pointsize>
     </font>
    </property>
    <property name="text">
     <string>Abort</string>
    </property>
   </widget>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>

qt_test.py:

import sys
from PyQt5 import QtWidgets, uic
  
app = QtWidgets.QApplication(sys.argv)

window = uic.loadUi("UI_LaserExpose.ui")
window.show()

PyCharm:

QMacStyle

environ({'PATH': '/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS', 'PS1': '\\[\\033[36m\\]\\u\\[\\033[m\\]@\\[\\033[32m\\]\\h:\\[\\033[33;1m\\]\\w\\[\\033[m\\]$ ', 'PYDEVD_LOAD_VALUES_ASYNC': 'True', 'DISPLAY': '/private/tmp/com.apple.launchd.X7BAfqm27I/org.macosforge.xquartz:0', 'QT_AUTO_SCREEN_SCALE_FACTOR': '2', 'VERSIONER_PYTHON_VERSION': '2.7', 'LOGNAME': 'gfattinger', 'XPC_SERVICE_NAME': 'com.jetbrains.pycharm.13112', 'PWD': '/Users/gfattinger/Documents/Python/LaserExpose', 'PYCHARM_HOSTED': '1', 'PYTHONPATH': '/Users/gfattinger/Documents/Python/LaserExpose:/Applications/PyCharm CE.app/Contents/helpers/third_party/thriftpy:/Applications/PyCharm CE.app/Contents/helpers/pydev', 'SHELL': '/bin/bash', 'LSCOLORS': 'ExFxBxDxCxegedabagacad', 'PYTHONIOENCODING': 'UTF-8', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'USER': 'gfattinger', 'CLICOLOR': '1', 'IPYTHONENABLE': 'False', 'TMPDIR': '/var/folders/qr/hlmd4zz12552msptsfzdnyfh0000gn/T/', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.WJj9owhNzD/Listeners', 'XPC_FLAGS': '0x0', 'PYTHONUNBUFFERED': '1', '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0', 'Apple_PubSub_Socket_Render': '/private/tmp/com.apple.launchd.2y4H29qPrI/Render', 'LC_CTYPE': 'en_US.UTF-8', 'HOME': '/Users/gfattinger', '__PYVENV_LAUNCHER__': '/usr/local/bin/python3'})

Bash:

environ({'TERM_PROGRAM': 'Apple_Terminal', 'SHELL': '/bin/bash', 'TERM': 'xterm-256color', 'CLICOLOR': '1', 'TMPDIR': '/var/folders/qr/hlmd4zz12552msptsfzdnyfh0000gn/T/', 'Apple_PubSub_Socket_Render': '/private/tmp/com.apple.launchd.2y4H29qPrI/Render', 'TERM_PROGRAM_VERSION': '421.2', 'TERM_SESSION_ID': 'C3A0B50C-04E2-4928-B4D2-BD13FF50D057', 'USER': 'gfattinger', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.WJj9owhNzD/Listeners', 'LSCOLORS': 'ExFxBxDxCxegedabagacad', 'PATH': '/opt/local/bin:/opt/local/sbin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/lib/python3.6/site-packages:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS', 'PWD': '/Users/gfattinger/Documents/Python/LaserExpose', 'LANG': 'en_US.UTF-8', 'XPC_FLAGS': '0x0', 'PS1': '\\[\\033[36m\\]\\u\\[\\033[m\\]@\\[\\033[32m\\]\\h:\\[\\033[33;1m\\]\\w\\[\\033[m\\]$ ', 'XPC_SERVICE_NAME': '0', 'SHLVL': '1', 'HOME': '/Users/gfattinger', 'PYTHONPATH': '/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/lib/python3.6/site-packages:', 'LOGNAME': 'gfattinger', 'DISPLAY': '/private/tmp/com.apple.launchd.X7BAfqm27I/org.macosforge.xquartz:0', '_': '/usr/local/bin/python3', 'OLDPWD': '/Users/gfattinger/Documents/Python', '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0', '__PYVENV_LAUNCHER__': '/usr/local/bin/python3', 'QT_AUTO_SCREEN_SCALE_FACTOR': '2'})

QMacStyle

Update:

Based on the question from @tbd, I compared the environment variables, and found that my bash still pointed to an old Python 3.6 folder. After restarting bash, this was gone, since I already edited my .bash_profile, but forgot to restart bash before.

Anyways, lo and behold, now the UI render when starting from bash was screwed up as well :-(.

I dug into the Python 3.6 folder entries, and found that this one, depending on whether I add it to the PYTHONPATH environment variable, let's be toggle the incorrect render on and off from bash:

export PYTHONPATH="/usr/local/lib/python3.6/site-packages"
python3 qt_test.py 

... renders correctly.

But

export PYTHONPATH=""
python3 qt_test.py

or

export PYTHONPATH="/usr/local/lib/python3.7/site-packages"
python3 qt_test.py

... produces the incorrect results.

Seems like Python 3.6 works, while Python 3.7 fails .... a bit stumped right now ...

Community
  • 1
  • 1

0 Answers0