This commit is contained in:
yumoqing 2022-11-26 15:16:43 +08:00
parent ef5c160c40
commit 2532efa9f2
4 changed files with 178 additions and 205 deletions

View File

@ -343,7 +343,7 @@ class Modal(VBox):
x = 0
if yn == 'c':
y = (self._target.height - self.height) / 2
elif yn == 't':
elif yn == 'b':
y = self._target.height - self.height
if y < 0:
y = 0
@ -351,6 +351,9 @@ class Modal(VBox):
self.pos = x, y
else:
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):
if self.parent:

View File

@ -53,12 +53,8 @@ class Message(TimedModal):
show_position = OptionProperty('br', options=['tl','tc','tr',
'cl','cc','cr',
'bl','bc','br'])
width_c = NumericProperty(15)
height_c = NumericProperty(6)
def __init__(self, **kw):
SUPER(Message, self, kw)
self.size_hint = None, None
self.set_position()
b = VBox(csscls=self.title_css)
b1 = HBox(size_hint_y=None, height=CSize(2))
b1.add_widget(AsyncImage(source=self.title_icon,
@ -83,34 +79,6 @@ class Message(TimedModal):
b.add_widget(b2)
self.add_widget(b)
def on_size(self, *args):
self.set_position()
try:
super().on_size(*args)
except:
pass
def set_position(self):
# self.pos_hint = None, None
self.size_hint = None, None
self.width = CSize(self.width_c)
self.height = CSize(self.height_c)
xn = self.show_position[1]
yn = self.show_position[0]
if xn == 'l':
self.anchor_x = 'left'
elif xn == 'c':
self.anchor_x = 'center'
else:
self.anchor_x = 'right'
if yn == 't':
self.anchor_y = 'top'
elif yn == 'c':
self.anchor_y = 'center'
else:
self.anchor_y = 'bottom'
class Error(Message):
default_title = 'Error'
default_message = 'Error message'

View File

@ -78,7 +78,7 @@ class ModalBehavior(object):
else:
self.pos = self._target.pos[0] + x, self._target.pos[1] + y
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)
def open(self):

View File

@ -24,7 +24,7 @@ from .qrdata import QRCodeWidget
# from .kivycamera import KivyCamera
from .filebrowser import FileLoaderBrowser
from .mapview import MapView
from .message import Conform
from .message import Conform, Error, Message
from .pagepanel import PagePanel
from .markdown import Markdown
# from .custom_camera import CustomCamera, QrReader
@ -80,6 +80,8 @@ r('TextInput', TextInput)
r('Markdown', Markdown)
r('PagePanel', PagePanel)
r('Conform', Conform)
r('Message', Message)
r('Error', Error)
r('Popup', Popup)
r('MapView', MapView)
r('DataGrid',DataGrid)