Делаю простенький блокнот для смартфонов, сделал по сути всё - можно что-нибудь добавить, написать, и удалить, осталось сделать только отображение кнопки перехода на каждый отдельный блокнот в столбик, чтобы можно было прокручивать вниз и вверх в поисках нужной заметки.
Для этого я добавил все кнопки в GridLayout, а его в ScrollView, и выглядит всё нормально, да вот только если я пытаюсь прокрутить вниз, то он банально возвращает к началу, как будто я пытаюсь листать куда-то за края, но это не так, там снизу есть ещё кнопки, к которым у меня нет доступа, так как он просто не даёт до них долистать.
Вот код в kv файле:
ChoiceWindow:
Crutch1:
ChoiceMenu1:
TextWindow1:
TextWindow2:
TextWindow3:
TextWindow4:
TextWindow5:
TextWindow6:
TextWindow7:
TextWindow8:
TextWindow9:
TextWindow10:
TextWindow11:
TextWindow12:
TextWindow13:
<Crutch1>:
name: "crutch"
BoxLayout:
orientation: "vertical"
size: root.width, root.height
Button:
text: "Блокнот с подвохом"
font_size: 40
background_color: (0.2, 0.2, 0.4, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'up'
<ChoiceMenu1>:
name: "choice_menu"
on_pre_enter:
root.title_on_menu(notebook_1, 1)
root.title_on_menu(notebook_2, 2)
root.title_on_menu(notebook_3, 3)
root.title_on_menu(notebook_4, 4)
root.title_on_menu(notebook_5, 5)
root.title_on_menu(notebook_6, 6)
root.title_on_menu(notebook_7, 7)
root.title_on_menu(notebook_8, 8)
root.title_on_menu(notebook_9, 9)
root.title_on_menu(notebook_10, 10)
root.title_on_menu(notebook_11, 11)
root.title_on_menu(notebook_12, 12)
root.title_on_menu(notebook_13, 13)
#oelpfb66koojhhfikckckkck
вот в нём ScrollView
ScrollView:
pos_hint: {'top': 0.9}
GridLayout:
size_hint_y: None
cols: 1
padding: 5
spacing: 5
Button: #1
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_1
on_release:
app.root.current = '1 notebook'
root.manager.transition.direction = 'left'
Button: #2
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_2
on_release:
app.root.current = '2 notebook'
root.manager.transition.direction = 'left'
Button: #3
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_3
on_release:
app.root.current = '3 notebook'
root.manager.transition.direction = 'left'
Button: #4
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_4
on_release:
app.root.current = '4 notebook'
root.manager.transition.direction = 'left'
Button: #5
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_5
on_release:
app.root.current = '5 notebook'
root.manager.transition.direction = 'left'
Button: #6
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_6
on_release:
app.root.current = '6 notebook'
root.manager.transition.direction = 'left'
Button: #7
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_7
on_release:
app.root.current = '7 notebook'
root.manager.transition.direction = 'left'
Button: #8
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_8
on_release:
app.root.current = '8 notebook'
root.manager.transition.direction = 'left'
Button: #9
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_9
on_release:
app.root.current = '9 notebook'
root.manager.transition.direction = 'left'
Button: #10
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_10
on_release:
app.root.current = '10 notebook'
root.manager.transition.direction = 'left'
Button: #11
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_11
on_release:
app.root.current = '11 notebook'
root.manager.transition.direction = 'left'
Button: #12
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_12
on_release:
app.root.current = '12 notebook'
root.manager.transition.direction = 'left'
Button: #13
size_hint: 1, None
size: 0, 60
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
id: notebook_13
on_release:
app.root.current = '13 notebook'
root.manager.transition.direction = 'left'
#lgplveiok3203kov0303vojIJVO
остальное:
FloatLayout:
orientation: "vertical"
size: root.width, root.height
padding: 5
spacing: 5
Button:
size_hint: 1, 0.1
pos_hint: {'top': 1}
text: "+ Добавить новый блокнот"
font_size: 25
background_color: (0.7,0.8,0.1,1) if self.state == 'normal' else (0.3,0.5,0.9,1)
on_release:
root.create_notebook()
<TextWindow1>:
name: '1 notebook'
on_pre_enter:
root.load_text(text_input, 1)
BoxLayout:
pos_hint: {'top': 1}
size_hint: 1, 0.1
orientation: 'horizontal'
size: root.width, root.height
Button:
size_hint: 1, 1
text: 'Сохранить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.save_text(text_input, 1)
Button:
size_hint: 1, 1
text: 'Удалить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.delete_text(1)
BoxLayout:
pos_hint: {'top': 0.9}
size_hint: 1, 0.9
orientation: 'vertical'
size: root.width, root.height
TextInput:
font_size: 20
id: text_input
<TextWindow2>:
name: '2 notebook'
on_pre_enter:
root.load_text(text_input, 2)
BoxLayout:
pos_hint: {'top': 1}
size_hint: 1, 0.1
orientation: 'horizontal'
size: root.width, root.height
Button:
size_hint: 1, 1
text: 'Сохранить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.save_text(text_input, 2)
Button:
size_hint: 1, 1
text: 'Удалить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.delete_text(2)
BoxLayout:
pos_hint: {'top': 0.9}
size_hint: 1, 0.9
orientation: 'vertical'
size: root.width, root.height
TextInput:
font_size: 20
id: text_input
***
<TextWindow12>:
name: '12 notebook'
on_pre_enter:
root.load_text(text_input, 12)
BoxLayout:
pos_hint: {'top': 1}
size_hint: 1, 0.1
orientation: 'horizontal'
size: root.width, root.height
Button:
size_hint: 1, 1
text: 'Сохранить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.save_text(text_input, 12)
Button:
size_hint: 1, 1
text: 'Удалить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.delete_text(12)
BoxLayout:
pos_hint: {'top': 0.9}
size_hint: 1, 0.9
orientation: 'vertical'
size: root.width, root.height
TextInput:
font_size: 20
id: text_input
<TextWindow13>:
name: '13 notebook'
on_pre_enter:
root.load_text(text_input, 13)
BoxLayout:
pos_hint: {'top': 1}
size_hint: 1, 0.1
orientation: 'horizontal'
size: root.width, root.height
Button:
size_hint: 1, 1
text: 'Сохранить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.save_text(text_input, 13)
Button:
size_hint: 1, 1
text: 'Удалить'
font_size: 20
background_color: (0.5, 0.8, 0.91, 1) if self.state == 'normal' else (0.3, 0.5, 0.9, 1)
on_release:
app.root.current = 'choice_menu'
root.manager.transition.direction = 'right'
on_press:
root.delete_text(13)
BoxLayout:
pos_hint: {'top': 0.9}
size_hint: 1, 0.9
orientation: 'vertical'
size: root.width, root.height
TextInput:
font_size: 20
id: text_input
#krmbfgrlp45-lh5-hkogkr94jg94gpoekfp309
Вот main.py:
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.widget import Widget
from kivy.lang import Builder
import sys
import os
import re
Window.size = (500, 750)
Window.clearcolor = (12/255, 12/255, 12/255, 1)
Window.title = "Блокнот с подвохом"
***
class ChoiceMenu1(Screen):
def title_on_menu(self, input, nu):
standard_title_on_menu(self, input, nu)
class Crutch1(Screen):
pass
***
class TextWindow1(Screen):
def load_text(self, input, nu):
standard_load_text(self, input, nu)
def save_text(self, input, nu):
standard_save_text(self, input, nu)
def delete_text(self, nu):
standard_delete_text(self, nu)
class TextWindow2(Screen):
def load_text(self, input, nu):
standard_load_text(self, input, nu)
def save_text(self, input, nu):
standard_save_text(self, input, nu)
def delete_text(self, nu):
standard_delete_text(self, nu)
***
class TextWindow12(Screen):
def load_text(self, input, nu):
standard_load_text(self, input, nu)
def save_text(self, input, nu):
standard_save_text(self, input, nu)
def delete_text(self, nu):
standard_delete_text(self, nu)
class TextWindow13(Screen):
def load_text(self, input, nu):
standard_load_text(self, input, nu)
def save_text(self, input, nu):
standard_save_text(self, input, nu)
def delete_text(self, nu):
standard_delete_text(self, nu)
# ormhldmbrlgpfbk5bdf4bpvbps
***
class ChoiceWindow(ScreenManager):
pass
kv = Builder.load_file("new_windows.kv")
class GayApp1(App):
def build(self):
return kv
if __name__ == "__main__":
GayApp1().run()
не могу понять, в чём причина такого повидения при прокрутке, думаю, что забыл указать какой-нибудь параметр, но какой не знаю.