PySolFC icon indicating copy to clipboard operation
PySolFC copied to clipboard

Poor presentation on Mac OS X

Open scottfurry opened this issue 6 years ago • 18 comments

Screenshot... https://imgur.com/6glSLwa Using MacOS High Sierra. Homebrew installed/updated and brewfile in project successfully executed. Presentation in menus and window decorations is just ...ah...UGH? Menu items are dark text on dark coloured background. Cant't read them unless mouse is scrolled over menu entry.

Either I missed a step in building the app bundle or something else is going on here.

scottfurry avatar May 02 '19 16:05 scottfurry

A little more detail... Console output from python setup_osx.py py2app produced the following message (near end of printout to console):

Modules not found (conditional imports):
 * PIL (pysollib.mfxutil)
 * StringIO (pkg_resources._vendor.six, six)
 * com (pkg_resources._vendor.appdirs)
 * com.sun.jna (pkg_resources._vendor.appdirs)
 * com.sun.jna.platform (pkg_resources._vendor.appdirs)
 * jnius (pysollib.kivy.LApp, pysollib.kivy.tkhtml)
 * kivy.uix.behaviors (pysollib.kivy.toolbar)
 * kivy.uix.boxlayout (pysollib.kivy.toolbar)
 * kivy.uix.image (pysollib.kivy.toolbar)
 * ossaudiodev (pysollib.pysolaudio)
 * pygame (pysollib.pysolaudio)
 * pygame.base (pysollib.pysolaudio)
 * pygame.mixer_music (pysollib.pysolaudio)
 * pygame.rwobject (pysollib.pysolaudio)
 * pygame.time (pysollib.pysolaudio)
 * pysollib.pysolgtk.card (pysollib.pysoltk)
 * pysollib.pysolgtk.colorsdialog (pysollib.pysoltk)
 * pysollib.pysolgtk.edittextdialog (pysollib.pysoltk)
 * pysollib.pysolgtk.findcarddialog () [module alias]
 * pysollib.pysolgtk.fontsdialog (pysollib.pysoltk)
 * pysollib.pysolgtk.gameinfodialog (pysollib.pysoltk)
 * pysollib.pysolgtk.menubar (pysollib.pysoltk)
 * pysollib.pysolgtk.playeroptionsdialog (pysollib.pysoltk)
 * pysollib.pysolgtk.progressbar (pysollib.pysoltk)
 * pysollib.pysolgtk.selectcardset (pysollib.pysoltk)
 * pysollib.pysolgtk.solverdialog () [module alias]
 * pysollib.pysolgtk.soundoptionsdialog (pysollib.pysoltk)
 * pysollib.pysolgtk.statusbar (pysollib.pysoltk)
 * pysollib.pysolgtk.timeoutsdialog (pysollib.pysoltk)
 * pysollib.pysolgtk.tkcanvas (pysollib.pysoltk)
 * pysollib.pysolgtk.tkconst (pysollib.pysoltk)
 * pysollib.pysolgtk.tkhtml (pysollib.pysoltk)
 * pysollib.pysolgtk.tkstats (pysollib.pysoltk)
 * pysollib.pysolgtk.tkutil (pysollib.pysoltk)
 * pysollib.pysolgtk.tkwidget (pysollib.pysoltk)
 * pysollib.pysolgtk.tkwrap (pysollib.pysoltk)
 * pysollib.pysolgtk.toolbar (pysollib.pysoltk)
 * pysolsoundserver (pysollib.pysolaudio)

Relevent output from brew list --versions:

$ brew list --versions
autoconf 2.69
boost 1.69.0_2
cmake 3.14.3
cpanminus 1.9019
gettext 0.19.8.1
gnutls 3.6.7.1
icu4c 64.2
openssl 1.0.2r
p11-kit 0.23.15
pcre2 10.33
perl 5.28.1
pkg-config 0.29.2
pyenv 1.2.11
pyenv-virtualenv 1.1.3
python 3.7.3
python@2 2.7.16
tcl-tk 8.6.9

scottfurry avatar May 02 '19 16:05 scottfurry

@scottfurry : hi! I admit we didn't test too much on macos due to us lacking mac hardware. Is there anything in the console/terminal when you start pysol from the cmd line?

shlomif avatar May 02 '19 20:05 shlomif

@scottfurry : hi! I admit we didn't test too much on macos due to us lacking mac hardware. Is there anything in the console/terminal when you start pysol from the cmd line?

python pysol.py
Traceback (most recent call last):
  File "pysol.py", line 28, in <module>
    init()
  File "/Users/[paths]/pysolfc-src/pysollib/init.py", line 92, in init
    from six.moves import tkinter

I'm presuming error message is derived from not output above where pysollib mentioned earlier is not found. My impression is that there is a missing "something" to tell python "find that library here" when it comes to pysollib.

But I don't know enough about python, let alone python w/ homebrew on a Mac, to say definitively. However, I'm will to try things. I've sort of got my head around the process to build the app bundle. I just think there's some python-library path settings that need to be tweaked.

And some updates to details may be needed. About box details seem dated. But that can be a seperate issue number.

scottfurry avatar May 02 '19 21:05 scottfurry

@scottfurry : try installing https://pypi.org/project/six/ using pip or maybe you need to set https://stackoverflow.com/questions/19917492/how-to-use-pythonpath .

shlomif avatar May 03 '19 07:05 shlomif

@scottfurry : try installing https://pypi.org/project/six/ using pip or maybe you need to set https://stackoverflow.com/questions/19917492/how-to-use-pythonpath .

$ pip freeze
certifi==2019.3.9
pipenv==2018.11.26
random2==1.0.1
six==1.12.0

$PYTHONPATH is empty and putting in a value does not appear to resolve the issue. Tried:

sys.path.append(".")

In setup_osx.py after the call to import sys. Made things worse as app would terminate with problems opening plist files. Double checking installed modules from Brewfile.

scottfurry avatar May 03 '19 14:05 scottfurry

Using makefile to execute testing. Initial make tests failed with error. (See here for backgound on error and fix). Editted gen_individual_import_tests.py line 18:

str.replace(d + "/" +
                               re.sub("\\.py$", "", f), "/", "."))

Python3 portions of test pased. Python2 failed(expected as I only want to build py3 version).

scottfurry avatar May 03 '19 15:05 scottfurry

I am able to get the app bundle built on Mac High Sierra. And execution appears "okay", but there are some behaviours that do not seem "right". Have to study more.

Presentation problems appear to be a issue in app behaviour when a setting in Mac OS is enabled. Reference: General Settings dialog If user selects "Use dark menu and Dock", we get the problems enountered in last screen shot above. Without this enabled, everything appears as expected. This is not the same as "Dark Mode" in Mac Mojave, but is similar.

Researching. This article seems promising.

scottfurry avatar May 03 '19 15:05 scottfurry

I'm stabbing in the dark here, but I wonder if this is an issue with Tkinter on OS X. PySolFC still uses Tkinter for its GUI elements, correct?

AntumDeluge avatar May 08 '19 01:05 AntumDeluge

@AntumDeluge - I'll have to dig into this one tomorrow when I'm at my Mac machine. A search came up with this little nugget from homebrew about what version of TCL-TK gets installed. I didn't run into any errors when I did the brew install process but it does give me pause for thought. It should be better investigated/understood.

scottfurry avatar May 08 '19 01:05 scottfurry

I'll also have to look into this reporting Gist of post, white text on white background being resolved with python update. Tomorrow's search.

scottfurry avatar May 08 '19 02:05 scottfurry

I found this wiki page that lists some differences in the Tk code for OS X as opposed to Windows & Linux. Not sure if it will help in debugging. In the "Menu" section is says there shouldn't be any issues as the "Tk menu command is hooked into the Mac OS X global menubar".

AntumDeluge avatar May 08 '19 02:05 AntumDeluge

Thanks for the link. A quick scan leads me to think this is directed at stock Mac software as they reference installed Py2/TKinter. No mention of homebrew/Py3, which is what I'm using to build against. Link does give some hints and details about detecting Mojave, which could be useful down the road.

scottfurry avatar May 08 '19 02:05 scottfurry

@scottfurry : any news?

shlomif avatar Jun 25 '19 13:06 shlomif

Life got in the way... I'll put this on my plate for this week.

scottfurry avatar Jun 25 '19 13:06 scottfurry

I poked around some color-related code and managed to find a workaround for the invisible menu font color. Before committing to this solution you should know that I was just removing lines without knowing their original purpose.

The screenshot also shows that some toolbar icons stay blank. osx_menucolors

--- a/pysollib/winsystems/aqua.py
+++ b/pysollib/winsystems/aqua.py
@@ -40,8 +40,8 @@ def init_root_window(root, app):
     elif USE_TILE:
         style = ttk.Style(root)
         color = style.lookup('.', 'background')
-        if color:
-            root.tk_setPalette(color)   # for non-ttk widgets
+        #if color:
+        #    root.tk_setPalette(color)   # for non-ttk widgets
 
         if app.opt.tile_theme == 'aqua':
             # standard Tk scrollbars work on OS X, but ttk ones look weird

jnumm avatar Aug 22 '19 06:08 jnumm

My dev is usually Linux (mac is used by spouse so I'm not always on it). So this bug got shuffled off with other issues.

Looks like some promise.

I had been wanting to approach this from the aspect of detect dark mode (High Sierra or Mojave). There was some articles (here(stackoverflow), here(apple dev), and here(blog) ).

Although all the links given had swift code examples, I want to believe that there was a "pythonic" variation that can be employed. Again, I just hadn't gotten there yet.

scottfurry avatar Aug 22 '19 06:08 scottfurry

Updates:

  • Python installed via brew has a broken Tcl/Tk, in my experience. Please try again with a python package from Python.org that bundles a newer Tk. For me, that fixes blank toolbar icons as well as spuriously disabled menu items. Brew forum post discussing the problem.

  • The fix I presented two comments above is in master now.

jnumm avatar Feb 09 '20 21:02 jnumm

Will test w/ newer Tk.

scottfurry avatar Feb 09 '20 22:02 scottfurry