2017-06-16 71 views
1

即時通訊仍然是kivy的先行者,當我在Windows上啓動我的kivy應用程序時,我得到一個黑winodw,窗口適合整個筆記本電腦屏幕。我該如何解決這個問題,以及如何調整窗口大小?在windows上獲得黑屏時,我的kivy應用程序

我的Python代碼

# File name FaceRecognition.py 
import kivy 

from kivy.app import App 
from kivy.uix.floatlayout import FloatLayout 
from kivy.uix.screenmanager import ScreenManager, Screen 
from kivy.uix.button import Button 
from kivy.uix.widget import Widget 
from kivy.uix.label import Label 
from kivy.lang import Builder 

# Define each screen 

class ScreenOne(Screen): 
    pass 

class ScreenTwo(Screen): 
    pass 

class ScreenManagement(ScreenManager): 
    pass 


Builder.load_file("facerecognition.kv") 

class FaceRecognitionApp(App): 
    def build(self): 
     return ScreenManagement() 

if __name__=="__main__": 
    FaceRecognitionApp().run() 

我千伏文件

# File name FaceRecognition.kv 
#: kivy 1.9.1 


ScreenManagement: 
    id: screen_management 
    ScreenOne: 
    ScreenTwo: 


<[email protected]>: 

    color: .8,.9,0,1 # yellow color 
    font_size: 32 # font size 
    size_hint: .2,.1 

<ScreenOne>: 
    name: "screen1" 
    id: screen_one 

    FloatLayout: 

     Label: 
      text:"Hello\n Welcome to my App\n" 
      font_size:40 
      color: 0,0,0,1 
     MyButton: 
      text: 'Next' 
      pos_hint:{'right':1, 'y':0} 
      on_press:root.manager.current="screen2" 

<ScreenOne>: 
    name: "screen2" 
    id: screen_two 

    FloatLayout: 

     Label: 
      text:"Please insert your Name\n Please insert your Password\n" 
      font_size:40 
      color: 0,0,0,1 
     MyButton: 
      text: 'Next' 
      pos_hint:{'right':1, 'y':0} 
      on_press:root.manager.current="screen1" 

回答

0
  • 首先你在你的KV文件中定義<ScreenOne>兩次重要的是,第二個應該是<ScreenTwo>
  • 要定義通過在構建方法中返回一個根小部件。你也可以在你的kv文件中定義它,不要在其周圍放置<>。你需要擺脫一個定義。我只是把它放在kv文件中的<>
  • 你的標籤顏色是黑色的,因此黑色的黑色,你什麼也看不到。我將其更改爲白色color: 1,1,1,1
  • 窗口未填滿我的筆記本電腦上的整個屏幕。我認爲這不是一個代碼問題。

這是kv文件,其中包含我在列表中提到的所有更改。它在我的電腦上運行。

# File name FaceRecognition.kv 
#: kivy 1.9.1 


<ScreenManagement>: 
    id: screen_management 
    ScreenOne: 
    ScreenTwo: 


<[email protected]>: 

    color: .8,.9,0,1 # yellow color 
    font_size: 32 # font size 
    size_hint: .2,.1 

<ScreenOne>: 
    name: "screen1" 
    id: screen_one 

    FloatLayout: 

     Label: 
      text:"Hello\n Welcome to my App\n" 
      font_size:40 
      color: 1,1,1,1 
     MyButton: 
      text: 'Next' 
      pos_hint:{'right':1, 'y':0} 
      on_press:root.manager.current="screen2" 

<ScreenTwo>: 
    name: "screen2" 
    id: screen_two 

    FloatLayout: 

     Label: 
      text:"Please insert your Name\n Please insert your Password\n" 
      font_size:40 
      color: 1,1,1,1 
     MyButton: 
      text: 'Next' 
      pos_hint:{'right':1, 'y':0} 
      on_press:root.manager.current="screen1" 
相關問題