簡體   English   中英

為什么 kivy 不顯示文本框

[英]Why isn't kivy show text box

為什么 kivy 不顯示此代碼的文本框? 請幫助我知道如何讓 kivy 使用這種樣式添加文本框。

謝謝你

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput



class textbox(GridLayout):
    def __initial__(self, **kwargs):
        super(MyGrid, self).__initial__(**kwards)
        self.cols = 2
        self.add_widger(Label(text = "Point for good"))
        self.name = TextInput(multiline = False)
        self.add_widget(self.name)


if __name__ == '__main__':

    textbox().run()

For any kivy program, You need to inherit from App class and override the build method and place your UI elements here, and call run() method from the instance of the class inheriting the the App class

其次,它的add_widget()不是add_widger ,也許你的意思是__init__()而不是__initial__

這是更正后的代碼:

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput

class TextBox(App):
   

    def build(self):
        grid = GridLayout()
        grid.cols = 2
        grid.add_widget(Label(text = "Point for good"))
        name = TextInput(multiline = False)
        grid.add_widget(name)

        return grid

if __name__ == '__main__':
    TextBox().run()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM