0

The program works fine on other computers that run window's or ubuntu but the text won't show on the buttons. Here's a snippet of a longer code:

from Tkinter import *

from math import atan
from math import log
import math
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt



# --- function ---


def create_first_frame():
    global root
    global frame

    # frame.destroy()

    frame = Frame(bg="blue")
    frame.pack()

    label1 = Label(frame, text="hello!", fg="white", bg="blue", font="normal 30")
    label1.pack()

    button1 = Button(frame, text="Enter", fg="white", bg="blue", font="normal 20")
    button1.pack()

    button2 = Button(frame, text="Exit", font="normal", fg="white", bg="red", command=root.destroy)

    button2.pack(side=LEFT)




root = Tk()
create_first_frame()
root.mainloop()

We were expecting words like "start" and "exit" to show.

We just want the colors of the buttons to show along with the text

  • It's sad that Tkinter Buttons doesn't have much flexibility on macOS you can change the `fg` but the `bg` cannot be changed. It is because of the restriction and limited access to have a change in macOS ui. See this [post](https://stackoverflow.com/questions/1529847/how-to-change-the-foreground-or-background-colour-of-a-tkinter-button-on-mac-os). – Saad May 08 '19 at 23:47

1 Answers1

0

I am not sure what the question is. I took out unnecessary imports, and ran

from tkinter import *

def create_first_frame():
    global root
    global frame

    # frame.destroy()

    frame = Frame(bg="blue")
    frame.pack()

    label1 = Label(frame, text="hello!", fg="white", bg="blue", font="normal 30")
    label1.pack()

    button1 = Button(frame, text="Enter", fg="white", bg="blue", font="normal 20")
    button1.pack()

    button2 = Button(frame, text="Exit", font="normal", fg="white", bg="red", command=root.destroy)

    button2.pack(side=LEFT)

root = Tk()
create_first_frame()
root.mainloop()

Which creates for me:

expected GUI

This is colored as you have specified...

Reedinationer
  • 5,661
  • 1
  • 12
  • 33
  • 1
    I agree it's not clear from the question, but I think the OP wants to know why it doesn't work on a system running macos (but does on windows or ubuntu). – martineau May 08 '19 at 22:06