Kivy -Label -PositionierungsproblemePython

Python-Programme
Anonymous
 Kivy -Label -Positionierungsprobleme

Post by Anonymous »

Ich bin ein Python -Anfänger, und ich habe versucht, einen YouTube -Downloader zu bauen. Eingabe. < /p>
Das Problem ist, dass dieses Etikett ein seltsames Verhalten anzeigt (zumindest für mich). Wie die Position ist am Boden festgehalten.
oder als ob meine App nur die Hälfte des Bildschirms verwendet. Setzen oder falsch einstellen.
Vielleicht ist es so etwas. < /p>
Ich hoffe, Sie können helfen.

Code: Select all

import kivy
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView

class MyApp(App):
def build(self):
float_layout = FloatLayout()
# Make a BoxLayout to organiseren the widgets
box_layout = BoxLayout(orientation='vertical', size_hint=(1, None), pos_hint={'top': 0.78})

# Make a Label to display text
self.label = Label(text="YTDownloader", font_size=90, size_hint_y=None,  height=100)
box_layout.add_widget(self.label)

self.label2 = Label(text="Youtube Downloader", size_hint_y=None,  height=100)
box_layout.add_widget(self.label2)
#spacer label
self.label3 = Label(text="", size_hint_y=None,  height=20)
box_layout.add_widget(self.label3)

# Make a TextInput-widget
self.text_input = TextInput(hint_text="Voer zoektermen in...", size_hint=(None,  None), height=100, width=900, pos_hint={'center_x': 0.5}, padding=(20,20))
box_layout.add_widget(self.text_input)
#another spacer label
self.label4 = Label(text="", size_hint_y=None,  height=30)
box_layout.add_widget(self.label4)

# Make a Button-widget
button = Button(text="Zoek!", size_hint=(None,  None), height=100, width=300, pos_hint={'center_x': 0.5})
# connect a function to the button
button.bind(on_press=self.on_button_press)
box_layout.add_widget(button)

self.labelOutput = Label(text="", size_hint_y=None, width=960, text_size=(960, None), valign='top')
self.labelOutput.bind(texture_size=self.update_label_height)
box_layout.add_widget(self.labelOutput)

float_layout.add_widget(box_layout)

return float_layout

def on_button_press(self, instance):
# get the input text and display it in the output label
input_text = self.text_input.text
self.labelOutput.text = f"You entered: {input_text}"

def update_label_height(self, instance, value):
instance.height = instance.texture_size[1]

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

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post