bugfix
This commit is contained in:
parent
167ff968e3
commit
267ddcd92b
7
kivyblocks/download.py
Normal file
7
kivyblocks/download.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from kivy.properties import StringProperty
|
||||||
|
|
||||||
|
class DownloadFile(ClickableIconText):
|
||||||
|
def __init__(self, **kw):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
BIN
kivyblocks/imgs/download.png
Normal file
BIN
kivyblocks/imgs/download.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
BIN
kivyblocks/imgs/upload.png
Normal file
BIN
kivyblocks/imgs/upload.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
@ -191,7 +191,7 @@ class MarkdownBody(VBox):
|
|||||||
self.md_obj = md_obj
|
self.md_obj = md_obj
|
||||||
super().__init__(**kw)
|
super().__init__(**kw)
|
||||||
self.padding=padding
|
self.padding=padding
|
||||||
self.size_hint = None,None
|
self.size_hint = 1,None
|
||||||
self.bind(parent=self.resize)
|
self.bind(parent=self.resize)
|
||||||
self.resize()
|
self.resize()
|
||||||
|
|
||||||
@ -205,6 +205,7 @@ class MarkdownBody(VBox):
|
|||||||
f(v)
|
f(v)
|
||||||
|
|
||||||
def resize(self, *args):
|
def resize(self, *args):
|
||||||
|
return
|
||||||
Logger.info('MDBody:resize called')
|
Logger.info('MDBody:resize called')
|
||||||
if self.parent:
|
if self.parent:
|
||||||
ps = [0,0,0,0]
|
ps = [0,0,0,0]
|
||||||
|
@ -42,10 +42,12 @@ from .block_test import BlockTest
|
|||||||
from .hierarchy import Hierarchy
|
from .hierarchy import Hierarchy
|
||||||
from .price import PriceView
|
from .price import PriceView
|
||||||
from .ffpyplayer_video import FFVideo
|
from .ffpyplayer_video import FFVideo
|
||||||
|
from .upload import UploadFile
|
||||||
|
|
||||||
r = Factory.register
|
r = Factory.register
|
||||||
# if kivy.platform in ['win','linux', 'macosx']:
|
# if kivy.platform in ['win','linux', 'macosx']:
|
||||||
# r('ScreenWithMic', ScreenWithMic)
|
# r('ScreenWithMic', ScreenWithMic)
|
||||||
|
r('UploadFile', UploadFile)
|
||||||
r('FFVideo', FFVideo)
|
r('FFVideo', FFVideo)
|
||||||
r('AnchorBox', AnchorBox)
|
r('AnchorBox', AnchorBox)
|
||||||
r('FloatBox', FloatBox)
|
r('FloatBox', FloatBox)
|
||||||
|
57
kivyblocks/upload.py
Normal file
57
kivyblocks/upload.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import os
|
||||||
|
from kivy.properties import StringProperty, ListProperty
|
||||||
|
from kivyblocks.utils import blockImage, CSize
|
||||||
|
import requests
|
||||||
|
from plyer import filechooser
|
||||||
|
from .i18n import I18n
|
||||||
|
from .clickable import ClickableIconText
|
||||||
|
from .baseWidget import Running
|
||||||
|
from .message import Error
|
||||||
|
|
||||||
|
class UploadFile(ClickableIconText):
|
||||||
|
upload_url = StringProperty(None)
|
||||||
|
name = StringProperty('upfile')
|
||||||
|
# suffixes = ListProperty([])
|
||||||
|
def __init__(self, **kw):
|
||||||
|
super().__init__(**kw)
|
||||||
|
self.otext = 'please select file'
|
||||||
|
self.img_kw = {
|
||||||
|
"size_hint":[None, None],
|
||||||
|
"width":CSize(1),
|
||||||
|
"height":CSize(1)
|
||||||
|
}
|
||||||
|
self.source = blockImage('upload.png')
|
||||||
|
self.file_url = None
|
||||||
|
self.running = None
|
||||||
|
|
||||||
|
def getValue(self):
|
||||||
|
return {
|
||||||
|
self.name:self.file_url
|
||||||
|
}
|
||||||
|
|
||||||
|
def on_press(self, *args):
|
||||||
|
i18n = I18n()
|
||||||
|
filechooser.open_file(title=i18n('open file'),
|
||||||
|
on_selection=self.file_selected)
|
||||||
|
|
||||||
|
def file_selected(self, files):
|
||||||
|
running = Running(self)
|
||||||
|
def readfile(f):
|
||||||
|
with open(f, 'rb') as o:
|
||||||
|
d = o.read(102400)
|
||||||
|
if not d:
|
||||||
|
return
|
||||||
|
yield d
|
||||||
|
fpath = files[0]
|
||||||
|
fn = os.path.basename(fpath)
|
||||||
|
print('fn=', fn)
|
||||||
|
headers={
|
||||||
|
'Content-Type': 'application/octet-stream',
|
||||||
|
'Content-Disposition':'attachments;filename={}'.format(fn)
|
||||||
|
}
|
||||||
|
r = requests.post(self.upload_url,
|
||||||
|
data=readfile(files[0]),
|
||||||
|
headers=headers
|
||||||
|
)
|
||||||
|
running.dismiss()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user