如何在 Kivy 中使用 fileChooser 选择多个文件?
How do I get multiple file selected with fileChooser in Kivy?
.py:
class file(Popup):
load = ObjectProperty()
class file1(Screen):
file_path = StringProperty(None)
the_popup = ObjectProperty(None)
def select_to(self):
self.the_popup= file(load=self.load)
self.the_popup.open()
def load(self, selection):
pdf= FPDF()
self.file_path = str(selection[0])
self.the_popup.dismiss()
imgs=[]
imgs.append(self.file_path)
for image in imgs:
width, height= 0,0
pdf.add_page()
pdf.image(image,0,0,width,height)
pdf.save('name.pdf')
.kv
<file>
title: "Choose a .jpg File"
BoxLayout:
orientation:"vertical"
FileChooserIconView:
id:filechooser
multiselect: True
BoxLayout:
spacing: 20
Button:
text: "Cancel"
on_release: root.dismiss()
Button:
text: "Load"
on_release: root.load(filechooser.selection)
<file1>
BoxLayout:
orientation:'vertical'
Button:
on_release: root.select_to()
我有问题如何在一个 pdf 中使用多个图像 select?任何人都可以在此代码中提供帮助吗?
def load(self, selection):
pdf= FPDF()
self.file_path = str(selection[0])
self.the_popup.dismiss()
imgs=[]
imgs.append(self.file_path)
for image in selection:
width, height= 0,0
pdf.add_page()
pdf.image(image,0,0,width,height)
pdf.save('name.pdf')
.py:
class file(Popup):
load = ObjectProperty()
class file1(Screen):
file_path = StringProperty(None)
the_popup = ObjectProperty(None)
def select_to(self):
self.the_popup= file(load=self.load)
self.the_popup.open()
def load(self, selection):
pdf= FPDF()
self.file_path = str(selection[0])
self.the_popup.dismiss()
imgs=[]
imgs.append(self.file_path)
for image in imgs:
width, height= 0,0
pdf.add_page()
pdf.image(image,0,0,width,height)
pdf.save('name.pdf')
.kv
<file>
title: "Choose a .jpg File"
BoxLayout:
orientation:"vertical"
FileChooserIconView:
id:filechooser
multiselect: True
BoxLayout:
spacing: 20
Button:
text: "Cancel"
on_release: root.dismiss()
Button:
text: "Load"
on_release: root.load(filechooser.selection)
<file1>
BoxLayout:
orientation:'vertical'
Button:
on_release: root.select_to()
我有问题如何在一个 pdf 中使用多个图像 select?任何人都可以在此代码中提供帮助吗?
def load(self, selection):
pdf= FPDF()
self.file_path = str(selection[0])
self.the_popup.dismiss()
imgs=[]
imgs.append(self.file_path)
for image in selection:
width, height= 0,0
pdf.add_page()
pdf.image(image,0,0,width,height)
pdf.save('name.pdf')