Skip to content

Commit

Permalink
finish removing dependency on six (#403)
Browse files Browse the repository at this point in the history
* finish removing dependency on six

* fix tkinter.FileDialog

* fix filedialog <> FileDialog
  • Loading branch information
a-detiste authored Oct 22, 2024
1 parent b3cdb7e commit f360600
Show file tree
Hide file tree
Showing 32 changed files with 64 additions and 89 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,18 @@ per the instructions above.
At the moment, this only works on POSIX (Linux, FreeBSD and similar) systems.
Windows and Mac users - you'll need to chip in with a script for your system.

#### 1 - Install build prerequisites: six and pysol-cards
#### 1 - Install build prerequisite: pysol-cards

This is kind of stupid and maybe it can be fixed in the future, but for now:

```
pip install six
pip install pysol-cards
```

You may want to use your OS distribution package system instead, for example:

```
sudo apt-get install python3-six
sudo apt-get install python3-pysol-cards
```

For Pillow compilation, libjpeg headers and libraries need to be available:
Expand Down
3 changes: 1 addition & 2 deletions pysollib/htmllib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
See the HTML 2.0 specification:
http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
"""
import html.parser as html_parser

from pysollib.formatter import AS_IS

from six.moves import html_parser


class HTMLParseError(RuntimeError):
"""Error raised when an HTML document can't be parsed."""
Expand Down
2 changes: 1 addition & 1 deletion pysollib/kivy/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ def mOpen(self, *event):
idir, ifile = "", ""
if not idir:
idir = self.app.dn.savegames
# d = tkFileDialog.Open()
# d = tkinter.filedialog.Open()
# filename = d.show(filetypes=self.FILETYPES,
# defaultextension=self.DEFAULTEXTENSION,
# initialdir=idir, initialfile=ifile)
Expand Down
2 changes: 1 addition & 1 deletion pysollib/tile/basetilemfxdialog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from six.moves import tkinter_ttk as ttk
import tkinter.ttk as ttk

from .tkwidget import MfxDialog

Expand Down
7 changes: 3 additions & 4 deletions pysollib/tile/fontsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
# ---------------------------------------------------------------------------

import tkinter
import tkinter.font
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.ui.tktile.tkutil import bind

from six.moves import tkinter_font
from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxDialog
from .tkwidget import PysolScale

Expand Down Expand Up @@ -109,7 +108,7 @@ def __init__(self, parent, title, init_font, **kw):
command=self.fontupdate, variable=self.size_var)
sc.grid(row=4, column=0, columnspan=2, sticky='news')
#
font_families = list(tkinter_font.families())
font_families = list(tkinter.font.families())
font_families.sort()
selected = -1
n = 0
Expand Down
4 changes: 2 additions & 2 deletions pysollib/tile/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
# ---------------------------------------------------------------------------##

import tkinter.ttk as ttk

from pysollib.mygettext import _, n_
from pysollib.settings import TITLE
from pysollib.ui.tktile.findcarddialog import connect_game_find_card_dialog
Expand All @@ -32,8 +34,6 @@
from pysollib.ui.tktile.solverdialog import connect_game_solver_dialog
from pysollib.util import CARDSET

from six.moves import tkinter_ttk as ttk

from .selectgame import SelectGameDialog, SelectGameDialogWithPreview
from .selecttile import SelectTileDialogWithPreview
from .soundoptionsdialog import SoundOptionsDialog
Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/playeroptionsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
# ---------------------------------------------------------------------------##

import tkinter
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _

from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxDialog


Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
# ---------------------------------------------------------------------------

import tkinter
import tkinter.ttk as ttk

from pysollib.ui.tktile.tkconst import EVENT_HANDLED
from pysollib.ui.tktile.tkutil import makeToplevel, setTransient

from six.moves import tkinter_ttk as ttk

# ************************************************************************
# * a simple progress bar
# ************************************************************************
Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/selectcardset.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import os
import tkinter
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct, USE_PIL
from pysollib.mygettext import _
Expand All @@ -32,8 +33,6 @@
from pysollib.ui.tktile.tkutil import bind, loadImage
from pysollib.util import CARDSET

from six.moves import tkinter_ttk as ttk

from .selecttree import SelectDialogTreeCanvas
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from .tkwidget import MfxDialog, MfxScrolledCanvas, PysolCombo, PysolScale
Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/selectgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import os
import tkinter
import tkinter.ttk as ttk
from collections import UserList

from pysollib.gamedb import GI
Expand All @@ -33,8 +34,6 @@
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
from pysollib.ui.tktile.tkutil import bind, unbind_destroy

from six.moves import tkinter_ttk as ttk

from .selecttree import SelectDialogTreeCanvas
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from .tkwidget import MfxDialog, MfxScrolledCanvas, PysolCombo
Expand Down
7 changes: 3 additions & 4 deletions pysollib/tile/selecttile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@

import os
import tkinter
import tkinter.colorchooser
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct, USE_PIL
from pysollib.mygettext import _
from pysollib.resource import TTI
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
from pysollib.ui.tktile.tkutil import bind

from six.moves import tkinter_colorchooser
from six.moves import tkinter_ttk as ttk

from .selecttree import SelectDialogTreeCanvas
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from .tkwidget import MfxDialog, MfxScrolledCanvas, PysolCombo
Expand Down Expand Up @@ -282,7 +281,7 @@ def mDone(self, button):
self.tree.n_expansions = 1 # save xyview in any case
if button == 10: # "Solid color..."
try:
c = tkinter_colorchooser.askcolor(
c = tkinter.colorchooser.askcolor(
master=self.top,
initialcolor=self.table_color,
title=_("Select table color"))
Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/soundoptionsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@

import os
import tkinter
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.pysolaudio import pysolsoundserver
from pysollib.settings import TITLE
from pysollib.ui.tktile.tkconst import EVENT_HANDLED

from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxDialog, MfxMessageDialog
from .tkwidget import PysolScale

Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
import os
import sys
import tkinter
import tkinter.ttk as ttk

from pysollib.mygettext import _

from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxTooltip

if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/timeoutsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
# ---------------------------------------------------------------------------##

import tkinter
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _

from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxDialog, PysolScale


Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/tkhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
import os
import sys
import tkinter
import tkinter.ttk as ttk

from pysollib.mfxutil import Struct
from pysollib.mygettext import _
from pysollib.ui.tktile.tkhtml import Base_HTMLViewer

from six.moves import tkinter_ttk as ttk

from .statusbar import HtmlStatusbar
from .tkwidget import MfxMessageDialog

Expand Down
13 changes: 6 additions & 7 deletions pysollib/tile/tkstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import os
import time
import tkinter
import tkinter.font
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct
from pysollib.mfxutil import format_time
Expand All @@ -32,9 +34,6 @@
from pysollib.stats import ProgressionFormatter, PysolStatsFormatter
from pysollib.ui.tktile.tkutil import bind, loadImage

from six.moves import tkinter_font
from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxDialog, MfxMessageDialog


Expand All @@ -54,11 +53,11 @@ def __init__(self, parent, title, app, player, gameid, **kw):
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

self.font = app.getFont('default')
self.tkfont = tkinter_font.Font(parent, self.font)
self.tkfont = tkinter.font.Font(parent, self.font)
self.font_metrics = self.tkfont.metrics()
style = ttk.Style(parent)
heading_font = style.lookup('Heading', 'font') # treeview heading
self.heading_tkfont = tkinter_font.Font(parent, heading_font)
self.heading_tkfont = tkinter.font.Font(parent, heading_font)

self.selected_game = None

Expand Down Expand Up @@ -502,10 +501,10 @@ class LogDialog(MfxDialog):
def __init__(self, parent, title, app, player, **kw):

self.font = app.getFont('default')
self.tkfont = tkinter_font.Font(parent, self.font)
self.tkfont = tkinter.font.Font(parent, self.font)
style = ttk.Style(parent)
heading_font = style.lookup('Heading', 'font') # treeview heading
self.heading_tkfont = tkinter_font.Font(parent, heading_font)
self.heading_tkfont = tkinter.font.Font(parent, heading_font)
self.font_metrics = self.tkfont.metrics()

self.CHAR_H = self.font_metrics['linespace']
Expand Down
7 changes: 3 additions & 4 deletions pysollib/tile/tkwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import os
import time
import tkinter
import tkinter.font
import tkinter.ttk as ttk
import traceback

from pysollib.mfxutil import KwStruct, destruct, kwdefault, openURL
Expand All @@ -35,9 +37,6 @@
from pysollib.ui.tktile.tkutil import bind, unbind_destroy
from pysollib.ui.tktile.tkutil import makeToplevel, setTransient

from six.moves import tkinter_font
from six.moves import tkinter_ttk as ttk

# ************************************************************************
# * abstract base class for the dialogs in this module
# ************************************************************************
Expand Down Expand Up @@ -313,7 +312,7 @@ def __init__(self, app, parent, title, **kw):

# font_name = msg.lookup('TLabel', 'font')
font_name = 'TkDefaultFont'
font = tkinter_font.Font(parent, name=font_name, exists=True)
font = tkinter.font.Font(parent, name=font_name, exists=True)
font = font.copy()
font.configure(underline=True)
url_label = ttk.Label(frame, text=kw.url, font=font,
Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import os
import tkinter
import tkinter.ttk as ttk

from pysollib.mfxutil import Image, ImageOps, ImageTk
from pysollib.mygettext import _, n_
Expand All @@ -33,8 +34,6 @@
from pysollib.util import IMAGE_EXTENSIONS
from pysollib.winsystems import TkSettings

from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxTooltip


Expand Down
3 changes: 1 addition & 2 deletions pysollib/tile/wizarddialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
# ---------------------------------------------------------------------------

import tkinter
import tkinter.ttk as ttk

from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.wizardpresets import presets
from pysollib.wizardutil import WizardWidgets

from six.moves import tkinter_ttk as ttk

from .tkwidget import MfxDialog
from .tkwidget import PysolCombo, PysolScale

Expand Down
5 changes: 2 additions & 3 deletions pysollib/tk/fontsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
# ---------------------------------------------------------------------------##

import tkinter
import tkinter.font

from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.tk.tkwidget import MfxDialog
from pysollib.ui.tktile.tkutil import bind

from six.moves import tkinter_font


class FontChooserDialog(MfxDialog):
def __init__(self, parent, title, init_font, **kw):
Expand Down Expand Up @@ -101,7 +100,7 @@ def __init__(self, parent, title, init_font, **kw):
self.size_var.set(self.font_size)
self.weight_var.set(self.font_weight == 'bold')
self.slant_var.set(self.font_slant == 'italic')
font_families = list(tkinter_font.families())
font_families = list(tkinter.font.families())
font_families.sort()
selected = -1
n = 0
Expand Down
5 changes: 2 additions & 3 deletions pysollib/tk/selecttile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
# ---------------------------------------------------------------------------##

import tkinter
import tkinter.colorchooser

from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.ui.tktile.selecttree import SelectDialogTreeData

from six.moves import tkinter_colorchooser

from .selecttree import SelectDialogTreeCanvas
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from .tkwidget import MfxDialog, MfxScrolledCanvas
Expand Down Expand Up @@ -176,7 +175,7 @@ def mDone(self, button):
self.tree.n_expansions = 1 # save xyview in any case
if button == 1: # "Solid color..."
try:
c = tkinter_colorchooser.askcolor(
c = tkinter.colorchooser.askcolor(
master=self.top,
initialcolor=self.table_color,
title=_("Select table color"))
Expand Down
Loading

0 comments on commit f360600

Please sign in to comment.