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.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
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/fb96bade-5a3d-4cb7-8514-1639e6f39dea%40googlegroups.com.
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/e11e53bd-484d-4eb2-9afb-2486be10970b%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/02287f2f-57bf-4447-8a90-9a9aa1375b53%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ff7bc512-f0ad-4b02-bf0b-8541e1874cf0%40googlegroups.com.
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/fdc3d34c-31a1-42d8-9440-0c0041404125%40googlegroups.com.
<path3.py>
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/fdc3d34c-31a1-42d8-9440-0c0041404125%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<path3.py>
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/1aeb59f1-e732-4cd5-9896-3f969c19075c%40googlegroups.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 docFile 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/138a1be8-0617-4b9c-81bc-c599b9b4f6d7%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/9685271b-dc67-4734-9cbd-b57a64fa905e%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/9caec8e4-b816-4f22-b250-66641a2b2811%40googlegroups.com.
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/9d2c0926-b6a1-4f0e-b5d9-83a8d1138a86%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/2D5F12A6-F942-40A4-B9BB-1AEB5E40B5F0%40cox.net.
...
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......
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/9d2c0926-b6a1-4f0e-b5d9-83a8d1138a86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.
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/cd8dffd8-7b57-4db1-bdb1-f783e6e1a7b6%40googlegroups.com.
<path3.py>
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/cd8dffd8-7b57-4db1-bdb1-f783e6e1a7b6%40googlegroups.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])
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e4b91df8-8da3-41ab-99f1-3f926878565c%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6c4554c2-ae85-48a5-aff4-ab2a8402cda8%40googlegroups.com.
Elliot Garbus於 2019年6月29日星期六 UTC-4上午12時03分51秒寫道:
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bo
Here are the things to change:
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3eb3f772-9042-4e17-9488-9a46b26b7afa%40googlegroups.com.
Elliot Garbus於 2019年6月29日星期六 UTC-4上午12時03分51秒寫道:
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:a
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)
--
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/44f2747f-92d3-4de8-85bb-38929c99c79e%40googlegroups.com.
Should I change this to??Button: text: "open" on_release: root.open(fi.read) root.dismiss()
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/97d8ddc7-7731-43c7-917f-f2462e3c54ce%40googlegroups.com.
--
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/f85a75d2-ab63-4788-80e7-5ce7507cff7c%40googlegroups.com.
<p
--
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/b56d877e-a4c4-440f-96e9-1730823c8b6b%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/a1581a4c-9b8d-4546-bfc0-68311ae8444b%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/c5819ef4-fd8c-4dc3-89ee-cb2903ef4b1e%40googlegroups.com.
Elliot Garbus於 2019年6月29日星期六 UTC-4下午7時51分56秒寫道:
def open_file(self<span
--
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/1f394462-5804-4b5e-b136-4ef685f0474a%40googlegroups.com.
Elliot Garbus於 2019年6月29日星期六 UTC-4下午7時51分56秒寫道:
<div style="border:none;border-
--
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/02327301-3435-4b80-9d5a-e7eef9eae380%40googlegroups.com.
<path4.py>
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/02327301-3435-4b80-9d5a-e7eef9eae380%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<path4.py>
<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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/a87406f4-71dc-4152-862b-cae9af73c8d8%40googlegroups.com.
Elliot Garbus於 2019年6月29日星期六 UTC-4下午7時51分56秒寫道:
with open<span style="font-size:9.0pt;color:black
<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
show_details: False # Created a new property called show_details, set it's initial state to false.
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: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:class MyWidget(BoxLayout): show_details = BooleanProperty(False)
<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
Label: text: 'File: ' + ('<None>' if not app.fc_filename else pathlib.Path(app.fc_filename).name)
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/a6fbc8db-68b1-4f92-b520-efea5391e347%40googlegroups.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於 2019年7月2日星期二 UTC-4上午1時03分17秒寫道:
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.
--
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/45511063-2888-48da-ade1-c8bdd326d55f%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d1d8009a-5bb7-4e94-8634-a22f5eaf7c1c%40googlegroups.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於 2019年7月2日星期二 UTC-4上午10時58分21秒寫道:
--
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/ffc4a55f-7fe7-498f-8648-ebd9bfd9cb19%40googlegroups.com.