Chaosbuffalolabs Project,, add FileChooser for csv files?

30 views
Skip to first unread message

gamzenurg...@gmail.com

unread,
Aug 5, 2017, 6:46:22 AM8/5/17
to Kivy users support
This project is drawing according to sample_data_1.csv and sample_data_2.csv files. 

Project:  https://github.com/chaosbuffalolabs/kivy-plotter/blob/master/main.py


Can I select the csv file using Filechooser?

Please help me for code editing.

ZenCODE

unread,
Aug 6, 2017, 4:04:10 AM8/6/17
to Kivy users support
Yes, you can. Please see the examples here:

     https://kivy.org/docs/api-kivy.uix.filechooser.html

We can't really do it for you, but we do want to help. Please try, then post what you struggle with, ideally giving a minimal example which exhibits the problem you are having.

Peace
Message has been deleted

gamzenurg...@gmail.com

unread,
Aug 7, 2017, 1:36:53 PM8/7/17
to Kivy users support
Hello,

First I found your project before I tried it.  https://gist.github.com/Zen-CODE/63749afae7faf70a0de419f9e5f76360

I tried to write the word in the selected text file to the page. Where am I making mistake?


import kivy

from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import ObjectProperty, ListProperty
from kivy.uix.popup import Popup
from kivy.lang import Builder
import os

Builder.load_string(
"""

<MainScreen>:
BoxLayout:
orientation: 'vertical'
BoxLayout:
size_hint_y: None
height: 30

Button:
text: 'Choose Source'
on_release: root.load_source()

Label:
id: _selection
text: "Word in selected text file""
size_hint_y: .5
canvas.before:
Color:
rgb: .5,.5,.4
Rectangle:
pos: self.pos
size: self.size

Button:
text: 'GO'
on_release: root.GetFolderName()

<LoadDialog>:
BoxLayout:
size: root.size
pos: root.pos
orientation: "vertical"

FileChooserListView:
path: '/volumes'
dirselect: True
id: filechooser
filter: ['*.mov']
multiselect: True

BoxLayout:
size_hint_y: None
height: 30

Button
text: "Cancel"
on_release: root.close(None)

Button
text: "Select"
on_release: root.close(filechooser.selection)
""")


class LoadDialog(FloatLayout):

selection = None
''' Holds a list of the file items return by the file chooser, None
otherwise.
'''

cancel = ObjectProperty(None)

def close(self, selection):
""" Close the dialog. The selected is boolean indicating acceptance or
cancellation. """
if selection is not None:
self.selection = selection
print "Select {0}".format(self.selection)
self.cancel()


class MainScreen(FloatLayout):
def dismiss_popup(self):
self._popup.dismiss()
if self.content.selection is not None:
self.ids._selection.text = str(self.text_input.text.selection)


def load_source(self):
self.content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
self._popup = Popup(title="Select Source Folder",
content=self.content,
size_hint=(0.9, 0.9))
self._popup.open()

def load(self, path, filename):
with open(os.path.join(path, filename[0])) as stream:
self.text_input.text = stream.read()
self.dismiss_popup()

################## I'd like to do a few python things with this but Can't figure out how to get variables from the dialog in Kivy to bind with this#########################
def GetFolderName(self, *args):
y = "name of chosen folder"
print y




class FootageImport(App):
def build(self):
return MainScreen()

if __name__ == "__main__":
FootageImport().run()



6 Ağustos 2017 Pazar 11:04:10 UTC+3 tarihinde ZenCODE yazdı:

ZenCODE

unread,
Aug 7, 2017, 2:03:11 PM8/7/17
to kivy-...@googlegroups.com
Firstly:


            text: "Word in selected text file""

needs to be

            text: "Word in selected text file"

Then there is no id called 'selection' or any id called 'text_input'. So this code is not really usable. I would suggest starting with something less ambitious. Start with a basic FileChooser, creating it, and getting values back from that as shown in the examples. Once you can do that, extending it to your needs should be simple, but there are too many issues with this code to offer simple advice. Get back to basics. Once that is done and dusted, you can post code that is runnable, so we are much more able to help.

Gamzenur Güleryüz

unread,
Aug 7, 2017, 3:50:15 PM8/7/17
to kivy-...@googlegroups.com
Im start with a basic FileChooser.It's okay to understand the basics. You transferred the selected file path to the screen. It is difficult to read inside the text file and print it on the screen. I have a problem with id called 'text_input'. Please help in the kv file part.

2017-08-07 21:03 GMT+03:00 ZenCODE <zenkey....@gmail.com>:
Firstly:

            text: "Word in selected text file""

needs to be

            text: "Word in selected text file"

Then there is no id called 'selection' or any id called 'text_input'. So this code is not really usable. I would suggest starting with something less ambitious. Start with a basic FileChooser, creating it, and getting values back from that as shown in the examples. Once you can do that, extending it to your needs should be simple, but there are too many issues with this code to offer simple advice. Get back to basics. Once that done and dusted, you can post code is runnable, so we are much more able to help.

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/ImbmFdnfZt4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages