On 4/19/2017 5:06 PM, Fari Tigar wrote:
> Properties are used with an accessors like *self, root, or app*, you
> can't just use fc, this would be a local variable.
> I would use for every main widget an id and make it available at the
> root level, like so:
> **
> Think about refactoring this to a method:
>
> * *you could do validations, exceptions etc.*
> * *debugging, testing is much easier with python files*
>
> on_submit:call('c:\python35\python '+self.selection[0])
>
> on_submit:root.my_method(self.selection)
>
> def my_method(self,selection):
> .....
>
> |
> #:import call subprocess.call<Btn@Button>: fc:fc
> size_hint:(0.1,0.1)StackLayout: orientation:'lr-tb'Btn:
> text:'list' on_press:root.fc.view_mode =self.text Btn:
> text:'icon' on_press:root.fc.view_mode =self.text Label:
> size_hint:.8,.1FileChooser: id:fc
> path:"C:\python35\share\kivy-examples" filters:['*.py']
> on_submit:call('c:\python35\python
> '+self.selection[0])FileChooserListLayoutFileChooserIconLayout
> |
I don't think you understood my question. My goal is to move the 2
on_press: lines inside the Btn class. How do I refer to the fc id from
within the Btn class?
#:import call subprocess.call <Btn@Button>: size_hint: (0.1, 0.1)
on_press: fc.view_mode = self.text
I also don't understand fc: fc. What is that supposed to mean/do?
> On Wednesday, April 19, 2017 at 9:34:34 PM UTC+2, Bob Gailer wrote:
>
> Following works:
>
> #:import call subprocess.call <Btn@Button>: size_hint: (0.1,
> 0.1) StackLayout: orientation: 'lr-tb' Btn: text: 'list'
> on_press: fc.view_mode = self.text Btn: text: 'icon' on_press:
> fc.view_mode = self.text Label: size_hint: .8, .1 FileChooser:
> id: fc path: "C:\python35\share\kivy-examples" filters:
> ['*.py'] on_submit: call('c:\python35\python ' +
> self.selection[0]) FileChooserListLayout FileChooserIconLayout
>
> If I move the on_press lines into the dynamic class it fails when
> I press a Btn: NameError: name 'fc' is not defined. How can I fix
> that?
>
> -- 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/coraR7tRzBQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
>
kivy-users+...@googlegroups.com
> <mailto:
kivy-users+...@googlegroups.com>. For more options,
> visit
https://groups.google.com/d/optout.
-- Image and video hosting by TinyPic