Hello everyone, im trying to use kivy with @Cheaterman 's kivy integration
And add something to core/window.py to use TextInput (crashing without this);
class CWindow:
def bind(self,**args):
pass
def unbind(self,**args):
pass
def PatchWindow(v=True):
if not v:kivy.core.window.Window=None
else:kivy.core.window.Window=CWindow()
PatchWindow()
Im trying to make multiple screens like intro, login, character select etc… (classic rpg style)
but when i switch to another kivy app, it doesnt get keyboard inputs! Here some codes and video;
uiIntro.py;
import sys
from panda3d.core import *
from panda3d_kivy.app import App
import vui
import uiPhase
class IntroWindow(App):
def movePhase(self,phase):
if phase=='login':
uiPhase.TARGET_PHASE=phase
self.stop()
return
def FadeIn(self):
if self.neuera_logo.opacity<1:
self.neuera_logo.opacity+=.01
return
self.fade=1
def FadeOut(self):
if self.neuera_logo.opacity>0:
self.neuera_logo.opacity-=.01
return
self.fade=2
def Fade(self,task):
if self.fade==2:
self.movePhase('login')
self.fade=3
return task.done
if self.fade==0:self.FadeIn()
if self.fade==1:self.FadeOut()
return task.cont
def build(self):
self.fade=0
self.canvas=vui.CCanvas(size=(vui.SCREEN_W,vui.SCREEN_H),pos=(0,0))
self.bg=vui.Image(parent=self.canvas, source='bin/neuera/ui/logo/black_screen.png', size=(vui.SCREEN_W,vui.SCREEN_H), fit_mode='cover')
self.neuera_logo=vui.Image(parent=self.canvas, source='bin/neuera/ui/logo/neuera_logo.png', size=(vui.SCREEN_W,vui.SCREEN_H), fit_mode='cover')
self.neuera_logo.opacity=0
taskMgr.add(self.Fade, 'intro_fade')
uiPhase.CUR_PHASE='intro'
return self.canvas
uiLogin.py;
import sys
from panda3d.core import *
from panda3d_kivy.app import App
import vui
import uiPhase
class LoginWindow(App):
def ExitGame(self):
self.stop()
sys.exit()
def build(self):
self.canvas=vui.CCanvas(size=(vui.SCREEN_W,vui.SCREEN_H),pos=(0,0))
self.bg=vui.Image(parent=self.canvas, source='bin/neuera/ui/general/windows/login_bg_1.png', size=(vui.SCREEN_W,vui.SCREEN_H), fit_mode='cover')
self.login_board=vui.Thinboard(parent=self.canvas, size=(256,200), pos=(vui.SCREEN_W*0.5-128,vui.SCREEN_H*0.5-80))
self.user_lbl=vui.Label(parent=self.login_board, text='username:', pos=(30,self.login_board.size[1]-50), size_hint = (1, None))
self.user_edit=vui.Edit(parent=self.login_board, text='testuser', multiline=False, size=(120,26), pos=(100,self.login_board.size[1]-60))
self.pass_lbl=vui.Label(parent=self.login_board, text='password:', pos=(30,self.login_board.size[1]-80), size_hint = (1, None))
self.pass_edit=vui.Edit(parent=self.login_board, text='testpass', password=True, multiline=False, size=(120,26), pos=(100,self.login_board.size[1]-90))
self.login_button = vui.Button(parent=self.login_board, text='Login', size_hint=(None, None), size=(120, 30), pos=(100,self.login_board.size[1]-130))
self.exit_button = vui.RedButton(parent=self.login_board, text='Exit', size_hint=(None, None), size=(120, 30), pos=(100,self.login_board.size[1]-165))
self.exit_button.setOnClick(self.ExitGame)
uiPhase.CUR_PHASE='login'
return self.canvas
main.py;
import sys
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from panda3d_kivy.app import App
from uiLogin import LoginWindow
from uiIntro import IntroWindow
import vui
import uiPhase
import time
class ValkeraApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
vui.initVUI()
self.login_wnd = None
self.intro_wnd = None
taskMgr.add(self.handle_ui_phase, 'handle_ui_phase')
time.sleep(1)
uiPhase.TARGET_PHASE='intro'
def handle_ui_phase(self,task):
if not uiPhase.TARGET_PHASE:return task.cont
if uiPhase.TARGET_PHASE=='login':
uiPhase.TARGET_PHASE=None
if not self.login_wnd:self.login_wnd=LoginWindow(self)
self.login_wnd.run()
return task.cont
if uiPhase.TARGET_PHASE=='intro':
uiPhase.TARGET_PHASE=None
if not self.intro_wnd:self.intro_wnd=IntroWindow(self)
self.intro_wnd.run()
return task.cont
return task.cont
app = ValkeraApp()
app.run()
uiLoginTest.py;
import sys
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from panda3d_kivy.app import App
from uiLogin import LoginWindow
import vui
class ValkeraApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
vui.initVUI()
self.login_wnd = LoginWindow(self)
self.login_wnd.run()
app = ValkeraApp()
app.run()
Any idea?
Kind Regards…