Open Microsoft Word file using tkinter Module in Python.
Source Code: Basic template
from tkinter import *
import os
#Basic code snipet for GUI interface of pyhton
st = Tk()
st.mainloop()
Source Code: Create application
from tkinter import *
import os
#path of word file
path = "path\Example.docx"
#functions
def open_word():
os.system(f"start {path}")
st = Tk()
st.title("Open MS Word")
st.geometry("200x250")
st.config(bg="black")
#use for write text
canvas = Canvas(st, width=200, height=30, bg="black")
canvas.create_text(100, 15, text="Open MS word", fill="white", font=("Helvetica 15 bold"))
canvas.pack()
#btn for open
open_btn = Button(st, text="Open Word", relief="sunken", borderwidth=3, activebackground="green", command=open_word)
open_btn.place(x=50, y=80, width=90, height=40)
#btn for close
# close_btn = Button(st, text="Close Word", relief="raised", borderwidth=3, activebackground="red")
# close_btn.place(x=50, y=130, width=90, height=40)
st.mainloop()
Description:
Discover how to create and open Microsoft Word files effortlessly using the Tkinter module in Python. This comprehensive tutorial walks you through the process of building a user-friendly GUI application to generate Word documents. Learn how to harness the power of Tkinter's graphical interface and seamlessly integrate it with Python's capabilities to enhance your document creation experience.
0 Comments