How to Auto-Scroll to Top

Hi!

Hope doing well, would like some help!

I was able to convert this to a exe file, but I can’t seem to figure out how to make it auto scroll to top after doe printing.

Here is code:
import os
import ctypes
import colorama
from colorama import Style, Fore, Back
from colorama import init
from rich.console import Console
import shutil
import curses
import sys
import shutil

Title page

columns = shutil.get_terminal_size().columns

print(“Authorized King James Bible”.center(columns))
print(“Thy word is a lamp unto my feet, and a light unto my path.”.center(columns))
print(“- Psalms 119:105”.center(columns))

Genesis title and chapter 1

print(“\n” + Fore.CYAN + “THE FIRST BOOK OF MOSES CALLED GENESIS” + Fore.RESET + “\n”)
print(Fore.GREEN + “Chapter 1” + Fore.RESET + “\n”)

Genesis chapter 1 verses

print(“1:1 ¶ IN the beginning God created the heaven and the earth.”)
print(“1:2 And the earth was without form, and void; and darkness was upon the face of the waters.”)
print(“1:3 And God said, Let there be light: and there was light.”)
print(“1:4 And God saw the light, that it was good: and God divided the light from the darkness.”)
print(“1:5 And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.”)
print(“1:6 ¶ And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.”)
print(“1:7 And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.”)
print(“1:8 And God called the firmament Heaven. And the evening and the morning were the second day.”)
print(“1:9 ¶ And God said, Let the waters under the heaven be gathered toget”)

print(“1:10 And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.”)
print(“1:11 And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.”)
print(“1:12 And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.”)
print(“1:13 And the evening and the morning were the third day.”)
print(“1:14 ¶ And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:”)
print(“1:15 And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.”)
print(“1:16 And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.”)
print(“1:17 And God set them in the firmament of the heaven to give light upon the earth.”)
print(“1:18 And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.”)
print(“1:19 And the evening and the morning were the fourth day.”)
print(“1:20 And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.”)
print(“1:21 And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.”)
print(“1:22 And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.”)
print(“1:23 And the evening and the morning were the fifth day.”)

#Day 5
print(“1:24 ¶ And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.”)
print(“1:25 And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that \x1B[3mit was\x1B[0m good.”)
print(“1:26 ¶ And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth.”)
print(“1:27 So God created man in his own image, in the image of God created he him; male and female created he them.”)
print(“1:28 And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth.”)
print(“1:29 ¶ And God said, Behold, I have given thee every herb bearing seed, which \x1B[3mis\x1B[0m upon the face of all the earth, and every tree, in the which \x1B[3mis\x1B[0m the fruit of a tree yielding seed; to thee it shall be for meat.”)
print(“1:30 And to every beaset of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein \x1B[3mthere is\x1B[0m life, \x1B[3mI have given\x1B[0m every green herb for meat: and it was so.”)
print(“1:31 And God saw every thing that he had made, and, behold, \x1B[3mit was\x1B[0m very good. And the evening and the morning were the sixth day.” + “\n”)

#Genesis Title & Chapter 2
print(Fore.GREEN + “Chapter 2” + Fore.RESET + “\n”)

#Blessing and scantifing the seventh day.
print(“2:1 THUS the heavens and the earth were finished, and all the host of them.”)
print(“2:2 And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.”)
print(“2:3 And God blessed the seventh day, and scanctified it: because that in it he had rested from all his work which God created and made.\n”)

#Introduction and forming Man from the dust of the ground.
print(“2:4 ¶ These \x1B[3mare\x1B[0m the genertions of heavens and of the earth when they were created, in the day that the LORD God made the earth and the heavens.”)
print(“2:5 And every plant of the field before it was in the earth, and every herb of the field before it grew: for the LORD God had not caused it to rain upon the earth,and \x1B[3mthere was\x1B[0m not a man to till the ground.”)
print(“2:6 But there went up a mist from the earth, and watered the whole face of the ground.”)
print(“2:7 And the LORD God formed man \x1B[3mof\x1B[0m the dust of the ground, and breathed into his nostrils the breath of life; and man became a living so.”)

#God plants a garden and tells the man to not eat from the tree of knowledge of good/evil and there were four heads that came out of the river of Eden.
print(“2:9 ¶ And the LORD planted a garden eastward in Eden: and there he put the an whom he had formed.”)
print(“2:10 And a river went out of Eden to water the garden: and from thence it was parted, and became into four heads.”)
print(“2:11 The name of the first \x1B[3mis\x1B[0m Pison: that \x1B[3mis\x1B[0m it which compaseth the whole land of Havilah, where \x1B[3mthere is\x1B[0m gold;”)
print(“2:12 And the gold of that land \x1B[3mis\x1B[0m good; there \x1B[3mis\x1B[0m bdellium and the onyx stone.”)
print(“2:13 And the name of the second river \x1B[3mis\x1B[0m Gihon: the same \x1B[3mis\x1B[0m that compasseth the whole land of Ethiopia.”)
print(“2:14 And the name of the third river is Hiddekel: that \x1B[3mis\x1B[0m it which goeth toward the east of Assyria. And the fourth river \x1B[3mis\x1B[0m Euphrates.”)
print(“2:15 And the LORD God took the man, and put him into the garden of Eden to dress it and to keep it.”)
print(“2:16 And the LORD God commanded the man, saying, Of every tree of the garden thou mayest freely eat:”)
print(“2:17 But of the tree of the knowledge of good and evil, thou shalt not eat of it: for in the day that thou eatest thereof thou shalt surely die.”)

#God makes a help meet for the man which he made a woman.
print(“2:18 ¶ And the LORD God said, \x1B[3mit is\x1B[0m not good that the man should be alone; I will make him an help meet for him.”)
print(“2:19 And out of the ground the LORD God formed every beast of the field, and every fowl of the air; and brought \x1B[3mthem\x1B[0m unto Adam to see what he woudl call them: and whatsoever Adam called every living creature, that \x1B[3mwas\x1B[0m the name thereof.”)

Pause the script

input(“Press Enter to continue…”)

Thanks,

God bless,

Shawn

PS: Wish to make it work with terminal/cmd and other terminal apps.

First of all welcome @Godisgracious1031 .

And secondly, when you post code here, to make it read properly, follow this guidance: About the Python Help category. It would make a big difference if there were any loops in your code. I think you can go back and insert those markers in your original post (unless new members are restricted somehow).

Now, I see you are using ANSI escape sequences to control colour. So the obvious question is whether you could scroll the screen that way. I think you can’t.

It sounds like you make an .exe of this, and the idea is that someone should open it on their PC to display the passage. A Python program (like this) is a rather complicated and inflexible way to do that. Why not just send them a document, say HTML which they open in a browser?

If it has to be a program with a DOS window, I would take a slightly different approach, and write something that prints a certain number of lines, then pauses and waits for user input (space), before going on to the next screen-full. You could allow the user to go back a page too, or back to the top. Essentially it would behave like the command line utility more.

For that to work, you would want all the lines of the passage in a list, and a simple loop to read them out. But that is a better design anyway than all these print statements, because you could use the same program with a different passage just by changing what is in the list.

In a console application you could read that list from a file you name on the command line, but in an application canned as an .exe you’d have to find out how to bundle the text file.

1 Like