How to show the file name, path, details of document on a Label or RstDocument??

666 views
Skip to first unread message

Nightslayer Neptune

unread,
Jun 27, 2019, 1:54:35 PM6/27/19
to Kivy users support
in this python code, the previous version is without the red part. And I can successfully diplay the path and details of the documents in the terminal
However, once I tried to add the red part and want those info to show on my Kivy screen. The Kivy shut down automatically.

This is wt it show in terminal before it shut down.
kivy.lang.builder.BuilderException: Parser: File "<inline>", line 15:
 ...
      13:        text: fi.read()
      14:    RstDocument:
 >>   15:        text: "selected: %s" % filename[0]
 ...
 BuilderException: Parser: File "<inline>", line 15:
 ...
      13:        text: fi.read()
      14:    RstDocument:
 >>   15:        text: "selected: %s" % filename[0]
 ...
 NameError: name 'filename' is not defined
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 249, in create_handler
     return eval(value, idmap), bound_list
   File "<string>", line 15, in <module>
 
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 692, in _apply_rule
     rctx['ids'])
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 254, in create_handler
     cause=tb)


here is the python file:
  1 import kivy
  2
  3 from kivy.app import App
  4 from kivy.uix.boxlayout import BoxLayout
  5 from kivy.lang import Builder
  6
  7 import os
  8
  9 Builder.load_string("""
 10 <MyWidget>:
 11     id: my_widget
 12     Button
 13         text: "open"
 14         on_release: my_widget.open(filechooser.path, filechooser.selection)
 15     FileChooserListView:
 16         id: filechooser
 17         on_selection: my_widget.selected(filechooser.selection)
 18     Label:
 19         text: ''
 20     RstDocument
 21         text: fi.read()
 22     RstDocument:
 23         text: "selected: %s" % filename[0]

 24 """)
 25
 26 class MyWidget(BoxLayout):
 27     def open(self, path, filename):
 28         with open(os.path.join(path, filename[0])) as fi:
 29             print (fi.read())
 30
 31     def selected(self, filename):
 32         print ("selected: %s" % filename[0])
 33
 34
 35 class MyApp(App):
 36     def build(self):
 37         return MyWidget()
 38
 39 if __name__ == '__main__':
 40     MyApp().run()
~                                

Elliot Garbus

unread,
Jun 27, 2019, 2:03:39 PM6/27/19
to kivy-...@googlegroups.com

Assuming you want to print:

 

Selected: myfilename

 

Replace:  "selected: %s" % filename[0]  with : ‘selected: ‘ + filename[0]

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/1718bdc4-62de-44fd-93b3-079da270d2e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Nightslayer Neptune

unread,
Jun 27, 2019, 2:35:16 PM6/27/19
to Kivy users support
I can print that in the terminal with that code, just without the red part.
When i change to urs,  same thing is still happening 

Elliot Garbus於 2019年6月27日星期四 UTC-4下午2時03分39秒寫道:

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
Jun 27, 2019, 3:18:08 PM6/27/19
to kivy-...@googlegroups.com
Did you want filechooser.selection[0]


Sent from my iPhone
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 27, 2019, 3:35:59 PM6/27/19
to Kivy users support
you can change the whole code if u want, just want it to be functionable.
What I want is the test of the label is the path and the name of the file.
and i can show the whole file in the RstDocument

Elliot Garbus於 2019年6月27日星期四 UTC-4下午3時18分08秒寫道:

Elliot Garbus

unread,
Jun 27, 2019, 4:12:55 PM6/27/19
to kivy-...@googlegroups.com
Attach your code, it will be easier to see your issue. 

Sent from my iPhone
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 27, 2019, 4:17:33 PM6/27/19
to Kivy users support
 import kivy
  2
  3 from kivy.app import App
  4 from kivy.uix.boxlayout import BoxLayout
  5 from kivy.lang import Builder
  6
  7 import os
  8
  9 Builder.load_string("""
 10 <MyWidget>:
 11     id: my_widget
 12     Button
 13         text: "open"
 14         on_release: my_widget.open(filechooser.path, filechooser.selection)
 15     FileChooserListView:
 16         id: filechooser
 17         on_selection: my_widget.selected(filechooser.selection)
 18     Label:
 19         text: '' #this is for showing the name of the document
 20     TextInput:
 21         text: details #this is for the details of the document
 22     TextInput:
 23         text: path  #this is the path of it

 24 """)
 25
 26 class MyWidget(BoxLayout):
 27     def open(self, path, filename):
 28         with open(os.path.join(path, filename[0])) as fi:
 29             print (fi.read())
 30             details = fi.read()
 31
 32     def selected(self, filename):
 33         print ('selected:' + filename[0])
 34         path = 'selected:' + filename[0]
 35
 36
 37 class MyApp(App):
 38     def build(self):
 39         return MyWidget()
 40
 41 if __name__ == '__main__':
 42     MyApp().run()

Elliot Garbus

unread,
Jun 27, 2019, 9:19:38 PM6/27/19
to kivy-...@googlegroups.com

Please attach the files, so I don’t need to edit the code to run it. 

 

From: Nightslayer Neptune
Sent: Thursday, June 27, 2019 1:19 PM
To: Kivy users support

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 27, 2019, 9:28:13 PM6/27/19
to Kivy users support
Here is my code

Elliot Garbus於 2019年6月27日星期四 UTC-4下午9時19分38秒寫道:

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

path.py

Elliot Garbus

unread,
Jun 27, 2019, 10:37:06 PM6/27/19
to kivy-...@googlegroups.com

Let me know if you have any questions:

 

A few comments:

I made details a StringProperty.  Kivy Properties are special and create events when they change.  It is relatively easy to share the data between kivy and python using properties.  Another interesting point, while it looks like details is a class variable, it is in fact an instance variable.

 

I used the pathlib library to separate the file name and the path, this is a part of the python standard lib.

#: import pathlib pathlib imports the library so I can use it on the right side of the KV expressions.

 

The filechooser returns a list of all of the selected files.  I used the id fc to avoid some typing.  The first is fc.selection[0] it is the first file selected, if multi-select is not enabled, it is the only file selected.

 

The file and path displays both use the following logic:

text: 'File: ' + ('<None>' if not fc.selection else pathlib.Path(fc.selection[0]).name)

This is done so if there is nothing in the list <None> is displayed, you could use ‘ ‘, or anything else.  If you don’t do something like this the app will crash because the there is nothing in the list.

 

I accessed methods and variables that are defined in the MyWidget class in python as ‘root.’ In KV.  Root is a special name for accessing the class members.  

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.


To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

path.py

Nightslayer Neptune

unread,
Jun 28, 2019, 11:12:31 AM6/28/19
to Kivy users support
How about if I change it to sth like this
when I try to run the code. There has a Kivy window that have a browse button(for open a popup window for browing file), a label (for the name of browsed document), a rstdocument (for the details of it) and a label (for the path of it).
After I clicked the browse, it open a popup window for me to browse doc. after i click to open button, it close the popup and show all of those stuff in the first window.

Elliot Garbus於 2019年6月27日星期四 UTC-4下午10時37分06秒寫道:
path3.py

Elliot Garbus

unread,
Jun 28, 2019, 12:30:50 PM6/28/19
to kivy-...@googlegroups.com
Do you have a specific question?
You can certainly create what you have described. 

Sent from my iPhone
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

For more options, visit https://groups.google.com/d/optout.
<path3.py>

Nightslayer Neptune

unread,
Jun 28, 2019, 1:26:58 PM6/28/19
to Kivy users support
What it said when i tried to run the code.
Unable to find any valuable Cutbuffer provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
xclip - FileNotFoundError: [Errno 2] No such file or directory: 'xclip': 'xclip'
  File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/core/__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/core/clipboard/clipboard_xclip.py", line 17, in <module>
    p = subprocess.Popen(['xclip', '-version'], stdout=subprocess.PIPE)
  File "/home/user1/.conda/envs/kivy/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/home/user1/.conda/envs/kivy/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)

xsel - FileNotFoundError: [Errno 2] No such file or directory: 'xsel': 'xsel'
  File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/core/__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/core/clipboard/clipboard_xsel.py", line 16, in <module>
    p = subprocess.Popen(['xsel'], stdout=subprocess.PIPE)
  File "/home/user1/.conda/envs/kivy/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/home/user1/.conda/envs/kivy/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)

 Traceback (most recent call last):

   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 249, in create_handler
     return eval(value, idmap), bound_list
   File "<string>", line 23, in <module>
 NameError: name 'fc' is not defined
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):

   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 692, in _apply_rule
     rctx['ids'])
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 254, in create_handler
     cause=tb)
 kivy.lang.builder.BuilderException: Parser: File "<inline>", line 23:
 ...
      21:                text: 'File: ' + ('<None>' if not fc.selection else pathlib.Path(fc.selection[0]).name)
      22:            TextInput:
 >>   23:                text: 'Path: ' + ('<None>' if not fc.selection else str(pathlib.Path(fc.selection[0]).parent))
      24:        TextInput:
      25:            text: root.details #this is for the details of the document
 ...
 NameError: name 'fc' is not defined

   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 249, in create_handler
     return eval(value, idmap), bound_list
   File "<string>", line 23, in <module>
 
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "path3.py", line 67, in <module>
     MyApp().run()
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/app.py", line 829, in run
     root = self.build()
   File "path3.py", line 63, in build
     return MyWidget()
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/uix/boxlayout.py", line 145, in __init__
     super(BoxLayout, self).__init__(**kwargs)
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/uix/layout.py", line 76, in __init__
     super(Layout, self).__init__(**kwargs)
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/uix/widget.py", line 361, in __init__
     rule_children=rule_children)
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/uix/widget.py", line 469, in apply_class_lang_rules
     rule_children=rule_children)
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 538, in apply
     rule_children=rule_children)
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 707, in _apply_rule
     e), cause=tb)
 kivy.lang.builder.BuilderException: Parser: File "<inline>", line 23:
 ...
      21:                text: 'File: ' + ('<None>' if not fc.selection else pathlib.Path(fc.selection[0]).name)
      22:            TextInput:
 >>   23:                text: 'Path: ' + ('<None>' if not fc.selection else str(pathlib.Path(fc.selection[0]).parent))
      24:        TextInput:
      25:            text: root.details #this is for the details of the document
 ...
 BuilderException: Parser: File "<inline>", line 23:
 ...
      21:                text: 'File: ' + ('<None>' if not fc.selection else pathlib.Path(fc.selection[0]).name)
      22:            TextInput:
 >>   23:                text: 'Path: ' + ('<None>' if not fc.selection else str(pathlib.Path(fc.selection[0]).parent))
      24:        TextInput:
      25:            text: root.details #this is for the details of the document
 ...
 NameError: name 'fc' is not defined

   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 249, in create_handler
     return eval(value, idmap), bound_list
   File "<string>", line 23, in <module>

 
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 692, in _apply_rule
     rctx['ids'])
   File "/home/user1/.conda/envs/kivy/lib/python3.7/site-packages/kivy/lang/builder.py", line 254, in create_handler
     cause=tb)
 

Elliot Garbus於 2019年6月28日星期五 UTC-4下午12時30分50秒寫道:
<path3.py>
path3.py

Elliot Garbus

unread,
Jun 28, 2019, 3:23:54 PM6/28/19
to kivy-...@googlegroups.com
Here are some suggestions to help you move forward:

 kivy.lang.builder.BuilderException: Parser: File "<inline>", line 23:
 ...
      21:                text: 'File: ' + ('<None>' if not fc.selection else pathlib.Path(fc.selection[0]).name)
      22:            TextInput:
 >>   23:                text: 'Path: ' + ('<None>' if not fc.selection else str(pathlib.Path(fc.selection[0]).parent))
      24:        TextInput:
      25:            text: root.details #this is for the details of the document

The problem here is that the ID fc is defined in your popup, not in your widget.  You need a way to communicate the file name and path from the popup to the widget.  There are a number of different ways to do this.  One way would be to create a kivy string properties in under MyApp(App), lets call it fc_filename, you could then access it in KV code as app.fc_filename.

In your class MyWidget you define the method Browse.  The convention in Python is that classes use CamelCase and the method and function names use lowercase_words_separated_by_underscores.
You should name the method browse() not Browse(), this is just a convention, the code will work either way.  More that you want to know: https://www.python.org/dev/peps/pep-0008/#naming-conventions
class MyWidget(BoxLayout):
    details = StringProperty('')
    def Browse(self):  # use browse() to comply with conventions.
        b = BrowsePopup()
        b.open()

You are overloading a built-in function:
class BrowsePopup(Popup):
    details = StringProperty('')

    def open(self, filename):
        with open(filename) as fi:
            self.details = fi.read()
            print(self.details)

    def selected(self, filename):
        print('selected:' + filename)
You have defined the method open, but open is a built in.  Change the name from open to open_file (or another name you like)
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 28, 2019, 3:39:10 PM6/28/19
to Kivy users support
After I changed the code to this, it still have the same problem.

Elliot Garbus於 2019年6月28日星期五 UTC-4下午3時23分54秒寫道:
path3.py

Elliot Garbus

unread,
Jun 28, 2019, 3:58:57 PM6/28/19
to kivy-...@googlegroups.com

Good news, you have new problems! :) Here are 2 issues...

<MyWidget>:
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            orientation: 'horizontal'
            Label:
                text: 'File: ' + ('<None>' if not File else pathlib.Path(app.fc_filename).name) #name of doc
            TextInput:
                text: 'Path: ' + ('<None>' if not File else str(pathlib.Path(app.fc_filename).parent)) #path of doc
File should be app.fc_filename

class BrowsePopup(Popup):
    def __init__(self):
      details = StringProperty('')

Kivy properties do not get declared in the constructor. The kivy property should be declared as below.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 28, 2019, 4:06:39 PM6/28/19
to Kivy users support
After I changed to what u told me, it said
AttributeError: 'MyApp' object has no attribute 'Browse'

Elliot Garbus於 2019年6月28日星期五 UTC-4下午3時58分57秒寫道:
path3.py

Elliot Garbus

unread,
Jun 28, 2019, 5:23:49 PM6/28/19
to kivy-...@googlegroups.com
on_release: app.Browse

 

Should be:

 

on_release: root.browse()

 

you changed the name to browse, it is located in MyWidget (the root) not in the App.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.


To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 28, 2019, 5:36:44 PM6/28/19
to Kivy users support
after I changed to what you said. The app dont crash after I click browse now. However it dont have any respond too. There is nth happening in the terminal or the app.

Elliot Garbus於 2019年6月28日星期五 UTC-4下午5時23分49秒寫道:
path3.py

Elliot Garbus

unread,
Jun 28, 2019, 6:03:40 PM6/28/19
to kivy-...@googlegroups.com

on_release: root.browse  must be root.browse()
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 28, 2019, 8:02:55 PM6/28/19
to Kivy users support
After I changed, it said 咸蛋蒸肉餅: segmentation fault (core dumped)once i clicked the browse.

Elliot Garbus於 2019年6月28日星期五 UTC-4下午6時03分40秒寫道:

Elliot Garbus

unread,
Jun 28, 2019, 11:24:47 PM6/28/19
to kivy-...@googlegroups.com
Add some print statements, see if you can figure out where things are failing. 

I can see there is a problem in your kv for the pop up. A pop up must have on content tree. Put all of the widgets in the pop up under a layout. 

Sent from my iPhone
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Elliot Garbus

unread,
Jun 29, 2019, 12:03:51 AM6/29/19
to kivy-...@googlegroups.com
That should have said one content tree...

Sent from my iPhone

Nightslayer Neptune

unread,
Jun 29, 2019, 1:48:42 AM6/29/19
to Kivy users support
Thx for ur help, once I changed to that, sth horrible happen.

it said 
kivy.lang.parser.ParserException: Parser: File "<inline>", line 33:

 ...

      31:        Button:

      32:            text: 'back'

 >>   33:          on_release: root.dismiss()

      34:        FileChooserIconView:

      35:            id: fc

 ...

 Invalid indentation, must be a multiple of 4 spaces


However when I checked my code line 33 is not this kinds of things......


Elliot Garbus於 2019年6月29日星期六 UTC-4上午12時03分51秒寫道:

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
path3.py

Elliot Garbus

unread,
Jun 29, 2019, 8:30:40 AM6/29/19
to kivy-...@googlegroups.com
Make sure you don’t have tab characters in the code. The white space for each level of indent must be 4 spaces. 

Sent from my iPad
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

For more options, visit https://groups.google.com/d/optout.
<path3.py>

Elliot Garbus

unread,
Jun 29, 2019, 8:52:56 AM6/29/19
to kivy-...@googlegroups.com

I can see the problem it is on line 43 in the file.  Add 2 spaces.  The line number is for the KV string.

 

Another issue:


def open_file(self, filename):
   
with open_file(filename) as fi:
       
self.details = fi.read()
       
print(self.details)
 
should be:
 
def open_file(self, filename):
   
with open(filename) as fi:
       
self.details = fi.read()
       
print(self.details)

 

Additionally:

 

class BrowsePopup(Popup):
   
def __init__(self):
       
details = StringProperty('')

should be:

class BrowsePopup(Popup):
       
details = StringProperty('')

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.


To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 29, 2019, 10:53:31 AM6/29/19
to Kivy users support
Thx everything's seems run smoothly until, i choose a .py to open. The apps shut down automatically.
It said 'ValueError: None is not allowed for MyApp.fc_filename' in the terminal

Elliot Garbus於 2019年6月29日星期六 UTC-4上午8時52分56秒寫道:
path3.py

Elliot Garbus

unread,
Jun 29, 2019, 1:56:18 PM6/29/19
to kivy-...@googlegroups.com

So lets walk through this…

 

Look in the KV file. There are 2 things happening when you release the button.  The code bound to on-release: will execute.  And the code bound  to on_selection: will execute.  You could add some print statements to see what is happening.

on_release:
    print(‘on_release event fired’)
    root.open_file(fc.selection[0])
    print(‘open_file returned’)
    root.dismiss()

 

 

FileChooserIconView:
    id: fc
    on_selection:
        print(‘on_selection event fired’) 
        app.fc_filename = root.selected(fc.selection[0])
        print(‘file name set’)
 

Try adding print statements like this when your trying to debug these problems.  It will help you make progress and give you a better understanding of what is going on.

Take a look at this line, it is part of the on_selection code:

 

app.fc_filename = root.selected(fc.selection[0])

 

What does the method selected() return?  It is not returning a value.   You could change selected() to return the filename:

 

def selected(self, filename):
   
print('selected:'
+ filename)
   
return filename

 

Or you could get rid of selected() and move all of the functionality to the KV code:

on_selection:
    app.fc_filename = fc.selection[0]
    print(‘selected: ’ + fc.selection[0])

 

You have another challenge coming up.  You have a string property called details in both MyWidget and BrowsePopUp.  While the name is the same, these are 2 different variables and will not allow you to share data they way you intend.

You can move details to App, much like you did with fc_filename.

You will need to figure out how to access details from within file_open().  To do that you will need to use App.get_running_app().  Read: https://kivy.org/doc/stable/api-kivy.app.html?highlight=get_running#kivy.app.App.get_running_app

 

Then update browse:

def open_file(self, filename):
    app = App.get_running_app()
   
with open(filename) as fi:
        app.details = fi.read()
       
print(app.details)

 

I’ll leave the rest to you.  Good luck!

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 29, 2019, 2:19:05 PM6/29/19
to Kivy users support
Oh, that’s great. I can show the path and name now.
The app = App.get_running_app() is for the details of the doc??

Elliot Garbus於 2019年6月29日星期六 UTC-4下午1時56分18秒寫道:

Elliot Garbus

unread,
Jun 29, 2019, 2:29:47 PM6/29/19
to kivy-...@googlegroups.com

The app = App.get_running_app() is for the details of the doc?? 

Yes.

 

You will be opening the file in the popup, and writing the data to details.  You then need to display details in MyWidget.  To do this you need to have a way to access details from both the popup and Mywidget.  Move the decleration of details to App, and you can easily access it from kivy.  This is similar to what you did to access the fc_filename from both places.

 

You use the get_running_app() go gain access to ‘details’ from a python location outside of the main app class.

 

There are many different ways to do this – this is just one.

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 29, 2019, 4:02:19 PM6/29/19
to Kivy users support
I have make same changes now, and the app shut down run i tried to run it.

Elliot Garbus於 2019年6月29日星期六 UTC-4下午2時29分47秒寫道:


Elliot Garbus 2019629日星期六 UTC-4上午120351秒寫道:

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bo
path3.py

Elliot Garbus

unread,
Jun 29, 2019, 5:14:15 PM6/29/19
to kivy-...@googlegroups.com

Here are the things to change:

  1. ‘details’ should be declared in you App class only, remove from you class definitions, add to App.
  2. In BrowserPopup.open_files() access details as app.details, NOT self.details.  You need to access the new version you have created in App.
  3. All your references in KV should be to app.details (looks like this is okay)
 
 
class MyWidget(BoxLayout):
    details = StringProperty(
'') # Remove
   
    
def browse(self):
        b = BrowsePopup()
        b.open()

    
class BrowsePopup(Popup):
    details = StringProperty(
'') # Remove
    app = StringProperty(
'')
   
def open_file(self, filename):
       
app = App.get_running_app()
       
with open(filename) as fi:
           
self.details = fi.read()  # access details as app.details, change self.details to app.details
           
print(self.details)       # access details as app.details


class MyApp(App):
    fc_filename = StringProperty(
'')
    details = StringProperty('')   # Add details here so you can access easily from KV and the classes
   
    
def build(self):
       
return MyWidget()

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 29, 2019, 5:38:18 PM6/29/19
to Kivy users support
I still can't display the details in the RstDocument after those changes. It doesn't show anythings.

Elliot Garbus於 2019年6月29日星期六 UTC-4下午5時14分15秒寫道:


Elliot Garbus 2019629日星期六 UTC-4上午120351秒寫道:

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:a
path3.py

Elliot Garbus

unread,
Jun 29, 2019, 6:16:20 PM6/29/19
to kivy-...@googlegroups.com
You need to think step-by step about what is happening.  You press open on the popup and nothing happens, look at the code related to the button...

Button:
    text: "open"
    on_release: 
        #root.open(fc.selection[0])
        root.dismiss()
You have commented out the code, the only action for releasing the button is to dismiss the popup.   Recall the method you want to call is open_file() ... so un-comment the code, and change the method name.

class BrowsePopup(Popup):
    app = StringProperty('')         # delete this, you are not using this as a string property.
    def open_file(self, filename):
        app = App.get_running_app()  # you are getting a pointer to the current running app
        with open(filename) as fi:
            app.details = fi.read()  # and using that pointer to access details, app.details
            print(app.details)

I like how you have improved the formatting of the app.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 29, 2019, 6:42:06 PM6/29/19
to Kivy users support
Should I change this to??
Button:
    text: "open"
    on_release: 
        root.open(fi.read)
        root.dismiss()

Elliot Garbus於 2019年6月29日星期六 UTC-4下午6時16分20秒寫道:

Elliot Garbus

unread,
Jun 29, 2019, 7:12:52 PM6/29/19
to kivy-...@googlegroups.com
Button:
    text: "open"
    on_release: 
        root.open_file(fc.selection[0])  
        root.dismiss()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 29, 2019, 7:45:43 PM6/29/19
to Kivy users support
Oh, thx. Everything's work now. Can I asked one more things??
Why the path and name of the program, was showed before I clicked the open. But the details was opened after I clicked open??
I just want to know the difference and how to make that.

Elliot Garbus於 2019年6月29日星期六 UTC-4下午7時12分52秒寫道:
path3.py

Elliot Garbus

unread,
Jun 29, 2019, 7:51:56 PM6/29/19
to kivy-...@googlegroups.com
When you click on the file, the on_selection event happens, and you are using that to set the filename and path.
When you click on the open button you are reading the file and setting 'details'.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jun 29, 2019, 9:20:22 PM6/29/19
to Kivy users support
So if I want to change everything to show, when open is clicked
I just need to transfer those from on_selection to on_release of open button??

Elliot Garbus於 2019年6月29日星期六 UTC-4下午7時51分56秒寫道:
<p

Elliot Garbus

unread,
Jun 29, 2019, 11:23:15 PM6/29/19
to kivy-...@googlegroups.com
Yes.  Give it a try. 

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jul 1, 2019, 10:26:58 AM7/1/19
to Kivy users support
Thx a lot, now I wanna to make more changes.
I added a edit button now.
After I clicked open. I want to show the Name of file. In the top left corner.(That's is successfully done)
When I clicked edit, The bellow Label, RstDocument will show the rest, name, path details again.

However, when I clicked the open, all the information which is name(both of them), path show.
and when I clicked Edit. The app shut down. And the terminal said, AttributeError: 'MyWidget' object has no attribute 'open_file'

Elliot Garbus於 2019年6月29日星期六 UTC-4下午11時23分15秒寫道:
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
path4.py

Elliot Garbus

unread,
Jul 1, 2019, 10:44:01 AM7/1/19
to kivy-...@googlegroups.com

Open_file, and fc.selection are defined in BrowsePipup, you are now trying to call them from MyWidget.  This is the problem.

 

When something is refered to as root. In KV, it means look in this root class.  This is why you can’t access open_file with the edit button.

 

You could continue to open the file in the BrowsePopUp, and copy the data into details, and use the edit button to show app.details in the TextInput window.   Give that a try.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.


To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jul 1, 2019, 10:51:23 AM7/1/19
to Kivy users support
But I thought, I have input the data to MyApp already.

what is the different between the app and root.

How can I do that??

Elliot Garbus於 2019年7月1日星期一 UTC-4上午10時44分01秒寫道:

Elliot Garbus

unread,
Jul 1, 2019, 10:55:42 AM7/1/19
to kivy-...@googlegroups.com

Read: https://kivy.org/doc/stable/api-kivy.lang.html?highlight=language

Value Expressions, on_property Expressions, ids, and Reserved Keywords

 

I’m running to a meeting happy to help more later.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.


To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jul 1, 2019, 11:03:10 AM7/1/19
to Kivy users support
Now, I changed the .py to this. The app dont crash now, however, it still display those things except the details, when I clicked opened. And when clicked edit, the details didn't show up.

Elliot Garbus於 2019年7月1日星期一 UTC-4上午10時55分42秒寫道:


Elliot Garbus 2019629日星期六 UTC-4下午75156秒寫道:

def open_file(self<span 
path4.py

Elliot Garbus

unread,
Jul 1, 2019, 12:23:47 PM7/1/19
to kivy-...@googlegroups.com
In BrowsePopup in the kv code, call open_file() when the browser open button is pressed.
This will put the file data in app.details

Create a new variable called 'show_details', use it to show and hide the data.  Have it show the data when edit is pressed.
example attached
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
path4.py

Nightslayer Neptune

unread,
Jul 1, 2019, 1:13:28 PM7/1/19
to Kivy users support
Should I do sth like that??
Also, I cant find any example attached. How do u do that? for show and hide data??

Elliot Garbus於 2019年7月1日星期一 UTC-4下午12時23分47秒寫道:


Elliot Garbus 2019629日星期六 UTC-4下午75156秒寫道:

<div style="border:none;border-
path4.py

Elliot Garbus

unread,
Jul 1, 2019, 2:48:01 PM7/1/19
to kivy-...@googlegroups.com
Apologies, I attached the wrong file. I’ll send it later today. 
Try some experiments, it is the best way to learn. 

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

For more options, visit https://groups.google.com/d/optout.
<path4.py>

Nightslayer Neptune

unread,
Jul 1, 2019, 3:11:08 PM7/1/19
to Kivy users support
Moreover, I dont think hide and show is suitable for me cause, I may change the details of display in another tabbed panel later

Elliot Garbus於 2019年7月1日星期一 UTC-4下午2時48分01秒寫道:
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
<path4.py>

Elliot Garbus

unread,
Jul 1, 2019, 9:29:11 PM7/1/19
to kivy-...@googlegroups.com
The updated file is attached.  I'll briefly describe the changes I've made, in comments below, I'll mark my changes in red to make them easy to find.
What is interesting in this example is creating a property directly in KV, and then accessing it using  .parent to move up the widget tree.


<MyWidget>:
    BoxLayout:
        orientation: 'vertical'
        show_details: False                  # Created a new property called show_details, set it's initial state to false.
        BoxLayout:
            size_hint_y: .2
            orientation: 'horizontal'
            Label:
                text: 'File: ' + ('<None>' if not app.fc_filename else pathlib.Path(app.fc_filename).name) #name of doc
            Button:
                text: 'Edit'
                on_release: 
                    self.parent.parent.show_details = True  # When edit is pressed set show details, uses .parent.parent to access an attribute 2 levels up the widget tree
        Label:
            text: 'File: ' + ('<None>' if not app.fc_filename else pathlib.Path(app.fc_filename).name) #name of doc
            size_hint_y: .1
        TextInput:
            text: 'Path: ' + ('<None>' if not app.fc_filename else str(pathlib.Path(app.fc_filename).parent)) #path of doc
            size_hint_y: .1
        TextInput:
            text: app.details if self.parent.show_details else '' # use show_details to control showing app.details 
        Button:
            size_hint_y: .1
            text: 'Browse'
            on_release:
                self.parent.show_details = False   #When the use start to look for a new file, clear out the 
                root.browse()

<BrowsePopup>:
    id: my_widget
    size_hint: .8, .8
    auto_dismiss: False
    title: 'browse'
    BoxLayout:
        orientation: 'vertical'
        FileChooserIconView:
            id: fc
            on_selection:
        BoxLayout:
            size_hint_y: .1
            orientation: 'horizontal'
            Button:
                text: 'back'
                on_release: root.dismiss()
            Button:
                text: "open"
                on_release: 
                    app.fc_filename = fc.selection[0]
                    print('selected: ' + fc.selection[0])
                    root.open_file(fc.selection[0])          # This call reads the file and puts the data in to app.fc_selection
                    root.dismiss()
""")
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
path4_1.py

Nightslayer Neptune

unread,
Jul 1, 2019, 10:43:40 PM7/1/19
to Kivy users support
Can I know more about parent? and which part you use it and the purpose is??Is it related to child??
Moreover, I want the second row and third row(the second name and path to hide until edit is pressed), so I made some changes, however, it still show, before I edit them

Elliot Garbus於 2019年7月1日星期一 UTC-4下午9時29分11秒寫道:


Elliot Garbus 2019629日星期六 UTC-4下午75156秒寫道:

        with open<span style="font-size:9.0pt;color:black
path3.py

Elliot Garbus

unread,
Jul 2, 2019, 1:03:17 AM7/2/19
to kivy-...@googlegroups.com
Parent is a property of a Widget, read: https://kivy.org/doc/stable/api-kivy.uix.widget.html?highlight=widget%20parent#kivy.uix.widget.Widget.parent
also take a look at children

The widgets sit in a data structure called a 'tree'.  If your not familiar with trees, you may want to search for a reference or a video on youtube.  The diagram below is a simple example of a tree.  In the diagram:   The node 2 is the root of the tree, like the root widget.  Node 2 has two children (nodes 7 & 5).  Node 7's parent is node 2.  Node 6's parent is node 7.




We can use the parent and children to access variables in different locations on the tree.  There is a method in widget called walk that can walk all of the notes in the widget tree.  read: https://kivy.org/doc/stable/api-kivy.uix.widget.html?highlight=widget%20walk#kivy.uix.widget.Widget.walk

Lets look at a sample of the KV code:

<MyWidget>:
    BoxLayout:
        id: find_me                          # Added this id for this example
	
orientation: 'vertical'
        show_details: False                  # Created a new property called show_details, set it's initial state to false.
        BoxLayout:
            size_hint_y: .2
            orientation: 'horizontal'
            Label:
                text: 'File: ' + ('<None>' if not app.fc_filename else pathlib.Path(app.fc_filename).name) #name of doc
            Button:
                text: 'Edit'
                on_release: 
                    self.parent.parent.show_details = True  # When edit is pressed set show details, uses .parent.parent to access an attribute 2 levels up the widget tree
      

    Now lets look at these pieces:

        show_details: False                  # Created a new property called show_details, set it's initial state to false.
I created show_details.  This is creating a property in MyWidget class.  I'll show you another way to do it further down this note. I can access this property from MyWidget (python code) as:
self.ids.find_me.show_details


Now we will look at parent.
self.parent.parent.show_details = True
Look where this code sits, it sits under Button.  Code inside button can  access the members of Button, using self.  I could for example access text in Button  by using 'self.text' for example:
        Button:
            text: 'This is the initial text'
            on_release: self.text = 'This will update the button text'

Now going back to:
self.parent.parent.show_details = True
Look up from Button in your KV code.  The next layer up is BoxLayout.  BoxLayout has children Button and Label.  BoxLayout is the parent of Button.  BoxLayout has a parent, also a BoxLayout, that is where show_details is located. So I can access it with self.parent.parent.show_details, here is another example:

I hope that made some sense.  A better, easier to understand way to do it would be to declare the property in in python in the MyWidget class and access it using root.  For example:
class MyWidget(BoxLayout):
    show_details = BooleanProperty(False)

and use 'root.'  in KV to access the property show_details, as shown below:
<MyWidget>:
    BoxLayout:
        id: find_me
        orientation: 'vertical'
        # show_details: False
        BoxLayout:
            size_hint_y: .2
            orientation: 'horizontal'
            Label:
                text: 'File: ' + ('<None>' if not app.fc_filename else pathlib.Path(app.fc_filename).name) #name of doc
            Button:
                text: 'Edit'
                on_release: 
                    root.show_details = True     

And root.show_details is used to select between app_details or ' ' as the output to show in your edit window.
 TextInput:
    text: app.details if root.show_details else '' #this is for the details of the document 

I have attached an updated file that declares show_details in Python and uses root.show_details in KV.
Summary:
I am setting show_details to False at startup, I set it to True when the Edit button is released, and it is used to select the string to be displayed in the TextInput field.

Moreover, I want the second row and third row(the second name and path to hide until edit is pressed), so I made some changes, however, it still show, before I edit them.

You could use a method like the one used here to delay showing the name of the file.
Currently you have:

Label:
    text: 'File: ' + ('<None>' if not app.fc_filename else pathlib.Path(app.fc_filename).name)
You can change it to:
Label:
    text: 'File: ' + ('<None>' if (not app.fc_filename or not root.show_details) else pathlib.Path(app.fc_filename).name)

this will show <None> until the edit button is pressed, making root.show_details True.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
path4_2.py

Nightslayer Neptune

unread,
Jul 2, 2019, 9:24:48 AM7/2/19
to Kivy users support
Thx for your explanation, however, I still dont understand the different between 2 <my widget> that you give me. 
DO you mean that
The first <my widget> is using parent and children, while the other is using the <root>?  It seems they are the same. And why you comment the show_details in the second <my_widget>

Elliot Garbus於 2019年7月2日星期二 UTC-4上午1時03分17秒寫道:

Elliot Garbus

unread,
Jul 2, 2019, 10:17:56 AM7/2/19
to kivy-...@googlegroups.com

DO you mean that The first <my widget> is using parent and children, while the other is using the <root>?

It seems they are the same. And why you comment the show_details in the second <my_widget>

In the file path4_1, “show_details” is declared in the KV file, and accessed using the “.parent” in the KV file.

 

In the file path4_2, “show_details” is declared in the python code. 

class MyWidget(BoxLayout):
    show_details = BooleanProperty(
False)

Because it is declared in the Python code I wanted to remove it from the KV code, and commented it out.  “show_details” is accessed in the KV code with “root.show_details”

 

From: Nightslayer Neptune
Sent: Tuesday, July 2, 2019 6:26 AM
To: Kivy users support
Subject: Re: [kivy-users] How to show the file name, path, detailsofdocumentonaLabelorRstDocument??

 

Thx for your explanation, however, I still dont understand the different between 2 <my widget> that you give me. 

DO you mean that

The first <my widget> is using parent and children, while the other is using the <root>?  It seems they are the same. And why you comment the show_details in the second <my_widget>

Elliot Garbus 201972日星期二 UTC-4上午10317秒寫道:

Parent is a property of a Widget, read: https://kivy.org/doc/stable/api-kivy.uix.widget.html?highlight=widget%20parent#kivy.uix.widget.Widget.parent
also take a look at children

The widgets sit in a data structure called a 'tree'.  If your not familiar with trees, you may want to search for a reference or a video on youtube.  The diagram below is a simple example of a tree.  In the diagram:   The node 2 is the root of the tree, like the root widget.  Node 2 has two children (nodes 7 & 5).  Node 7's parent is node 2.  Node 6's parent is node 7.

https://lh4.googleusercontent.com/proxy/aEzuyhaQhgwLggrOzsHRADHHSVhK4nEqmwfSOdu8XGio9kl6qmne5NThEP8WYorYxF4FnO7RNkSZVx7-WfxNkGJSmkaBjNGRv0HbtISl76KrNTEyGQl_6hzDnOknhwbvkU8MsgOjWUzDNt-8FsBAeU1vG3CMDrM=w5000-h5000

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jul 2, 2019, 10:42:56 AM7/2/19
to Kivy users support
So if I want it to be done in KV. I just need to deleted that in python and use the code again??

Elliot Garbus於 2019年7月2日星期二 UTC-4上午10時17分56秒寫道:

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
Jul 2, 2019, 10:58:21 AM7/2/19
to kivy-...@googlegroups.com

I’d recommend using the path4_2.py file, and delete the commented out code, and start from there.  It is better to use the

“root.show_details”.  

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.


To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Nightslayer Neptune

unread,
Jul 2, 2019, 1:40:11 PM7/2/19
to Kivy users support
Thx a lot. I guess everything’s is clear now. Have a nice day. Hope to see you again

Elliot Garbus於 2019年7月2日星期二 UTC-4上午10時58分21秒寫道:
Message has been deleted
Message has been deleted

Elliot Garbus

unread,
Jul 15, 2019, 2:24:47 PM7/15/19
to kivy-...@googlegroups.com

The filechooser attribute to set the starting path for the filechooser is named ‘path’

 

BoxLayout:
   
orientation: 'vertical'
   
FileChooserListView:
       
id: fc
        filters:
root.filters
       
path: root.path

 

I have a file dialog example on GitHub that allows the user to select a drive this is critical for windows and a nice to have on mac when dealing with USB sticks.

https://github.com/ElliotGarbus/KivyFileAndDrive

 

It’s a little rough.  This was a testbed for some code I was working on.  Let me know if it helps.

 

From: Nightslayer Neptune
Sent: Monday, July 15, 2019 11:02 AM
To: Kivy users support
Subject: Re: [kivy-users] How to show the file name, path, detailsofdocumentonaLabelorRstDocument??

 

 

Sorry to ask in here again.

I just have a little question.

Is it ok to start a Browse in a specific file?? everytime i browse, it start from the very beginning. But what I want is start in a specific file. Is it ok to do that??

 

I used rootpath in the .kv. However, once I tried to browse it the application crash

 

what I added is

rootpath: home/user1

 

however it said, NameError: name 'home' is not defined

 

when I changed to rootpath: /home/user1

I cant even open the app

 cause it said SyntaxError: invalid syntax

Elliot Garbus 201972日星期二 UTC-4上午105821秒寫道:

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.

Reply all
Reply to author
Forward
0 new messages