Button Mac OS

broken image


Question or issue on macOS:

I've been working through the Tkinter chapters in Programming Python and encountered a problem where the foreground and background colours of a button will not change. I am working on a Mac OS X 10.6 system with Python 2.6.1. The colours of a label will change, but not the colours of a button. For example:

On my Mac system the colours of the label change, but the colours of the button do not. On a Windows system with Python 2.6.1 the colours of both the label and button change.

Anyone know what is going wrong?

On MacOs High Sierra the play button and next and prev (media buttons in the top of keyboard) are controlling what is in the main window and not my music from Spotify or iTunes. Techno darwin mac os. This removes the idea of the button as I now have to open iTunes and then pause the music. Before I could just press the button when in Safari to pause the music. In this tutorial, I will show you how to get the red,green,and yellow mac buttons in the top left hand corner. The basics to how this works is, you download.

I've checked Interface Builder and it appears that there is no option to change the foreground or background colour of a button in that tool. There is the ability to edit the foreground and background colours of a label.

The Mac OS X rendering system (Quartz?) may just not support (easily) changing the fg and bg of a button.

How to solve this problem?

Solution no. 1:

I think the answer is that the buttons on the mac simply don't support changing the background and foreground colors. As you've seen, this isn't unique to Tk.

Button Mac Os Catalina

Solution no. 2:

Download

There is a solution for changing the background of buttons on Mac.

Use:

For example:

This results in the following, a nice button that fits in with the background:

Solution no. 3:

For anyone else who happens upon this question as I did, the solution is to use the ttk module, which is available by default on OS X 10.7. Unfortunately, setting the background color still doesn't work out of the box, but text color does.

It requires a small change to the code:

Original:

With ttk:

Solution no. 4:

You can do it with tkmacosx from Pypi

Installation:-

for python2

Button Macro Software

for python3

Now use it:

It works fine on mac os x.

P.S For more information see it on Pypi Mr dynamite mac os.

Solution no. 5:

Its quite annoying that after years this is still a problem.

Anyways, as others have mentioned, highlightbackground (the border color) can be used in place of background on a Mac. If you increase the size of the border to be huge (the size of the button or greater), you will get a nice, solid background color. This will give your button the appearance of a label. Jam9 mac os.

This works if you are using place, but not if you are using something like grid. With grid, increasing the border size increases the button size automatically, unfortunately.

However, if you must use grid, you can always hack it….create your colorless grid button. Next use place to parent a background color button on top of it. This will be the button with the ‘command' on it or the button you bind events to.

If you want your code to be OS independent, you can either add an ‘if OS 'Mac'‘ statement or even add a custom function that modifies the button if its on a Mac but leaves it alone on Windows or Linux. Here's the former:

Mac

There is a solution for changing the background of buttons on Mac.

Use:

For example:

This results in the following, a nice button that fits in with the background:

Solution no. 3:

For anyone else who happens upon this question as I did, the solution is to use the ttk module, which is available by default on OS X 10.7. Unfortunately, setting the background color still doesn't work out of the box, but text color does.

It requires a small change to the code:

Original:

With ttk:

Solution no. 4:

You can do it with tkmacosx from Pypi

Installation:-

for python2

Button Macro Software

for python3

Now use it:

It works fine on mac os x.

P.S For more information see it on Pypi Mr dynamite mac os.

Solution no. 5:

Its quite annoying that after years this is still a problem.

Anyways, as others have mentioned, highlightbackground (the border color) can be used in place of background on a Mac. If you increase the size of the border to be huge (the size of the button or greater), you will get a nice, solid background color. This will give your button the appearance of a label. Jam9 mac os.

This works if you are using place, but not if you are using something like grid. With grid, increasing the border size increases the button size automatically, unfortunately.

However, if you must use grid, you can always hack it….create your colorless grid button. Next use place to parent a background color button on top of it. This will be the button with the ‘command' on it or the button you bind events to.

If you want your code to be OS independent, you can either add an ‘if OS 'Mac'‘ statement or even add a custom function that modifies the button if its on a Mac but leaves it alone on Windows or Linux. Here's the former:

Solution no. 6:

This worked for me:

Solution no. 7:

Button Mac Os Catalina

I was looking as to why this doesn't work as well. I found a quick way to try and fix it is to have a label and then bind a click with the label. Then have the label change colors for a short time to mimic clicking. Here is an example.

Solution no. 8:

Confirm following code can change the background of tkinter Button on Mac OS X.

But it cannot change bg of ttk.Button.

Hope this helps!

How to start up in macOS from Windows

  1. From the notification area on the right side of the Windows taskbar, click to show hidden icons.
  2. Click the Boot Camp icon .
  3. From the menu shown, choose Restart in macOS.
    If you haven't installed the latest Boot Camp updates, you might get the message 'Could not locate the OS X boot volume.'

Or use Startup Manager as your Mac starts up:

  1. Restart your Mac from the Start menu in Windows.
  2. Press and hold the Option (or Alt) ⌥ key as your Mac begins to restart.
  3. Select your Mac startup volume (Macintosh HD) in the Startup Manager window, then press Return or click the up arrow:

How to start up in Windows from macOS

  • Use Startup Manager to choose your Windows (Boot Camp) volume during startup.
  • Or select your Boot Camp volume in Startup Disk preferences, then restart.

Learn more

  • If you're having difficulty using VoiceOver or another screen reader to complete these steps, please contact Apple Support.
  • Learn how to install Windows 10 on your Mac.




broken image