1

I am new to linux, so would be great if anyone could help me on this!

I want to open a file, say a text file using text editor from terminal. The thing is i dont want to just view/edit the file. I know i could do this using cat or vi. But i wanted to open something by its corresponding application and I wanted to do this from terminal. Is it possible?

I actually wanted to open the file from a gui i am building. I am building my gui using tkinter python.

So i am looking for a command to open the file so that i could use it in my subprocess command.

blackfury
  • 675
  • 3
  • 11
  • 22

2 Answers2

0

A repeat of an earlier question, but it's hard to search for if you don't know about the "start" command in windows or "open" on OSX. xdg-open is the Linux desktop equivalent.

https://superuser.com/questions/38984/linux-equivalent-command-for-open-command-on-mac-windows

[Edit] I'm taking the requirement to mean "command picture.jpg" should open in your image viewer, "command song.mp3" should open in the users music player etc. Open from the terminal, not literally in the terminal... If command == xdg-open, it should work.

Community
  • 1
  • 1
Ian McGowan
  • 3,461
  • 3
  • 18
  • 23
0

Refer here Opening File (Tkinter)

In GUI programming, think of the GUI as a tree or a graph. The root is your main GUI window, and within it contains different elements (Labels, Buttons, Images, TextBoxes, etc.), which are your children to your tree.

In order to use tkinter in python:

import tkinter as tk
root = tk.Tk()

A window pops up. that is your root GUI window with nothing in it. If you close this window, the root GUI object will be destroyed.

You can use similar approach for your GUI. See more here http://www.python-course.eu/tkinter_labels.php

Community
  • 1
  • 1
priya
  • 63
  • 7