From a6d9883d934417a18a4a1dd66c562063baad3b65 Mon Sep 17 00:00:00 2001 From: dschmidt Date: Sun, 2 Feb 2020 15:44:18 +0100 Subject: [PATCH 1/2] add alphanumeric chars to append node and increase special chars list --- .vscode/launch.json | 15 +++++++++ mentalist/view/adder.py | 68 +++++++++++++++++++++++++++++++++++++++-- mentalist/view/const.py | 4 ++- 3 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9900e87 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Verwendet IntelliSense zum Ermitteln möglicher Attribute. + // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. + // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Mentalist", + "type": "python", + "request": "launch", + "program": "pyinstaller_stub.py", + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/mentalist/view/adder.py b/mentalist/view/adder.py index 4e0aff5..785d032 100644 --- a/mentalist/view/adder.py +++ b/mentalist/view/adder.py @@ -5,7 +5,7 @@ import locale from .base_words import BaseWordsNode, center_window -from .const import NUMBER_LIST, DATE_FORMATS, SPECIAL_CHARACTERS +from .const import NUMBER_LIST, DATE_FORMATS, SPECIAL_CHARACTERS, ALPHANUMERIC_CHARS from .. import model @@ -20,6 +20,7 @@ def __init__(self, controller, master=None, main=None, type_='Append', allow_rem self.custom_num_window = None self.entry_string = None self.date_format = Tk.StringVar() + self.alphanum_format = Tk.StringVar() self.special_dlg = None self.chk_special = [] @@ -35,9 +36,9 @@ def add_upper_button(self): mb.menu.add_cascade(label='Words', menu=m_words, underline=0) m_words.add_command(label='Custom File...', command=partial(self.open_file_dlg, partial(self.controller.add_attr, label='File:', right_label_text='Calculating...', node_view=self, attr_class=model.FileAttr, controller=self.controller))) m_words.add_command(label='Custom String...', command=partial(self.open_string_popup, 'String')) - + self.add_file_menu(m_words, m_words) - + # In addition to BaseFile's attributes, we have numbers, dates, # and special characters m_numbers = Tk.Menu(mb, tearoff=0) @@ -55,6 +56,8 @@ def add_upper_button(self): mb.menu.add_command(label="Special Characters...", command=self.open_special_dlg) + mb.menu.add_command(label="Alphanumeric Characters...", command=self.open_alphaNumeric_dlg) + # Area and zip codes from lookup tables for code_type in ['Area', 'Zip']: m_area_zip = Tk.Menu(mb, tearoff=0) @@ -263,3 +266,62 @@ def on_ok_special_dlg(self, *args): label = 'Special Characters: {}'.format(' '.join(checked_vals)) self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings=checked_vals) self.cancel_special() + + def open_alphaNumeric_dlg(self): + '''Open a popup for selecting alphaNumeric characters + ''' + self.alphaNumeric_dlg = Tk.Toplevel() + self.alphaNumeric_dlg.withdraw() + self.alphaNumeric_dlg.title('Select AlphaNumeric Characters') + self.alphaNumeric_dlg.resizable(width=False, height=False) + frame = Tk.Frame(self.alphaNumeric_dlg) + lb = Tk.Label(frame, text='Select AlphaNumeric Characters'.format(self.title)) + lb.pack(fill='both', side='top') + + box = Tk.Frame(frame) + drop_down = Tk.OptionMenu(frame, self.alphanum_format, *ALPHANUMERIC_CHARS) + drop_down.configure(width=max(map(len, ALPHANUMERIC_CHARS)) + 4) + self.alphanum_format.set('a-z') + drop_down.pack(side='top') + + # lb1 = Tk.Label(box, text='Number: ') + # lb1.pack(side='left', padx=5) + # self.sp_case = Tk.Spinbox(box, width=12, from_=1, to=50) + # self.sp_case.pack(side='left') + + box.pack(fill='both', side='top', padx=30, pady=20) + + # Ok and Cancel buttons + btn_box = Tk.Frame(frame) + btn_cancel = Tk.Button(btn_box, text='Cancel', command=self.cancel_alphaNumeric) + btn_cancel.pack(side='right', padx=10, pady=20) + btn_ok = Tk.Button(btn_box, text='Ok', command=self.on_ok_alphaNumeric_dlg) + btn_ok.pack(side='left', padx=10, pady=20) + btn_box.pack() + frame.pack(fill='both', padx=60, pady=10) + + center_window(self.alphaNumeric_dlg, self.main.master) + self.alphaNumeric_dlg.focus_set() + + def cancel_alphaNumeric(self, *args): + if self.alphaNumeric_dlg: + self.alphaNumeric_dlg.destroy() + self.alphaNumeric_dlg = None + + def on_ok_alphaNumeric_dlg(self, *args): + '''Ok was pressed, add the alphanumeric character attribute + ''' + checked_vals = self.alphanum_format.get() + # amount = self.sp_case.get() + + if len(checked_vals) > 0: + label = 'AlphaNumeric Characters: {}'.format(' '.join(checked_vals)) + if checked_vals == "a-z": + self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="abcdefghijklmnopqrstuvwxyz") + elif checked_vals == "a-zA-Z": + self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + elif checked_vals == "a-zA-Z0-9": + self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + self.cancel_alphaNumeric() + + \ No newline at end of file diff --git a/mentalist/view/const.py b/mentalist/view/const.py index b543242..4457b4e 100644 --- a/mentalist/view/const.py +++ b/mentalist/view/const.py @@ -19,6 +19,8 @@ DATE_FORMATS = ['mmddyy', 'ddmmyy', 'mmddyyyy', 'ddmmyyyy', 'mmyyyy', 'mmyy', 'mmdd'] -SPECIAL_CHARACTERS = '''!@#$%^&*()-=_+`~[]{}\|/:;'"''' +SPECIAL_CHARACTERS = '''!@#$%^&*()-=_+~[]{}\|/:;'"`´?§€<>°''' SPECIAL_TYPES = ['One at a time', 'All together'] + +ALPHANUMERIC_CHARS = ['a-z', 'a-zA-Z', 'a-zA-Z0-9'] From 3afbdf3389ebe98a2e5994aa2d46b763b9fa82d8 Mon Sep 17 00:00:00 2001 From: dschmidt Date: Mon, 20 Apr 2020 19:56:47 +0200 Subject: [PATCH 2/2] add more possible alphanumeric characters --- mentalist/view/adder.py | 4 ++++ mentalist/view/const.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mentalist/view/adder.py b/mentalist/view/adder.py index 785d032..0787be4 100644 --- a/mentalist/view/adder.py +++ b/mentalist/view/adder.py @@ -318,10 +318,14 @@ def on_ok_alphaNumeric_dlg(self, *args): label = 'AlphaNumeric Characters: {}'.format(' '.join(checked_vals)) if checked_vals == "a-z": self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="abcdefghijklmnopqrstuvwxyz") + elif checked_vals == "A-Z": + self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="ABCDEFGHIJKLMNOPQRSTUVWXYZ") elif checked_vals == "a-zA-Z": self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") elif checked_vals == "a-zA-Z0-9": self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + elif checked_vals == "0-9": + self.controller.add_attr(label=label, node_view=self, attr_class=model.StringListAttr, strings="0123456789") self.cancel_alphaNumeric() \ No newline at end of file diff --git a/mentalist/view/const.py b/mentalist/view/const.py index 4457b4e..6b3815c 100644 --- a/mentalist/view/const.py +++ b/mentalist/view/const.py @@ -23,4 +23,4 @@ SPECIAL_TYPES = ['One at a time', 'All together'] -ALPHANUMERIC_CHARS = ['a-z', 'a-zA-Z', 'a-zA-Z0-9'] +ALPHANUMERIC_CHARS = ['a-z', 'A-Z', 'a-zA-Z', 'a-zA-Z0-9', '0-9']