[IPython-dev] Open-file dialog in the notebook for data files

Antonino Ingargiola tritemio at gmail.com
Wed Dec 17 19:15:04 EST 2014


I found that I can trigger an open file dialog simply with

<input type="file" id="theFile" />

in a markdown cell.

The question is, is there a way to put the file name in a python variable?

Antonio


On Wed, Dec 17, 2014 at 3:36 PM, Adam Hughes <hughesadam87 at gmail.com> wrote:
>
> Oh, ya sorry, I don't think there's a widget (AFAIK) that could pop up a
> file system browser.  While there are pre-existing widgets like that in the
> Traits library, they're probably not supported by the lighter Traitlets
> library on which Traits is built.
>
> On Wed, Dec 17, 2014 at 6:08 PM, Antonino Ingargiola <tritemio at gmail.com>
> wrote:
>>
>> Hi Adam,
>>
>> thanks for offering to help. Just to clarify, I need to browse the
>> filesystem to find the file, not just show a list of files in a folder.
>>
>> I have some basic familiarity with the standard ipython widgets but I
>> don't remember having seen something resembling an open-file dialog.
>>
>> Any pointer is appreciated,
>> Antonio
>>
>> On Wed, Dec 17, 2014 at 1:25 PM, Adam Hughes <hughesadam87 at gmail.com>
>> wrote:
>>>
>>> You can do a widget box and next to it a button, like "Load file" and
>>> then link the button click even to the name of the text in the file.   I
>>> can give you some help later this week if you have trouble finding how to
>>> do that (we are about to pack up computers for a lab move)
>>>
>>> On Wed, Dec 17, 2014 at 4:11 PM, Antonino Ingargiola <tritemio at gmail.com
>>> > wrote:
>>>>
>>>> Yes, is there a widget I can use for that? If yes I must have missed
>>>> it...
>>>>
>>>> Antonio
>>>>
>>>> On Wed, Dec 17, 2014 at 11:53 AM, Adam Hughes <hughesadam87 at gmail.com>
>>>> wrote:
>>>>>
>>>>> Would you be able to just use an IPython widget to get the file name?
>>>>>
>>>>> On Wed, Dec 17, 2014 at 2:37 PM, Antonino Ingargiola <
>>>>> tritemio at gmail.com> wrote:
>>>>>
>>>>>> Dear ipython developers,
>>>>>>
>>>>>> I occasionally have the need to get a data file name via a GUI dialog
>>>>>> when using the notebook.
>>>>>>
>>>>>> Opening a QT dialog from the notebook involves initializing the QT
>>>>>> gui. At the same time I always use inline plots so I also need to enable
>>>>>> the inline plot backed. This can be done with
>>>>>>
>>>>>>     %gui qt
>>>>>>     %matplotlib inline
>>>>>>
>>>>>> These commands work when executed manually on different cells.
>>>>>> However, the previous commands will freeze the ipython notebook if
>>>>>> they are in the same cell or if executing the notebook with Run-All (open
>>>>>> issue #5798 <https://github.com/ipython/ipython/issues/5798>). The
>>>>>> problem is multi-platform and occurs both with PySide and PyQT.
>>>>>>
>>>>>> Is there any workaround for this? It really bothers me to lose the
>>>>>> ability to Run-All when I enable the QT gui.
>>>>>>
>>>>>> Alternatively would be possible to use a javascript dialog to select
>>>>>> a file on the filesystem? If yes an example would be nice.
>>>>>>
>>>>>> PS: I'm using ipython 2.x
>>>>>>
>>>>>> Thanks,
>>>>>> Antonio
>>>>>>
>>>>>> _______________________________________________
>>>>>> IPython-dev mailing list
>>>>>> IPython-dev at scipy.org
>>>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> IPython-dev mailing list
>>>>> IPython-dev at scipy.org
>>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>>
>>>>>
>>>> _______________________________________________
>>>> IPython-dev mailing list
>>>> IPython-dev at scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>
>>>>
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>
>>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141217/3cc07dd4/attachment.html>


More information about the IPython-dev mailing list