Build A Text Editor Part 2 - Open and Save As Files - Python Tkinter GUI Tutorial

Поділитися
Вставка
  • Опубліковано 5 вер 2024
  • In this video we'll continue building our Text Editor with Tkinter and Python. Well add the "New File" function, the "Open File" function, and the "Save As File" Function.
    Opening and Saving files with Python and Tkinter are pretty easy, in fact we've looked at doing this exact thing in past videos. And creating a "New" file is done simply by deleting whatever was in our Text Widget already...and we know how to do that already too!

КОМЕНТАРІ • 111

  • @Codemycom
    @Codemycom  4 роки тому +1

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My UA-cam Channel:
    bit.ly/2UFLKgj bit.ly/2IGzvOR
    ▶️ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
    ▶️ Get The Code
    bit.ly/3fLFQ8p

  • @adistar-964
    @adistar-964 4 роки тому +4

    Amazing tutorial...
    I have been following u from the start when u uploaded this series.

  • @Learnobyte
    @Learnobyte Рік тому

    Great Teacher,

  • @jager0724
    @jager0724 4 роки тому +2

    This is insane
    I came here for ideas, because I'm making my text editor in electron.js and React, but I might as well switch to this...
    It's so so SO MUCH SIMPLER than js

    • @Codemycom
      @Codemycom  4 роки тому

      yeah js kind of sucks lol

    • @jager0724
      @jager0724 4 роки тому

      @@Codemycom Tell me about it
      It's like an abusive marriage where I have to do all the work :/
      Python, on the other hand, seems more of a casual hookup

    • @Codemycom
      @Codemycom  4 роки тому

      @@jager0724 yep

  • @jenilchudgar
    @jenilchudgar 2 роки тому

    Nice Video!

  • @aviralkaushik3171
    @aviralkaushik3171 4 роки тому +1

    Sir John, Please make a video for how to print something with printer hardware By python. Please make this video as soon as possible.
    By the way thank you for teaching us different languages for developing and now I can develpe many app with the help of you
    Thank you John Sir
    Regards,
    Anil Kumar Kaushik

    • @Codemycom
      @Codemycom  4 роки тому

      I likely will look at print at some point

    • @aviralkaushik3171
      @aviralkaushik3171 4 роки тому

      @@Codemycom Sir first of all thank you for replying, sir I want to ask after how much time(approx.) or how much videos you will make the video on printing trough printer hardware. Please sir tell me how much approx. time should I wait to watch the video on such a wonderful topic? Please reply sir.
      Thank You John Sir
      Regards
      Aviral Kaushik
      (R. S. V. P)

    • @Codemycom
      @Codemycom  4 роки тому

      @@aviralkaushik3171 Sorry, I have no idea

  • @leobozkir5425
    @leobozkir5425 3 роки тому +2

    Hello John! Thanks for this awesome tutorial. But I have a question: In the previous tutorial, you used "1.0", (string) but now you used a 1.0. (float) What is the difference?

    • @Codemycom
      @Codemycom  3 роки тому +2

      One is a number, one is not a number.

  • @P.L.D.
    @P.L.D. 3 роки тому

    Thanks! Amazing videos!

  • @rishibakshi2004
    @rishibakshi2004 2 роки тому

    thankuuu so much for this❤❤❤ god bless you

  • @walthansen6333
    @walthansen6333 3 роки тому

    Love these videos.... did find something though.... for the 'filetypes' at the end of the filedialog line, mine has to have [ ] at one point. [(file type, file ext)]

  • @zodyakpodcast4957
    @zodyakpodcast4957 2 роки тому

    nice

  • @helmiahmadfauzi1791
    @helmiahmadfauzi1791 2 роки тому

    Hey, John, thank you for this video, but I have one problem, whenever I text something and then use save as file, the window title shows up a folder path of the file like "Icon/sample.txt". So, how do I get rid of that only to show the filename instead?

  • @salehborhani4948
    @salehborhani4948 2 роки тому

    Thanks for this great video

  • @hello-ps1qm
    @hello-ps1qm 2 роки тому

    i have a problem about this code line here
    stuff = text_file.read()
    and the error
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 847: character maps to

  • @samrachkem7408
    @samrachkem7408 2 роки тому

    Hello John! Could you make a tutorial for building a Text editor using kivy also?

  • @afc_zanzoon9887
    @afc_zanzoon9887 4 роки тому +1

    What’s the frame.grid_forget() alternative for using .pack()?

    • @Codemycom
      @Codemycom  4 роки тому

      pack_forget() come on man...

  • @skladus
    @skladus 3 роки тому +1

    Hi. Thanks for all the tutorial videos. I've learned so much from your movies. I have a little problem with the status bar. When I open a file, the status bar does not show the path to the file. Instead it says:

    • @Codemycom
      @Codemycom  3 роки тому

      Sorry, I don’t know what’s going on but it might have something to do with the Linux file system.

    • @skladus
      @skladus 3 роки тому

      @@CodemycomOMG! Ok, problem solved. Funny thing. I mess with the line: text_file = filedialog.askopenfile(), instead text_file = filedialog.askopenfilename(). Everything is working fine now. And your code isn't working because i still reload my old code:D. Too many windows open:P. Sorry for the trouble;)

    • @leahblack4417
      @leahblack4417 2 роки тому

      When updating the status bar, use " root.title(f'{name.name} - Editor Title') "

  • @NeerajSharma-jn9xv
    @NeerajSharma-jn9xv 3 роки тому

    Great!

  • @NotBeHaris
    @NotBeHaris 4 роки тому

    Hi.
    I am waiting for django tutorial. Are you planning for more tutorials on djano or not.
    Or what about next tutorial topics.
    Thanks Respect for you from @Pakistan

    • @Codemycom
      @Codemycom  4 роки тому +1

      Will get back to the django blog at some point.

    • @NotBeHaris
      @NotBeHaris 4 роки тому

      @@Codemycom i am waiting for this.

    • @NotBeHaris
      @NotBeHaris 4 роки тому

      @@Codemycom Thanks

  • @shubhammali2072
    @shubhammali2072 2 роки тому

    Hi, I try this method with a button to save images but it's not working

    • @Codemycom
      @Codemycom  2 роки тому

      What did you do differently from the video?

  • @diabolobeays
    @diabolobeays 2 роки тому

    Hey, everytime i try to Save As... i get this Error: " File ". File ".../main.py", line 16, in saveas_file
    text_file = open(text_file, 'w')
    TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper"
    Help.

  • @estebanbr7596
    @estebanbr7596 2 роки тому

    Is there a way to save the file without putting the name manually?

    • @Codemycom
      @Codemycom  2 роки тому

      Sure, using a file dialog box

  • @siyabonganxumalo4574
    @siyabonganxumalo4574 3 роки тому

    Hi John
    How can you open a file without using filedialog? The file is a docx file not text and is on the same folder as the code.

    • @ij1316
      @ij1316 3 роки тому

      Import os and use os.startfile("Path to file/File name")
      This will open the file using default apps like MS Word for .docx, etc.

  • @solomonwiredu
    @solomonwiredu Рік тому

    Can I save my tkinter window with it's widget as a pdf?

    • @Codemycom
      @Codemycom  Рік тому

      Sure, but I don't have any videos on that

  • @Acem8887
    @Acem8887 4 роки тому +1

    Hi! Can you please make our app auto update using esky or something else using something like github?

    • @Codemycom
      @Codemycom  4 роки тому +1

      No clue what you mean

    • @Acem8887
      @Acem8887 4 роки тому +1

      Codemy.com hello again. What i mean is for example when there is an update for discord it auto updates itself on program startup. how can we do that on our python app?

    • @Codemycom
      @Codemycom  4 роки тому

      @@Acem8887 Oh that's way more complicated then any of these simple videos...

  • @LioncatDevStudio
    @LioncatDevStudio 4 роки тому

    Can u do a tutorial to show line numbers in the text editor?

    • @Codemycom
      @Codemycom  4 роки тому

      What do you mean by line numbers?

    • @justone4272
      @justone4272 4 роки тому

      @@Codemycom Like to the side where it displays every next lines number at the side, just like VS Code or any other editor of sorts.

    • @Codemycom
      @Codemycom  4 роки тому

      @@justone4272 Ah got it...probably won't do that for this text editor.

    • @justone4272
      @justone4272 4 роки тому

      @@Codemycom Alright, cant ask for more, and I am thankful enough that this was at least here. Again thank you a lot!

    • @Codemycom
      @Codemycom  4 роки тому

      @@justone4272 :-)

  • @arunbeckham8384
    @arunbeckham8384 3 роки тому

    Hai John!! For me 'File as been saved' message is not generating? please help me out.

    • @Codemycom
      @Codemycom  3 роки тому

      You likely have a typo in your code

  • @nisargchaudhary1980
    @nisargchaudhary1980 4 роки тому

    hello, My status bar didn't work from the previous tutorial itself. Can you help me out....

    • @Codemycom
      @Codemycom  4 роки тому

      Check your code for errors vs the video

    • @nisargchaudhary1980
      @nisargchaudhary1980 4 роки тому

      @@Codemycom
      I checked , I copied same but it's not showing the status bar itself

    • @Codemycom
      @Codemycom  4 роки тому

      @@nisargchaudhary1980 Sorry, but you did not copy the same or else it would work. Put it aside for a day and check it again, the error will likely pop right out then.

  • @suryanshtokas6337
    @suryanshtokas6337 4 роки тому

    Please make a video on how to make a maptlotlib graph appear in the same window with tkinter. Not pop up in another window.

    • @Codemycom
      @Codemycom  4 роки тому

      You probably need to use the canvas for that

    • @suryanshtokas6337
      @suryanshtokas6337 4 роки тому

      @@Codemycom Sir could you make a tutorial for that. Please

    • @Codemycom
      @Codemycom  4 роки тому

      @@suryanshtokas6337 Maybe someday

    • @suryanshtokas6337
      @suryanshtokas6337 4 роки тому

      @@Codemycom Thanks sir. Sentdex did one but you are such a great teacher so I was kinda hoping that you'd do one

  • @Zhisaoka
    @Zhisaoka 3 роки тому

    thanks so much, but I have one error that I cannot find the answer to anywhere, not even stack overflow.
    I know its coming from the root,config(menu=my_menu) I use "wn" instead of root though
    here is the error:" _tkinter.TclError: unknown option "-menu""
    btw. I fixed my python IDLE :D,
    I might just make my own for fun now, well after I figure out the error though

    • @Codemycom
      @Codemycom  3 роки тому

      it should be root.config not root,config

    • @Zhisaoka
      @Zhisaoka 3 роки тому

      @@Codemycom oh, I have that in the original. Sorry I just misspeled

    • @Zhisaoka
      @Zhisaoka 3 роки тому

      @@Codemycom here is the reall code:
      my_menu = Menu(wn)
      wn.config(menu=my_menu)
      def new_file():
      my_text.delete("1.0", END)
      wn.title("New File - FIle")
      status_bar.config(text="New File Created")
      And the original error is:
      Traceback (most recent call last):
      File "/Users/MyName/Documents/ProjectName.py", line 68, in
      file_menu.add_command(label="New File", menu=new_file)
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 3299, in add_command
      self.add('command', cnf or kw)
      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 3286, in add
      self.tk.call((self._w, 'add', itemType) +
      _tkinter.TclError: unknown option "-menu"

    • @Codemycom
      @Codemycom  3 роки тому

      @@Zhisaoka Then you have some other typo in your code...check it against the code in the video.

    • @Zhisaoka
      @Zhisaoka 3 роки тому

      @@Codemycom I tryed, but I will again.
      Thanks

  • @aakarshkumar6935
    @aakarshkumar6935 4 роки тому

    Sir could you please add a print option.

  • @karanindersingh8257
    @karanindersingh8257 4 роки тому

    Hi sir, I'm new to your channel and I really like how you teach, but I'm just 14 years old can I do this course?
    Plz tell

    • @Codemycom
      @Codemycom  4 роки тому +1

      Try it and see...there's nothing stopping you :-)

    • @karanindersingh8257
      @karanindersingh8257 4 роки тому

      @@Codemycom Thnx a lot sir, I'll sure start it tomorrow 👍🏼

    • @Codemycom
      @Codemycom  4 роки тому +5

      @@karanindersingh8257 Why not today? People who say they'll start things tomorrow, never do.

  • @bharaths7816
    @bharaths7816 3 роки тому

    Can We Save The TXT File As PDF?

    • @Codemycom
      @Codemycom  3 роки тому

      Sure

    • @bharaths7816
      @bharaths7816 3 роки тому

      @@Codemycom First Of All Thank You For Replying, I tried it but when I opened the pdf file it says something went wrong y I got this Error?

    • @Codemycom
      @Codemycom  3 роки тому

      @@bharaths7816 Well yeah, it takes a lot of specific coding to do this.

    • @bharaths7816
      @bharaths7816 3 роки тому

      @@Codemycom Ohh So Can You Please Make A Specific Video For It Asap It Would Be A Great Help For Me And Others? 🤘

    • @Codemycom
      @Codemycom  3 роки тому +1

      @@bharaths7816 MIght do that yes

  • @dioovaheaven3265
    @dioovaheaven3265 3 роки тому

    the save as isnt working

  • @indragupta7402
    @indragupta7402 3 роки тому +1

    Plz share source code

    • @Codemycom
      @Codemycom  3 роки тому

      Check pinned comment for link

  • @mastakouris
    @mastakouris 3 роки тому

    The save as does not actually save the files

    • @Codemycom
      @Codemycom  3 роки тому

      Huh?

    • @mastakouris
      @mastakouris 3 роки тому

      @@Codemycom I mean, I made the "Save as" function and when I click the save as button it shows the file explorer and everything but kit does not actually "save" the files there. When I try to find them they are not on the folder. I can give you my code if you want to.

    • @Codemycom
      @Codemycom  3 роки тому

      @@mastakouris What did you do differently than me? You likely have a typo.

    • @mastakouris
      @mastakouris 3 роки тому

      @@Codemycom ok I fixed it

    • @Codemycom
      @Codemycom  3 роки тому +1

      @@mastakouris cool

  • @pirog-x
    @pirog-x 3 роки тому

    gime me code please

    • @Codemycom
      @Codemycom  3 роки тому

      Code is always in the pinned comment

  • @ronf6900
    @ronf6900 Рік тому

    .