Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # a simple code to show how to open a file by:
- # "open with" context menu option.
- # "drag" and drop a text file on the .exe file
- # .exe built with pyinstaller
- # author: David Emanuel Sandoval
- from tkinter import *
- from tkinter.scrolledtext import *
- import sys
- def main():
- root = Tk()
- text = ScrolledText(root)
- text.pack(expand=YES, fill=BOTH)
- root.mainloop()
- if __name__ == '__main__':
- try:
- f = open(sys.argv[1])
- content = f.read()
- f.close()
- root = Tk()
- text = ScrolledText(root)
- text.insert(0.0, content)
- text.pack(expand=YES, fill=BOTH)
- root.mainloop()
- except:
- main()
Advertisement
Add Comment
Please, Sign In to add comment