Skip to content

Commit

Permalink
Switch to getFile for image selection; pass image_path as unicode
Browse files Browse the repository at this point in the history
Should fix a TypeError that was occuring on Windows for some users.
(Strangely enough I've never run into this myself, neither on Linux nor
Windows)
  • Loading branch information
glutanimate committed Feb 14, 2017
1 parent aecc5e7 commit 3159c05
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions image_occlusion_enhanced/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@
import logging, sys
import os

from PyQt4.QtGui import QFileDialog, QAction, QKeySequence
from PyQt4.QtCore import QUrl
from aqt.qt import *

from aqt import mw
from aqt.editor import Editor
from aqt.addcards import AddCards
from aqt.editcurrent import EditCurrent
from aqt.reviewer import Reviewer
from aqt.utils import tooltip, saveGeom, restoreGeom
from aqt.utils import getFile, tooltip, saveGeom, restoreGeom
from anki.hooks import wrap, addHook

import tempfile
Expand Down Expand Up @@ -112,16 +110,16 @@ def getImage(self, parent=None, noclip=False):
# workaround for a clipboard bug
return self.getImage(noclip=True)
else:
return image_path
return unicode(image_path)

# retrieve last used image directory
prev_image_dir = self.lconf["dir"]
if not prev_image_dir or not os.path.isdir(prev_image_dir):
prev_image_dir = IO_HOME

image_path = QFileDialog.getOpenFileName(parent,
"Choose Image", prev_image_dir,
"Image Files (*.png *jpg *.jpeg *.gif)")
image_path = getFile(parent, "Choose an Image", None,
"Image Files (*.png *jpg *.jpeg *.gif)",
dir=prev_image_dir)

if not image_path:
return None
Expand Down

0 comments on commit 3159c05

Please sign in to comment.