Skip to content

Make FontFamilyDropdown compatible w/ Python 3.13 #109

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ttkwidgets/font/familydropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
License: GNU GPLv3
Source: This repository
"""

# Based on an idea by Nelson Brochado (https://www.github.com/nbro/tkinter-kit)
import tkinter as tk
from tkinter import font

from ttkwidgets.autocomplete import AutocompleteCombobox


Expand All @@ -28,7 +30,13 @@
self._fonts = font_families
self._font = tk.StringVar(master)
self.__callback = callback
AutocompleteCombobox.__init__(self, master, textvariable=self._font, completevalues=font_families, **kwargs)
AutocompleteCombobox.__init__(
self,
master,
textvariable=self._font,
completevalues=font_families,
**kwargs,
)
self.bind("<<ComboboxSelected>>", self._on_select)
self.bind("<Return>", self._on_select)

Expand All @@ -49,7 +57,7 @@
:return: None if no font is selected and font family name if one is selected.
:rtype: None or str
"""
if self._font.get() is "" or self._font.get() not in self._fonts:
if self._font.get() == "" or self._font.get() not in self._fonts:

Check warning on line 60 in ttkwidgets/font/familydropdown.py

View check run for this annotation

Codecov / codecov/patch

ttkwidgets/font/familydropdown.py#L60

Added line #L60 was not covered by tests
return None
else:
return self._font.get()
4 changes: 3 additions & 1 deletion ttkwidgets/font/familylistbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
License: GNU GPLv3
Source: This repository
"""

# Based on an idea by Nelson Brochado (https://www.github.com/nbro/tkinter-kit)
import tkinter as tk
from tkinter import font

from ttkwidgets import ScrolledListbox


Expand Down Expand Up @@ -54,6 +56,6 @@ def selection(self):
:rtype: None or str
"""
selection = self.listbox.curselection()
if len(selection) is 0:
if not len(selection):
return None
return self.font_indexes[self.listbox.curselection()[0]]
3 changes: 2 additions & 1 deletion ttkwidgets/font/sizedropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
License: GNU GPLv3
Source: This repository
"""

# Based on an idea by Nelson Brochado (https://www.github.com/nbro/tkinter-kit)
from ttkwidgets.autocomplete import AutocompleteCombobox

Expand Down Expand Up @@ -45,7 +46,7 @@ def selection(self):
:return: None if no value is selected and size if selected.
:rtype: None or int
"""
if self.get() is "":
if self.get() == "":
return None
else:
return int(self.get())