1
new_file = tempfile.mktemp('.txt')
open(new_file, 'w').write(self.txt_billArea.get('1.0', END))

os.open(new_file)
os.startfile(new_file,'print')

I'm using Fedora for python learning. I want to print a hard copy printing option and by researching from web and YouTube I got os.startfile() is only for windows system. But it's not working for Linux. So how could I use this on Linux(Fedora)?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • 1
    According to [the documentation](https://docs.python.org/3/library/os.html) os.startfile() is only available on Windows –  Nov 17 '21 at 16:34
  • Then how to use hardcopy printing method on Linux? Help me please.. – Shibu Dhara Nov 17 '21 at 16:41
  • 1
    Does this answer your question? [Is there an platform independent equivalent of os.startfile()?](https://stackoverflow.com/questions/17317219/is-there-an-platform-independent-equivalent-of-os-startfile) – nofinator Nov 17 '21 at 17:08
  • Note that the `print` command may not work in Fedora. Perhaps `lp`? – nofinator Nov 17 '21 at 17:12
  • The startfile() is not available for Linux. But i found that opener = "open" if sys.platform == "darwin" else "xdg-open" subprocess.call([opener, new_file]) its only helps to open file in linux text editor, Actually i wanted to open the printer window after open that file in text editor. How i do this in Linux(Fedora)? – Shibu Dhara Nov 17 '21 at 18:09

0 Answers0