futurize stage2 gui

This commit is contained in:
Simon Forman 2020-04-23 23:38:10 -07:00
parent 29d510eb46
commit f949efe1a4
6 changed files with 18 additions and 7 deletions

View File

@ -10,7 +10,9 @@ file, so you can just do, e.g.:
''' '''
from __future__ import print_function from __future__ import print_function
import base64, os, StringIO, zipfile from future import standard_library
standard_library.install_aliases()
import base64, os, io, zipfile
def initialize(joy_home): def initialize(joy_home):
@ -18,7 +20,7 @@ def initialize(joy_home):
def create_data(from_dir='./default_joy_home'): def create_data(from_dir='./default_joy_home'):
f = StringIO.StringIO() f = io.StringIO()
z = zipfile.ZipFile(f, mode='w') z = zipfile.ZipFile(f, mode='w')
for fn in os.listdir(from_dir): for fn in os.listdir(from_dir):
from_fn = os.path.join(from_dir, fn) from_fn = os.path.join(from_dir, fn)
@ -27,7 +29,7 @@ def create_data(from_dir='./default_joy_home'):
return base64.encodestring(f.getvalue()) return base64.encodestring(f.getvalue())
Z = zipfile.ZipFile(StringIO.StringIO(base64.decodestring('''\ Z = zipfile.ZipFile(io.StringIO(base64.decodestring('''\
UEsDBBQAAAAAAJKh9Uw/yHAgFQQAABUEAAALAAAAc2NyYXRjaC50eHRyZXNldF9sb2cgd29yZHMg UEsDBBQAAAAAAJKh9Uw/yHAgFQQAABUEAAALAAAAc2NyYXRjaC50eHRyZXNldF9sb2cgd29yZHMg
bW91c2VfYmluZGluZ3Mga2V5X2JpbmRpbmdzCgpTdGFjayBDaGF0dGVyCgogZHVwIGR1cGQgZHVw bW91c2VfYmluZGluZ3Mga2V5X2JpbmRpbmdzCgpTdGFjayBDaGF0dGVyCgogZHVwIGR1cGQgZHVw
ZGQgb3ZlciB0dWNrCiBwb3AgcG9wZCBwb3BkZCBwb3BvcCBwb3BvcGQgcG9wb3BkZAogc3dhcCBy ZGQgb3ZlciB0dWNrCiBwb3AgcG9wZCBwb3BkZCBwb3BvcCBwb3BvcGQgcG9wb3BkZAogc3dhcCBy

View File

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
('''\ ('''\
Joypy - Copyright © 2018 Simon Forman Joypy - Copyright © 2018 Simon Forman
''' '''
@ -10,7 +12,7 @@ Joypy - Copyright © 2018 Simon Forman
' Right-click on these commands to see docs on UI commands: key_bindings mouse_bindings') ' Right-click on these commands to see docs on UI commands: key_bindings mouse_bindings')
import logging, os, pickle, sys import logging, os, pickle, sys
from textwrap import dedent from textwrap import dedent
from ConfigParser import RawConfigParser from configparser import RawConfigParser
from joy.gui.utils import init_home, argparser, FileFaker from joy.gui.utils import init_home, argparser, FileFaker
@ -60,7 +62,7 @@ def commands():
'F4 - Paste item on top of stack to insertion cursor.', 'F4 - Paste item on top of stack to insertion cursor.',
'Shift-F4 - Pop and paste top of stack to insertion cursor.', 'Shift-F4 - Pop and paste top of stack to insertion cursor.',
] ]
for key, command in GLOBAL_COMMANDS.iteritems(): for key, command in GLOBAL_COMMANDS.items():
commands.append('%s - %s' % (key.lstrip('<').rstrip('>'), command)) commands.append('%s - %s' % (key.lstrip('<').rstrip('>'), command))
print('\n'.join([''] + sorted(commands))) print('\n'.join([''] + sorted(commands)))
return args return args

View File

@ -20,10 +20,11 @@
#Do-nothing event handler. #Do-nothing event handler.
from builtins import object
nothing = lambda event: None nothing = lambda event: None
class MouseBindingsMixin: class MouseBindingsMixin(object):
"""TextViewerWidget mixin class to provide mouse bindings.""" """TextViewerWidget mixin class to provide mouse bindings."""
def __init__(self): def __init__(self):

View File

@ -35,6 +35,10 @@ The GUI
''' '''
from __future__ import print_function from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import str, map, object
from past.builtins import basestring
try: try:
import tkinter as tk import tkinter as tk
from tkinter.font import families, Font from tkinter.font import families, Font
@ -85,7 +89,7 @@ TEXT_BINDINGS = {
} }
class SavingMixin: class SavingMixin(object):
def __init__(self, saver=None, filename=None, save_delay=2000): def __init__(self, saver=None, filename=None, save_delay=2000):
self.saver = self._saver if saver is None else saver self.saver = self._saver if saver is None else saver

View File

@ -1,4 +1,5 @@
from __future__ import print_function from __future__ import print_function
from builtins import object
import argparse, os, sys import argparse, os, sys
from os import listdir, mkdir from os import listdir, mkdir
from os.path import abspath, exists, expanduser, isfile, join from os.path import abspath, exists, expanduser, isfile, join

View File

@ -18,6 +18,7 @@
# along with joy.py. If not see <http://www.gnu.org/licenses/>. # along with joy.py. If not see <http://www.gnu.org/licenses/>.
# #
from __future__ import print_function from __future__ import print_function
from builtins import object
from logging import getLogger from logging import getLogger
_log = getLogger(__name__) _log = getLogger(__name__)