This commit is contained in:
yumoqing 2023-10-09 13:52:30 +08:00
parent 263636779b
commit 9e60443e79
249 changed files with 698 additions and 678 deletions

0
README.md Normal file → Executable file
View File

0
docs/blocks.md Normal file → Executable file
View File

0
docs/changelog.md Normal file → Executable file
View File

0
docs/cn/binds.md Normal file → Executable file
View File

0
docs/cn/cdf.md Normal file → Executable file
View File

0
docs/cn/index.md Normal file → Executable file
View File

0
docs/cn/intro.md Normal file → Executable file
View File

0
docs/en/box.md Normal file → Executable file
View File

0
docs/imgs/hello_window.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
github-speed-up.md Normal file → Executable file
View File

0
kivyblocks/__init__.py Normal file → Executable file
View File

0
kivyblocks/android_rotation.py Normal file → Executable file
View File

0
kivyblocks/anz/__init__.py Normal file → Executable file
View File

0
kivyblocks/anz/bluetooth.py Normal file → Executable file
View File

0
kivyblocks/aplayer.py Normal file → Executable file
View File

0
kivyblocks/backendfunction.py Normal file → Executable file
View File

21
kivyblocks/baseWidget.py Normal file → Executable file
View File

@ -75,7 +75,7 @@ from .threadcall import HttpClient
from .i18n import I18n
from .widget_css import WidgetCSS
from .ready import WidgetReady
from .utils import CSize, SUPER
from .utils import CSize
from .swipebehavior import SwipeBehavior
from .widgetExt.inputext import MyDropDown
@ -140,7 +140,7 @@ def ScatterBox(WidgetCSS, WidgetReady, ScatterLayout):
class Box(WidgetCSS, WidgetReady, BoxLayout):
def __init__(self, **kw):
try:
SUPER(Box, self, kw)
super(Box, self).__init__(**kw)
except Exception as e:
print('Box(',kw,') Error')
raise e
@ -157,9 +157,7 @@ class VBox(Box):
Box.__init__(self, **kw)
class SwipeBox(SwipeBehavior, Box):
def __init__(self, **kw):
SUPER(SwipeBox, self, kw)
pass
class Text(Label):
lang=StringProperty('')
@ -182,7 +180,7 @@ class Text(Label):
if not kwargs.get('text'):
kwargs['text'] = kwargs.get('otext','')
SUPER(Text, self, kwargs)
super(Text, self).__init__(**kwargs)
if self._i18n:
self.i18n.addI18nWidget(self)
if self.wrap:
@ -277,6 +275,7 @@ class Modal(VBox):
self._target = None
super(Modal, self).__init__(**kw)
self.set_size_position()
print('size_hint=', self.size_hint, kw)
self._target.bind(size=self.set_size_position)
self.register_event_type('on_open')
self.register_event_type('on_pre_open')
@ -299,7 +298,7 @@ class Modal(VBox):
return super().on_touch_down(touch)
def on_target(self):
def on_target(self, o, target):
w = Window
if self.target is not None:
w = Factory.Blocks.getWidgetById(self.target)
@ -324,9 +323,9 @@ class Modal(VBox):
self.width = self.size_hint_x * self._target.width
if self.size_hint_y:
self.height = self.size_hint_y * self._target.height
print(self.width, self.height,
self.size_hint_x, self.size_hint_y,
self._target.size
print("size with target:", self.width, self.height,
self.size_hint, self.size_hint,
"target size=", self._target.size
)
self.set_modal_position()
@ -392,7 +391,7 @@ class TimedModal(Modal):
show_time = NumericProperty(0)
def __init__(self, **kw):
self.time_task = None
SUPER(TimedModal, self, kw)
super(TimedModal, self).__init__(**kw)
def open(self, *args, **kw):
if self.time_task is not None:

0
kivyblocks/bgcolorbehavior.py Normal file → Executable file
View File

0
kivyblocks/block_test.py Normal file → Executable file
View File

2
kivyblocks/blocks.py Normal file → Executable file
View File

@ -204,7 +204,7 @@ x = ClassX{klass_cnt}()
return None
if url.startswith('file://'):
return self.script.dispatch(url, **params)
return self.script.dispatch(url, params)
elif url.startswith('http://') or url.startswith('https://'):
try:
hc = HttpClient()

18
kivyblocks/blocksapp.py Normal file → Executable file
View File

@ -60,10 +60,13 @@ class BlocksApp(App):
with codecs.open(config.css.css_filename, 'r', 'utf-8') as f:
d = json.load(f)
self.buildCsses(d)
try:
if config.css.css_url:
hc = HttpClient()
d = hc.get(self.realurl(config.css.css_url))
self.buildCsses(d)
except:
pass
def on_rotate(self,*largs):
self.current_rotation = Window.rotation
@ -76,10 +79,19 @@ class BlocksApp(App):
register_css(k,v)
def build(self):
config = getConfig()
self.workers = Workers(maxworkers=config.maxworkers or 80)
self.workers.start()
try:
i18n = I18n()
except:
i18n = None
self.platform = platform
self.is_desktop = platform in ['win', 'linux', 'macosx']
config = getConfig()
self.default_params = {}
if config.default_params:
self.default_params.update(config.default_params)
self.public_headers = {
"platform":self.platform
}
@ -88,8 +100,6 @@ class BlocksApp(App):
Window.bind(on_request_close=self.on_close)
Window.bind(on_rotate=self.on_rotate)
Window.bind(size=self.device_info)
self.workers = Workers(maxworkers=config.maxworkers or 80)
self.workers.start()
self.load_csses()
self.running = True
if config.root:
@ -163,7 +173,7 @@ class BlocksApp(App):
}
self.public_headers.update(device)
def on_close(self, *args):
def on_close(self, *args, **kwargs):
self.workers.running = False
return False

0
kivyblocks/boxViewer.py Normal file → Executable file
View File

0
kivyblocks/circle_progress.py Normal file → Executable file
View File

0
kivyblocks/clickable.py Normal file → Executable file
View File

0
kivyblocks/color_definitions.py Normal file → Executable file
View File

0
kivyblocks/colorcalc.py Normal file → Executable file
View File

0
kivyblocks/command_action.py Normal file → Executable file
View File

0
kivyblocks/dataloader.py Normal file → Executable file
View File

0
kivyblocks/date_picker.py Normal file → Executable file
View File

0
kivyblocks/dateinput.py Normal file → Executable file
View File

0
kivyblocks/defaultimage.py Normal file → Executable file
View File

66
kivyblocks/dg.py Normal file → Executable file
View File

@ -25,7 +25,7 @@ from appPublic.uniqueID import getID
from appPublic.myTE import string_template_render
from .utils import *
from .baseWidget import Text, HBox, VBox, Running
from .baseWidget import Text, HBox, VBox
from .scrollpanel import ScrollPanel
from .paging import Paging, RelatedLoader
from .ready import WidgetReady
@ -56,17 +56,19 @@ class Cell(ButtonBehavior, WidgetCSS, BoxLayout):
"""
self.desc = desc
self.row = row
self.part = self.row.part
self.datagrid = self.part.datagrid
super().__init__(size_hint=(None,None),
width = self.desc['width'],
width = self.desc['width']
height = self.row.part.datagrid.rowHeight()
print(f'Cell:{width=}, {height=},value={desc["value"]}')
super().__init__(size_hint=(None,None),
width=width,
bgcolor=[0.1,0.5,0.5],
height=height
)
self.csscls=self.row.part.datagrid.row_normal_css
if self.row.header:
self.csscls=self.row.part.datagrid.header_css
if desc['header']:
bl = Text(i18n=True, otext=str(desc['value']),
bl = Text(i18n=True, text=str(desc['value']),
font_size=CSize(1),wrap=True,
halign='left', valign='middle'
)
@ -74,14 +76,6 @@ class Cell(ButtonBehavior, WidgetCSS, BoxLayout):
else:
self.cell_type = 'data'
bl = UiFactory.build_view_widget(desc,self.row.row_data)
if self.row.header and desc['name'] == '_checkable_action_':
id = self.row.row_data[idfield]
if self.row.part.datagrid.is_checked(id):
bl.setValue(True)
else:
bl.setValue(False)
bl.bind(select_state=self.row.checkable_action)
self.colume_name = desc['name']
if bl:
self.add_widget(bl)
@ -99,7 +93,6 @@ class Row(BoxLayout):
"""
self.part = part
self.datagrid = self.part.datagrid
self.header = header
self.row_data = data
self.row_id = None
@ -114,9 +107,6 @@ class Row(BoxLayout):
self.height = self.part.datagrid.rowHeight()
self.init(0)
def checkable_action(self, o, *args):
self.datagrid.set_checked_rows(self.row_id, o.select_state)
def on_row_press(self, *args):
pass
@ -162,6 +152,7 @@ class Header(WidgetReady, ScrollPanel):
for i,f in enumerate(rd) ]
self.header = Row(self.part,rd,header=True)
self.add_widget(self.header)
self.size_hint_y = None
self.height = self.header.height
class Body(WidgetReady, ScrollPanel):
@ -182,6 +173,7 @@ class Body(WidgetReady, ScrollPanel):
row.row_id = id
self.add_widget(row,index=index)
self.idRow[id] = row
print(f'row size={row.size}, hint={row.size_hint}')
return row
def clearRows(self):
@ -327,7 +319,6 @@ class DataGrid(VBox):
]
}
"""
checkable = BooleanProperty(False)
row_selected = BooleanProperty(False)
row_normal_css = StringProperty('default')
row_selected_css = StringProperty('default')
@ -341,16 +332,6 @@ class DataGrid(VBox):
fields = ListProperty(None)
tailer = DictProperty(None)
def __init__(self,**options):
if self.checkable:
self.fields.insert(0, {
"name":"_checkable_action_",
"label":" ",
"type":"checkbox",
"width":CSize(2),
"freeze_flag":True
})
self.checked_rows = []
self.select_rowid = None
self.rowheight = None
self.on_sizeTask = None
@ -388,16 +369,11 @@ class DataGrid(VBox):
self.tailer_widgets = {}
self.build_tailer(self.tailer)
def set_checked_rows(self, rowid, flag):
if flag and rowid not in self.checked_ids:
self.checked_ids.append(rowid)
if not flag:
self.checked_ids = [ id for id in self.checked_ids if id !=rowid]
def on_rowpress(self, *args):
print('on_rowpress fire, args=', args)
def on_cellpress(self, *args):
print('on_cesspress fire, args=', args)
print('on_cellpress fire, args=', args)
def on_headerpress(self, *args):
print('on_headerpress fire, args=', args)
@ -462,7 +438,7 @@ class DataGrid(VBox):
desc = {
"widgettype":"Text",
"options":{
"otext":n,
"text":n,
"i18n":True,
}
}
@ -596,6 +572,7 @@ class DataGrid(VBox):
self.delRow(id)
def addRow(self,data, **kw):
# print('addRow()', data)
id = getID()
f_row = None
if self.freeze_part:
@ -639,6 +616,23 @@ class DataGrid(VBox):
fs.append(f)
return fs
def show_size(self, *args, **kw):
print(f'dg:{self.size}')
print(f'normal_part:{self.normal_part.size}')
print(f'body:{self.normal_part.body.size}')
print(f'row:{self.normal_part.body.children[0].size}')
print(f'row:{self.normal_part.body.children[0].size}')
sp = self.normal_part.body.children[0]
print(f'rows={len(sp.children) - 1}')
for i, r in enumerate(sp.children):
print(f'{i} {r.size=}')
if self.normal_part.parent.parent == self:
print('part ok')
else:
print('part parent=', self.normal_part.parent)
if self.normal_part.body.parent == self.normal_part:
print('body ok')
def get_selected_data(self):
if not self.selected_rowid:
return {}

0
kivyblocks/download.py Normal file → Executable file
View File

0
kivyblocks/externalwidgetmanager.py Normal file → Executable file
View File

0
kivyblocks/ffpyplayer_video.py Normal file → Executable file
View File

0
kivyblocks/filebrowser.py Normal file → Executable file
View File

1
kivyblocks/form.py Normal file → Executable file
View File

@ -32,6 +32,7 @@ form options
"method"
}
"cols":"1"
"inputwidth",
"labelwidth":
"textsize":
"inputheight":

0
kivyblocks/gps.py Normal file → Executable file
View File

0
kivyblocks/hack_ffpyplayer.py Normal file → Executable file
View File

0
kivyblocks/hierarchy.py Normal file → Executable file
View File

0
kivyblocks/hostimage.py Normal file → Executable file
View File

0
kivyblocks/httpvplayer.py Normal file → Executable file
View File

0
kivyblocks/i18n.py Normal file → Executable file
View File

BIN
kivyblocks/imgs/.DS_Store vendored Normal file → Executable file

Binary file not shown.

0
kivyblocks/imgs/Mute64x64.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

0
kivyblocks/imgs/Play64X64.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

0
kivyblocks/imgs/Sound64x64.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

0
kivyblocks/imgs/backword.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

0
kivyblocks/imgs/broken.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

0
kivyblocks/imgs/bullet_arrow_down.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

0
kivyblocks/imgs/bullet_arrow_right.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 315 B

0
kivyblocks/imgs/cancel.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

0
kivyblocks/imgs/checkbox-off.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

0
kivyblocks/imgs/checkbox-on.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

0
kivyblocks/imgs/clear.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 108 KiB

0
kivyblocks/imgs/conform.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

0
kivyblocks/imgs/crud_add.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

0
kivyblocks/imgs/crud_browser.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

0
kivyblocks/imgs/crud_del.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

0
kivyblocks/imgs/crud_edit.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

0
kivyblocks/imgs/crud_filter.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
kivyblocks/imgs/delete.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
kivyblocks/imgs/doing.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 171 KiB

0
kivyblocks/imgs/download.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

0
kivyblocks/imgs/error.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

0
kivyblocks/imgs/folder.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 537 B

0
kivyblocks/imgs/icon_view.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

0
kivyblocks/imgs/info.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

0
kivyblocks/imgs/kivymd_512.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

0
kivyblocks/imgs/kivymd_logo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

0
kivyblocks/imgs/list_view.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

0
kivyblocks/imgs/loading.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

0
kivyblocks/imgs/loading1.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

0
kivyblocks/imgs/menu.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
kivyblocks/imgs/musictrack.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

0
kivyblocks/imgs/musictrack_d.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

0
kivyblocks/imgs/next.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

0
kivyblocks/imgs/next_d.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
kivyblocks/imgs/org_sound.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

0
kivyblocks/imgs/org_sound_d.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

0
kivyblocks/imgs/origin.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

0
kivyblocks/imgs/pause.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

0
kivyblocks/imgs/pause_d.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

0
kivyblocks/imgs/photo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
kivyblocks/imgs/picture_empty.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 463 B

After

Width:  |  Height:  |  Size: 463 B

0
kivyblocks/imgs/play.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

0
kivyblocks/imgs/play_d.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
kivyblocks/imgs/power64x64.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

0
kivyblocks/imgs/previous.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

0
kivyblocks/imgs/quad_shadow-0.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

0
kivyblocks/imgs/quad_shadow-1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

0
kivyblocks/imgs/quad_shadow-2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

0
kivyblocks/imgs/quad_shadow.atlas Normal file → Executable file
View File

0
kivyblocks/imgs/question.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

0
kivyblocks/imgs/rec_shadow-0.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

0
kivyblocks/imgs/rec_shadow-1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

0
kivyblocks/imgs/rec_shadow.atlas Normal file → Executable file
View File

0
kivyblocks/imgs/rec_st_shadow-0.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

0
kivyblocks/imgs/rec_st_shadow-1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

0
kivyblocks/imgs/rec_st_shadow-2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Some files were not shown because too many files have changed in this diff Show More