Button Text Of Tkinter Does Not Work In Mojave
Solution 1:
Changing Appearance to Light Mode fixed this problem for me.
To change appearance, go to Settings -> General -> Appearance -> Light Mode.
Solution 2:
I guess there is a bug in Tk. I am on MacOS 10.14.3 If you maximize and minimize the tkinter window the text on the button appears, another solution that worked for me is
from tkinter import *
from tkinter import ttk
button1 = ttk.Button(*your args here*)
Solution 3:
I had this same exact error, and to get it fixed I had to change my buttons to ttk.Button
and set a style. For example, add the following to import:
try: from tkinter import ttk # python 3except: import ttk # python 2.7
And then after the root init:
style = ttk.Style()
style.map("C.TButton",
foreground=[('pressed', 'red'), ('active', 'blue')],
background=[('pressed', '!disabled', 'black'),
('active', 'white')]
)
Then when you are instantiating the Button:
self.button = ttk.Button(self, text="my cooool button",
command=self.load_something_cool, style="C.TButton")
It worked perfectly to ensure that the text is displayed properly. Before I added the ttk bit, I was in the same boat as you in Mojave.
Solution 4:
I also had this problem, 100% reproducible on my Mac after upgrading to Mojave and when using Homebrew's python3.
Switching to Python.org 's Python 3.7.1 package download totally eliminated the problem for me.
Solution 5:
Here's an example that patches up the problem for me (at least until the Python/Tkinter stuff gets cleaned up):
import tkinter
root = tkinter.Tk()
tkinter.Button(root, text='button').pack()
deffix():
a = root.winfo_geometry().split('+')[0]
b = a.split('x')
w = int(b[0])
h = int(b[1])
root.geometry('%dx%d' % (w+1,h+1))
root.update()
root.after(0, fix)
tkinter.mainloop()
This was tested on macOS Version 10.14.2 (18C54) and Python 3.7.2 (loaded via Home-brew).
Post a Comment for "Button Text Of Tkinter Does Not Work In Mojave"