GTK wants str encoded in utf-8
__file__ doesn't respect the filesystemencoding when frozen on nt
This commit is contained in:
1 parent
55216231c8
commit
a8ef497a3f
3 files changed
+12
-10
No files matched your search
@@ -58,8 +58,7 @@ class TrytonIconFactory(gtk.IconFactory):
|
||||
continue
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(
|
||||
os.path.join(PIXMAPS_DIR, fname).decode(
|
||||
sys.getfilesystemencoding()))
|
||||
os.path.join(PIXMAPS_DIR, fname).decode('utf-8'))
|
||||
except Exception:
|
||||
continue
|
||||
icon_set = gtk.IconSet(pixbuf)
|
||||
@@ -105,7 +104,7 @@ class TrytonIconFactory(gtk.IconFactory):
|
||||
with os.fdopen(fileno, 'w') as svgfile:
|
||||
svgfile.write(icon['icon'])
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(path.decode(
|
||||
sys.getfilesystemencoding()))
|
||||
sys.getfilesystemencoding().encode('utf-8')))
|
||||
os.remove(path)
|
||||
iconset = gtk.IconSet(pixbuf)
|
||||
self.add(icon['name'], iconset)
|
||||
@@ -308,7 +307,7 @@ def file_selection(title, filename='', parent=None,
|
||||
filename = win.get_preview_filename()
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename.decode(
|
||||
sys.getfilesystemencoding()), 128, 128)
|
||||
sys.getfilesystemencoding().encode('utf-8')), 128, 128)
|
||||
img.set_from_pixbuf(pixbuf)
|
||||
have_preview = True
|
||||
except Exception:
|
||||
|
||||
+8
-4
@@ -175,8 +175,13 @@ class ConfigManager(object):
|
||||
self.defaults.get(key)))
|
||||
|
||||
CONFIG = ConfigManager()
|
||||
CURRENT_DIR = os.path.abspath(os.path.normpath(os.path.join(
|
||||
os.path.dirname(__file__), '..')))
|
||||
if os.name == 'nt' and hasattr(sys, 'frozen'):
|
||||
CURRENT_DIR = os.path.dirname(unicode(sys.executable,
|
||||
sys.getfilesystemencoding()))
|
||||
else:
|
||||
CURRENT_DIR = os.path.abspath(os.path.normpath(os.path.join(
|
||||
unicode(os.path.dirname(__file__), sys.getfilesystemencoding()),
|
||||
'..')))
|
||||
PREFIX = os.path.abspath(os.path.normpath(os.path.join(
|
||||
os.path.dirname(sys.argv[0]), '..')))
|
||||
PIXMAPS_DIR = os.path.join(CURRENT_DIR, 'share', 'pixmaps', 'tryton')
|
||||
@@ -188,8 +193,7 @@ if not os.path.isdir(PIXMAPS_DIR):
|
||||
PIXMAPS_DIR = os.path.join(PREFIX, 'share', 'pixmaps', 'tryton')
|
||||
|
||||
TRYTON_ICON = gtk.gdk.pixbuf_new_from_file(
|
||||
os.path.join(PIXMAPS_DIR, 'tryton-icon.png').decode(
|
||||
sys.getfilesystemencoding()))
|
||||
os.path.join(PIXMAPS_DIR, 'tryton-icon.png').encode('utf-8'))
|
||||
|
||||
def _data_dir():
|
||||
data_dir = os.path.join(CURRENT_DIR, 'share', 'tryton')
|
||||
|
||||
@@ -10,7 +10,6 @@ import re
|
||||
import gettext
|
||||
import threading
|
||||
import time
|
||||
import sys
|
||||
|
||||
from tryton.version import VERSION
|
||||
import tryton.common as common
|
||||
@@ -371,7 +370,7 @@ class DBLogin(object):
|
||||
self.dialog.set_default_response(gtk.RESPONSE_OK)
|
||||
image = gtk.Image()
|
||||
image.set_from_file(os.path.join(PIXMAPS_DIR,
|
||||
'tryton.png').decode(sys.getfilesystemencoding()))
|
||||
'tryton.png').decode('utf-8'))
|
||||
image.set_alignment(0.5, 1)
|
||||
ebox = gtk.EventBox()
|
||||
ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#1b2019"))
|
||||
|
||||
Reference in new issue
Block a user