Reputation: 3179
Those are the codes:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
Builder.load_file("view.kv")
class LoginWidget(Widget):
pass
class ClientApp(App):
def build(self):
return LoginWidget()
if __name__ == '__main__':
ClientApp().run()
#:kivy 1.9.0
<LoginWidget>:
f_username: username
f_password: password
GridLayout:
rows: 2
cols: 2
Label:
text: "Okul Numarası"
TextInput:
id: username
Label:
text: "Şifre"
TextInput:
id: password
password: True
However, it is at the bottom-left, in a compressed view as below:
I had written some bunch of codes like a month ago and I remember I was not having these issues. Am I missing something?
Upvotes: 0
Views: 741
Reputation: 1
I just wanted to admit that I found the answer helpful. I had written my code only in .py file. In my case I wrote these two lines: self.size=self.size self.size_hint=(1,1) and it has been resolved after days of ideas, so thank you.
def __init__(self):
GridLayout.__init__(self)
self.hours=[]
self.cols=1
self.rows=9
self.allthemoney=TextInput(hint_text="", height=50, width=350,font_size=30)
self.allthemoney.show_keyboard()
self.add_widget(self.allthemoney)
for i in range(7):
self.hours.append(TextInput(hint_text="Worker number "+str(i+1)+" hours", height=50, width=500,font_size=30))
self.hours[i].show_keyboard()
self.add_widget(self.hours[i])
self.add_widget(Button(text="submit", size=(300,70),on_press=self.submit,font_size=60))
self.size = self.size
self.size_hint = (1, 1)
Upvotes: 0
Reputation: 8747
Your GridLayout
has a default size of 100x100 pixels. Set the size
property to change it:
<LoginWidget>:
f_username: username
f_password: password
GridLayout:
size: root.size # set the size manually
rows: 2
cols: 2
Label:
text: "Okul Numarası"
TextInput:
id: username
Label:
text: "Şifre"
TextInput:
id: password
password: True
That's because the parent is a subclass of Widget
. You can also derive from a Layout class instead:
class LoginWidget(FloatLayout):
pass
Then you could use size_hint
property to controll precisely how much space it should take.
Upvotes: 4