Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Simple Button to Choose Path
-
Completely new to UI Buttons and what not. I went through and created an interface with a couple buttons and ALL I want to be able to do is to grab the value of the button pushed so I can use it for a file path...
This seems super easy but I can't find anything anywhere that simply describes how to do it. All I can do is change the title of it to "Hello"! LOL
Thank you for any help...
-
If I correctly understand what you mind with "the value of the button", try:
import ui class myview(ui.View): def __init__(self): b1 = ui.Button() b1.frame=(10,10,100,32) b1.title = 'path1' b1.action = self.button_tapped self.add_subview(b1) b2 = ui.Button() b2.frame=(120,10,100,32) b2.title = 'path2' b2.action = self.button_tapped self.add_subview(b2) def button_tapped(self,sender): path = sender.title print(path) v = myview() v.present()
-
If you are trying to "pause" a script while the user chooses from a set of choices, then look at the
dialogs
module. Or you can use wait_modal