'React NW.js menubar setup crash

I created a React NW.js application using the npx create-nw-react-app ... command line. I'm working in a Linux environment. So far, so good. I managed to make it work with some custom configuration like window size or title. But when I tried to setup a menu, the application just crashed to desktop. As the documentation said, I wrote in the index.tsx file:

    var menu = new nw.Menu({ type: 'menubar' });

    var submenu = new nw.Menu();
    submenu.append(new nw.MenuItem({ label: 'Item A' }));
    submenu.append(new nw.MenuItem({ label: 'Item B' }));

    menu.append(new nw.MenuItem({
      label: 'First Menu',
      submenu: submenu
    }));

    nw.Window.get().menu = menu;

No variables are null, but this is not working. Any idea?

Thanks for your help!



Solution 1:[1]

Assuming your input file has one word per line, you can read each line, check the length of the word and if it is 7, write to the output file:

with open('input.txt', 'r') as f_in, open('output.txt', 'w') as f_out:
    for line in f_in:
        if len(line.strip()) == 7: # we strip the newline and possible spaces
            f_out.write(line)

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 mozway