Skip to content

Commit

Permalink
Update docstrings to reflect recent changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
hreikin committed Apr 16, 2022
1 parent 2ca2a7f commit 0c0e113
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
11 changes: 11 additions & 0 deletions tkintermd/constants.py
Expand Up @@ -20,6 +20,17 @@
strikethrough_md_ignore (tuple): Markdown syntax to ignore for strikethrough
highlighting.
default_md_string (str): Default string to show in the editor when it loads.
default_template_top (str): Default template, top portion.
default_template_middle (str): Default template, middle portion.
default_template_bottom (str): Default template, bottom portion.
centered_template_top (str): Centered template, top portion.
centered_template_middle (str): Centered template, middle portion.
centered_template_bottom (str): Centered template, bottom portion.
template_list (list(str)): List of available template names.
template_dict (dict(list)): Lists of template values linked with the
appropriate name.
edit_warning (str): Warning message displayed to user when enabling edit
before export functionality.
"""
from pathlib import Path
from pymdownx import emoji
Expand Down
42 changes: 27 additions & 15 deletions tkintermd/frame.py
Expand Up @@ -206,13 +206,13 @@ def popup(self, event):
Provides the following options:
- Cut
- Copy
- Paste
- Undo
- Redo
- Find
- Select All
- Cut.
- Copy.
- Paste.
- Undo.
- Redo.
- Find.
- Select All.
"""
self.right_click.tk_popup(event.x_root, event.y_root)

Expand Down Expand Up @@ -356,11 +356,13 @@ def on_input_change(self, event):
When the user types:
- Get the current text area contents
- Convert the markdown formatted string to HTML
- Load the HTML string and apply CSS styling to the HTML frame.
- Check the markdown and apply formatting to the text area
- Reset the modified flag
- Get the current text area contents.
- Convert the markdown formatted string to HTML.
- Merge the converted markdown with the currently selected template.
- Load the merged HTML into the document preview.
- Update the HTML content/states within the export options edit area.
- Check the markdown and apply formatting to the text area.
- Reset the modified flag.
"""
md2html = Markdown(extensions=constants.extensions, extension_configs=constants.extension_configs)
markdownText = self.text_area.get("1.0", END)
Expand All @@ -381,9 +383,9 @@ def load_style(self, stylename):
- Load and configure the text area and `tags` with the Pygments styles
and custom `Lexer` tags.
- Set the background and text colour CSS values to match the values of
the currently selected style.
- Load the CSS into the HTML previeW area.
- Create the CSS styling to be merged with the HTML template
- Generate a `<<Modified>>` event to update the styles when a new style
is chosen.
"""
self.style = get_style_by_name(stylename)
self.syntax_highlighting_tags = []
Expand Down Expand Up @@ -518,6 +520,12 @@ def check_markdown_both_sides(self, md_syntax, md_ignore, md_special, strikethro
self.apply_markdown_both_sides(self.cur_selection, self.md_syntax)

def change_template(self, template_name):
"""Change the currently selected template.
Get the selected template name from the `StringVar` for the `Combobox`
and compare it with the templates dictionary. If the name matches the
key then set the relevant template values and update all the previews.
"""
template_name = self.template_combobox_value.get()
for key, val in constants.template_dict.items():
if template_name == key:
Expand All @@ -527,6 +535,10 @@ def change_template(self, template_name):
self.text_area.event_generate("<<Modified>>")

def enable_edit(self):
"""Enable editing of HTML before export.
Displays a warning to the user and enables HTML editing prior to export.
"""
mbox.showwarning(title="Warning", message=constants.edit_warning)
self.export_options_text_area.configure(state="normal")
self.export_options_edit_btn.configure(state="disabled")
Expand Down

0 comments on commit 0c0e113

Please sign in to comment.