Package: pysentation
Table of Contents:IntroductionInstallationHow to use pysentation?pysentation filepysentation scopeSlidesPropertiesTitleTitle alignColorThemeExpandInterpretableCommentsCodesLinesSlideshow screenHot keysOptionsColors and themesColorsThemesBugs/RequestsLicenseIntroductionpysentationis aCLIfor displaying Pythonpresentations.pysentation, by taking aPython filewritten with simple but specificrules, canconvertthe contents of the Python file into aslide showand display it.Follow the documentation or readthissection for more information.↑ Table of contentsInstallationYou can usepipto install:python3 -m pip install pysentationAnd also toupgrade:python3 -m pip install --upgrade pysentationIf there is aproblem, install therequirement packagesseparately as below and then try again.First, download therequirements.txtfile withcurl:curl -o requirements.txt https://raw.githubusercontent.com/mimseyedi/pysentation/master/requirements.txtThen install thepackagesin therequirements.txtusingpip:python3 -m pip install -r requirements.txtYou can still do ityourselfwithout needing therequirements.txtfile:python3 -m pip install rich==13.4.1 getkey==0.6.5 click==8.1.3↑ Table of contentsHow to use pysentation?There are two ways to use pysentation!The first way is theclassicway of reading thedocument. You may be surprised, but many people live with documents and love to read them. That's why this possibility is completely available for people who belong to this category, and if you like documents, it's better to continue right now.But there is asecond way! What could be better thanunderstandinghow to work with a programwhileyou areinsideit andusingit? I like documents, butbelieveme, this method is much moreinteresting! Letpysentationintroduceitselfto you.There are two verysimplesteps for this.First of all,downloadthis pysentation file with the help ofcurl:curl -o train_journey.py https://raw.githubusercontent.com/mimseyedi/pysentation/master/docs/guide/train_journey.pyThen after you installpysentation, run the file you downloaded with thepysentationcommand:pysentation train_journey.py↑ Table of contentspysentation fileTo usepysentation, you first need apysentation file. The pysentation file is actually aPython fileor a converted file with (.pysent) suffix. But it followsrulesthat can be converted into aslideshowand interpreted bypysentation CLI.↑ Table of contentspysentation scopeApysentationfile consists of apysentationscope. Specifying the scope of the pysentation is mandatory so that theinterpretationcan be done correctly:#pysentation{......#pysentation}Thisrangespecifies thepresentation environment. All pysentationcommandsand attributes in apython fileare a pythoncomment, but they havespecial namesso that they can beinterpretedcorrectly.↑ Table of contentsSlidesEachpysentationconsists of one or moreslides. To make aslide, just do the following:#pysentation{#>slide...#pysentation}Now, after#>slide, you candefineslidepropertiesand slideelements, which we will explain below.You can also defineseveralslides inone scope:#pysentation{#>slide...#>slide...#>slide...#pysentation}↑ Table of contentsPropertiesEachslidehaspropertiesthat canchangethe presentation of the slide. These properties arelistedin the table below, which I will examine one by one in the following:PropertyActionDefinition formDefault valueTitleYou can change the title of the slide with this property.#-title: Slide's TitlenoneTitle alignYou can change the slide title align with this property.#-title_align: leftcenterColorYou can change the color of the slide with this property.#-color: greendefaultThemeYou can change the theme of syntax highlighters of the slide with this property.#-theme: github-darkgruvbox-darkExpandWith this property, it can be specified that the slide box is the same width as the screen or stretched to the size of the slide elements.#-expand: TrueTrueInterpretableWith this property, it is possible to determine whether the codes inside the slide are interpreted and their output is displayed or not.#-interpretable: FalseTrueNote: Properties are case sensitive and must be written as defined.↑ Table of contentsTitleThis feature refers to the slide:#pysentation{#>slide#-title: First slide#pysentation}Output:┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ First slide ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                             ┃
┃                                                                                             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛↑ Table of contentsTitle alignThis property specifies thelocationof the slidetitleand it can be defined inthreemodes:right,centerandleft(The default value iscenter):#pysentation{#>slide#-title: First slide#-title_align: left#pysentation}Output:┏━ First slide ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                             ┃
┃                                                                                             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛↑ Table of contentsColorThis property refers to thecolorof the slide and itscomponents(The default value is equal todefaultor color of the terminal font):Clickhereto view the available colors.↑ Table of contentsThemeThis property refers to thethemeof thesyntax highlightersin the slide(The default value isgruvbox-dark):Clickhereto view the available themes.↑ Table of contentsExpandBy setting this property toTrueorFalse, you can specify whether thesizeof the slide is the same as the size of thescreenor the size of theelementsinside it(The default value isTrue):#pysentation{#>slide#-expand: False#pysentation}↑ Table of contentsInterpretableIf this property isTrue, all thecodesinside a slide will beinterpreted separatelywith the help ofPython interpreterand theoutputwill bedisplayedunder them in aseparate box. But if its value isFalse, it will not do this(The default value isTrue):#pysentation{#>slide#-interpretable: False#pysentation}↑ Table of contentsCommentsThecommentsare actually the explanations that we can see in theslides. The content of the comments can beanythingand can be given different modes according to thestylesof therichmodule.Comments start with#::#pysentation{#>slide#-title: Wonderful slide#: Hello!, this is my wonderfull slide.#: Yes, you see right! I am a comment that can be displayed!#: Also, I can make the word [yellow]"can"[/yellow] yellow like this.#pysentation}Output:↑ Table of contentsCodesThe codes have nospecial characteristicsand can be easily written andinterpretedif needed:#pysentation{#>slide#-title: Legal age#: Here is a simple example of if and else statements:age=19ifage>=18:print("Access Granted!")else:print("Access Denied! Underage")#pysentation}Output:┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Legal age ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                             ┃
┃  Here is a simple example of if and else statements:                                        ┃
┃                                                                                             ┃
┃ ❱ 1 age = 19                                                                                ┃
┃   2 if age >= 18:                                                                           ┃
┃   3 │   print("Access Granted!")                                                            ┃
┃   4 else:                                                                                   ┃
┃   5 │   print("Access Denied! Underage")                                                    ┃
┃   6                                                                                         ┃
┃                                                                                             ┃
┃ ╭─ Output ────────────────────────────────────────────────────────────────────────────────╮ ┃
┃ │ Access Granted!                                                                         │ ┃
┃ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ┃
┃                                                                                             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛Even if the coderaisesanexception, theerror messagewill be displayed:#pysentation{#>slide#-title: About [italic]ERRORS[/italic] and how to display them#: Pay attention to the following example of how errors are displayed:defdiv(a,b):returna/bprint(div(4,0))#pysentation}Output:┏━━━━━━━━━━━━━━━━━━━━━━━━━━━ About ERRORS and how to display them ━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                             ┃
┃  Pay attention to the following example of how errors are displayed:                        ┃
┃                                                                                             ┃
┃ ❱ 1 def div(a, b):                                                                          ┃
┃   2 │   return a / b                                                                        ┃
┃   3                                                                                         ┃
┃   4 print(div(4, 0))                                                                        ┃
┃                                                                                             ┃
┃ ╭─ <Error> ───────────────────────────────────────────────────────────────────────────────╮ ┃
┃ │ Exception Type: ZeroDivisionError                                                       │ ┃
┃ │ Exception Message: division by zero                                                     │ ┃
┃ │ Scope <module>, Line 4                                                                  │ ┃
┃ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ┃
┃                                                                                             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛↑ Table of contentsLinesLinesare the simplestelementsof slides. The task of these line elements is todrawahorizontalline toseparatethe screen, and its sign is#_line.#pysentation{#>slide#-title: About lines with merge sort#-interpretable: False#:Create sub_array2 ← A[start..mid] and sub_array2 ← A[mid+1..end]defmergeSort(arr):mid=len(arr)//2sub_array1=arr[:mid]sub_array2=arr[mid:]#_line#:Sort the two halves:mergeSort(sub_array1)mergeSort(sub_array2)# Initial values for pointers that we use to keep track of where we are in each arrayi=j=k=0#_line#:Until we reach the end of either start or end, pick larger among elements start and end and place them in the correct position in the sorted array:whilei<len(sub_array1)andj<len(sub_array2):ifsub_array1[i]<sub_array2[j]:arr[k]=sub_array1[i]i+=1else:arr[k]=sub_array2[j]j+=1k+=1#_line#:When all elements are traversed in either arr1 or arr2, pick up the remaining elements and put in sorted array:whilei<len(sub_array1):arr[k]=sub_array1[i]i+=1k+=1whilej<len(sub_array2):arr[k]=sub_array2[j]j+=1k+=1#pysentation}Output:┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ About lines with merge sort ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                             ┃
┃ Create sub_array2 ← A and sub_array2 ← A                                                    ┃
┃                                                                                             ┃
┃ ❱ 1 def mergeSort(arr):                                                                     ┃
┃   2 │   mid = len(arr)//2                                                                   ┃
┃   3 │   sub_array1 = arr[:mid]                                                              ┃
┃   4 │   sub_array2 = arr[mid:]                                                              ┃
┃                                                                                             ┃
┃ ─────────────────────────────────────────────────────────────────────────────────────────── ┃
┃                                                                                             ┃
┃ Sort the two halves:                                                                        ┃
┃                                                                                             ┃
┃   1 │   mergeSort(sub_array1)                                                               ┃
┃   2 │   mergeSort(sub_array2)                                                               ┃
┃   3 │   # Initial values for pointers that we use to keep track of where we are in each ... ┃
┃   4 │   i = j = k = 0                                                                       ┃
┃                                                                                             ┃
┃ ─────────────────────────────────────────────────────────────────────────────────────────── ┃
┃                                                                                             ┃
┃ Until we reach the end of either start or end, pick larger among elements start and end and ┃
┃ place them in the correct position in the sorted array:                                     ┃
┃                                                                                             ┃
┃   1 │   while i < len(sub_array1) and j < len(sub_array2):                                  ┃
┃   2 │   │   if sub_array1[i] < sub_array2[j]:                                               ┃
┃   3 │   │   │   arr[k] = sub_array1[i]                                                      ┃
┃   4 │   │   │   i += 1                                                                      ┃
┃   5 │   │   else:                                                                           ┃
┃   6 │   │   │   arr[k] = sub_array2[j]                                                      ┃
┃   7 │   │   │   j += 1                                                                      ┃
┃   8 │   │   k += 1                                                                          ┃
┃                                                                                             ┃
┃ ─────────────────────────────────────────────────────────────────────────────────────────── ┃
┃                                                                                             ┃
┃ When all elements are traversed in either arr1 or arr2, pick up the remaining elements and  ┃
┃ put in sorted array:                                                                        ┃
┃                                                                                             ┃
┃   1 │   while i < len(sub_array1):                                                          ┃
┃   2 │   │   arr[k] = sub_array1[i]                                                          ┃
┃   3 │   │   i += 1                                                                          ┃
┃   4 │   │   k += 1                                                                          ┃
┃   5 │                                                                                       ┃
┃   6 │   while j < len(sub_array2):                                                          ┃
┃   7 │   │   arr[k] = sub_array2[j]                                                          ┃
┃   8 │   │   j += 1                                                                          ┃
┃   9 │   │   k += 1                                                                          ┃
┃                                                                                             ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛↑ Table of contentsSlideshow screenTheslideshow screenis themainscreen for displaying slides. When we have prepared apysentation file, we canrunthe slides with the help of the followingcommandandmanageit with the help of specialkeys:pysentation my_file.py | my_file.pysent↑ Table of contentsHot keysThe following table introduces thehot keys:KeyActionRight→Next slide.Left←Previous slide.Up↑Highlight top line.Down↓Highlight bottom line.fGo to first slide.lGo to last slide.rReset the current slide.shift + rReset the screen.jjump to a slide by slide numbershift + sSearch by slide titleshift + kDisplay The hot-keys guide.qQuit.↑ Table of contentsOptionsOptionsaresettingsthat can besetbeforerunningthescreenandslides.You can use-hor--helpto see them:pysentation --helpOutput:Options:
  -f, --from INTEGER      Start showing the screen from the selected slide.
  -c, --color TEXT        Set color for all slides.
  -t, --theme TEXT        Set syntax highlighter theme for all slides.
  -d, --disable           Disable code interpretation for all slides.
  -p, --property INTEGER  Display the properties of the selected slide.
  -s, --slides            Display the slides on the screen with their
                          position.
  -e, --export PATH       Export a Python file to an encrypted file with a
                          .pysent suffix.
  -o, --output PATH       Writing all slides in order in a text file.
  -v, --version           Display the current version of pysentation installed
                          on the system.
  -h, --help              Show this message and exit.↑ Table of contentsColors and themesThere are manycolorsandthemesto use inpysentationthat all follow therichmodule. They are mentioned below.↑ Table of contentsColorsThis is a list of16main colors that you canusein pysentation. You can see the information of more diverse colors fromhere.Note: To use any color, you can mention its name, number, hex code and rgb number.ColorNameNumberHexRGB"black"0--"red"1--"green"2--"yellow"3--"blue"4--"magenta"5--"cyan"6--"white"7--"bright_black"8--"bright_red"9--"bright_green"10--"bright_yellow"11--"bright_blue"12--"bright_magenta"13--"bright_cyan"14--"bright_white"15--↑ Table of contentsThemesPopularandhigh-qualitythemes are listed so that you canusethem. Visitherefor more.Note: To use these themes, you must mention its full name, and in case of mistake, the default theme will be selected.NameLightDarkbw:heavy_check_mark:sas:heavy_check_mark:staroffice:heavy_check_mark:xcode:heavy_check_mark:default:heavy_check_mark:monokai:heavy_check_mark:lightbulb:heavy_check_mark:github-dark:heavy_check_mark:rrt:heavy_check_mark:gruvbox-dark:heavy_check_mark:gruvbox-light:heavy_check_mark:solarized-light:heavy_check_mark:solarized-dark:heavy_check_mark:nord:heavy_check_mark:paraiso-light:heavy_check_mark:paraiso-dark:heavy_check_mark:autumn:heavy_check_mark:vim:heavy_check_mark:vs:heavy_check_mark:one-dark:heavy_check_mark:dracula:heavy_check_mark:↑ Table of contentsBugs/RequestsPlease sendbug reportsandfeaturerequests throughgithub issue tracker.↑ Table of contentsLicensepysentationis afreeandopen sourceproject under theGPL-3LICENSE. Anycontributionis welcome. You can do this byregisteringapull request.↑ Table of contents