Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Remove support for python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Dec 31, 2018
1 parent 365f865 commit 38bbd02
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 56 deletions.
18 changes: 5 additions & 13 deletions _unittests/ut_module/test_code_style.py
Expand Up @@ -46,20 +46,16 @@ def test_code_style_src(self):
'R0913', 'R0914', 'R0915', 'R1702', 'R1705',
'W0613',
'W0123', 'W0212', 'W0703', 'W0201'),
skip=["tp_transfer_files.py:376: [E731]",
"_nbconvert_config.py:",
"Redefining built-in 'open'",
"Redefining built-in 'help'",
skip=["_nbconvert_config.py:",
#
"Uses of a deprecated module 'tkinter.tix'",
"Unable to import 'Tix'",
"Redefining name 'fLOG'",
"Unable to import 'tkFont'",
"Unable to import 'StringIO'",
"tk_window.py:56",
"tk_window.py:68",
"function_helper.py:122",
"Unable to import 'Tkinter'"])
"Unable to import 'Tkinter'",
"tk_window.py:50: W0603",
"tk_window.py:62: W0603",
])

def test_code_style_test(self):
fLOG(
Expand All @@ -85,12 +81,8 @@ def test_code_style_test(self):
"skip___' imported but unused",
"[E402] module ",
"imported as skip_",
"Unable to import 'StringIO'",
"Redefining built-in 'open'",
"Unused variable 'fig'",
"Redefining built-in 'FileNotFoundError'",
"test_windows_autopy3.py:",
"Unable to import 'Tkinter'",
"Unused import src",
])

Expand Down
5 changes: 0 additions & 5 deletions src/tkinterquickhelper/funcwin/default_functions.py
Expand Up @@ -8,15 +8,10 @@
import os
import re
import random

from pyquickhelper.loghelper.flog import fLOG, GetSepLine
from pyquickhelper.filehelper.synchelper import explore_folder_iterfile


if sys.version_info[0] == 2:
from codecs import open


_keep_var_character = re.compile("[^a-zA-Z0-9_]")


Expand Down
13 changes: 3 additions & 10 deletions src/tkinterquickhelper/funcwin/frame_function.py
Expand Up @@ -7,21 +7,14 @@
import os
import inspect
import threading

import tkinter
import tkinter.font as tkFont
from io import StringIO
from pyquickhelper.loghelper.flog import fLOG, GetLogFile
from .tk_window import create_tk
from .function_helper import has_unknown_parameters, extract_function_information, private_adjust_parameters, private_get_function
from .storing_functions import _private_restore, _private_store, interpret_parameter

if sys.version_info[0] == 2:
import Tkinter as tkinter
import tkFont
from StringIO import StringIO
else:
import tkinter
import tkinter.font as tkFont
from io import StringIO


class FrameFunction(tkinter.Frame):
"""
Expand Down
8 changes: 2 additions & 6 deletions src/tkinterquickhelper/funcwin/frame_params.py
Expand Up @@ -6,23 +6,19 @@
"""
import sys
import os
import tkinter
from .tk_window import create_tk
from .function_helper import private_adjust_parameters
from .storing_functions import _private_restore, _private_store, interpret_parameter

if sys.version_info[0] == 2:
import Tkinter as tkinter
else:
import tkinter


class FrameParams(tkinter.Frame):
"""
Creates a Frame window for a list of parameters.
"""

def __init__(self, parent, restore=True, width=100, raise_exception=False,
params=None, help="", key_save="", command_leave=None):
params=None, help="", key_save="", command_leave=None): # pylint: disable=W0622
"""
@param parent window parent
@param restore if True, check if existing saved parameters are present
Expand Down
1 change: 0 additions & 1 deletion src/tkinterquickhelper/funcwin/function_helper.py
Expand Up @@ -7,7 +7,6 @@
import re
import inspect
import datetime

from pyquickhelper.loghelper.flog import guess_machine_parameter


Expand Down
17 changes: 8 additions & 9 deletions src/tkinterquickhelper/funcwin/main_window.py
Expand Up @@ -5,18 +5,14 @@
@brief building windows to use a function and specify its parameter based on a python function
"""
import os
import sys
import warnings
import tkinter
import tkinter.tix as ttix # pylint: disable=W0402
from tkinter import TclError
from .tk_window import create_tixtk
from .frame_function import FrameFunction
from .storing_functions import get_icon

if sys.version_info[0] == 2:
import Tkinter as tkinter
import Tix as ttix
else:
import tkinter
import tkinter.tix as ttix


class MainFrame(tkinter.Frame):

Expand Down Expand Up @@ -174,7 +170,10 @@ def main_loop_functions(functions, first=None, restore=True, width=100,

ico = get_icon() if ico is None else ico
root = create_tixtk()
root.iconbitmap(ico)
try:
root.iconbitmap(ico)
except TclError:
warnings.warn("Unable to load icon '{0}'".format(ico))
fr = MainFrame(parent=root, functions=functions, first=first, restore=restore,
width=width, raise_exception=raise_exception, overwrite=overwrite,
hide=hide)
Expand Down
4 changes: 0 additions & 4 deletions src/tkinterquickhelper/funcwin/storing_functions.py
Expand Up @@ -3,7 +3,6 @@
@file
@brief Common functions used for @see cl FrameFunction and @see cl FrameParams.
"""
import sys
import os
import copy
import datetime
Expand All @@ -12,9 +11,6 @@
from pyquickhelper.loghelper.convert_helper import str2datetime
from pyquickhelper.loghelper.flog import fLOG, guess_machine_parameter

if sys.version_info[0] == 2:
from codecs import open


def _private_store(function_name, param):
"""
Expand Down
10 changes: 2 additions & 8 deletions src/tkinterquickhelper/funcwin/tk_window.py
Expand Up @@ -3,15 +3,9 @@
@file
@brief Handles window `Tk <https://docs.python.org/3.4/library/tkinter.html#tkinter.Tk>`_
"""

import sys

if sys.version_info[0] == 2:
import Tkinter as tkinter
import Tix as ttix
else:
import tkinter
import tkinter.tix as ttix
import tkinter
import tkinter.tix as ttix # pylint: disable=W0402


def X_is_running():
Expand Down

0 comments on commit 38bbd02

Please sign in to comment.