Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ec8eb1e

Browse files
python code file for markdown viewer added
1 parent bd9f3c2 commit ec8eb1e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎Markdown-viewer/viewer.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# import tkinter as tk
2+
from tkinter import *
3+
from tkinter import font
4+
from tkinter.ttk import *
5+
from markdown2 import Markdown
6+
from tkhtmlview import HTMLLabel
7+
8+
# Function to display markdown on button click
9+
def onKeyUp():
10+
markdown = Markdown()
11+
markdownText = markdown_editor.get("1.0", END)
12+
html = markdown.convert(markdownText)
13+
result.set_html(html)
14+
15+
16+
# Creating tkinter window
17+
window = Tk()
18+
window.title('Markdown viewer')
19+
window.geometry('1200x1000')
20+
window.configure(bg='white')
21+
22+
# Styling font and button
23+
myfont = font.Font(family="Helvetica", size=14)
24+
style = Style()
25+
style.configure('TButton', font=('calibri', 20, 'bold'),
26+
foreground='Blue')
27+
28+
# Placing widgets into Tkinter window
29+
submit_btn = Button(text="View Markdown", command=onKeyUp, style='TButton')
30+
submit_btn.pack(ipadx=30, ipady=6)
31+
32+
markdown_editor = Text(width="1", insertborderwidth=2,
33+
selectborderwidth=2)
34+
markdown_editor.insert(END, '# Add Markdown here')
35+
markdown_editor.pack(fill=BOTH, expand=1, side=LEFT, padx=10, pady=10)
36+
markdown_editor.configure(font=myfont)
37+
38+
result = HTMLLabel(width="1", html="<h1>Markdown Viewer</h1>")
39+
result.pack(fill=BOTH, expand=1, side=RIGHT, padx=10, pady=10)
40+
41+
42+
window.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /