Не могу изменить цвет кнопок в Tkinter на MacBookPython

Программы на Python
Ответить
Anonymous
 Не могу изменить цвет кнопок в Tkinter на MacBook

Сообщение Anonymous »

Работаю над своим первым (школьным) проектом с использованием tkinter, python 3, и по ходу дела мне приходится этому учить себя. Я хочу изменить цвет кнопок, но это не работает. Для контекста я использую MacBook и ноутбук Jupyter. Никаких ошибок не выдается, и, насколько мне известно, с кодом все в порядке.
Когда я попытался установить tkmacosx с помощью pip, он выдал ошибку. Вот мой код ниже:

Код: Выделить всё

import tkinter as tk

from tkmacosx import Button

# Deals with main screen details

root = tk.Tk()

root.title("main screen")
root.configure(bg = '#1B5004')
root.geometry("1500x1000")

# End of main screen settings

# Title

title = tk.Label(text= "California's Native Wildlife", bg = '#1B5004', font = ("Times", 30))
title.place(x = 550, y = 20)

# Buttons redirecting to the two other screens

vegetation = tk.Button(root, text = "Vegetation", highlightbackground = '#14d659', highlightcolor = '#14d659', font = ("Arial", 25))
vegetation.pack(pady = 20)

root.mainloop()
< /code>
Это ошибка, которую я дает мне, когда я добавляю кнопку TKMacosx Import: < /p>
AttributeError                            Traceback (most recent call last)
Cell In[5], line 3
1 import tkinter as tk
----> 3 from tkmacosx import Button
5 # Deals with main screen details
7 root = tk.Tk()

File /opt/anaconda3/lib/python3.12/site-packages/tkmacosx/__init__.py:27
15 """
16 This module provides some modified widgets of Tkinter which works better on macos
17 and some more useful functions and classes as well. For example Button of tkmacosx which
(...)
22 https://github.com/Saadmairaj/tkmacosx#tkmacosx
23 """
25 __version__ = '0.1.6'
---> 27 from tkmacosx.basewidget import check_appearance, get_shade, delta
28 from tkmacosx.variables import ColorVar, DictVar, SaveVar
29 from tkmacosx.widget import Button, CircleButton, SFrame, Marquee, Radiobutton

File /opt/anaconda3/lib/python3.12/site-packages/tkmacosx/basewidget.py:1221
1215             raise _tk.TclError(
1216                 'bad anchor position "{}": must be n, ne, e, se, s, sw, w, nw, or center'.format(anchor))
1218         return self.coords(item, x, y)
-> 1221 class ButtonBase(_Canvas, _button_functions):
1222     """Internal class used for tkinter macos Buttton"""
1224     def __init__(self, _type=None, master=None, cnf={}, **kw):

File /opt/anaconda3/lib/python3.12/site-packages/tkmacosx/basewidget.py:1309, in ButtonBase()
1306     _return.extend(self._features)
1307     return sorted(list(set(_return)))
-> 1309 @tkv._colorvar_patch_destroy
1310 def destroy(self):
1311     """Destroy this and all descendants widgets. This will
1312     end the application of this Tcl interpreter."""
1313     main_win = self.winfo_toplevel()

AttributeError: module 'tkmacosx.variables' has no attribute '_colorvar_patch_destroy'
Любая помощь и советы оценены

Подробнее здесь: https://stackoverflow.com/questions/793 ... on-macbook
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»