Follow-up Comment #6, bug #17739 (project mypaint):
ah didn't see your comment #3 :)
Yes I need to get rid the encode('utf-8') to make it open the file but then I
forgot to make it utf-8 when passing it to gtk.Recent
OK It works now thanks. Seems like this
main.py
...
from gui import application
from optparse import OptionParser
import sys, time
def win32_utf16_argv():
"""Uses shell32.GetCommandLineArgvW to get sys.argv as a list of Unicode
strings.
Versions 2.x of Python don't support Unicode in sys.argv on
Windows, with the underlying Windows API instead replacing multi-byte
characters with '?'.
"""
try:
from ctypes import POINTER, byref, cdll, c_int, windll
from ctypes.wintypes import LPCWSTR, LPWSTR
GetCommandLineW = cdll.kernel32.GetCommandLineW
GetCommandLineW.argtypes = []
GetCommandLineW.restype = LPCWSTR
CommandLineToArgvW = windll.shell32.CommandLineToArgvW
CommandLineToArgvW.argtypes = [LPCWSTR, POINTER(c_int)]
CommandLineToArgvW.restype = POINTER(LPWSTR)
cmd = GetCommandLineW()
argc = c_int(0)
argv = CommandLineToArgvW(cmd, byref(argc))
if argc.value > 0:
# Remove Python executable if present
if argc.value - len(sys.argv) == 1:
start = 1
else:
start = 0
return [argv[i] for i in
xrange(start, argc.value)]
except Exception:
pass
# main entry, called from the "mypaint" script
def main(datapath, confpath):
if sys.platform == 'win32':
sys.argv = win32_utf16_argv()
parser = OptionParser('usage: %prog [options] [FILE]')
parser.add_option('-c', '--config', metavar='DIR', default=confpath,
help='use config directory DIR instead of ~/.mypaint/')
parser.add_option('-l', '--logfile', metavar='FILE', default=None,
help='append python stdout and stderr to FILE')
parser.add_option('-t', '--trace', action="store_true",
help='print all exectued python statements')
options, args = parser.parse_args()
if sys.platform != 'win32':
args = [s.decode(sys.getfilesystemencoding()) for s in args]
...
filehandling.py
...
gtk.recent_manager_get_default().add_full(helpers.filename2uri(self.filename),
{
'app_name': 'mypaint',
'app_exec': sys.argv[0].encode('utf-8'),
# todo: get mime_type
'mime_type': 'application/octet-stream'
}
)
...
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?17739>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Mypaint-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/mypaint-bugs
