Skip to content

Commit 79d7331

Browse files
committed
Fixed bug with entering paths on Windows.
GUI has its own entry-point now, 'nescient-ui'. Ensured the GUI cannot be interacted with when adding files.
1 parent 01f00f2 commit 79d7331

File tree

8 files changed

+25
-16
lines changed

8 files changed

+25
-16
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Unless otherwise specified via command line flags, Nescient packs and unpacks fi
8989

9090
Command line help can be viewed with ``nescient -h``.
9191

92-
Nescient also has a GUI mode, which can be run by simply running ``nescient``.
92+
Nescient also has a GUI mode, which can be run by simply running ``nescient-ui``.
9393

9494
Development
9595
===========
112 KB
Binary file not shown.

dist/Nescient-0.6.1.tar.gz

141 KB
Binary file not shown.

nescient/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# SOFTWARE.
2121
#
2222
# nescient/__init__.py
23-
"""Nescient v0.6.0
23+
"""Nescient v0.6.1
2424
2525
A Python program for packing/unpacking encrypted, salted, and authenticated file containers.
2626
@@ -30,7 +30,7 @@
3030

3131
# Versions will always take the form major.minor.patch[.develop]. The develop increment is optional.
3232
# A valid version will have the string form *.*.*[.dev*], where any integer may take the place of a *.
33-
__version__ = '0.6.0'
33+
__version__ = '0.6.1'
3434
url = 'https://github.com/arantonitis/nescient'
3535

3636

nescient/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from nescient.packer import PACKING_MODES, DEFAULT_PACKING_MODE, NescientPacker, PackingError
1515
from nescient.timing import estimate_time, EstimatedTimer, load_benchmarks, benchmark_mode
1616
from nescient.process import start_packer_process
17-
from nescient.gui import NescientUI
17+
from nescient.gui import main as start_gui
1818

1919

2020
# Prompt the user with a yes-no question
@@ -40,8 +40,7 @@ def ask_yesno(prompt, default=True, newline=False, noprompt=False):
4040
def main():
4141
# If run with no arguments, start the GUI
4242
if len(sys.argv) == 1:
43-
gui = NescientUI()
44-
gui.mainloop()
43+
start_gui()
4544
sys.exit(0)
4645
parser = ArgumentParser(prog='nescient', description=description, formatter_class=RawTextHelpFormatter)
4746
parser.add_argument('packing_choice', choices=['pack', 'unpack'], metavar='pack|unpack',

nescient/gui.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
""" Graphical User Interface (GUI) for Nescient. """
66
# TODO: Options, documentation, better path awareness, working directory changes, non-blocking benchmarking, About
77
import os
8+
import sys
89
import glob
910
import webbrowser
1011
from tkinter import Tk, Label, PhotoImage, OptionMenu, StringVar, Frame, Text, Scrollbar, RIGHT, Y, WORD, DISABLED, \
@@ -210,7 +211,7 @@ def close(self):
210211

211212
# The main UI
212213
class NescientUI(Tk):
213-
def __init__(self):
214+
def __init__(self, paths=None):
214215
Tk.__init__(self)
215216
self.title('Nescient ' + __version__)
216217
try:
@@ -239,6 +240,8 @@ def __init__(self):
239240
self.grid_columnconfigure(1, weight=1)
240241
# Set up initial variables
241242
self.paths = []
243+
if paths:
244+
self.add_files('auto', paths)
242245
self.state = 'ready'
243246
self.open_dir = os.getcwd()
244247

@@ -278,22 +281,24 @@ def threaded_task(self, func, *args, **kwargs):
278281
self.state = 'ready'
279282
return return_value
280283

281-
def add_files(self, choice):
284+
def add_files(self, choice, paths=None):
282285
self.status.config(text='Adding files...')
286+
self.global_widget_state(DISABLED)
283287
if choice == 'glob':
284288
pattern = self.path_select.entry.get()
285289
paths = [path for path in glob.glob(pattern, recursive=True) if os.path.isfile(path)]
286-
else: # choice == 'dialog':
290+
elif choice == 'dialog':
287291
paths = list(filedialog.askopenfilenames(initialdir=self.open_dir, parent=self, title='Add files'))
288292
if paths:
289293
self.open_dir = os.path.dirname(paths[0])
290294
for path in paths:
291295
if not self.paths:
292296
self.text.clear()
293297
if path not in self.paths:
294-
self.text.insert(path + '\n', path.replace(' ', '?'))
298+
self.text.insert(path + '\n', 'path%s' % len(self.paths))
295299
self.paths.append(path)
296300
self.status.config(text='Ready.')
301+
self.global_widget_state(NORMAL)
297302

298303
def clear_paths(self):
299304
self.status.config(text='Clearing paths...')
@@ -323,10 +328,10 @@ def password_failed(self, password):
323328

324329
def packing_loop(self, choice, packer):
325330
self.title('Nescient %s - %s' % (__version__, 'Packing' if choice == 'pack' else 'Unpacking'))
326-
for path in self.paths:
331+
for path_num, path in enumerate(self.paths):
327332
try:
328333
# Color and scroll to the tag
329-
tag = path.replace(' ', '?')
334+
tag = 'path%s' % path_num
330335
self.text.text.see('%s.first' % tag)
331336
self.text.tag_config(tag, background='#369a9d')
332337
# Fix the out path and set up display text
@@ -389,8 +394,12 @@ def benchmark_all_modes(self):
389394
self.mode_select.display_rate_info()
390395
self.status.config(text='Ready')
391396
self.title('Nescient ' + __version__)
397+
398+
def main():
399+
paths = sys.argv[1:] if len(sys.argv) > 1 else None
400+
gui = NescientUI(paths)
401+
gui.mainloop()
392402

393403

394404
if __name__ == '__main__':
395-
gui = NescientUI()
396-
gui.mainloop()
405+
main()

nescient/nessie.ico

5.56 KB
Binary file not shown.

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
author_email='[email protected]',
2828
url=url,
2929
packages=['nescient', 'nescient.crypto', 'nescient.resources'],
30-
package_data={'nescient': ['*.png'], 'nescient.crypto': ['*.pyx'], 'nescient.resources': ['*gif']},
30+
package_data={'nescient': ['*.png', '*.ico'], 'nescient.crypto': ['*.pyx'], 'nescient.resources': ['*gif']},
3131
ext_modules=extensions,
32-
entry_points={'console_scripts': ['nescient = nescient.__main__:main']},
32+
entry_points={'console_scripts': ['nescient = nescient.__main__:main'],
33+
'gui_scripts': ['nescient-ui = nescient.gui:main']},
3334
license='MIT',
3435
classifiers=['License :: OSI Approved :: MIT License'],
3536
python_requires='>=3.3'

0 commit comments

Comments
 (0)