[Workaround] Full_screen() is not working (py5 in VS Code on MacOs)

Hello! While size() is working fine, I can’t get full_screen() to work and get this error message below. The problem with size() is that I can’t click on the window’s green button that would allow me to be in a true full screen mode, even if I provide the pixel height and width that correspond to my Mac’s viewport dimensions.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'API misuse: modification of a menu's items on a non-main thread when the menu is part of the main menu. Main menu contents may only be modified from the main thread.'
*** First throw call stack:

[lots of lines here]

libc++abi: terminating due to uncaught exception of type NSException
zsh: abort 

What I tested

The different sketches examples on py5’s doc. I also tried to provide a screen number, put things in settings() instead of setup()… But maybe I missed something.

import py5

x = 0


def settings():
    py5.full_screen()
   # py5.size(400, 200) It works fine with size


def setup():
    py5.background(0)


def draw():
    py5.fill(100)
    py5.rect(100, 100, 20, 20)


py5.run_sketch()

Specs

  • Mac book pro M3 nov 2023, MacOs Sequoia 15.4.1
  • py5 0.10.4a2 Now 0.10.6a0
  • Python 3.13.3
  • Java JDK Temurin-21.0.7+6
  • Visual Studio Code 1.99.3 (Universal), with some extensions (Microsoft’s ones for Python, autopep8…). No Jupyter Notebook, files run in the integrated terminal (zsh) with a virtual environment (venv).

Resources I found

I could not find something strictly related to py5 or Processing but maybe this issue on GitHub can gives you a better understanding of what is happening behind https://github.com/fyne-io/fyne/issues/782.

Thanks for your help!

I can’t get your demo to run on my mac either (no VSCode):
Returns this error on my system:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread! '

As stated, size() works ok but green window button is not enabled at setup(). An alternate approach that you could use is set_resizable() to add this capability. The following works on my system using the Thonny editor:

# Uses Imported mode for py5

def setup():
    size(400, 200)
    get_surface().set_resizable(True)
    background(0)

def draw():
    fill(100)
    rect(100, 100, 20, 20)


Output: - notice green button is enabled and window will go fullScreen

1 Like
1 Like

Hi, @Bcome ! Thank you for reporting this.

First, I want to point out that I am currently recovering from surgery on my left arm. I can’t really type right now or do the kind of investigation that I want to do right now. However, I was able to test your example and full_screen() is working on my Mac computer.

Right now I am using Python 3.9. I did some preliminary testing with python 3.13 a week or two ago and I did find there were some issues with exceptions similar to yours that I have not yet gotten to the bottom of. I would suggest first trying a earlier version of Python. Not necessarily Python 3.9, but please try Python 3.10 or 3.11.

I am also using Java Temurin-17.0.13+11, but I doubt that is the problem here.

Also please upgrade to the latest version of py5. The latest version is 0.10.6a0, out two weeks ago. This version contains the latest processing jars.

3 Likes

Also, how are you running this? You mentioned VS code. Are you using VS code as an editor? Are you running the python code through the terminal? Or are you running it in a Jupyter notebook through VS code?

Just reporting full_screen() works in my PC on Garuda Linux (Arch-based distro).
Although more like a maximized window rather than an actual fullscreen.

Graphics card is an NVIDIA GeForce GTX 1660 SUPER on KDE Plasma 6.3.5 (Wayland) under Linux kernel 6.14.9-zen1-1-zen.

Other specs are:

  • (‘JAVA_HOME environment variable’, ‘/usr/lib/jvm/default’)
  • (‘jvm version’, (21, 0, 7))
  • (‘default jvm path’, ‘/usr/lib/jvm/java-21-openjdk/lib/server/libjvm.so’)

Here’s the code I use to inspect the Java/py5/Jpype environment:

#!/usr/bin/env python

import py5
import py5_tools

import sys
from os import environ as env

from java.lang.System import getenv, getProperty as prop

print(*py5_tools.get_jvm_debug_info().items(), sep="\n")

print("\nVendor:", prop("java.vendor"))
print("Version:", prop("java.version"))
print("OS:", prop("os.name"), prop("os.arch"), prop("os.version"))

print("\nUser:", prop("user.name"), prop("user.dir"))
print("Java:", prop("java.home"))

print("\nJAVA_HOME:", getenv("JAVA_HOME"), env.get("JAVA_HOME"))
# print("JDK_HOME:", getenv("JDK_HOME"), env.get("JDK_HOME"))
# print("GRAALVM_HOME:", getenv("GRAALVM_HOME"), env.get("GRAALVM_HOME"))

print("\nVenv:", sys.prefix)
print("\nInstance:", getattr(py5, "_instance"))

# print("\nJars:", prop("java.class.path"))

Hello, I tried this alternate approach and it works, thanks a lot!

Hello, first of all, all the best with your recovery and thanks for testing my example code. Svan pointed an alternate approach that I’ll use for now, as I have a project to finish and present next week. Since I’m using other libraries and I’m not very familiar with working with Python, venv and so on, I’m afraid of breaking something if I try to downgrade my python version. Or to spend to much time on that.

But when my project will be over, I’ll be happy to test that. I also upgraded py5 as you suggested. Regarding VS Code, I’m using it as an editor (no Jupyter notebook). I run python files in the integrated terminal (zsh apparently) and since VS Code proposed me to do that, I’m using a virtual environment. Hope that helps.

Another workaround is calling size() passing display_width & display_height as its arguments:
py5.size(py5.display_width, py5.display_height)

It should behave similarly to py5.full_screen()

py5.size(py5.display_width, py5.display_height)
Could you toggle fullScreen back to regular like the green button on macos window?

I don’t own a Mac, sorry. :red_apple:

Then try out it out with whatever you have. How do you re-size a window that you have set to display width/height?

By default, no canvas is resizable, unless we configure it so:

#!/usr/bin/env python

import py5

def setup():
    # py5.full_screen()
    py5.size(py5.display_width, py5.display_height)
    py5.get_surface().set_resizable(True)


py5.run_sketch()

On a mac that’s not really full screen; you can see the title bar at the top. With true full screen all you see is the canvas; depends on what interface the user wants.

Perhaps you meant ‘window’ and not ‘canvas’? The canvas is part of a window. It’s true that the Processing runtime creates windows without the resizable mask baked in; it has to be added later if the user wants it (in the objc world the user controls the mac window buttons enabled at startup). The exception in our sphere is the window created by the FX2D renderer; it comes pre-packaged with the resizable attribute and doesn’t have to be added later.

#  Uses Imported mode for py5

import javafx

def settings():
    size(400, 200, FX2D)

def setup():
    background(0)
    
def draw():
    fill(100)
    rect(100, 100, 20, 20)

That’s why I said using size() + display_width + display_height was another “workaround”!

Only full_screen(), which works for me on Linux btW, is supposed to provide an actual non-“menubar” window.

It’s not worth debating, but if the user uses set_resizable() they get the real deal on a mac, and not a ‘workaround’ (initial post indicates macos). What we should be trying to figure out is why full_screen works in Linux and not on a mac using a later python version. I’m editing my answer to call it an ‘alternate approach’ instead of a ‘workaround’.