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 · 98 comments
Open

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

PySimpleGUI opened this issue Oct 28, 2020 · 98 comments
Labels
Platform Specific Issue - Mac Macs have a multitude of problems when using tkinter

Comments

@PySimpleGUI
Copy link
Owner

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 PySimpleGUI added help wanted Extra attention is needed community input desired Platform Specific Issue - Mac Macs have a multitude of problems when using tkinter labels Oct 28, 2020
@PySimpleGUI
Copy link
Owner Author

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 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 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 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 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

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 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

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.

@PySimpleGUI
Copy link
Owner Author

I need some help from Macs users

There was a patch posted to GitHub to try and get around this problem of no titlebar. I need to understand if:

  • The patch fixes the problem on non 8.,6.10 systems
  • The patch doesn't cause problems with 8.6.10

Can someone download the GitHub version and try it?

@tkozzer
Copy link

tkozzer commented Nov 7, 2020

I would love to help. I have everything set up as far as the tkinter version, but I'm not sure how to import the 4.30.0.13 version of PySimpleGUI. How exactly do you download that version and use it?

@jason990420
Copy link
Collaborator

It should be with same patch in most update version.

Upgrading from GitHub Using PySimpleGUI

@PySimpleGUI
Copy link
Owner Author

Not sure what to do about this patch. I'm pulling together a release to PyPI now and without it being properly tested on a Mac, I'm going to have to pull the code from the release. I would rather release a known problem than potentially a whole new set of problems. Of course, my preference is to get this fixed for good and post to PyPI.

If there are Mac users that are capable of running a few tests, I, and I'm guessing a few of your fellow Mac users, would appreciate the help.

@PySimpleGUI
Copy link
Owner Author

I don't want to delay the release while waiting for Mac users to test the new code. So, I've added more code to control when the patch is executed. I can't just toss this "fix" out there and potentially break existing Mac users. Well, technically I could, but I prefer not to create problems for users that have working code today.

To enable the patch for no-titlebar windows on a Mac call set_options with the parameter enable_mac_notitlebar_patch set to True.

    sg.set_options(enable_mac_notitlebar_patch=True)

The patch will cause an additional call when a no-titlebar Window is created:

root.wm_overrideredirect(False)

The patch will only execute on Macs that are running tkinter versions < 8.6.10.

By default the patch is disabled. You have to take affirmative action in order to get the patch by calling set_options.

This code is in version 4.30.0.26 and is on GitHub now. It will be released in version 4.31.0 shortly.

@tkozzer
Copy link

tkozzer commented Nov 14, 2020

Like I said before, I would be willing to run any tests on your previous patch. I have two different mac devices running different versions of the OS. I am also running various versions of python and tcl/tk.

Apologies if this is a dumb question, but how do I install these versions (4.30.0.13 or 4.30.026)? I usually use pip install, but if I have do something different then I need a bit of guidance to help you out.

@PySimpleGUI
Copy link
Owner Author

4.31.0 was posted to PyPI earlier today. You can pip install it like you have other versions.

Add the line of code in the previous post and you'll be running with the patch enabled.

 sg.set_options(enable_mac_notitlebar_patch=True)

You can install GitHub versions using the sg.main() user interface by clicking the red button that says "Upgade". 4.31.0 is the Current version on GitHub and the one that's been released to PyPI.

@tkozzer
Copy link

tkozzer commented Nov 14, 2020

I did a few different tests on different versions of tcl/tk (8.5.9, 8.6.8, 8.6.10) and I found that the original code
image
will make the titlebar appear to be disabled, but I can click on the minimize or x button. If I minimize it and then bring it back up then the titlebar is completely disabled. This happens on both 8.5.9 and 8.6.8. Everything works good for 8.6.10. (like mentioned in previous comments)

Next, I tried to run it with your patch.
image
What ended up happening was the titlebar was active and both the minimize and the x buttons worked, and when I minimized it and brought the window back up it would then be disabled, similar to what I mentioned above.

So the issues are still happening with versions 8.6.8 and lower.

Here was the original code using tkinter to get a no-titlebar draggable window.
image
I found this code when I was searching around to try and solve this issue of trying to hide the titlebar. This is using tcl/tk 8.6.8 or below
https://stackoverflow.com/questions/29641616/drag-window-when-using-overrideredirect

Versions
MacOS: 10.15.7
PySimpleGUI: 4.31.0 latest
Python: 3.8.1, 3.8.6, 3.9.0

For tcl/tk 8.6.8 or lower
neither patch or original example work

@PySimpleGUI
Copy link
Owner Author

Did you see a message on the console that the patch was being applied?

What's odd about the tests is that the technique I'm using to achieve the no-titlebar is one that was previously posted here. It's basically to repeat the override but with a False value. It's also odd that there's a locking up behavior that appears to be new.

Can you make sure that you see this message:

'* Applying Mac no_titlebar patch *

If you do not see this message, then the patch was not applied.

It would be helpful if you printed the version of PySimpleGUI in addition to printing the version of tkinter just to be sure we're working with the combination of variables we think we are.

I'm suspecting more and more that the MacOS has a role to play here as well. I didn't hear of this no-titlebar problem and the problem with tooltips until earlier this year. These features were some of the first to be released in PySimpleGUI, and yet there was no report of problems with these features until not that long ago.

The drag-anywhere part of this hasn't been discussed before and is new data. Can we focus on just getting the no-titlebar code tested and working?

@PySimpleGUI
Copy link
Owner Author

The "fix" for this may very well end up being that Mac users must run tkinter 8.6.10. I'm spending too much time and energy on a problem that's clearly a bug in the Mac software. Not being able to test the code is making this a nearly impossible task to get completed.

I've been here once before with the tk button bug, which was a known problem for over 6 years and yet wasn't fixed. The fix for that was to add support for ttk buttons to PySimpleGUI. It was a lot of work, but ultimately allowed Mac users to use PySimpleGUI. Unlike that bug, this one appears to have caught the attention of the tkinter / Mac developers and it was fixed in 8.6.10. That means there's a path for Mac users to follow that they can get to on their own, without these kinds of hacks and workarounds being added to the code.

I like my Mac users, but it's hard to justify investing too much into supporting that platform when the number of users is tiny. I don't believe installs have ever broken 10% for the Mac.

image

@tkozzer
Copy link

tkozzer commented Nov 15, 2020

Yea it seems like a huge hassle for a small group of users. I just downloaded macOS v11 (new this week), and there seems to be some different behavior. For instance, the minimize and x buttons are completely disabled now unlike my previous post.

One thing I also noticed with tkinter on macOS v11 is that for tk/tcl v8.5.9, I only need to say root.overrideredirect(True) for no titlebar, but when I try to do the same on tk/tcl v8.6.8 it doesn't work. I still need to do

root.overrideredirect(True)
root.overrideredirect(False)

in order to get it to work.

FYI, I was getting the log message saying that the patch was being applied. Also the version of PySimpleGUI I was using was 4.31.0 Released 13-Nov-2020.

@PySimpleGUI
Copy link
Owner Author

I don't mind supporting a small group of users with some code specific to the Mac platform. The problem is that it's been a moving target. I've not been able to find a stable footing recently. Things were seemingly going great after Mac users switched to installing from Python.org instead of Homebrew. That got everyone away from releases that had trouble with buttons and tables. But then something seems to have changed. I think that something was likely the Mac OS.

As I mentioned earlier, there are 3 variables at play. There is the tkinter version, the PySimpleGUI version and the MacOC version. I'm tossing out the Python version from that list because while tkinter is packaged with Python and can differ from one release of Python to another, as long as we're tracking the tkinter version, then the Python version doesn't matter. I don't have a handle on the outcome is for the combinations are for those 3 variables other than a report on occasion that "it doesn't work".

Doing anything with 8.5.9 is going way too far back. PySimpleGUI supports Python 3.4 and up, which is going back 6 years. That's been a challenge, but one that's reasonable as the Raspberry Pi often comes with this version of Python. There is little I can do to get around this other than forcing Pi users to update their Python version and I would rather not have that happen as it's not a trivial thing to do.

8.5.9 was released over 10 years ago. Some context... the same year 8.5.9 was released, so was 2.7.0. Python 3 was at 3.1. It's going back way too far to be of any real value. I understand the context you're using it for, which is to demonstrate that at one time no titlebar worked, but going back a decade to find a working version of anything is pretty extreme. It's a lifetime in software.

Hearing that MacOS v11 has any bearing on how tkinter operates is even more exasperating. The OS itself should have no impact... zero... on how tkinter and Python work.

It's disappointing to hear that the patch did not have a positive impact since what it does in set the wm_overrideredirect back to False, whichi is supposed to fix the problem. Here is the code that does is executed for no-titlebar on a Mac:

                MyFlexForm.TKroot.wm_overrideredirect(True)
                # Special case for Mac. Need to clear flag again if not tkinter version 8.6.10+
                if sys.platform.startswith('darwin') and ENABLE_MAC_NOTITLEBAR_PATCH and (sum([int(i) for i in tclversion_detailed.split('.')]) < 24):
                    print('* Applying Mac no_titlebar patch *')
                    MyFlexForm.TKroot.wm_overrideredirect(False)

The message "Application Mac no_titlebar patch" is shown just prior to setting the wm_overrideredirect back to False.

I would love to publish a version of PySimpleGUI that works with all of the Mac OS versions on all versions of tkinter, but that's what I've been attempting to do since the initial launch of PySimpleGUI, and it seems like the latest efforts have consistently fallen short.

The only known working fix I'm aware of at this point is requiring Mac users to install 8.6.10. That seems to produce results that work. The PySimpleGUI "fix" is shaping up to be an error message that is printed when someone attempts to create a no titlebar window or tries to set tooltips. It's a terrible solution from a useability standpoint, but I don't see any other way out of this. It beats requiring users to install a decade old version of tkinter.

I am concerned about the use of homebrew installs of Python and tkinter. It was only last year that we figured out that homebrew was the source of the problems and that installing from Python.org fixed those problems.

If you want to try adding additional calls to wm_overrideredirect or perform some other operation on the tkinter root object, you can access it directly using the Window member variable window.TKroot. Maybe you can find a combination of calls that will work. I'm striking out evidently.

@PySimpleGUI
Copy link
Owner Author

I don't believe they're related, but you might want to try turning off the modal setting for the window as a test.

@tkozzer
Copy link

tkozzer commented Nov 15, 2020

Just want to clear something up about tk/tcl 8.5.9... the only reason that I was using that version is because it was packaged with the homebrew python 3.9.1 installation. I was just using whatever they gave me. So like you said it may be a homebrew problem.

I'll mess around a bit with downloading some of the python.org releases. I have no problem helping you figure this out. Maybe I could do some testing that is bit more controlled for the different variables at play. It might take me a bit of time to do this, but If you have specific things that you want me to try other than what you mention previously, let me know.

@tkozzer
Copy link

tkozzer commented Nov 15, 2020

Another thing that I wanted to mention is when I use tkinter and I make the call root.overrideredirect(True) a window won't even appear. So there is a bit more going on here if you ask me since when using PySimpleGUI the window will appear albeit it doesn't remove the titlebar, it only disables it. ( for versions < 8.6.10 )

@PySimpleGUI
Copy link
Owner Author

I have no problem helping you figure this out.

Well.... I'm going to jump at this opportunity. I would like to solve this problem so that Mac users aren't forced to install 8.6.10. It's not an easy thing to do as has been shown through the above comments.

tk/tcl 8.5.9... the only reason that I was using that version is because it was packaged with the homebrew python 3.9.1 installation.

WOW.... jump plain WOW....

What a graphic example of why using Homebrew for Python installation is not a good idea. On one hand, I could see someone saying that because "it works" then it's fine to use, but it's not that simple. The amount of tkinter code added since 8.5.9 has to be significant as tkinter hasn't stood still for a decade.

I find this to be stunning news. :-( What an uphill battle.

Please try installing from Python.org. Some time back I added the need to install from Python.org to the documentation:

https://pysimplegui.readthedocs.io/en/latest/#macs

It's so strange that these problems seem to have come out of nowhere. Even though the number of Mac users is small, they do exist and they are using PySimpleGUI on tkinter. I'm sure that if this feature was broken 2 years ago that someone would have said something. They most certainly complained about the button color problems.

It would be nice if the testing were carefully organized and tracked. A matrix of combinations would be very helpful.

I would like to see if there's a way to try older versions of everything and then step forward until something breaks.

That would be my ideal plan.

@norambna
Copy link

norambna commented Nov 16, 2020

Just my 2 cents. I am not a Mac user, but I had to develop something in python for macOS, so this is were I got my limited experience from.

A couple of months ago, when I tried my options I tried python versions downloaded directly from python.org. At that time I spend a lot of time with python.org version 3.6.8, which comes bundled with Tcl/Tk 8.6.8. And it definitively has bugs when trying the various elements of PySimpleGUI. I think it is just tkinter, it is not so polished for macOS. By default Python's Homebrew version DOES NOT come with Tcl/Tk (see here and here), but of course there are probably many unofficial "brews". The Pyenv version does not come with Tcl/Tk. I used the trick I posted above to try Tcl/Tk 8.6.10. As I said, it is still not perfect, but in my testings it was definitively the better option. I had to make a product, I tested what worked and what not, and used the things that worked for my project.

BTW, modal windows don't work with python.org version 3.6.8, which comes bundled with Tcl/Tk 8.6.8 and they also give problems with a pyenv python and Tcl/Tk 8.6.10. See here.

edit: and macOS comes with Tcl/Tk 8.5.9 as part of the operating system. That is why you get that version if your python does not come bundled with a newer version Tcl/Tk. So, if your are using a regular brew install of python, that python will use the Tcl/Tk version that comes with the operating system. That is why you get Tcl/Tk 8.5.9 when using a regular homebrew python. And that is why my trick has to explicitly instruct pyenv's python to use the newer brew install of tcl-tk

@PySimpleGUI
Copy link
Owner Author

Oh... I forgot about that modal thing.

The popup tests we've been running can be tried with modal disabled.

@tkozzer .... can you please try this popup test?

sg.popup_no_titlebar('This should not have a titlebar', modal=False)

Also, just to be sure the drag_anywhere isn't causing trouble, try this popup as well.

sg.popup_no_titlebar('This should not have a titlebar', modal=False, grab_anywhere=False)

To get the maximum control and visibility as to what options are being set, switching to making a Window is likely a better way to test. Here's a program that we can work with on this problem:

import PySimpleGUI as sg


layout = [[sg.Text('A no-titlebar test')],
          [sg.Button('Ok'), sg.Button('Exit')]]

window = sg.Window('Title', layout, no_titlebar=True, grab_anywhere=False, modal=False)

while True:
    event, values = window.read()
    print(event, values)
    if event in (sg.WIN_CLOSED, 'Exit'):
        break

window.close()

@PySimpleGUI
Copy link
Owner Author

I'm putting together a release today as there are some changes that need to get up to PyPI quickly. If modal windows are indeed broken for the Mac, across the board, for all versions of tkinter, then I'll disable them in this release. Can someone verify that modal windows do not work correctly for 8.6.10 and other versions? I'm still not clear on the combinations of tkinter and MacOS that produce these different problems.

@nachocho
Copy link

nachocho commented Aug 4, 2021

Please open an issue for the right click menu if you want to report a problem. This issue can't become a general purpose catch all for Mac problems. It was opened specifically to address the no-titlebar problem.

It's the middle button on a Mac that brings up the menu from previous reports.

Sure, I can do that. Although if this is a known issue and there is an issue about it, do you want me to open a new one anyway?

@PySimpleGUI
Copy link
Owner Author

New Issue

Although if this is a known issue and there is an issue about it, do you want me to open a new one anyway?

How about following the normal process for issues. If you have a problem - search the issues. If one is found, then you may find a workaround or solution. Add your information to the issue. If not, then open a new one.

You've got the right instincts here or you wouldn't have asked the question.
image

Final version (let's hope!) 4.45.0.43 was posted

I've added back the check for version so that if the tkinter version is 8.6.10+ then the patch will not ever be applied.

For the time being, I'm printing the information about this patch when you import PySimpleGUI. In the future, once the dust settles, this info can be removed. I've tried to make the information printed to be as clear as possible. Same with the settings window:

image

@nachocho
Copy link

nachocho commented Aug 4, 2021

Great! Thanks for all the hard work put into this.
I will look for the issue(s) about the right-click menus and follow up there.

@PySimpleGUI
Copy link
Owner Author

I will look for the issue(s) about the right-click menus and follow up there.

I've checked in a change, version 4.45.0.45, for you to try. For the Mac it's binding Button2, which on a Mac is the right button. I don't know if you're on a Mac Book or not. If so, then I don't think you have a "middle" button which is what it was bound to prior to this change. If you can test 4.45.0.45 that would be swell.

@nachocho
Copy link

nachocho commented Aug 5, 2021

I will look for the issue(s) about the right-click menus and follow up there.

I've checked in a change, version 4.45.0.45, for you to try. For the Mac it's binding Button2, which on a Mac is the right button. I don't know if you're on a Mac Book or not. If so, then I don't think you have a "middle" button which is what it was bound to prior to this change. If you can test 4.45.0.45 that would be swell.

Great, I will test that in a few hours. The keyboard I use with my mac is actually a 2-button one, so no middle button :)
By what you describe I think it will work with 2-button mouses, so I will give you my feedback after my day at work is done.

@PySimpleGUI
Copy link
Owner Author

The keyboard I use with my mac is actually a 2-button one, so no middle button :)

AH! That would explain it as well as explain this weird Mac thing where the rightmost button is "Button2" even when 3 buttons exist. The laws of physics don't seem to apply when working with the Mac sometimes.

Thank you for offering to check it out later. Hoping to finally get this posted to PyPI and get everyone that hasn't upgraded to 8.6.10 working with no-titlebar windows and tooltips. It seems like the Mac has a path to getting 8.6.10 easier than Windows has. I appreciate you sticking around to test these Mac changes all week.

@PySimpleGUI
Copy link
Owner Author

@nachocho do you have a Mac laptop? Can you describe the type of mouse it is? I would like to document the type of hardware that earlier versions won't have access to right-click menus.

@nachocho
Copy link

nachocho commented Aug 6, 2021

The keyboard I use with my mac is actually a 2-button one, so no middle button :)

AH! That would explain it as well as explain this weird Mac thing where the rightmost button is "Button2" even when 3 buttons exist. The laws of physics don't seem to apply when working with the Mac sometimes.

Thank you for offering to check it out later. Hoping to finally get this posted to PyPI and get everyone that hasn't upgraded to 8.6.10 working with no-titlebar windows and tooltips. It seems like the Mac has a path to getting 8.6.10 easier than Windows has. I appreciate you sticking around to test these Mac changes all week.

Not a problem. And yay! This new 4.46.0.46 version fixes the right-click menu! I tested this on both tkinter 8.6.8 and 8.6.11. The right-click menu appears when clicking the right mouse button and events fire correctly. Another bug bites the dust :)

I thought right-click menus can be used on Combo elements as well, but was surprised to see that there is no right_click_menu parameter in its constructor. I only tested this on an Input and a Button element.

@nachocho
Copy link

nachocho commented Aug 6, 2021

@nachocho do you have a Mac laptop? Can you describe the type of mouse it is? I would like to document the type of hardware that earlier versions won't have access to right-click menus.

No, I have a MacMini, so my keyboard and mouse are generic, I am using a Logitech wireless keyboard with an integrated trackpad, it only has 2 buttons on the trackpad, so no middle button and no mouse scroll wheel.

But I do have a generic USB mouse, it does not have 3 buttons but does have the scroll wheel which I think can be clicked so not sure if that one passes for a middle button. If you would like me to test something with it, just say the word and I can do some tests.

@PySimpleGUI PySimpleGUI added the In progress Currently working on label Aug 6, 2021
@PySimpleGUI
Copy link
Owner Author

And yay! This new 4.46.0.46 version fixes the right-click menu!

Score one for the team!

image

@PySimpleGUI
Copy link
Owner Author

I thought right-click menus can be used on Combo elements as well, but was surprised to see that there is no right_click_menu parameter in its constructor.

I was writing the release notes last night and the change that I've made for those elements that do not have one in the constructor is they will inherit from the Window's right-click menu if possible. A few more elements got right click this release as well. There was quite a bit of stuff done with right click's this time around but I didn't get 100% coverage. It's the classic - Time, quality, features.... choose 1. To date no one had noticed the new ones I added this release. They were never requested that I can recall. It's a little unusual to add a right click to a radio button for example.

Right click menu

  • added to Radio Checkbox Tabgroup Spin Slider
  • Elements that don't have a right_click_menu parm now pick up the default from the Window
  • Added a right click menu callback to cover portions of the window that don't have an element on them
  • Changed Button binding for Mac to Button2 (the right button rather than middle on the other systems)
  • Made right click menus based on button release (MUCH better)

@nachocho
Copy link

nachocho commented Aug 6, 2021

You are right that it would be odd to see right-click menus for radio buttons hahaha, but it is frequent to attach that kind of right-click menus to combo boxes, table cells, text boxes, buttons, list boxes.

Would be a nice addition to get right-click menus on combo boxes and table elements, although the table one might be trickier.

@norambna
Copy link

norambna commented Aug 6, 2021

AH! That would explain it as well as explain this weird Mac thing where the rightmost button is "Button2" even when 3 buttons exist. The laws of physics don't seem to apply when working with the Mac sometimes.

A bit of background on Mac mice:
800px-The_Apple_Mouse
Just one button!

And the very latest official Mac mouse is the Magic Mouse and it has no buttons at all. It's really an hybrid between a mouse and a trackpad
MK2E3_AV1
On the magic mouse you can tap the right part and it acts as a right click and on the left side is a left click. On a Mac trackpad a click with one finger is a left click and with two fingers is a right click. What a Magic Mouse and Mac Trackpad don't have is a middle click, unless you install a 3rd party solution.

@AndreaWesterinen
Copy link

Why is the "Mac patches" output not an option in set_options? It should not be hard-coded.

At this moment, following messages for all MacOS users are hard coded and cannot be suppressed.

if running_mac():
print('Your Mac patches are:')
print('Modal windows disabled:', ENABLE_MAC_MODAL_DISABLE_PATCH)
print('No titlebar patch:', ENABLE_MAC_NOTITLEBAR_PATCH)
print('No grab anywhere allowed with titlebar:', ENABLE_MAC_DISABLE_GRAB_ANYWHERE_WITH_TITLEBAR)
print('Currently the no titlebar patch ' + ('WILL' if _mac_should_apply_notitlebar_patch() else 'WILL NOT') + ' be applied')

Yes, the code can be removed manually, but this is seems like something MANY people will want to do. It should be fixed in the main branch.

@PySimpleGUI
Copy link
Owner Author

The reason it's there, and hardcoded, was to get the attention of Mac users.

You might notice from the 89 comments above that the Mac has come close to being dropped from PySimpleGUI a number of times. It was only in the last release that things started to get under control, but only if Mac users set various patches from the new Mac system settings. It'll be gone by the next release.

@PySimpleGUI
Copy link
Owner Author

The prints have been removed if anyone wants a version prior to the 4.48.0 release.

@PySimpleGUI PySimpleGUI removed help wanted Extra attention is needed In progress Currently working on community input desired labels Oct 1, 2021
@PySimpleGUI
Copy link
Owner Author

4.49.0 posted to PyPI today. No more Mac prints.

@ArthurZhou
Copy link

I think I`ve found a solution

I found that if you write like this, the bar will be shown:

            root = tk.Tk()
            root.attributes('-alpha', 0.8)
            root.title('Monitor v{0}'.format(VER))
            size = '%dx%d+%d+%d' % (320, 180, 0, 0)
            root.geometry(size)
            root.resizable(width=False, height=False)
            root.overrideredirect(True)
            root.overrideredirect(False)

Screen Shot 2022-05-16 at 12 21 53

But if you do this, the title bar disappeared:

            root = tk.Tk()
            root.overrideredirect(True)
            root.overrideredirect(False)
            root.attributes('-alpha', 0.8)
            root.title('Monitor v{0}'.format(VER))
            size = '%dx%d+%d+%d' % (320, 180, 0, 0)
            root.geometry(size)
            root.resizable(width=False, height=False)

It looks like this:
Screen Shot 2022-05-16 at 12 20 39

My platform:
python3.7
tk/tcl: 8.6.8
MacOS: 11.6.5

@macdeport
Copy link

import platform
print(f'{platform.platform()}') 

import PySimpleGUI as sg
from sys import version_info as v
print(f'Python: {v.major}.{v.minor}.{v.micro}')
print(f'Tk/Tcl: {sg.tclversion_detailed}\n')

import tkinter as tk
VER=0.99
root = tk.Tk()
root.attributes('-alpha', 0.8)
root.title('Monitor v{0}'.format(VER))
size = '%dx%d+%d+%d' % (320, 180, 0, 0)
root.geometry(size)
root.resizable(width=False, height=False)
root.overrideredirect(True)
root.overrideredirect(False)
macOS-10.10.5-x86_64-i386-64bit
Python: 3.9.12
Tk/Tcl: 8.6.12

Traceback (most recent call last):
  File "/var/folders/0d/dj43zrpj3kg85hdt91_cjwy00000gp/T/BBEditRunTemp-untitled text 20.py", line 26, in <module>
    root.overrideredirect(True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 2176, in wm_overrideredirect
    return self._getboolean(self.tk.call(
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1448, in _getboolean
    return self.tk.getboolean(string)
_tkinter.TclError: expected boolean value but got ""

Cheers

@ArthurZhou
Copy link

ArthurZhou commented May 16, 2022

import platform
print(f'{platform.platform()}') 

import PySimpleGUI as sg
from sys import version_info as v
print(f'Python: {v.major}.{v.minor}.{v.micro}')
print(f'Tk/Tcl: {sg.tclversion_detailed}\n')

import tkinter as tk
VER=0.99
root = tk.Tk()
root.attributes('-alpha', 0.8)
root.title('Monitor v{0}'.format(VER))
size = '%dx%d+%d+%d' % (320, 180, 0, 0)
root.geometry(size)
root.resizable(width=False, height=False)
root.overrideredirect(True)
root.overrideredirect(False)
macOS-10.10.5-x86_64-i386-64bit
Python: 3.9.12
Tk/Tcl: 8.6.12

Traceback (most recent call last):
  File "/var/folders/0d/dj43zrpj3kg85hdt91_cjwy00000gp/T/BBEditRunTemp-untitled text 20.py", line 26, in <module>
    root.overrideredirect(True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 2176, in wm_overrideredirect
    return self._getboolean(self.tk.call(
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1448, in _getboolean
    return self.tk.getboolean(string)
_tkinter.TclError: expected boolean value but got ""

Cheers

Will this work on your computer?

import PySimpleGUI as sg

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

Somebody else try this on tk/tcl 8.6.10, and the following function works correctly.
I haven't try it on tk8.6.12, so maybe this one could work.

@macdeport
Copy link

Works here perfectly. Useful for crowded displays, thank you.
floating-screenshot-153037

@PySimpleGUI
Copy link
Owner Author

Thank you folks for the help!!

Every datapoint is very helpful!! These Mac problems have been some of the most transient, environment-specific, and try as I might to be patient in finding the fixes, sometimes frustrating... so the help is really appreciated.

@PySimpleGUI
Copy link
Owner Author

This issue may spark a new level of complexity that I've tried not to have in the code if at all possible and that is code that's tied to specific versions of the Mac OS and/or tkinter. There are some tkinter specific patches in there where a general tkinter bug has a fix for a specific problem.

With the Mac, I've not had enough bandwidth, consistent help, a team member with the knowledge and hardware to test fixes going back to early versions of the Mac environments that would enable this kind of complexity. The result has been a very course level of control.... the Mac Patch Control in the system settings.

This is looking hopeful..... I like hopeful

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Specific Issue - Mac Macs have a multitude of problems when using tkinter
Projects
None yet
Development

No branches or pull requests

10 participants