So I ran into an interesting error/bug, I don't know which yet, but when running my Python curses script using the box()
method I got the following result:
The desired and expected out put is to be a normal box... made of lines.
Here is the code for the script:
import curses
import init
import os
import time
MONSTER_LIST = init.init()
ENCOUNTER = []
def main(scr):
curses.curs_set(0)
scr.clear()
h, w = scr.getmaxyx()
get_number = "Number of players in party?"
center_y, center_x = h//2, w//2 - len(get_number)//2
scr.addstr(center_y, center_x, get_number)
scr.refresh()
NUMBER = int(scr.getstr())
scr.clear()
get_number = "Average rounded level of the Party"
center_y, center_x = h//2, w//2 - len(get_number)//2
scr.addstr(center_y, center_x, get_number)
scr.refresh()
LEVEL = int(scr.getstr())
y = h-1
bottom_text = "[S]earch [H]omebrew, S[A]ve, [Q]uit"
FLAG = True
scr.clear()
encounter_y, encounter_x = h-2, w-2
while FLAG:
scr.addstr(0,0, 'D&D Encounter Builder')
scr.addstr(y,0, bottom_text)
Encounter_window = curses.newwin(encounter_y, encounter_x,1,1)
encounter_box_y, encounter_box_x = Encounter_window.getmaxyx()
Encounter_window.box(encounter_box_y, encounter_box_x)
Encounter_window.addstr(1,2, 'Encounter list')
Encounter_window.addstr(encounter_box_y-3, 2, f"Difficulty = {init.cr_calculation(NUMBER, LEVEL, ENCOUNTER)}")
scr.refresh()
Encounter_window.refresh()
CHOICE = scr.getch()
FLAG = False
curses.wrapper(main)
If this helps, I am using Arch 5.9.8-arch1-1 and I am using st-256 for my terminal emulator.
Thanks for the help in advance
This is a documented feature of curses which the Python binding uses:
window.box([vertch, horch])
Similar to border(), but both ls and rs are vertch and both ts and bs are horch. The default corner characters are always used by this function.
Your example isn't setting the box size, but instead the characters used to draw it.
The character "0" has the value 48. Actually your horizontal characters aren't 0's, but probably
216 Ø
If you're seeing 6's for the vertical character, that is because the character for "6" happens to be 48 (0) + 6 = 54.