Results 1 to 7 of 7

Thread: running python 3 scripts from graphical file manager

  1. #1

    Default running python 3 scripts from graphical file manager

    To run my own python 3 scripts I've taken these steps:

    - added the shebang to the top of the script
    - copied the script to /usr/local/bin
    - chmod +x on the copied script to make it executable
    - chown the script to my limited user account

    This has enabled me to run scripts successfully from the terminal command line. I cannot, however, run them from the graphical file manager. Double-clicking the icon only opens the script in a text editor. Selecting Open With>Other Applications>Choose Applications does not provide an option for python 3.4, and the Add button to add python 3.4 to the context menu is grayed out and inactive. How can I enable myself to execute python 3 scripts from within the graphical login manager?

    I am running OpenSUSE 13.2 Gnome 64-bit.

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    27,198
    Blog Entries
    15

    Default Re: running python 3 scripts from graphical file manager

    On Thu 21 May 2015 07:46:02 PM CDT, inkonstant wrote:


    To run my own python 3 scripts I've taken these steps:

    - added the shebang to the top of the script
    - copied the script to /usr/local/bin
    - chmod +x on the copied script to make it executable
    - chown the script to my limited user account

    This has enabled me to run scripts successfully from the terminal
    command line. I cannot, however, run them from the graphical file
    manager. Double-clicking the icon only opens the script in a text
    editor. Selecting Open With>Other Applications>Choose Applications does
    not provide an option for python 3.4, and the Add button to add python
    3.4 to the context menu is grayed out and inactive. How can I enable
    myself to execute python 3 scripts from within the graphical login
    manager?

    I am running OpenSUSE 13.2 Gnome 64-bit.


    Hi
    Create a desktop file and pop it in ~/.local/share/applications or if
    wanting system wide /usr/share/applications.

    If it's just for your use placing in ~/bin would be enough...

    For example here is one I have for Arduino sitting in ~/Desktop;

    Code:
    [Desktop Entry]
    Name=Arduino
    Comment=Arduino integration environment tool
    Version=1.0
    Icon=/home/malcolml/.icons/Arduino_Logo.svg
    Exec=/data/makeblock/arduino-1.6.2/arduino
    Type=Application
    Terminal=false
    Encoding=UTF-8
    Categories=Development;IDE;
    Desktop specs for openSUSE are here;
    https://en.opensuse.org/openSUSE:Pac...enu_categories

    --
    Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
    SUSE Linux Enterprise Desktop 12 GNOME 3.10.1 Kernel 3.12.39-47-default
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!


  3. #3

    Default Re: running python 3 scripts from graphical file manager

    It didn't work. I created a file named /usr/share/applications/python3.4.desktop and checked its ls -Falib to make sure the profile was correct. After I logged out and back in the listing still wasn't in the context menu. I then did a hard reboot and same result. Here's the file I created in case I screwed something up (since there are just no appropriate categories for what I'm trying to do here):

    Code:
    [Desktop Entry]
    Name=Python3
    Exec=/usr/bin/python3.4
    Icon=
    Terminal=False
    Type=Aoplication
    Encoding=utf-8
    Categories=System;TrayApplication

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    27,198
    Blog Entries
    15

    Default Re: running python 3 scripts from graphical file manager

    Quote Originally Posted by inkonstant View Post
    It didn't work. I created a file named /usr/share/applications/python3.4.desktop and checked its ls -Falib to make sure the profile was correct. After I logged out and back in the listing still wasn't in the context menu. I then did a hard reboot and same result. Here's the file I created in case I screwed something up (since there are just no appropriate categories for what I'm trying to do here):

    Code:
    [Desktop Entry]
    Name=Python3
    Exec=/usr/bin/python3.4
    Icon=
    Terminal=False
    Type=Aoplication
    Encoding=utf-8
    Categories=System;TrayApplication
    Hi
    No, Name is the name of your script or a friendly name, Exec is the script name/path in /usr/local/bin and Encoding is upper case.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  5. #5

    Default Re: running python 3 scripts from graphical file manager

    It still didn't work. I have given up and accepted that the Gnome developers have permanently screwed up Gnome by removing the option to add custom applications to the Open With context menu. It's like Linux developers deliberately cripple everything Linux in order to force people to switch back to Windows. In Windows I can run the script just fine from any directory even without a shebang.

    And I hate the stupid captcha every time I try to post a message because my vision is bad and the captcha is almost unreadable. I always have to try eight or nine times before I"m allowed to make a post.

  6. #6
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,768

    Default Re: running python 3 scripts from graphical file manager

    Make an acccount here and log in then no more captcha

    Windows uses the file extension to determine how to run a program. Can't speak for Gnome but in KDE you can associate an extension with a program like in Windows so you can associate .py with python. The shabang tells the shell what program to run the file against.

  7. #7
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,459
    Blog Entries
    2

    Default Re: running python 3 scripts from graphical file manager

    Why aren't you using something like PyDev to configure and switch between Python environments?

    I'm not sure where the logic is to invoke a version of Python in the boot sequence.

    Or, pls explain the entire picture what you're trying to do (run a special service or other app that requires Python 3? But even in that case there is a "proper solution")

    TSU

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •