separate_pages
quadrismegistus 4 years ago
parent 60edbc00f0
commit ab1aaac180

@ -0,0 +1 @@
Subproject commit 7fbab74c5693430ea486ac359fa7a032596c232b

@ -0,0 +1,69 @@
from kivy.uix.scrollview import ScrollView
class EndEventScroll(ScrollView):
def on_scroll_stop(self, *args, **kwargs):
result = super(EndEventScroll, self).on_scroll_stop(*args, **kwargs)
if self.scroll_y < 0 and hasattr(self, 'on_end_event'):
self.on_end_event()
return result
if __name__ == '__main__':
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.properties import ObjectProperty
class CustomScrollView(EndEventScroll):
layout1 = ObjectProperty(None)
def on_end_event(self):
height = 0.0
for i in range(40):
btn = Button(text=str(i), size_hint=(None, None),
size=(200, 100))
self.layout1.add_widget(btn)
height += btn.height
height = float(height / self.layout1.cols)
procent = (100.0 * height)/float(self.layout1.height)
self.scroll_y += procent/100.0
class ScrollViewApp(App):
def build(self):
layout1 = GridLayout(cols=4, spacing=10, size_hint=(None, None))
layout1.bind(minimum_height=layout1.setter('height'),
minimum_width=layout1.setter('width'))
for i in range(40):
btn = Button(text=str(i), size_hint=(None, None),
size=(200, 100))
layout1.add_widget(btn)
scrollview1 = CustomScrollView(bar_width='2dp', layout1=layout1)
scrollview1.add_widget(layout1)
layout2 = GridLayout(cols=4, spacing=10, size_hint=(None, None))
layout2.bind(minimum_height=layout2.setter('height'),
minimum_width=layout2.setter('width'))
for i in range(40):
btn = Button(text=str(i), size_hint=(None, None),
size=(200, 100))
layout2.add_widget(btn)
scrollview2 = ScrollView(scroll_type=['bars'],
bar_width='9dp',
scroll_wheel_distance=100)
scrollview2.add_widget(layout2)
root = GridLayout(cols=2)
root.add_widget(scrollview1)
root.add_widget(scrollview2)
return root
ScrollViewApp().run()

@ -1 +1,40 @@
<kivymd.uix.button.MDIconButton object at 0x7f58c1d9f798><kivymd.uix.button.MDIconButton object at 0x7fa7a11b0660>
testing
<class '__main__.MyLayout'>
<class '__main__.MainApp'>
testing2
<class '__main__.MainApp'>
testing2
<class '__main__.MainApp'>
<class '__main__.MainApp'>
<class '__main__.MainApp'>
<__main__.MyIconButton object at 0x7f7d4ea78c78>
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

@ -1,40 +1,9 @@
#:import get_color_from_hex kivy.utils.get_color_from_hex
#:import images_path kivymd.images_path
#:import colors kivymd.color_definitions.colors
#:import partial functools.partial
#:import NoTransition kivy.uix.screenmanager.NoTransition
ScreenManager:
BaseScreen:
FeedScreen:
<BaseScreen>:
name: 'base'
MDToolbar:
title: "Gyre"
pos_hint: {'center_x': .5, 'center_y': 0.95}
md_bg_color: get_color_from_hex(colors['Red']['500'])
background_palette: 'Red'
background_hue: '500'
right_action_items: [['radio-tower', lambda x: x], ['camera', lambda x: x], ['play', lambda x: x]]
left_action_items: [[f"{images_path}kivymd_alpha.png", lambda x: x]]
MDFillRoundFlatButton:
text: "Gyre"
halign: "center"
pos_hint: {"center_x": 0.5, "center_y": 0.5}
md_bg_color: get_color_from_hex(colors['Red']['500'])
MDLabel:
text: "Turning and turning in the widening gyre..."
pos_hint: {"center_x": 0.5, "center_y": 0.435}
halign:"center"
<FeedScreen>
name: 'feed'
MDLabel:
text: "The falcon cannot hear the falconer..."
pos_hint: {"center_x": 0.5, "center_y": 0.3}
halign:"center"
MyLayout:
MyToolbar

@ -1,34 +1,164 @@
from kivy.uix.screenmanager import Screen,ScreenManager
from kivymd.app import MDApp
from kivymd.uix.button import MDFillRoundFlatButton
from kivymd.uix.button import MDFillRoundFlatButton, MDIconButton
from kivymd.uix.toolbar import MDToolbar
from kivymd.uix.screen import MDScreen
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivymd.theming import ThemeManager
from kivy.properties import ObjectProperty,ListProperty
import time
from collections import OrderedDict
from functools import partial
from kivy.uix.screenmanager import NoTransition
from kivymd.uix.label import MDLabel
from kivy.uix.widget import Widget
root = None
app = None
def log(x):
with open('log.txt','a+') as of:
of.write(str(x)+'\n')
class BaseScreen(Screen):
pass
class MyLayout(BoxLayout):
scr_mngr = ObjectProperty(None)
#orientation = 'vertical'
def change_screen(self, screen, *args):
self.scr_mngr.current = screen
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.orientation='vertical'
self.add_widget(MyToolbar())
class MyIconButton(MDIconButton):
kwargs = dict(theme_text_color='Custom',text_color=(1,0,0,1),pos_hint = {'center_y': 0.5})
def __init__(self, screen_name, *args, **kwargs):
kwargs = dict(list(self.kwargs.items()) + list(kwargs.items()))
kwargs['on_release'] = lambda x: app.change_screen(screen_name)
super().__init__(*args, **kwargs)
class MyLabel(MDLabel):
kwargs = dict(theme_text_color='Custom',text_color=(1,0,0,1), pos_hint = {'center_y': 0.5})
def __init__(self, *args, **kwargs):
kwargs = dict(list(self.kwargs.items()) + list(kwargs.items()))
super().__init__(*args, **kwargs)
class MyToolbar(MDToolbar):
def change_screen(self,x, *args, **kwargs):
app.change_screen(x)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.id='toolbar'
self.title='Gyre'
self.pos_hint = {'center_x': .5, 'center_y': 0.95}
self.md_bg_color = (0,0,0,1)
# self.ids['left_actions'] = left = Widget()
# self.ids['right_actions'] = right = Widget()
# self.specific_text_color = (1,0,0,1)
# Add icons
self.add_widget(MyIconButton('feed', icon='radio-tower'))
self.add_widget(MyIconButton('people', icon='account-group'))
self.add_widget(MyIconButton('events', icon='calendar'))
self.add_widget(MyIconButton('messages', icon='message-processing-outline'))
self.add_widget(MyIconButton('notifications', icon='bell-outline'))
# def button_notif(self):
# return MyIconButton('notifications', icon='bell-outline')
class BaseScreen(MDScreen):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
#self.add_widget(MDLabel(text='Turning and turning in the widening gyre \nThe falcon cannot hear the falconer;\nThings fall apart; the centre cannot hold;\nMere anarchy is loosed upon the world,\nThe blood-dimmed tide is loosed, and everywhere \nThe ceremony of innocence is drowned;\nThe best lack all conviction, while the worst \nAre full of passionate intensity.\n\nSurely some revelation is at hand;\nSurely the Second Coming is at hand. \nThe Second Coming! Hardly are those words out \nWhen a vast image out of Spiritus Mundi\nTroubles my sight: somewhere in sands of the desert \nA shape with lion body and the head of a man, \nA gaze blank and pitiless as the sun, \nIs moving its slow thighs, while all about it \nReel shadows of the indignant desert birds. \nThe darkness drops again; but now I know \nThat twenty centuries of stony sleep\nWere vexed to nightmare by a rocking cradle, \nAnd what rough beast, its hour come round at last, \nSlouches towards Bethlehem to be born?'))
class FeedScreen(BaseScreen):
pass
class WelcomeScreen(BaseScreen):
id='welcome'
#def on_enter(self, *args, **kwargs):
# super().on_enter()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# self.add_widget(
# MDFillRoundFlatButton(
# text="Hello, World",
# pos_hint={"center_x": 0.5, "center_y": 0.5},
# )
# )
self.add_widget(
MyLabel(
text='Turning and turning in the widening gyre \nThe falcon cannot hear the falconer;\nThings fall apart; the centre cannot hold;\nMere anarchy is loosed upon the world,\nThe blood-dimmed tide is loosed, and everywhere \nThe ceremony of innocence is drowned;\nThe best lack all conviction, while the worst \nAre full of passionate intensity.\n\nSurely some revelation is at hand;\nSurely the Second Coming is at hand. \nThe Second Coming! Hardly are those words out \nWhen a vast image out of Spiritus Mundi\nTroubles my sight: somewhere in sands of the desert \nA shape with lion body and the head of a man, \nA gaze blank and pitiless as the sun, \nIs moving its slow thighs, while all about it \nReel shadows of the indignant desert birds. \nThe darkness drops again; but now I know \nThat twenty centuries of stony sleep\nWere vexed to nightmare by a rocking cradle, \nAnd what rough beast, its hour come round at last, \nSlouches towards Bethlehem to be born?',
halign='center'
)
)
pass
class PeopleScreen(BaseScreen):
pass
class EventsScreen(BaseScreen):
pass
class MessagesScreen(BaseScreen):
pass
class NotificationsScreen(BaseScreen):
pass
class MainApp(MDApp):
# def build(self):
# self.theme_cls.primary_palette = "Red" # "Purple", "Red"
title = 'Gyre'
def build(self):
Builder.load_file('main.kv')
global root,app
root = MyLayout()
app = self
self.theme_cls = ThemeManager()
self.theme_cls.primary_palette='Red'
self.theme_cls.theme_style='Dark'
self.screens = OrderedDict()
self.screens['welcome']=WelcomeScreen(name='welcome')
self.screens['feed']=FeedScreen(name='feed')
self.screens['people']=PeopleScreen(name='people')
self.screens['events']=EventsScreen(name='events')
self.screens['messages']=MessagesScreen(name='messages')
self.screens['notifications']=NotificationsScreen(name='notifications')
self.sm = ScreenManager()
self.sm.add_widget(BaseScreen(name='base'))
self.sm.add_widget(FeedScreen(name='feed'))
for screen in self.screens.values():
self.sm.add_widget(screen)
root.add_widget(self.sm)
return self.sm
return Builder.load_file('main.kv')
return root
def go(self,x):
self.sm.current=x
def change_screen(self,x):
#log('testing2')
self.sm.switch_to(self.screens[x], transition=NoTransition())

@ -0,0 +1,102 @@
#:import get_color_from_hex kivy.utils.get_color_from_hex
#:import images_path kivymd.images_path
#:import colors kivymd.color_definitions.colors
#:import partial functools.partial
#:import NoTransition kivy.uix.screenmanager.NoTransition
MyLayout:
scr_mngr: scr_mngr
orientation: 'vertical'
height: self.minimum_height
canvas:
Color:
rgba: 0,0,0,1 #get_color_from_hex(colors['Gray']['900'])
Rectangle:
pos: self.pos
size: self.size
MyToolbar:
id: toolbar
title: app.title
pos_hint: {'center_x': .5, 'center_y': 1}
md_bg_color: 0,0,0,1
background_palette: 'Red'
background_hue: '500'
specific_text_color: 1,0,0,1
right_action_items: [['radio-tower', partial(root.change_screen, 'feed')], ['account-group', partial(root.change_screen, 'people')], ['calendar', partial(root.change_screen, 'events')], ['message-processing-outline', partial(root.change_screen, 'messages')], ['bell-outline', partial(root.change_screen, 'notifications')]]
left_action_items: [[f"spiral3.png", partial(root.change_screen, 'welcome')]]
ScreenManager:
id: scr_mngr
transition: NoTransition()
WelcomeScreen:
name: 'welcome'
MDLabel:
text: "Turning and turning in the widening gyre \nThe falcon cannot hear the falconer;\nThings fall apart; the centre cannot hold;\nMere anarchy is loosed upon the world,\nThe blood-dimmed tide is loosed, and everywhere \nThe ceremony of innocence is drowned;\nThe best lack all conviction, while the worst \nAre full of passionate intensity.\n\nSurely some revelation is at hand;\nSurely the Second Coming is at hand. \nThe Second Coming! Hardly are those words out \nWhen a vast image out of Spiritus Mundi\nTroubles my sight: somewhere in sands of the desert \nA shape with lion body and the head of a man, \nA gaze blank and pitiless as the sun, \nIs moving its slow thighs, while all about it \nReel shadows of the indignant desert birds. \nThe darkness drops again; but now I know \nThat twenty centuries of stony sleep\nWere vexed to nightmare by a rocking cradle, \nAnd what rough beast, its hour come round at last, \nSlouches towards Bethlehem to be born?"
pos_hint: {"center_x": 0.5, "center_y": 0.5}
halign:"center"
theme_text_color: "Custom"
text_color: 1, 0, 0, 1
FeedScreen:
name: 'feed'
MDLabel:
text: "FEED Turning and turning in the widening gyre..."
pos_hint: {"center_x": 0.5, "center_y": 0.95}
halign:"center"
theme_text_color: "Custom"
text_color: 1, 0, 0, 1
PeopleScreen:
name: 'people'
MDLabel:
text: "The falcon cannot hear the falconer..."
pos_hint: {"center_x": 0.5, "center_y": 0.95}
halign:"center"
EventsScreen:
name: 'events'
MessagesScreen:
name: 'messages'
NotificationsScreen:
name: 'notifications'
# ScreenManager:
# BaseScreen:
# FeedScreen:
# <BaseScreen>:
# name: 'base'
# MDFillRoundFlatButton:
# text: "Gyre"
# halign: "center"
# pos_hint: {"center_x": 0.5, "center_y": 0.5}
# md_bg_color: get_color_from_hex(colors['Red']['500'])
# MDLabel:
# text: "Turning and turning in the widening gyre..."
# pos_hint: {"center_x": 0.5, "center_y": 0.435}
# halign:"center"
# <FeedScreen>
# name: 'feed'
# MDLabel:
# text: "The falcon cannot hear the falconer..."
# pos_hint: {"center_x": 0.5, "center_y": 0.3}
# halign:"center"

@ -0,0 +1,58 @@
from kivy.uix.screenmanager import Screen,ScreenManager
from kivymd.app import MDApp
from kivymd.uix.button import MDFillRoundFlatButton
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivymd.theming import ThemeManager
from kivy.properties import ObjectProperty
from kivymd.uix.label import MDLabel
class MyLayout(BoxLayout):
scr_mngr = ObjectProperty(None)
def change_screen(self, screen, *args):
self.scr_mngr.current = screen
class FeedScreen(Screen):
def on_enter(self):
with open('log.txt','a+') as of: of.write(str(dir(self)))
print(dir(self))
#self.add_widget(MDLabel(text='hello world!'))
pass
class WelcomeScreen(Screen):
pass
class PeopleScreen(Screen):
pass
class EventsScreen(Screen):
pass
class MessagesScreen(Screen):
pass
class NotificationsScreen(Screen):
pass
class MainApp(MDApp):
# def build(self):
# self.theme_cls.primary_palette = "Red" # "Purple", "Red"
title = 'Gyre'
def build(self):
#self.theme_cls.primary_palette = "Green" # "Purple", "Red"
Builder.load_file('main.kv')
# self.sm = ScreenManager()
# self.sm.add_widget(BaseScreen(name='base'))
# self.sm.add_widget(FeedScreen(name='feed'))
# return self.sm
if __name__ == '__main__':
App = MainApp()
App.run()

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
<g><g transform="matrix(1 0 0 -1 0 800)"><path d="M504.7,313.8c25.2,13.1,36.8,33.5,34.6,61.4c-2.2,27.8-13.7,50.9-34.6,69.2c-30.5,23.5-64.2,30.7-101.2,21.5c-37-9.1-65.1-30.7-84.2-64.6c-24.4-45.3-30.5-87.9-18.3-127.9c12.2-40,37.9-73.5,77-100.5c39.2-27,81.4-39.6,126.6-37.9c71.4,5.2,126.8,38.1,166.4,98.6c39.6,60.5,51.1,125.5,34.6,195.2c-18.3,80.1-64.2,139-137.7,176.9s-149,44.2-226.5,18.9c-69.6-20.9-124.7-63.5-165.1-127.9c-40.5-64.4-58.1-134-52.9-208.9c7.8-80.9,39.8-151.2,95.9-210.8c56.1-59.6,123.8-96.4,203-110.3C499.1-47.3,573.3-38.2,645.1-6c71.8,32.2,128.1,80.9,169,146.2c43.5,68.7,65.3,137.5,65.3,206.2c0,13.9,6.1,26.3,18.3,37.2c12.2,10.9,26.1,15,41.8,12.4c20,0,33.9-8,41.8-24.1c7.8-16.1,10.4-33.7,7.8-52.9C977.7,190.3,922.9,80.2,824.5-11.2c-98.3-91.4-212.3-137.1-342-137.1c-62.7,0-123.1,12.6-181.4,37.9C242.8-85.2,193-51.4,151.6-9.2C110.3,33,76.4,81.7,49.8,137C23.3,192.2,10,250.1,10,310.6S22.6,432.2,47.9,494c33.1,71.4,82.2,129.2,147.5,173.6c65.3,44.4,133.1,70.5,203.6,78.3c70.5,7.8,140.3-3.9,209.5-35.2c69.2-31.3,123.4-81.8,162.5-151.4c40.9-67,57.2-141.2,49-222.6s-40.7-150.3-97.2-206.9c-54.8-54.8-121.8-86.2-201-94c-79.2-7.8-151.9,10.9-218,56.1c-61.8,44.4-99.2,104.9-112.3,181.4c-13.1,76.6,4.4,146.6,52.2,210.2c30.5,40.9,70.7,69,120.7,84.2c50,15.2,99.4,14.4,148.2-2.6c48.7-17,86.2-48.1,112.3-93.3c14.8-25.2,22.4-54.2,22.8-86.8c0.4-32.6-5.2-62.9-17-90.7c-11.7-27.8-30.5-50.5-56.1-67.9C548.9,209,520,202,487.8,205.5c-45.3,0-81.6,19.1-109,57.4s-28.9,77-4.6,116.2c17.4,23.5,39.6,33.7,66.6,30.7c27-3,46.6-15,58.7-35.9c3.5-13.1,5.7-24.6,6.5-34.6c0.9-10,0.9-16.8,0-20.2L504.7,313.8z"/></g></g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -55,4 +55,4 @@ if __name__ == '__main__':
w = Watcher()
w.run()

Loading…
Cancel
Save