Reputation: 917
Can someone tell me how to set a kivy window to full screen mode using the design language?
The result I'm looking for is either bordered full screen/border-less full screen. If you run the following example you'll see exactly what I'm trying to achieve.
from kivy.core.window import Window
from kivy.uix.widget import Widget
from kivy.config import Config
from kivy.app import App
class ExampleClass(Widget):
pass
class ExampleApp(App):
def build(self):
return ExampleClass()
Window.fullscreen = 'auto'
ExampleApp().run()
'''
If you've never run it with that setting before. Be ready for borderless
Full screen output.It can be scary the first time you see it lol :D
'''
An example of the code I'm working with is as follows.
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.graphics import Canvas
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.config import Config
class StartScreen(Screen):
def Mute_Audio(self):
pass
def new_g(self):
pass
def l_g(self):
pass
def Settings(self):
pass
class SelectionScreen(Screen):
pass
class MyScreenManager(ScreenManager):
pass
root_widget = Builder.load_string('''
#:import FadeTransition kivy.uix.screenmanager.FadeTransition
MyScreenManager:
transition: FadeTransition()
StartScreen:
SelectionScreen:
<StartScreen>:
name: 'start_screen'
canvas:
Rectangle:
pos: self.pos
size: self.size
Button:
id: b_1
pos: 330,350
size_hint: 0.2, 0.1
text: 'button 1'
font_size: 18
on_press: root.new_g()
on_release: app.root.current = 'selection_screen'
Button:
id: b_2
pos: 330, 280
size_hint: 0.2, 0.1
text: 'button_2'
font_size: 18
Button:
id: settings
pos: 330, 210
size_hint: 0.2, 0.1
text: 'Settings'
font_size: 18
Button:
id: mute_button
pos:658, 495
size_hint: 0.2, 0.2
<SelectionScreen>:
name: 'selection_screen'
canvas:
Rectangle:
pos: self.pos
''')
class ExampleApp(App):
def build(self):
self.title = 'Save me Stack Overflow'
return root_widget
ExampleApp().run()
to reiterate, I need help setting the window to full screen using the design language. I just have no idea how to set it to full screen with kv.
UPDATE:
To re-iterate. I don't care about the positioning of widgets or how the full screen looks. All I need to know is how to set a Window to full screen mode using the design language aka KV.
I showed two examples. The first example shows what I want to do. In that it shows a border-less full screen window. The second example illustrates an example of the design language. I need to achieve the same result produced in the first example in the second example but instead of doing it in straight python I need to do it in the design language.
Upvotes: 3
Views: 3434
Reputation: 8066
It seems it is possible to do it from the KV file! (using setattr)
some kv file:
#:import Window kivy.core.window.Window
<RootWidget>:
some_property: setattr(Window, 'fullscreen' , 'auto') or 'real_value!'
It is hackish though...
Upvotes: 3