I'm trying to use tkinter with python3 to open an image, see here a piece of code :
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --- Python 3.4
from PIL import Image
import Tkinter as tk
from Tkinter import filedialog
import numpy as np
import os
var = 'n'
# Importing the image to correct
while var != 'o' :
var = raw_input("Press \"o\" to open the image to correct\n")
var = var.lower()
root = tk.Tk()
root.withdraw()
path = filedialog.askopenfilename()
image_test = Image.open(path)
I have installed python3-tk, and I have the demo window when I write
python3 -m tkinter
in the terminal. I tried several combinations that did not work :
import tkinter as tk
from tkinter import filedialog
gives
ImportError : No module named tkinter
,
import Tkinter as tk
from Tkinter import filedialog
gives
ImportError : cannot import name filedialog
I tried with _tinker , FileDialog, file_dialog, but I always have "ImportError : cannot import name filedialog". Any clue ?