Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Question] * MAC USERS * is no_titlebar working for you? #3553

Open
PySimpleGUI opened this issue Oct 28, 2020 · 8 comments
Open

[ Question] * MAC USERS * is no_titlebar working for you? #3553

PySimpleGUI opened this issue Oct 28, 2020 · 8 comments

Comments

@PySimpleGUI
Copy link
Owner

@PySimpleGUI PySimpleGUI commented Oct 28, 2020

Type of Issues (Enhancement, Error, Bug, Question)

Bug / Problem with tkinter

Does no_titlebar work?
Does tooltips work?

Operating System

Mac

Python version

3.6+

PySimpleGUI Port and Version

This is where things get important to understand.

I would like to know from someone running 8.610 and also someone NOT running 8.6.10.

I'm trying to understand if this is specific to 8.6.10.

You can get the detailed tkinter version by adding this line to your code:

print(sg.tkinter.Tcl().eval('info patchlevel'))

Description of Problem / Question / Details

I recall no_titlebar issues on the Mac and would like to make a concerted effort to fix them if there's a problem. I really need some solid help from a couple of Mac users.

I need someone that can do these:

  • Get accurate tkinter version info (I code is provided)
  • Being able to try a couple of potential fixes when posted to GitHub

Code To Duplicate

A short program that isolates and demonstrates the problem (i.e. please don't paste a link to your 400 line program.... instead paste your 10 line program in full).

Yes, it is a pain to narrow down problems, but it's part of the debugging process. Help me help you by providing something that can be executed so that work on getting you a fix or a workaround can immediately begin.

This pre-formatted code block is all set for you to paste in your bit of code:

print(sg.tkinter.Tcl().eval('info patchlevel'))

You can test to see if you've got problems by running:

import PySimpleGUI as sg

sg.popup_no_titlebar('This should not have a titlebar')

image

@PySimpleGUI
Copy link
Owner Author

@PySimpleGUI PySimpleGUI commented Oct 28, 2020

Part of the problem of debugging this in the past is that there was never really a proper table made to aid in debugging. There are 3 variables at play:

  1. PySimpleGUI version
  2. tkinter version
  3. MacOS version

Much of the time, it's been the tkinter version that's been the focus. I'm unsure if tkinter is responsible for all of the problems seen.

@tkozzer
Copy link

@tkozzer tkozzer commented Oct 29, 2020

Here is my breakdown:

PySimpleGUI v4.30.0
tkinter v8.6
MacOS 10.15.7

I also want to mention that I use Homebrew for my python binaries.

Screen Shot 2020-10-28 at 8 10 31 PM

Edit:

Python v3.8.1

@norambna
Copy link

@norambna norambna commented Oct 29, 2020

macOS High Sierra Version 10.13.6
PySimpleGUI Version 4.30.0.12
tcl ver = 8.6 tkinter version = 8.6
tcl detailed version = 8.6.10
Python Version 3.8.6

And... it works!
it_works

edit: The environment that gave me the fewest headaches regarding tkinter:

Homebrew -> brew install tcl-tk
Homebrew -> brew install pyenv -> Python (see below)

env \
  PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
  LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \
  CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
  CFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PYTHON_CONFIGURE_OPTS="--enable-framework --with-tcltk-includes='-I$(brew --prefix tcl-tk)/include' --with-tcltk-libs='-L$(brew --prefix tcl-tk)/lib -ltcl8.6 -ltk8.6'" \
  pyenv install 3.8.6

pyenv global 3.8.6

and to make this my default python:

echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

@tkozzer
Copy link

@tkozzer tkozzer commented Oct 31, 2020

I followed all the steps listed by @norambna and I got it to work for me. It was a bit cumbersome to jump through all the hoops though.

Python v3.8.6
PySimpleGUI v4.30.0
tkinter v8.6
MacOS 10.15.7
pyenv v1.2.21
tcl-tk v8.6.10

image

@norambna
Copy link

@norambna norambna commented Oct 31, 2020

I'm glad it helped! I know I had a hard time till finding a solution to all my macOS/tkinter problems. This won't solve all tkinter issues, but it's clearly the best way to work with it on macOS.

@PySimpleGUI
Copy link
Owner Author

@PySimpleGUI PySimpleGUI commented Oct 31, 2020

Does it appear that tkinter version 8.6.10 is what fixes this problem?

If all versions have problems except 8.6.10, then I could check for that version and apply the "fix" only to non-8.6.10 releases.

What I've been really confused about is if this is a recent problem or has no-titlebar never worked on the Mac. It seems odd that it would have never worked, but it's difficult to tell for sure.

The "fix" I've seen is potentially going to break other stuff which is why I've hesitated adding it to the code.

These steps are pretty ugly so I think that I've got to do something about this. Users can't be expected to go through this much trouble. I'll pull together a release for GitHub with the fix that checks the tkinter version number and only applies it when the version is not 8.6.10.

@elguaxo
Copy link

@elguaxo elguaxo commented Oct 31, 2020

Does it appear that tkinter version 8.6.10 is what fixes this problem?

For me, yes. 8.6.10 solves a ton of issues.

@PySimpleGUI
Copy link
Owner Author

@PySimpleGUI PySimpleGUI commented Nov 1, 2020

I just posted 4.30.0.13 that contains a patch if the version is less than 8.6.10.

If this "fixes" the problem, then I want to try one more patch. This new patch clears the wm_overrideredirect flag after first setting it.

root.wm_overrideredirect(True)
root.wm_overrideredirect(False)

What I would like to try next is to set it to True again so that the operation is a True False True. The idea here is that for some systems, it may be working correctly if the value is set to True. What I don't want to do is break all of the installs where it is functioning correctly today and setting it to True again may provide a workaround that does the right thing on all versions of tkinter on Mac.

You will see this message printed on the console if the patch is applied:
* Applying Mac no_titlebar patch *

One way to test this is through the test harness which will save you from having to write code to call and test popups. One of the tabs in the test harness (invoked by running PySimpleGUI.py file or calling sg.main()) is used to test popups.

image

This will let you quickly check both the no-titlebar window as well as by calling popups with a titlebar.

It may be difficult to spot because the background is the same as your test window. If you click No Titlebar button, you'll see this little window

image

I hope this fixes the non 8.6.10 version as well as not running on 8.6.10+. If it doesn't I'll quickly put together another test to see if setting it back again works.

If we get this nailed down, I'll get the release posted to PyPI as a high-priority release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.