'Python: Curses on windows 10: Multiple windows flickering

I'm making a Curses music player UI with python and curses on windows 10. My program makes windows and renders them. This is the part of the code suspected to cause the flicker:

from ui_elements import *
from pynput.keyboard import Key, Listener
import curses
from curses import panel

def make_panel(x, y, width, height):
    _panel = curses.newwin(height, width, y, x)
    _panel = panel.new_panel(_panel)
    _panel.top()
    return _panel

class HomeScreen:
    def __init__(self, parent):
        self.parent = parent
        self.dimensions = self.parent.parent.stdscr.getmaxyx()

        # Make all the panels
        self.panels = {
            "side-navbar": make_panel(0, 0, 30, self.dimensions[0]),
            "main-content": make_panel(30, 0, self.dimensions[1] - 30, self.dimensions[0])
        }

        self.listener = Listener(on_press=self.on_key_press)
        self.listener.start()

        self.num = 0

    def on_key_press(self, key):
        pass

    def render(self):
        self.dimensions = self.parent.parent.stdscr.getmaxyx()

        win = self.panels["side-navbar"].window()
        win.border()
        win.addstr(1, 1, "Sidebar")
        win.refresh()

        win = self.panels["main-content"].window()
        win.border()
        win.addstr(1, 1, "Home")
        win.refresh()

        return ""

When I use STDSCR instead of creating a new screen, it works just fine. But when I use another screen, this happens:

flicker

Any help would be highly appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source