@@ -43,83 +43,93 @@ def __init__(self, master, **kwargs):
43
43
self .logger = log .create_logger ()
44
44
45
45
# Toolbar.
46
- self .top_bar = tk .Frame (self .master )
47
- self .open_btn = tk .Button (self .top_bar , text = "Open" , command = self .open_md_file )
46
+ self .root_toolbar = tk .Frame (self .master )
47
+ self .open_btn = tk .Button (self .root_toolbar , text = "Open" , command = self .open_md_file )
48
48
self .open_btn .pack (side = "left" , padx = 0 , pady = 0 )
49
- self .save_as_btn = tk .Button (self .top_bar , text = "Save As" , command = self .save_as_md_file )
49
+ self .save_as_btn = tk .Button (self .root_toolbar , text = "Save As" , command = self .save_as_md_file )
50
50
self .save_as_btn .pack (side = "left" , padx = 0 , pady = 0 )
51
- self .save_btn = tk .Button (self .top_bar , text = "Save" , command = self .save_md_file )
51
+ self .save_btn = tk .Button (self .root_toolbar , text = "Save" , command = self .save_md_file )
52
52
self .save_btn .pack (side = "left" , padx = 0 , pady = 0 )
53
- self .export_as_btn = tk .Button (self .top_bar , text = "Export HTML" , command = self .save_as_html_file )
53
+ self .export_as_btn = tk .Button (self .root_toolbar , text = "Export HTML" , command = self .save_as_html_file )
54
54
self .export_as_btn .pack (side = "left" , padx = 0 , pady = 0 )
55
- self .undo_btn = tk .Button (self .top_bar , text = "Undo" , command = lambda : self .text_area .event_generate ("<<Undo>>" ))
55
+ # Button to choose pygments style for editor, preview and HTML.
56
+ self .style_opt_btn = tk .Menubutton (self .root_toolbar , text = "Editor Style" , relief = "raised" )
57
+ self .style_opt_btn .pack (side = "left" , padx = 0 , pady = 0 )
58
+ self .root_toolbar .pack (side = "top" , fill = "x" )
59
+
60
+ # Creating the widgets
61
+ self .editor_pw = tk .PanedWindow (self .master , orient = "horizontal" )
62
+ # Root editor frame
63
+ self .editor_root_frame = tk .Frame (self .editor_pw )
64
+ # Toolbar buttons
65
+ self .editor_toolbar = tk .Frame (self .editor_root_frame )
66
+ self .undo_btn = tk .Button (self .editor_toolbar , text = "Undo" , command = lambda : self .text_area .event_generate ("<<Undo>>" ))
56
67
self .undo_btn .pack (side = "left" , padx = 0 , pady = 0 )
57
- self .redo_btn = tk .Button (self .top_bar , text = "Redo" , command = lambda : self .text_area .event_generate ("<<Redo>>" ))
68
+ self .redo_btn = tk .Button (self .editor_toolbar , text = "Redo" , command = lambda : self .text_area .event_generate ("<<Redo>>" ))
58
69
self .redo_btn .pack (side = "left" , padx = 0 , pady = 0 )
59
- self .cut_btn = tk .Button (self .top_bar , text = "Cut" , command = lambda : self .text_area .event_generate ("<<Cut>>" ))
70
+ self .cut_btn = tk .Button (self .editor_toolbar , text = "Cut" , command = lambda : self .text_area .event_generate ("<<Cut>>" ))
60
71
self .cut_btn .pack (side = "left" , padx = 0 , pady = 0 )
61
- self .copy_btn = tk .Button (self .top_bar , text = "Copy" , command = lambda : self .text_area .event_generate ("<<Copy>>" ))
72
+ self .copy_btn = tk .Button (self .editor_toolbar , text = "Copy" , command = lambda : self .text_area .event_generate ("<<Copy>>" ))
62
73
self .copy_btn .pack (side = "left" , padx = 0 , pady = 0 )
63
- self .paste_btn = tk .Button (self .top_bar , text = "Paste" , command = lambda : self .text_area .event_generate ("<<Paste>>" ))
74
+ self .paste_btn = tk .Button (self .editor_toolbar , text = "Paste" , command = lambda : self .text_area .event_generate ("<<Paste>>" ))
64
75
self .paste_btn .pack (side = "left" , padx = 0 , pady = 0 )
65
- self .find_btn = tk .Button (self .top_bar , text = "Find" , command = self .find )
76
+ self .find_btn = tk .Button (self .editor_toolbar , text = "Find" , command = self .find )
66
77
self .find_btn .pack (side = "left" , padx = 0 , pady = 0 )
67
- self .bold_btn = tk .Button (self .top_bar , text = "Bold" , command = lambda : self .check_markdown_both_sides (constants .bold_md_syntax , constants .bold_md_ignore , constants .bold_md_special ))
78
+ self .bold_btn = tk .Button (self .editor_toolbar , text = "Bold" , command = lambda : self .check_markdown_both_sides (constants .bold_md_syntax , constants .bold_md_ignore , constants .bold_md_special ))
68
79
self .bold_btn .pack (side = "left" , padx = 0 , pady = 0 )
69
- self .italic_btn = tk .Button (self .top_bar , text = "Italic" , command = lambda : self .check_markdown_both_sides (constants .italic_md_syntax , constants .italic_md_ignore , constants .italic_md_special ))
80
+ self .italic_btn = tk .Button (self .editor_toolbar , text = "Italic" , command = lambda : self .check_markdown_both_sides (constants .italic_md_syntax , constants .italic_md_ignore , constants .italic_md_special ))
70
81
self .italic_btn .pack (side = "left" , padx = 0 , pady = 0 )
71
- self .bold_italic_btn = tk .Button (self .top_bar , text = "Bold Italic" , command = lambda : self .check_markdown_both_sides (constants .bold_italic_md_syntax , constants .bold_italic_md_ignore , constants .bold_italic_md_special ))
82
+ self .bold_italic_btn = tk .Button (self .editor_toolbar , text = "Bold Italic" , command = lambda : self .check_markdown_both_sides (constants .bold_italic_md_syntax , constants .bold_italic_md_ignore , constants .bold_italic_md_special ))
72
83
self .bold_italic_btn .pack (side = "left" , padx = 0 , pady = 0 )
73
- self .strikethrough_btn = tk .Button (self .top_bar , text = "Strikethrough" , command = lambda : self .check_markdown_both_sides (constants .strikethrough_md_syntax , constants .strikethrough_md_ignore , md_special = None , strikethrough = True ))
84
+ self .strikethrough_btn = tk .Button (self .editor_toolbar , text = "Strikethrough" , command = lambda : self .check_markdown_both_sides (constants .strikethrough_md_syntax , constants .strikethrough_md_ignore , md_special = None , strikethrough = True ))
74
85
self .strikethrough_btn .pack (side = "left" , padx = 0 , pady = 0 )
75
- # self.heading_btn = tk.Button(self.top_bar , text="Heading")
86
+ # self.heading_btn = tk.Button(self.editor_toolbar , text="Heading")
76
87
# self.heading_btn.pack(side="left", padx=0, pady=0)
77
- # self.unordered_list_btn = tk.Button(self.top_bar , text="Unordered List")
88
+ # self.unordered_list_btn = tk.Button(self.editor_toolbar , text="Unordered List")
78
89
# self.unordered_list_btn.pack(side="left", padx=0, pady=0)
79
- # self.ordered_list_btn = tk.Button(self.top_bar , text="Ordered List")
90
+ # self.ordered_list_btn = tk.Button(self.editor_toolbar , text="Ordered List")
80
91
# self.ordered_list_btn.pack(side="left", padx=0, pady=0)
81
- # self.checklist_btn = tk.Button(self.top_bar , text="Checklist")
92
+ # self.checklist_btn = tk.Button(self.editor_toolbar , text="Checklist")
82
93
# self.checklist_btn.pack(side="left", padx=0, pady=0)
83
- # self.blockquote_btn = tk.Button(self.top_bar , text="Blockquote")
94
+ # self.blockquote_btn = tk.Button(self.editor_toolbar , text="Blockquote")
84
95
# self.blockquote_btn.pack(side="left", padx=0, pady=0)
85
- # self.codeblock_btn = tk.Button(self.top_bar , text="Codeblock")
96
+ # self.codeblock_btn = tk.Button(self.editor_toolbar , text="Codeblock")
86
97
# self.codeblock_btn.pack(side="left", padx=0, pady=0)
87
- # self.table_btn = tk.Button(self.top_bar , text="Table")
98
+ # self.table_btn = tk.Button(self.editor_toolbar , text="Table")
88
99
# self.table_btn.pack(side="left", padx=0, pady=0)
89
- # self.link_btn = tk.Button(self.top_bar , text="Link")
100
+ # self.link_btn = tk.Button(self.editor_toolbar , text="Link")
90
101
# self.link_btn.pack(side="left", padx=0, pady=0)
91
- # self.image_btn = tk.Button(self.top_bar , text="Image")
102
+ # self.image_btn = tk.Button(self.editor_toolbar , text="Image")
92
103
# self.image_btn.pack(side="left", padx=0, pady=0)
93
-
94
- self .style_opt_btn = tk .Menubutton (self .top_bar , text = "Editor Style" , relief = "raised" )
95
- self .style_opt_btn .pack (side = "left" , padx = 0 , pady = 0 )
96
-
97
- self .top_bar .pack (side = "top" , fill = "x" )
98
-
99
- # Creating the widgets
100
- self .editor_pw = tk .PanedWindow (self .master , orient = "horizontal" )
101
- self .editor_frame = ScrolledTextBox (self .editor_pw )
104
+ self .editor_toolbar .pack (side = "top" , fill = "x" )
105
+ # Editor frame with scrollbar and text area.
106
+ self .editor_frame = ScrolledTextBox (self .editor_root_frame )
102
107
self .text_area = self .editor_frame .tbox
108
+ self .editor_frame .pack (fill = "both" , expand = 1 )
109
+ # Tabs for the preview and export options.
103
110
self .preview_tabs = Notebook (self .editor_pw )
104
- #make the previews
111
+ # HTML rendered preview.
105
112
self .preview_document = HtmlFrame (self .preview_tabs )
106
-
113
+ # Root frame for export options.
107
114
self .export_options_root_frame = tk .Frame (self .preview_tabs )
115
+ # Export options frame.
108
116
self .export_options_frame = tk .Frame (self .export_options_root_frame )
109
117
self .export_options_placeholder = tk .Label (self .export_options_frame , text = "Placeholder" , justify = "center" )
110
118
self .export_options_placeholder .pack (fill = "both" , expand = 1 )
111
119
self .export_options_frame .pack (fill = "both" , expand = 1 )
120
+ # HTML code preview/edit before export with scrollbar and text area.
112
121
self .export_options_text_area_frame = ScrolledTextBox (self .export_options_root_frame )
113
122
self .export_options_text_area = self .export_options_text_area_frame .tbox
114
123
self .export_options_text_area_frame .pack (fill = "both" , expand = 1 )
124
+ # Add the rendered preview and export options to the Notebook tabs.
115
125
self .preview_tabs .add (self .preview_document , text = "Preview Document" )
116
126
self .preview_tabs .add (self .export_options_root_frame , text = "Export Options" )
117
- #add the areas to the paned window
118
- self .editor_pw .add (self .editor_frame )
127
+ # Add the editor and preview/export areas to the paned window.
128
+ self .editor_pw .add (self .editor_root_frame )
119
129
self .editor_pw .add (self .preview_tabs )
120
130
self .editor_pw .pack (side = "left" , fill = "both" , expand = 1 )
121
131
122
- # load the self.style_opt_btn menu
132
+ # Load the self.style_opt_btn menu, this needs to be after the editor.
123
133
self .style_menu = tk .Menu (self .style_opt_btn , tearoff = False )
124
134
for style_name in get_all_styles ():
125
135
# dynamcially get names of styles exported by pygments
0 commit comments