Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _create_popup(self, *_):
app = App.get_running_app()
if app.database_scanning:
return
content = BoxLayout(orientation='vertical')
popup_width = min(0.95 * Window.width, dp(500))
self.popup = popup = NormalPopup(title=self.title, content=content, size_hint=(None, 0.9), width=popup_width)
if not self.value:
content.add_widget(ShortLabel(height=app.button_scale * 3, text="You must set at least one database directory.\n\nThis is a folder where your photos are stored.\nNew photos will be imported to a database folder."))
content.add_widget(BoxLayout())
else:
folders = filter(None, self.value.split(';'))
folderdata = []
for folder in folders:
folderdata.append({'text': folder})
self.folderlist = folderlist = FolderSettingsList(size_hint=(1, .8), id='folderlist')
folderlist.data = folderdata
content.add_widget(folderlist)
buttons = BoxLayout(orientation='horizontal', size_hint=(1, None), height=app.button_scale)
addbutton = NormalButton(text='+')
addbutton.bind(on_release=self.add_path)
removebutton = NormalButton(text='-')
removebutton.bind(on_release=self.remove_path)
okbutton = WideButton(text='OK')
okbutton.bind(on_release=self._dismiss)
buttons.add_widget(addbutton)
def _create_popup(self, *_):
app = App.get_running_app()
if app.database_scanning:
return
content = BoxLayout(orientation='vertical')
popup_width = min(0.95 * Window.width, dp(500))
self.popup = popup = NormalPopup(title=self.title, content=content, size_hint=(None, 0.9), width=popup_width)
if not self.value:
content.add_widget(ShortLabel(height=app.button_scale * 3, text="You must set at least one database directory.\n\nThis is a folder where your photos are stored.\nNew photos will be imported to a database folder."))
content.add_widget(BoxLayout())
else:
folders = filter(None, self.value.split(';'))
folderdata = []
for folder in folders:
folderdata.append({'text': folder})
self.folderlist = folderlist = FolderSettingsList(size_hint=(1, .8), id='folderlist')
folderlist.data = folderdata
content.add_widget(folderlist)
buttons = BoxLayout(orientation='horizontal', size_hint=(1, None), height=app.button_scale)
addbutton = NormalButton(text='+')
addbutton.bind(on_release=self.add_path)
def _create_popup(self, instance):
# create popup layout
content = BoxLayout(orientation='vertical', spacing=5)
self.popup = popup = Popup(title=self.title,
content=content, size_hint=(None, None), size=(400, 250))
# create the textinput used for numeric input
self.textinput = textinput = TextInput(text=str(self.value),
font_size=24, multiline=False, size_hint_y=None, height=50)
textinput.bind(on_text_validate=self._validate)
self.textinput = textinput
# construct the content, widget are used as a spacer
content.add_widget(Widget())
content.add_widget(textinput)
content.add_widget(Widget())
content.add_widget(SettingSpacer())
# 2 buttons are created for accept or cancel the current value
def warn(self, title, text, action, cancel=1, tcolor=(1, .1, .1, 1)):
""" Opens a dialog with a warning"""
content = BoxLayout(orientation='vertical')
label = Label(halign='center')
label.text = text
content.add_widget(label)
buttons = BoxLayout(size_hint=(1, .4))
if cancel:
cancel_btn = Button(background_color=(.13, .13, .2, 1),
on_release=self.dismiss_popup)
cancel_btn.text = 'Cancel'
buttons.add_widget(cancel_btn)
ok_btn = Button(background_color=(.13, .13, .2, 1),
on_release=action)
ok_btn.text = 'OK'
buttons.add_widget(ok_btn)
content.add_widget(buttons)
title_color = tcolor
self.popup = AutoPopup(title_align='center', content=content,
title_size='18sp',
for path, name in fav_list:
if isdir(path):
self.add_node(TreeLabel(text=name, path=path), favs)
def trigger_populate(self, node):
if not node.path or node.nodes:
return
parent = node.path
_next = next(walk(parent))
if _next:
for path in _next[1]:
self.add_node(TreeLabel(text=path, path=parent + sep + path),
node)
class FileBrowser(BoxLayout):
'''FileBrowser class, see module documentation for more information.
'''
__events__ = ('on_canceled', 'on_success', 'on_submit')
select_state = OptionProperty('normal', options=('normal', 'down'))
'''State of the 'select' button, must be one of 'normal' or 'down'.
The state is 'down' only when the button is currently touched/clicked,
otherwise 'normal'. This button functions as the typical Ok/Select/Save
button.
:data:`select_state` is an :class:`~kivy.properties.OptionProperty`.
'''
cancel_state = OptionProperty('normal', options=('normal', 'down'))
'''State of the 'cancel' button, must be one of 'normal' or 'down'.
The state is 'down' only when the button is currently touched/clicked,
pos: self.pos
size: self.size
source: f'{images_path}swipe_shadow.png'
MDIconButton:
id: delet_post_button
size_hint: None, None
size: dp(56), dp(56)
icon: 'delete'
disabled: True
on_release: root.callback(root, None)
"""
)
class MDSeparator(ThemableBehavior, BoxLayout):
"""A separator line"""
color = ListProperty()
"""Separator color."""
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.on_orientation()
def on_orientation(self, *args):
self.size_hint = (
(1, None) if self.orientation == "horizontal" else (None, 1)
)
if self.orientation == "horizontal":
self.height = dp(1)
else:
def __init__(self, oMainWidget, **kwargs):
super(ConsoleWidget, self).__init__(**kwargs)
self.m_oMainWidget = oMainWidget
self.orientation="vertical"
self.inputlayout = BoxLayout(orientation='vertical', size_hint=(1, 0.1))
self.make_consoleinput()
self.add_widget(self.inputlayout)
buttonslayout = BoxLayout(size_hint=(1, 0.1),orientation="horizontal")
label1 = Label(text="History:", size_hint=(0.1, 1))
buttonslayout.add_widget(label1)
btn1 = Button(text='<', size_hint=(1.0 / 20.0, 1))
btn1.bind(on_press = self.on_history_back)
buttonslayout.add_widget(btn1)
btn2 = Button(text='>', size_hint=(1.0 / 20.0, 1))
btn2.bind(on_press = self.on_history_forward)
buttonslayout.add_widget(btn2)
buttonslayout.add_widget(Label(text="Screen:", size_hint=(0.1, 1)))
btn3 = Button(text='Clear', size_hint=(0.1, 1))
btn3.bind(on_press = self.on_clearbutton)
buttonslayout.add_widget(btn3)
btn.bind(on_release=toggle_layout)
def select_2nd_item(*l):
acc.select(acc.children[-2])
btn2 = Button(text='Select 2nd item')
btn2.bind(on_release=select_2nd_item)
from kivy.uix.slider import Slider
slider = Slider()
def update_min_space(instance, value):
acc.min_space = value
slider.bind(value=update_min_space)
root = BoxLayout(spacing=20, padding=20)
controls = BoxLayout(orientation='vertical', size_hint_x=.3)
controls.add_widget(btn)
controls.add_widget(btn2)
controls.add_widget(slider)
root.add_widget(controls)
root.add_widget(acc)
runTouchApp(root)