bugfix
This commit is contained in:
parent
ef5c160c40
commit
2532efa9f2
@ -343,7 +343,7 @@ class Modal(VBox):
|
|||||||
x = 0
|
x = 0
|
||||||
if yn == 'c':
|
if yn == 'c':
|
||||||
y = (self._target.height - self.height) / 2
|
y = (self._target.height - self.height) / 2
|
||||||
elif yn == 't':
|
elif yn == 'b':
|
||||||
y = self._target.height - self.height
|
y = self._target.height - self.height
|
||||||
if y < 0:
|
if y < 0:
|
||||||
y = 0
|
y = 0
|
||||||
@ -351,6 +351,9 @@ class Modal(VBox):
|
|||||||
self.pos = x, y
|
self.pos = x, y
|
||||||
else:
|
else:
|
||||||
self.pos = self._target.pos[0] + x, self._target.pos[1] + y
|
self.pos = self._target.pos[0] + x, self._target.pos[1] + y
|
||||||
|
Mx = Window.width
|
||||||
|
My = Window.height
|
||||||
|
self.pos_hint = {'x':self.pos[0]/Mx, 'y':self.pos[1]/My}
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
if self.parent:
|
if self.parent:
|
||||||
|
@ -1,202 +1,170 @@
|
|||||||
|
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
from kivy.core.window import Window
|
from kivy.core.window import Window
|
||||||
from kivy.properties import StringProperty, NumericProperty, \
|
from kivy.properties import StringProperty, NumericProperty, \
|
||||||
OptionProperty
|
OptionProperty
|
||||||
from kivy.uix.image import AsyncImage
|
from kivy.uix.image import AsyncImage
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .baseWidget import Modal, Text, HBox,VBox, TimedModal
|
from .baseWidget import Modal, Text, HBox,VBox, TimedModal
|
||||||
from .widget_css import register_css
|
from .widget_css import register_css
|
||||||
from .clickable import ClickableIconText
|
from .clickable import ClickableIconText
|
||||||
from .toggleitems import PressableBox
|
from .toggleitems import PressableBox
|
||||||
|
|
||||||
error_default_title_css = {
|
error_default_title_css = {
|
||||||
"bgcolor":[0.88,0,0,1],
|
"bgcolor":[0.88,0,0,1],
|
||||||
"fgcolor":[0.12,0.12,0.12,1]
|
"fgcolor":[0.12,0.12,0.12,1]
|
||||||
}
|
}
|
||||||
|
|
||||||
conform_default_title_css = {
|
conform_default_title_css = {
|
||||||
"bgcolor":[0.88,0.88,0.88,1],
|
"bgcolor":[0.88,0.88,0.88,1],
|
||||||
"fgcolor":[0.12,0.12,0.12,1]
|
"fgcolor":[0.12,0.12,0.12,1]
|
||||||
}
|
}
|
||||||
conform_default_body_css = {
|
conform_default_body_css = {
|
||||||
"bgcolor":[0.92,0.92,0.92,1],
|
"bgcolor":[0.92,0.92,0.92,1],
|
||||||
"fgcolor":[0.16,0.16,0.16,1]
|
"fgcolor":[0.16,0.16,0.16,1]
|
||||||
}
|
}
|
||||||
|
|
||||||
conform_button_default_css = {
|
conform_button_default_css = {
|
||||||
"bgcolor":[0.05,0.85,0.05,1],
|
"bgcolor":[0.05,0.85,0.05,1],
|
||||||
"fgcolor":[0.95,0.95,0.95,1]
|
"fgcolor":[0.95,0.95,0.95,1]
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel_button_default_css = {
|
cancel_button_default_css = {
|
||||||
"bgcolor":[0.85, 0.5, 0.5, 1],
|
"bgcolor":[0.85, 0.5, 0.5, 1],
|
||||||
"fgcolor":[0.9, 0.90, 0.9, 1]
|
"fgcolor":[0.9, 0.90, 0.9, 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
register_css('conform_default_title_css', conform_default_title_css)
|
register_css('conform_default_title_css', conform_default_title_css)
|
||||||
register_css('message_default_title_css', conform_default_title_css)
|
register_css('message_default_title_css', conform_default_title_css)
|
||||||
register_css('error_default_title_css', error_default_title_css)
|
register_css('error_default_title_css', error_default_title_css)
|
||||||
register_css('conform_default_body_css', conform_default_body_css)
|
register_css('conform_default_body_css', conform_default_body_css)
|
||||||
register_css('message_default_body_css', conform_default_body_css)
|
register_css('message_default_body_css', conform_default_body_css)
|
||||||
register_css('conform_button_default_css', conform_button_default_css)
|
register_css('conform_button_default_css', conform_button_default_css)
|
||||||
register_css('cancel_button_default_css', cancel_button_default_css)
|
register_css('cancel_button_default_css', cancel_button_default_css)
|
||||||
|
|
||||||
class Message(TimedModal):
|
class Message(TimedModal):
|
||||||
title = StringProperty(None)
|
title = StringProperty(None)
|
||||||
default_title = 'Message'
|
default_title = 'Message'
|
||||||
default_message = 'Message'
|
default_message = 'Message'
|
||||||
title_icon = StringProperty(blockImage('info.png'))
|
title_icon = StringProperty(blockImage('info.png'))
|
||||||
message = StringProperty(None)
|
message = StringProperty(None)
|
||||||
body_css = StringProperty('message_default_body_css')
|
body_css = StringProperty('message_default_body_css')
|
||||||
title_css = StringProperty('message_default_title_css')
|
title_css = StringProperty('message_default_title_css')
|
||||||
show_position = OptionProperty('br', options=['tl','tc','tr',
|
show_position = OptionProperty('br', options=['tl','tc','tr',
|
||||||
'cl','cc','cr',
|
'cl','cc','cr',
|
||||||
'bl','bc','br'])
|
'bl','bc','br'])
|
||||||
width_c = NumericProperty(15)
|
def __init__(self, **kw):
|
||||||
height_c = NumericProperty(6)
|
SUPER(Message, self, kw)
|
||||||
def __init__(self, **kw):
|
b = VBox(csscls=self.title_css)
|
||||||
SUPER(Message, self, kw)
|
b1 = HBox(size_hint_y=None, height=CSize(2))
|
||||||
self.size_hint = None, None
|
b1.add_widget(AsyncImage(source=self.title_icon,
|
||||||
self.set_position()
|
size_hint=[None,None],
|
||||||
b = VBox(csscls=self.title_css)
|
height=CSize(1.2),
|
||||||
b1 = HBox(size_hint_y=None, height=CSize(2))
|
width=CSize(1.2)))
|
||||||
b1.add_widget(AsyncImage(source=self.title_icon,
|
b1.add_widget(Text(otext=self.title or self.default_title,
|
||||||
size_hint=[None,None],
|
font_size=CSize(1.2),
|
||||||
height=CSize(1.2),
|
i18n=True,
|
||||||
width=CSize(1.2)))
|
wrap=True,
|
||||||
b1.add_widget(Text(otext=self.title or self.default_title,
|
halign='left',
|
||||||
font_size=CSize(1.2),
|
valign='center',
|
||||||
i18n=True,
|
))
|
||||||
wrap=True,
|
b.add_widget(b1)
|
||||||
halign='left',
|
b2 = HBox(csscls=self.body_css)
|
||||||
valign='center',
|
b2.add_widget(Text(text=self.message or self.default_message,
|
||||||
))
|
i18n=True,
|
||||||
b.add_widget(b1)
|
wrap=True,
|
||||||
b2 = HBox(csscls=self.body_css)
|
halign='left',
|
||||||
b2.add_widget(Text(text=self.message or self.default_message,
|
size_hint=(1,1),
|
||||||
i18n=True,
|
font_size=CSize(1)))
|
||||||
wrap=True,
|
b.add_widget(b2)
|
||||||
halign='left',
|
self.add_widget(b)
|
||||||
size_hint=(1,1),
|
|
||||||
font_size=CSize(1)))
|
class Error(Message):
|
||||||
b.add_widget(b2)
|
default_title = 'Error'
|
||||||
self.add_widget(b)
|
default_message = 'Error message'
|
||||||
|
title_icon = StringProperty(blockImage('error.png'))
|
||||||
def on_size(self, *args):
|
title_css = StringProperty('error_default_title_css')
|
||||||
self.set_position()
|
|
||||||
try:
|
class Conform(Modal):
|
||||||
super().on_size(*args)
|
title = StringProperty(None)
|
||||||
except:
|
title_icon = StringProperty(None)
|
||||||
pass
|
message = StringProperty(None)
|
||||||
|
conform_icon = StringProperty(None)
|
||||||
def set_position(self):
|
cancel_icon = StringProperty(None)
|
||||||
# self.pos_hint = None, None
|
title_css = StringProperty('conform_default_title_css')
|
||||||
self.size_hint = None, None
|
body_css = StringProperty('conform_default_body_css')
|
||||||
self.width = CSize(self.width_c)
|
conform_css = StringProperty('conform_button_default_css')
|
||||||
self.height = CSize(self.height_c)
|
cancel_css = StringProperty('cancel_button_default_css')
|
||||||
xn = self.show_position[1]
|
def __init__(self, **kw):
|
||||||
yn = self.show_position[0]
|
super(Conform, self).__init__(**kw)
|
||||||
|
self.register_event_type('on_cancel')
|
||||||
if xn == 'l':
|
self.register_event_type('on_conform')
|
||||||
self.anchor_x = 'left'
|
self.auto_dismiss = False
|
||||||
elif xn == 'c':
|
b = VBox(csscls=self.title_css)
|
||||||
self.anchor_x = 'center'
|
b1 = HBox(size_hint_y=None, height=CSize(2))
|
||||||
else:
|
b1.add_widget(AsyncImage(source=self.title_icon or \
|
||||||
self.anchor_x = 'right'
|
blockImage('question.png'),
|
||||||
if yn == 't':
|
size_hint=[None,None],
|
||||||
self.anchor_y = 'top'
|
height=CSize(1.2),
|
||||||
elif yn == 'c':
|
width=CSize(1.2)))
|
||||||
self.anchor_y = 'center'
|
b1.add_widget(Text(otext=self.title or 'Conform',
|
||||||
else:
|
font_size=CSize(1.2),
|
||||||
self.anchor_y = 'bottom'
|
i18n=True,
|
||||||
|
wrap=True,
|
||||||
class Error(Message):
|
halign='left',
|
||||||
default_title = 'Error'
|
valign='center',
|
||||||
default_message = 'Error message'
|
))
|
||||||
title_icon = StringProperty(blockImage('error.png'))
|
b.add_widget(b1)
|
||||||
title_css = StringProperty('error_default_title_css')
|
b2 = HBox(csscls=self.body_css)
|
||||||
|
|
||||||
class Conform(Modal):
|
b2.add_widget(Text(text=self.message or 'Please conform',
|
||||||
title = StringProperty(None)
|
i18n=True,
|
||||||
title_icon = StringProperty(None)
|
wrap=True,
|
||||||
message = StringProperty(None)
|
halign='left',
|
||||||
conform_icon = StringProperty(None)
|
size_hint=(1,1),
|
||||||
cancel_icon = StringProperty(None)
|
font_size=CSize(1)))
|
||||||
title_css = StringProperty('conform_default_title_css')
|
b.add_widget(b2)
|
||||||
body_css = StringProperty('conform_default_body_css')
|
b3 = HBox(size_hint_y=None,
|
||||||
conform_css = StringProperty('conform_button_default_css')
|
height=CSize(2),
|
||||||
cancel_css = StringProperty('cancel_button_default_css')
|
csscls=self.body_css)
|
||||||
def __init__(self, **kw):
|
w_cancel = ClickableIconText(text='Cancel',
|
||||||
super(Conform, self).__init__(**kw)
|
source=self.cancel_icon or
|
||||||
self.register_event_type('on_cancel')
|
blockImage('cancel.png'),
|
||||||
self.register_event_type('on_conform')
|
img_kw={
|
||||||
self.auto_dismiss = False
|
"size_hint":[None, None],
|
||||||
b = VBox(csscls=self.title_css)
|
"height":CSize(1),
|
||||||
b1 = HBox(size_hint_y=None, height=CSize(2))
|
"width":CSize(1)
|
||||||
b1.add_widget(AsyncImage(source=self.title_icon or \
|
},
|
||||||
blockImage('question.png'),
|
csscls=self.cancel_css
|
||||||
size_hint=[None,None],
|
)
|
||||||
height=CSize(1.2),
|
w_conform = ClickableIconText(text='Conform',
|
||||||
width=CSize(1.2)))
|
source=self.conform_icon or
|
||||||
b1.add_widget(Text(otext=self.title or 'Conform',
|
blockImage('question.png'),
|
||||||
font_size=CSize(1.2),
|
img_kw={
|
||||||
i18n=True,
|
"size_hint":[None, None],
|
||||||
wrap=True,
|
"height":CSize(1),
|
||||||
halign='left',
|
"width":CSize(1)
|
||||||
valign='center',
|
},
|
||||||
))
|
csscls=self.conform_css
|
||||||
b.add_widget(b1)
|
)
|
||||||
b2 = HBox(csscls=self.body_css)
|
w_cancel.bind(on_press=self.cancel_press)
|
||||||
|
w_conform.bind(on_press=self.conform_press)
|
||||||
b2.add_widget(Text(text=self.message or 'Please conform',
|
|
||||||
i18n=True,
|
b3.add_widget(w_conform)
|
||||||
wrap=True,
|
b3.add_widget(w_cancel)
|
||||||
halign='left',
|
b.add_widget(b3)
|
||||||
size_hint=(1,1),
|
self.add_widget(b)
|
||||||
font_size=CSize(1)))
|
|
||||||
b.add_widget(b2)
|
def cancel_press(self,o, v=None):
|
||||||
b3 = HBox(size_hint_y=None,
|
self.dispatch('on_cancel')
|
||||||
height=CSize(2),
|
|
||||||
csscls=self.body_css)
|
def conform_press(self, o, v=None):
|
||||||
w_cancel = ClickableIconText(text='Cancel',
|
self.dispatch('on_conform')
|
||||||
source=self.cancel_icon or
|
|
||||||
blockImage('cancel.png'),
|
def on_cancel(self):
|
||||||
img_kw={
|
self.dismiss()
|
||||||
"size_hint":[None, None],
|
|
||||||
"height":CSize(1),
|
def on_conform(self):
|
||||||
"width":CSize(1)
|
self.dismiss()
|
||||||
},
|
|
||||||
csscls=self.cancel_css
|
|
||||||
)
|
|
||||||
w_conform = ClickableIconText(text='Conform',
|
|
||||||
source=self.conform_icon or
|
|
||||||
blockImage('question.png'),
|
|
||||||
img_kw={
|
|
||||||
"size_hint":[None, None],
|
|
||||||
"height":CSize(1),
|
|
||||||
"width":CSize(1)
|
|
||||||
},
|
|
||||||
csscls=self.conform_css
|
|
||||||
)
|
|
||||||
w_cancel.bind(on_press=self.cancel_press)
|
|
||||||
w_conform.bind(on_press=self.conform_press)
|
|
||||||
|
|
||||||
b3.add_widget(w_conform)
|
|
||||||
b3.add_widget(w_cancel)
|
|
||||||
b.add_widget(b3)
|
|
||||||
self.add_widget(b)
|
|
||||||
|
|
||||||
def cancel_press(self,o, v=None):
|
|
||||||
self.dispatch('on_cancel')
|
|
||||||
|
|
||||||
def conform_press(self, o, v=None):
|
|
||||||
self.dispatch('on_conform')
|
|
||||||
|
|
||||||
def on_cancel(self):
|
|
||||||
self.dismiss()
|
|
||||||
|
|
||||||
def on_conform(self):
|
|
||||||
self.dismiss()
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class ModalBehavior(object):
|
|||||||
else:
|
else:
|
||||||
self.pos = self._target.pos[0] + x, self._target.pos[1] + y
|
self.pos = self._target.pos[0] + x, self._target.pos[1] + y
|
||||||
Mx, My = Window.width, Window.height
|
Mx, My = Window.width, Window.height
|
||||||
self.pos_hint = {'x':x/Mx, 'y':y/My}
|
self.pos_hint = {'x':self.pos[0]/Mx, 'y':self.pos[1]/My}
|
||||||
print("modal",self._target.size, self.anchor, self.pos, self.size, self.size_hint)
|
print("modal",self._target.size, self.anchor, self.pos, self.size, self.size_hint)
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
|
@ -24,7 +24,7 @@ from .qrdata import QRCodeWidget
|
|||||||
# from .kivycamera import KivyCamera
|
# from .kivycamera import KivyCamera
|
||||||
from .filebrowser import FileLoaderBrowser
|
from .filebrowser import FileLoaderBrowser
|
||||||
from .mapview import MapView
|
from .mapview import MapView
|
||||||
from .message import Conform
|
from .message import Conform, Error, Message
|
||||||
from .pagepanel import PagePanel
|
from .pagepanel import PagePanel
|
||||||
from .markdown import Markdown
|
from .markdown import Markdown
|
||||||
# from .custom_camera import CustomCamera, QrReader
|
# from .custom_camera import CustomCamera, QrReader
|
||||||
@ -80,6 +80,8 @@ r('TextInput', TextInput)
|
|||||||
r('Markdown', Markdown)
|
r('Markdown', Markdown)
|
||||||
r('PagePanel', PagePanel)
|
r('PagePanel', PagePanel)
|
||||||
r('Conform', Conform)
|
r('Conform', Conform)
|
||||||
|
r('Message', Message)
|
||||||
|
r('Error', Error)
|
||||||
r('Popup', Popup)
|
r('Popup', Popup)
|
||||||
r('MapView', MapView)
|
r('MapView', MapView)
|
||||||
r('DataGrid',DataGrid)
|
r('DataGrid',DataGrid)
|
||||||
|
Loading…
Reference in New Issue
Block a user