fishtang
fishtang

Reputation: 179

Why is text not showing on my kivy label?

as far as I know, my codes are good because there is no error from the IDE, and I used the same code on another project and it works. I read from SO posts that say, maybe the object don't have the .text() method, that would give me an error, but I don't have an error. Another post that say could come from not set the table to an object. As far as I know, I referenced everything correctly.

does it have to do with the data type? thanks again for some insight.

main.py

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.lang.builder import Builder
from kivy.properties import ObjectProperty, StringProperty
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.graphics import Rectangle, Color
import socket

class Screen_Manager(ScreenManager):
    screen_1 = ObjectProperty()

class Screen_1(Screen):
    main_display = ObjectProperty()

    def __init__(self, **kwargs):
        super(Screen_1, self).__init__(**kwargs)

    def get_host(self):
        self.s = socket.gethostbyname(socket.gethostname())
        return self.s


class MainApp(App):

    def build(self):
        self.title = "Number Display App"
        self.sm = Screen_Manager()
        return self.sm

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

main.ky

<Screen_Manager>:
    Screen_1:

<Screen_1>:
    id: screen_1
    name: "first"

    main_display: display_1

    Label:
        id: display_1
        text: root.get_host()
        font_size: "30sp"

Upvotes: 0

Views: 362

Answers (1)

inclement
inclement

Reputation: 29488

It looks like you don't set the text of your label to anything but " ".

Upvotes: 1

Related Questions