OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

The curses screen isnt looking as expected

  • Thread starter Thread starter CodeLazy
  • Start date Start date
C

CodeLazy

Guest
So I was working on my Ubuntu a week ago and made this simple Python curses window that shows all of the files. The end result is expected to be a console file manager. The problem began when I booted up and entered my arch, as the Ubuntu was temporary. Once I booted up my arch, I configured it, and I was ready to start with the coding. Once I started to code I first wanted to run the code to see if everything runs smoothly, but to my shock, it all was weird. The whole screen, aka terminal, was white, the curses window, the text, and everything else was super weird (all grey without any of the text or anything else), and I don't understand why.

I have tried to change the background

here is the code:

Code:
from curses import wrapper
import os

class func:
    def __init__(self):
        self.path = os.getcwd()
        
    def colors(self):
        curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) # folder color
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK) # basic file color
        curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK) # executable file color
        self.CYAN = curses.color_pair(1)
        self.WHITE = curses.color_pair(2)
        self.GREEN = curses.color_pair(3)


    def show(self, stdscr):
        # start functions
        stdscr.clear()
        files = os.listdir(self.path)

        # dimensions for the window
        height = len(files) + 2
        width = 40
        start_y = 1
        start_x = 1 
        
        # creating the window and border 
        show_win = curses.newwin(height, width, start_y, start_x)
        show_win.border(0)

        # showing process
        for idx, filename in enumerate(files):
            show_win.addstr(idx + 1, 2, filename)

        # end commands
        show_win.refresh()
        show_win.getkey()
        

    def refresh(self, stdscr):
        stdscr.clear()
        stdscr.refresh()

    def main(self, stdscr):
        self.colors()
        self.refresh(stdscr)
        stdscr.clear()
        self.show(stdscr)
        stdscr.refresh()

    def running(self):
        wrapper(self.main)

if __name__ == "__main__":
    system = func()
    system.running()

Also update I tried it in my i3 terminal, and it worked. It was an all white terminal, while the one I was using is custom color shemed, so maybe that can help you all answer this.
<p>So I was working on my Ubuntu a week ago and made this simple Python curses window that shows all of the files. The end result is expected to be a console file manager. The problem began when I booted up and entered my arch, as the Ubuntu was temporary. Once I booted up my arch, I configured it, and I was ready to start with the coding. Once I started to code I first wanted to run the code to see if everything runs smoothly, but to my shock, it all was weird. The whole screen, aka terminal, was white, the curses window, the text, and everything else was super weird (all grey without any of the text or anything else), and I don't understand why.</p>
<p>I have tried to change the background</p>
<p>here is the code:</p>
<pre><code>
from curses import wrapper
import os

class func:
def __init__(self):
self.path = os.getcwd()

def colors(self):
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) # folder color
curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK) # basic file color
curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK) # executable file color
self.CYAN = curses.color_pair(1)
self.WHITE = curses.color_pair(2)
self.GREEN = curses.color_pair(3)


def show(self, stdscr):
# start functions
stdscr.clear()
files = os.listdir(self.path)

# dimensions for the window
height = len(files) + 2
width = 40
start_y = 1
start_x = 1

# creating the window and border
show_win = curses.newwin(height, width, start_y, start_x)
show_win.border(0)

# showing process
for idx, filename in enumerate(files):
show_win.addstr(idx + 1, 2, filename)

# end commands
show_win.refresh()
show_win.getkey()


def refresh(self, stdscr):
stdscr.clear()
stdscr.refresh()

def main(self, stdscr):
self.colors()
self.refresh(stdscr)
stdscr.clear()
self.show(stdscr)
stdscr.refresh()

def running(self):
wrapper(self.main)

if __name__ == "__main__":
system = func()
system.running()

</code></pre>
<p>Also update I tried it in my i3 terminal, and it worked. It was an all white terminal, while the one I was using is custom color shemed, so maybe that can help you all answer this.</p>
 

Latest posts

Online statistics

Members online
0
Guests online
5
Total visitors
5
Top