Commit 9f4009b4 authored by Diego André Sant'Ana's avatar Diego André Sant'Ana 🤞
Browse files

Alterou muita coisa para suportar o Python3- Correção bugs

parent c8a8ce6c
......@@ -14,7 +14,7 @@ if sys.version_info[0] < 3:
else:
import tkinter as Tk
from tk_utils import Utils
from .tk_utils import Utils
from util.x11_colors import X11Colors
class CustomGrid(Tk.Frame):
......
......@@ -14,7 +14,7 @@ if sys.version_info[0] < 3:
else:
import tkinter as Tk
from tk_itemmenu import *
from .tk_itemmenu import *
class Menu(object):
"""Class for GUI menus."""
......
......@@ -11,10 +11,12 @@
import sys
if sys.version_info[0] < 3:
import Tkinter as Tk
import thread
else:
import tkinter as Tk
import _thread as thread
import thread
class Popup(object):
"""Non-blocking popup class."""
......
......@@ -8,8 +8,18 @@
Author: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )
"""
import os
import tkMessageBox, Tkconstants, tkFileDialog
import tkColorChooser
import sys
if sys.version_info[0] < 3:
import tkMessageBox, Tkconstants, tkFileDialog
import tkColorChooser
else:
import tkinter.messagebox as tkMessageBox
import tkinter.constants as Tkconstants
from tkinter import filedialog as tkFileDialog
from tkinter import colorchooser as tkColorChooser
class Utils(object):
"""Utilities functionalities from Tkinter."""
......
......@@ -9,30 +9,52 @@
"""
import sys
try:
if sys.version_info < (3, 0):
# for Python2
import Tkinter as Tk
import tkMessageBox
import tk as tk_local
from interface import Interface, InterfaceException as IException
except ImportError:
else:
# for Python3
import tkinter as Tk
import tkinter.messagebox as tkMenssageBox
import tkinter as tk_local
import tkinter.messagebox as tkMessageBox
from .tk import tk_utils,tk_popup,tk_customframe,tk_canvas,tk_logger,tk_customdialog,tk_menu
class TkLocal:
def __init__(self,Utils, Menu,Image,Log,Pop, CustomGrid,SelectDialog,ChooseOneDialog,ConfigDialog):
self.Utils=Utils
self.Menu=Menu
self.Image=Image
self.Log=Log
self.Pop=Pop
self.CustomGrid=CustomGrid
self.SelectDialog=SelectDialog
self.ChooseOneDialog=ChooseOneDialog
self.ConfigDialog=ConfigDialog
tk_local=TkLocal
tk_local.Utils=tk_utils.Utils
tk_local.Menu=tk_menu.Menu
tk_local.Image=tk_canvas.Image
tk_local.Log=tk_logger.Log
tk_local.Pop=tk_popup.Popup
tk_local.CustomGrid=tk_customframe.CustomGrid
tk_local.SelectDialog=tk_customdialog.SelectDialog
tk_local.ChooseOneDialog=tk_customdialog.ChooseOneDialog
tk_local.ConfigDialog=tk_customdialog.ConfigDialog
from interface import Interface, InterfaceException as IException
class TkInterface(Interface):
"""Implements graphical interface and functionalities using Tkinter."""
MAX_CLASSES = 200
try:
if sys.version_info < (3, 0):
utils = tk_local.Utils
else:
utils = tk_local.Utils
except ImportError:
utils = tk_local.utils
def __init__(self, title):
"""Constructor.
......
......@@ -5,6 +5,7 @@
Name: pynovisao.py
Author: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )
"""
import sys
import gc
from collections import OrderedDict
import numpy as np
......@@ -181,6 +182,7 @@ class Act(object):
"""Open a new weight."""
self.weight_path = self.tk.utils.ask_weight_name()
self.classifier.weight_path = self.weight_path
print(self.weight_path)
def restore_image(self):
"""Refresh the image and clean the segmentation.
......@@ -1009,12 +1011,15 @@ class Act(object):
rmtree(matrix_path)
except Exception as e:
pass
mkdir(matrix_path, 0777)
mkdir(matrix_path,0o777)
for class_ in class_names:
real=matrix_path+human+class_+'/'
mkdir(real, 0777)
mkdir(real, 0o777)
for _class in class_names:
mkdir(real+computer+_class, 0777)
mkdir(real+computer+_class,0o777)
header_output = 'Starting Graphical Confusion Matrix\n\n'
......
......@@ -15,8 +15,8 @@ from collections import OrderedDict
from util.config import Config
from segmenter import Segmenter
from skimage_segmenter import SkimageSegmenter
from .segmenter import Segmenter
from .skimage_segmenter import SkimageSegmenter
class Felzenszwalb(Segmenter, SkimageSegmenter):
"""Run Felzenszwalb's method segmentation."""
......
......@@ -15,8 +15,8 @@ from collections import OrderedDict
from util.config import Config
from segmenter import Segmenter
from skimage_segmenter import SkimageSegmenter
from .segmenter import Segmenter
from .skimage_segmenter import SkimageSegmenter
class Quickshift(Segmenter, SkimageSegmenter):
"""Run Quickshift segmentation."""
......
......@@ -17,8 +17,8 @@ from util.config import Config
from util.utils import TimeUtils
from util.x11_colors import X11Colors
from segmenter import Segmenter
from skimage_segmenter import SkimageSegmenter
from .segmenter import Segmenter
from .skimage_segmenter import SkimageSegmenter
class Slic(Segmenter, SkimageSegmenter):
"""Run SLIC (Simple Linear Iterative Clustering) segmentation."""
......
......@@ -7,9 +7,8 @@
Name: config.py
Author: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )
"""
from x11_colors import X11Colors
from utils import BooleanUtils
from .x11_colors import X11Colors
from .utils import BooleanUtils
class Config(object):
"""Class used to store the configs of program. Extend and customize if needed."""
......
......@@ -620,7 +620,7 @@ class FileHelpers(object):
imlist[word].append(im)
count +=1
except IOError:
print ''
print('')
return [imlist, count]
......
......@@ -205,7 +205,7 @@ class X11Colors(object):
"""
idx = X11Colors.search_color(name)
return _x11_colors.values()[idx]
return list(_x11_colors.values())[idx]
@staticmethod
......@@ -297,15 +297,15 @@ class X11Colors(object):
Name of color chosen at random.
"""
ncolors = len(_x11_colors)
xcolorlist=list(_x11_colors.keys())
for i in range(0, ncolors):
index = random.randint(0, ncolors-1)
name = _x11_colors.keys()[index]
name = xcolorlist[index]
if name not in names:
return name
return _x11_colors.keys()[0]
return xcolorlist[0]
@staticmethod
def random_color():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment