def create_signature_entry(self):

        AlexLabel(self.interior, text=_("Signature:")).grid(row=3,
                                                            column=0,
                                                            sticky=W)
        self.signature_widget = AlexEntry(self.interior)
        self.signature_widget.grid(row=3, column=1, sticky=W, pady=5)
    def create_dialog(self):
        super().create_dialog()
        self.set_default_buttons()

        self.label = AlexLabel(self.interior)
        self.label.pack()

        self.entry = AlexEntry(self.interior)
        self.entry.pack()
class AlexLabelTest(AbstractComponentTest):
    def __init__(self):
        super().__init__()
        self.name = "Alex label test"

    def test_component(self, master, message_label):

        self.message_label = message_label
        self.master = master

        self.label1 = AlexLabel(master)
        self.label1.set('Label text:')
        self.label1.grid(row=0, column=0)

        self.entry1 = AlexEntry(master)
        self.entry1.set("Enter label text")
        self.entry1.grid(row=0, column=1)

        AlexButton(master, text='Set label text',
                   command=self._set_label_text).grid(row=1, column=0)
        AlexButton(master,
                   text='Set entry from label',
                   command=self._set_entry_from_label).grid(row=1, column=1)

    def _set_label_text(self):

        self.label1.set(self.entry1.get())
        self.entry1.set('')

    def _set_entry_from_label(self):

        self.entry1.set(self.label1.get())
class GenericTreeSelectionDialog(AbstractInputDialog):
    def __init__(self, window_manager, presenter):

        super().__init__(window_manager, presenter)

        self.tree_widget = None
        self.filter_is_set = False

    def create_dialog(self):

        super().create_dialog()

        self.label = AlexLabel(self.interior)
        self.label.pack(side=TOP, padx=5, pady=5)

        filter_frame = Frame(self.interior)
        AlexLabel(filter_frame, text=_('Search tree:')).pack(side=LEFT, pady=5)
        self.filter_entry = AlexEntry(filter_frame)
        self.filter_entry.bind("<KeyRelease>",
                               lambda event: self._apply_filter(event))
        self.filter_entry.pack(side=LEFT, fill=X, expand=YES)
        filter_frame.pack(side=TOP, expand=YES, fill=X)

        self.set_default_buttons()

    def config_dialog(self, label=_('Select a tree node')):
        self.label.set(label)

    def _apply_filter(self, event):
        filter_string = self.filter_entry.get()
        if len(filter_string) > 2:
            visible_nodes = self.tree_widget.apply_filter(filter_string)
            if visible_nodes < 20:
                self.tree_widget.expand_all()
            self.filter_is_set = True
        else:
            if self.filter_is_set:
                self.tree_widget.clear_filter()
                self.filter_is_set = False

    def set_tree(self, tree):
        if self.tree_widget is not None:
            self.tree_widget.destroy()
        self.tree_widget = AlexTree(self.interior, tree)
        self.tree_widget.pack()

    def activate(self, callback, label):
        if self.window is not None:
            self.label.set(label)
        super().activate(callback, label=label)

    input = property(lambda self: self.tree_widget.get())
    tree = property(None, set_tree)
Example #5
0
    def create_dialog(self):

        super().create_dialog()

        # Wizard page 1
        Label(self.pages[0], text=_("Start creating a CD")).pack(padx=5,
                                                                 pady=5)

        Label(self.pages[0], text=_("Enter a name for the CD:")).pack()
        self.name_entry = AlexEntry(self.pages[0])
        self.name_entry.pack()

        # Wizard page 2
        Label(self.pages[1], text=_("Start page as markdown:")).pack(padx=5,
                                                                     pady=5)
        self.start_page_entry = AlexText(self.pages[1])
        self.start_page_entry.pack()

        # Wizard page 3
        Label(self.pages[2], text=_("Impressum as markdown:")).pack(padx=5,
                                                                    pady=5)
        self.imprint_entry = AlexText(self.pages[2])
        self.imprint_entry.pack()

        # Wizard page 4
        Label(self.pages[3], text=_("Please enter a data range:")).pack(padx=5,
                                                                        pady=5)

        self.start_date_entry = AlexDateEntry(self.pages[3])
        self.start_date_entry.label = _("Enter start date:")
        self.start_date_entry.pack()

        self.end_date_entry = AlexDateEntry(self.pages[3])
        self.end_date_entry.label = _("Enter end date:")
        self.end_date_entry.pack()

        # Wizard page 5
        Label(self.pages[4], text=_("Please select a signature")).pack(padx=5,
                                                                       pady=5)
        self.signature_button = AlexButton(
            self.pages[4],
            command=lambda: self.signature_dialog.activate(
                self._signature_callback, label=_("Select a signature")))
        self.signature_button.pack()

        # Wizard page 6
        Label(self.pages[5],
              text=_("Please select a title image")).pack(padx=5, pady=5)
        self.start_image_button = AlexButton(
            self.pages[5], command=self._get_start_image_file)
        self.start_image_button.pack()
 def create_dialog(self):
     super().create_dialog()
     self.add_button(_("Set filter"), self.presenter.ok_action)
     self.add_button(_("Clear form"), self._clear_filter_form)
     self.add_button(_("Cancel"), self.presenter.cancel_action)
     self.search_term_entries = []
     for i in range(1, 4):
         AlexLabel(self.interior,
                   text=_("%d. search expression:") % i).grid(row=i - 1,
                                                              column=0,
                                                              sticky=W)
         entry = AlexEntry(self.interior)
         entry.grid(row=i - 1, column=1, sticky=W, pady=5)
         self.search_term_entries.append(entry)
Example #7
0
class ChronoDialog(AbstractInputDialog):
    '''
    Dialog to get the user input on which chrono to produce.
    '''
    @inject
    def __init__(self, window_manager: guiinjectorkeys.WINDOW_MANAGER_KEY,
                 presenter: CHRONO_DIALOG_PRESENTER_KEY):
        self.quarters = ("%s 1" % _('Quarter'), "%s 2" % _('Quarter'),
                         "%s 3" % _('Quarter'), "%s 4" % _('Quarter'))
        self.current_quarter = 1
        self.quarter_select = None
        self.year_entry = None

        super().__init__(window_manager, presenter)

    def create_dialog(self):
        super().create_dialog()

        AlexButton(self.buttons_frame,
                   text=_("Create chronology"),
                   command=self.presenter.ok_action).pack(side=LEFT)
        AlexButton(self.buttons_frame,
                   text=_("Cancel"),
                   command=self.presenter.cancel_action).pack(side=LEFT)

        self.quarter_select = AlexRadioGroup(self.interior,
                                             title=_('Quarter'),
                                             choices=self.quarters)
        self.quarter_select.pack()

        AlexLabel(self.interior, text=_(_("Year"))).pack(side=LEFT,
                                                         padx=10,
                                                         pady=10)
        self.year_entry = AlexEntry(self.interior)
        self.year_entry.pack(side=LEFT, padx=10, pady=10)

    def _get_quarter(self):
        return self.quarter_select.get() + 1

    def _get_year(self):
        try:
            year = int(self.year_entry.get())
        except ValueError:
            year = 0
        return year

    quarter = property(_get_quarter)
    year = property(_get_year)
    def create_dialog(self):

        super().create_dialog()

        self.label = AlexLabel(self.interior)
        self.label.pack(side=TOP, padx=5, pady=5)

        filter_frame = Frame(self.interior)
        AlexLabel(filter_frame, text=_('Search tree:')).pack(side=LEFT, pady=5)
        self.filter_entry = AlexEntry(filter_frame)
        self.filter_entry.bind("<KeyRelease>",
                               lambda event: self._apply_filter(event))
        self.filter_entry.pack(side=LEFT, fill=X, expand=YES)
        filter_frame.pack(side=TOP, expand=YES, fill=X)

        self.set_default_buttons()
class GenericInputEditDialog(AbstractInputDialog):
    def __init__(self, window_manager, presenter):
        super().__init__(window_manager, presenter)

    def create_dialog(self):
        super().create_dialog()
        self.set_default_buttons()

        self.label = AlexLabel(self.interior)
        self.label.pack()

        self.entry = AlexEntry(self.interior)
        self.entry.pack()

    def config_dialog(self, label=_('Please edit string:'), initvalue=''):

        self.label.set(label)
        self.entry.set(initvalue)

    def _get_entry(self):
        return self.entry.get()

    def _set_entry(self, value):
        self.entry.set(value)

    input = property(_get_entry, _set_entry)
    def test_component(self, master, message_label):

        self.message_label = message_label
        self.master = master

        self.label1 = AlexLabel(master)
        self.label1.set('Label text:')
        self.label1.grid(row=0, column=0)

        self.entry1 = AlexEntry(master)
        self.entry1.set("Enter label text")
        self.entry1.grid(row=0, column=1)

        AlexButton(master, text='Set label text',
                   command=self._set_label_text).grid(row=1, column=0)
        AlexButton(master,
                   text='Set entry from label',
                   command=self._set_entry_from_label).grid(row=1, column=1)
Example #11
0
    def create_dialog(self):
        super().create_dialog()

        AlexButton(self.buttons_frame,
                   text=_("Create chronology"),
                   command=self.presenter.ok_action).pack(side=LEFT)
        AlexButton(self.buttons_frame,
                   text=_("Cancel"),
                   command=self.presenter.cancel_action).pack(side=LEFT)

        self.quarter_select = AlexRadioGroup(self.interior,
                                             title=_('Quarter'),
                                             choices=self.quarters)
        self.quarter_select.pack()

        AlexLabel(self.interior, text=_(_("Year"))).pack(side=LEFT,
                                                         padx=10,
                                                         pady=10)
        self.year_entry = AlexEntry(self.interior)
        self.year_entry.pack(side=LEFT, padx=10, pady=10)
class BasicDocumentFilterDialog(GenericFilterDialog):  # @UndefinedVariable
    def create_dialog(self):
        super().create_dialog()

        self.create_signature_entry()

        AlexLabel(self.interior, text=_("No event link:")).grid(row=4,
                                                                column=0,
                                                                sticky=W)
        self.missing_event_checkbox = AlexCheckBox(self.interior)
        self.missing_event_checkbox.grid(row=4, column=1, sticky=W, pady=5)

    def create_signature_entry(self):

        AlexLabel(self.interior, text=_("Signature:")).grid(row=3,
                                                            column=0,
                                                            sticky=W)
        self.signature_widget = AlexEntry(self.interior)
        self.signature_widget.grid(row=3, column=1, sticky=W, pady=5)

    def _clear_filter_form(self):
        super()._clear_filter_form()
        self._set_signature(None)
        self.missing_event_checkbox.set(False)

    def _get_signature(self):

        if self.signature_widget.get() == '':
            return None
        else:
            return self.signature_widget.get()

    def _set_signature(self, value):

        if value == None:
            self.signature_widget.set('')
        else:
            self.signature_widget.set(value)

    def _get_missing_event_link(self):

        return self.missing_event_checkbox.get()

    def _set_missing_event_link(self, value):

        return self.missing_event_checkbox.set(value)

    signature = property(lambda self: self._get_signature(),
                         lambda self, value: self._set_signature())
    missing_event_link = property(_get_missing_event_link,
                                  _set_missing_event_link)
    def test_component(self, master, message_label):
        self.message_label = message_label
        self.master = master

        label1 = AlexLabel(master)
        label1.set('Entry 1:')
        label1.grid(row=0, column=0)

        self.entry1 = AlexEntry(master)
        self.entry1.set("Entry 1 text")
        self.entry1.grid(row=0, column=1)

        label2 = AlexLabel(master)
        label2.set('Entry 2:')
        label2.grid(row=1, column=0)

        self.entry2 = AlexEntry(master)
        self.entry2.set("Entry 2 text")
        self.entry2.grid(row=1, column=1)

        AlexButton(master, text='Switch input',
                   command=self._switch_input).grid(row=2, column=1)
class AlexEntryTest(AbstractComponentTest):
    def __init__(self):
        super().__init__()
        self.name = "Alex entry test"

    def test_component(self, master, message_label):
        self.message_label = message_label
        self.master = master

        label1 = AlexLabel(master)
        label1.set('Entry 1:')
        label1.grid(row=0, column=0)

        self.entry1 = AlexEntry(master)
        self.entry1.set("Entry 1 text")
        self.entry1.grid(row=0, column=1)

        label2 = AlexLabel(master)
        label2.set('Entry 2:')
        label2.grid(row=1, column=0)

        self.entry2 = AlexEntry(master)
        self.entry2.set("Entry 2 text")
        self.entry2.grid(row=1, column=1)

        AlexButton(master, text='Switch input',
                   command=self._switch_input).grid(row=2, column=1)

    def _switch_input(self):

        tmp = self.entry1.get()
        self.entry1.set(self.entry2.get())
        self.entry2.set(tmp)
Example #15
0
class ExportInfoWizard(Wizard):

    NO_SIGNATURE_SELECTED = _('No signature selected')
    NO_IMAGE_SELECTED = _('No title image selected')

    @inject
    def __init__(self, window_manager: guiinjectorkeys.WINDOW_MANAGER_KEY,
                 presenter: EXPORT_INFO_WIZARD_PRESENTER,
                 signature_dialog: SYSTEMATIC_POINT_SELECTION_DIALOG_KEY):

        super().__init__(window_manager,
                         presenter,
                         number_of_pages=6,
                         geometry="500x200")

        self.signature_dialog = signature_dialog

    def create_dialog(self):

        super().create_dialog()

        # Wizard page 1
        Label(self.pages[0], text=_("Start creating a CD")).pack(padx=5,
                                                                 pady=5)

        Label(self.pages[0], text=_("Enter a name for the CD:")).pack()
        self.name_entry = AlexEntry(self.pages[0])
        self.name_entry.pack()

        # Wizard page 2
        Label(self.pages[1], text=_("Start page as markdown:")).pack(padx=5,
                                                                     pady=5)
        self.start_page_entry = AlexText(self.pages[1])
        self.start_page_entry.pack()

        # Wizard page 3
        Label(self.pages[2], text=_("Impressum as markdown:")).pack(padx=5,
                                                                    pady=5)
        self.imprint_entry = AlexText(self.pages[2])
        self.imprint_entry.pack()

        # Wizard page 4
        Label(self.pages[3], text=_("Please enter a data range:")).pack(padx=5,
                                                                        pady=5)

        self.start_date_entry = AlexDateEntry(self.pages[3])
        self.start_date_entry.label = _("Enter start date:")
        self.start_date_entry.pack()

        self.end_date_entry = AlexDateEntry(self.pages[3])
        self.end_date_entry.label = _("Enter end date:")
        self.end_date_entry.pack()

        # Wizard page 5
        Label(self.pages[4], text=_("Please select a signature")).pack(padx=5,
                                                                       pady=5)
        self.signature_button = AlexButton(
            self.pages[4],
            command=lambda: self.signature_dialog.activate(
                self._signature_callback, label=_("Select a signature")))
        self.signature_button.pack()

        # Wizard page 6
        Label(self.pages[5],
              text=_("Please select a title image")).pack(padx=5, pady=5)
        self.start_image_button = AlexButton(
            self.pages[5], command=self._get_start_image_file)
        self.start_image_button.pack()

    def config_dialog(self, export_info=None):

        self.export_info = export_info

    def _signature_callback(self, signature):

        if signature is not None:
            self.signature_button.set(signature)

    def _get_start_image_file(self):

        self.window.attributes('-topmost', False)
        new_start_image = askopenfilename(filetypes=[(_("Image file"),
                                                      ".jpg")])
        self.window.attributes('-topmost', True)

        if new_start_image:
            self.start_image = new_start_image

    def _select_signature(self):

        self.signature_dialog.activate(self, self._select_signature_callback)

    def _select_signature_callback(self, signature):

        if signature:
            self.signature = self.signature_service.object_to_id(signature)

    def _get_export_info(self):

        export_info = ExportInfo()
        export_info.cd_name = self.name_entry.get()
        export_info.start_date = self.start_date_entry.get()
        export_info.end_date = self.end_date_entry.get()
        export_info.signature = self.signature
        export_info.start_image = self.start_image
        export_info.pagecontent['startpage'] = self.start_page_entry.get()
        export_info.pagecontent['imprint'] = self.imprint_entry.get()
        return export_info

    def _set_export_info(self, export_info):

        self.name_entry.set(export_info.cd_name)
        self.start_date_entry.set(export_info.start_date)
        self.end_date_entry.set(export_info.end_date)
        self.signature = export_info.signature
        self.start_image = export_info.start_image
        self.start_page_entry.set(export_info.pagecontent['startpage'])
        self.imprint_entry.set(export_info.pagecontent['imprint'])

    def _get_signature(self):

        signature = self.signature_button.get()

        if "%s" % signature == self.NO_SIGNATURE_SELECTED:
            return None

        return signature

    def _set_signature(self, signature):

        if signature is None:
            self.signature_button.set(self.NO_SIGNATURE_SELECTED)
        else:
            self.signature_button.set(signature)

    def _get_start_image(self):

        start_image = self.start_image_button.get()

        if start_image == self.NO_IMAGE_SELECTED:
            return None

        return start_image

    def _set_start_image(self, start_image):

        if start_image is None:
            self.start_image_button.set(self.NO_IMAGE_SELECTED)
        else:
            self.start_image_button.set(start_image)

    signature = property(_get_signature, _set_signature)
    start_image = property(_get_start_image, _set_start_image)
    export_info = property(_get_export_info, _set_export_info)