Giter Site home page Giter Site logo

ivannazaruk / dearpygui-markdown Goto Github PK

View Code? Open in Web Editor NEW
19.0 1.0 1.0 677 KB

Almost all basic Markdown implementation for DearPyGui, as well as additional support in the form of text customization (color, size) as a custom HTML tag.

License: MIT License

Python 100.00%
dearpygui markdown python3 tools library

dearpygui-markdown's Introduction

DearPyGui-Markdown

Almost all basic Markdown implementation, as well as additional support in the form of text customization (color, size) as a custom HTML tag.

video.mp4

How to run example

  1. git clone https://github.com/IvanNazaruk/DearPyGui-Markdown
  2. cd DearPyGui-Markdown
  3. pip install -r requirements.txt
  4. python example/main.py

How to install

  1. git clone https://github.com/IvanNazaruk/DearPyGui-Markdown
  2. cd DearPyGui-Markdown
  3. pip install -r requirements.txt
  4. Move DearPyGui_Markdown folder to your project
  5. Import the library into a Python script: import DearPyGui_Markdown as dpg_markdown

How to use

import dearpygui.dearpygui as dpg

import DearPyGui_Markdown as dpg_markdown # Import the library

# For convenience, I will create variables in which I will 
# store the font size and the path to the different font types.
# You can use not all types, if a type not created will be used, 
# the default font will be applied.
# The default font should always be
font_size = 25
default_font_path = './fonts/InterTight-Regular.ttf'
bold_font_path = './fonts/InterTight-Bold.ttf'
italic_font_path = './fonts/InterTight-Italic.ttf'
italic_bold_font_path = './fonts/InterTight-BoldItalic.ttf'

dpg.create_context()

# Set the DPG font registry so that the library can create 
# and load different font variations (different sizes)
# This item is mandatory!
dpg_markdown.set_font_registry(dpg.add_font_registry())

# You can also put your own fonts load function, this is needed 
# to add specific characters from the font file (e.g. Cyrillic)
# An example of the use can be found in the example folder (example/font.py)
# dpg_markdown.set_add_font_function({CUSTOM_ADD_FONT_FUNCTION})


# Function to set fonts, the first time you call it, 
# you must specify the default font (default argument)
# Return the default DPG font
dpg_font = dpg_markdown.set_font(
    font_size=font_size,
    default=default_font_path,
    bold=bold_font_path,
    italic=italic_font_path,
    italic_bold=italic_bold_font_path
)

# Apply the created DPG font
dpg.bind_font(dpg_font)

# Create DPG viewport, could have done this after dpg.create_context()
dpg.create_viewport(title='Markdown example', width=300, height=300)

# Minimal example of working with the library
with dpg.window(label="Example", width=240, height=210):
    dpg_markdown.add_text("This is text\n"
                          "*This is italic text*\n"
                          "__This is bold text__\n"
                          "***This is bold italic text***\n"
                          "<u>This is underline text</u>")

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

What supports?

  • Headings
  • Horizontal Rules
  • Styling text
    • Bold
    • Italic
    • Strikethrough
    • Links
    • Subscript
    • Superscript
  • Blockquotes
  • Lists:
    • Ordered
    • Unordered
    • Task
    • Nested
  • Code:
    • Line `
    • Blocks ```
    • Syntax highlight ```python (need installed Pygments: pip install pygments)
  • Images:
    • Link
    • Path
    • Emoji
  • Table

Custom HTML tag

<font>

  1. RGB color:
    • <font color="(255, 50, 255)">Test</font>
    • <font color="255, 50, 255, 50">Test</font>
    • <font color="[50, 50, 255, 100]">Test</font>
  2. HEX color:
    • <font color="#9628d1">Test</font>
    • <font color="#9628d1ba">Test</font>
  3. Size:
    • <font size=50>Test</font>
    • <font size="25">Test</font>
  4. Color + Size:
    • <font size=50 color="(255, 50, 255)">Test</font>
    • <font size="20" color="#9628d1ba">Test</font>

dearpygui-markdown's People

Contributors

ivannazaruk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

spectereye

dearpygui-markdown's Issues

Lib work properly in window item, but not with other containers

Hello, i've been experimenting with using this library to load documentation for my app directly from .md files in a help tab on my app.

I've noticed that the lib only work partially in that case, but work properly with window containers:
with tree_node containers (same effect with child_window):
image

with window containers:
image

I don't exclude the possibility that something affect the elements in a container above, but as far as i know i use the lib fonts everywhere, i have a global theme that don't change the behavior when i comment it out, so i'm a bit at my wits end.

if that helps, the hierarchy of containers toward the text is as follow : window -> group -> tab_bar -> tab -> text

very nice

keep improving it.congratulations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.