Configuration file altering (fullscreen)

Sorry for lots of newbie questions, but i try couple hours before i post in here, just FYI.

I am trying to go fullscreen in code with the default configuration file.

I change the fullscreen variable in code, however it doesnt go fullscreen even the variable is changed, do i need to call another function to go fullscreen after changing the variable?

import direct.directbase.DirectStart
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import TextNode
from pandac.PandaModules import ConfigVariableBool
import sys

def genLabelText(text, i):
    return OnscreenText(text = text, 
                        pos = (-1.3, 0.95-0.05*i),
                        fg = (1,1,0,1),
                        align = TextNode.ALeft, 
                        scale = .05)

fs = ConfigVariableBool("fullscreen")
fsText = genLabelText(str(fs), 0)

fs.setValue(1)
fsText = genLabelText(str(fs), 4)

run()

It’s only possible to change fullscreen like that before opening the window.
See this thread for a script that toggles fullscreen at runtime:
discourse.panda3d.org/viewtopic.php?t=2848

Oh, i already found out the way myself :smiley:
Guess i should try 1 hour more before i ask a question.

Here is my solution, but im sure the other is more elegant way though. So ill check it out too.

import sys
#import os

from pandac.PandaModules import * 
from direct.gui.OnscreenText import OnscreenText
import direct.directbase.DirectStart 
from pandac.PandaModules import ConfigVariableBool

#TExt stuff
def genLabelText(text, i):
    return OnscreenText(text = text, 
                        pos = (-1.3, 0.95-0.05*i),
                        fg = (1,1,0,1),
                        align = TextNode.ALeft, 
                        scale = .05)

#full screen toggle function
#basically changing the config variable of "fullscreen"
def changeFullScreen():
    if (not fs):
        fs.setValue(1)
    else:
        fs.setValue(0)
    base.openMainWindow()

#make object
fs = ConfigVariableBool("fullscreen")

#texts on screen
aspText = genLabelText("Aspect Ratio: "+str(base.getAspectRatio(win=None)), 0)
aspText = genLabelText("Press 'f' to toggle fullscreen", 1)

#read config file
fsText = genLabelText(str(fs), 4)

#fs.setValue(1)
#fsText = genLabelText(str(fs), 8)
#base.openMainWindow()

#key input
base.accept('escape', sys.exit)
base.accept('f', changeFullScreen)

run()