Skip to content

GOVINDARAJLE/python-notepad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

python notepad

def __showAbout(self):
    showinfo("Notepad")

def __openFile(self):

    self.__file = askopenfilename(defaultextension=".txt",
                                  filetypes=[("All Files", "*.*"),
                                             ("Text Documents", "*.txt")])



        # Try to open the file
        # set the window title
        self.__root.title(os.path.basename(self.__file) + " - Notepad")
        self.__thisTextArea.delete(1.0, END)

        file = open(self.__file, "r")

        self.__thisTextArea.insert(1.0, file.read())

        file.close()

def __newFile(self):
    self.__root.title("Untitled - Notepad")
    self.__file = None
    self.__thisTextArea.delete(1.0, END)


    if self.__file == None:
        # Save as new file
        self.__file = asksaveasfilename(initialfile='Untitled.txt',
                                        defaultextension=".txt",
                                        filetypes=[("All Files", "*.*"),
                                                   ("Text Documents", "*.txt")])


            # Try to save the file
            file = open(self.__file, "w")
            file.write(self.__thisTextArea.get(1.0, END))
            file.close()

            # Change the window title
            self.__root.title(os.path.basename(self.__file) + " - Notepad")

Python GUI – tkinter

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create the GUI applications. Creating a GUI using tkinter is an easy task. To create a tkinter app:

Importing the module – tkinter Create the main window (container) Add any number of widgets to the main window Apply the event Trigger on the widgets. Importing tkinter is same as importing any other module in the Python code. Note that the name of the module in Python 2.x is ‘Tkinter’ and in Python 3.x it is ‘tkinter’.

  1. Tk(screenName=None, baseName=None, className=’Tk’, useTk=1): To create a main window, tkinter offers a method ‘Tk(screenName=None, baseName=None, className=’Tk’, useTk=1)’. To change the name of the window, you can change the className to the desired one. The basic code used to create the main window of the application is:

![ ]m=tkinter.Tk() where m is the name of the main window object

  1. mainloop(): There is a method known by the name mainloop() is used when your application is ready to run. mainloop() is an infinite loop used to run the application, wait for an event to occur and process the event as long as the window is not closed.

! [ ]m.mainloop()

tkinter also offers access to the geometric configuration of the widgets which can organize the widgets in the parent windows. There are mainly three geometry manager classes class.

1.pack() method:It organizes the widgets in blocks before placing in the parent widget. 2.grid() method:It organizes the widgets in grid (table-like structure) before placing in the parent widget. 3.place() method:It organizes the widgets by placing them on specific positions directed by the programmer.

About

python notepad

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages