@@achyarfauzan4880 Thanks for your question, but I am not sure I understand you correctly. Can you perhaps elaborate on what it is you're actually trying to achieve? Please provide some additional info. Thanks!
Hey. keep up the great work. I've just subscribed to your channel. Can you do a tutorial on how to generate a .pdf file in python if you don't already have such a tutorial?
Can i run the gui app when i open My Microsoft word app ? So if i fill data and press "submit" in gui, i can see my data in Microsoft word change. without i close and reopen my Microsoft word
You are a genius. What a wonderful tutorial. Easy to understand, well explained, and to the point. I hope to post full projects using Python Tkinter and PySimpleGUI. You really deserve TEN STARS
Thank you for this video, you have turned an hour long chore into a 5 minute giggle fest. I could not get the gui working, but the app in vs code is enough for me.
As always invaluable. I was thinking of adding Pandas also, so for a company with say 100 employees can have this template and read the data from an excel file, and generate all the empoloyees contracts in matter of seconds.
Thank you! That is a fantastic idea. 👍 I went ahead and created the following solution for you: Code: github.com/Sven-Bo/word-generator-based-on-excel-list Demo: raw.githubusercontent.com/Sven-Bo/word-generator-based-on-excel-list/master/demo.jpg I hope you like the solution :)
Thanks for watching. Sure, that is possible with PySimpleGUI. Regarding the dropdown list, have a look at the documentation under list-box: pysimplegui.readthedocs.io/en/latest/call%20reference/#listbox-element In my other tutorial (entry form for Excel), you can see how to implement those elements incl. the checkbox (returns TRUE/FALSE): th-cam.com/video/svcv8uub0D0/w-d-xo.html I hope this helps! Happy Coding!
This was super helpful Sven! Thanks so much! But I've got a question, Can you please help? Is it possible to duplicate the template with DIFFERENT VARIABLES, and add it as another Page? I'd really appreciate your help on this Sven :)! Thanks!
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hello! Great tutorial! May I ask if its possible to do reverse in this? Taking the data from the saved doc file to the program we made? Like using [Open] button to get data from a document previously produced with this? Thank you! Maybe like adding a field code/reference on word so we have strings to capture? Thanks!
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
another question. after execute i have this error: No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI37762\\document.docx' , why? and what can i do?
Very good but the Main Part is missing 😅 how you can change + Save different docx files (version1.docx, version2.docx,..) with the same named fields inside of the docx files?
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Very good tutorial, but I have a question if we use a {Client} or [Name] or , how can we do this, as financial contracts are much more complex Example: {TermTitle} {Senior} {Currency} {AggPrinAmount} {Collared}{Type} Notes due {MaturityDate format “yyyy”}
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
Thanks for watching. I have created the following version for you: gist.github.com/Sven-Bo/bfaff775394579d4915aab9c43700633 Please adjust the output folder(path) [Line 30] to your needs. I hope you like the solution. Happy Coding!
Hey Sven, great tutorial, thank you so much! How can I make a value print in the Word template file (just like you showed in the non-GUI part) using the user data input?
@@CodingIsFun I got it! Now my problem is I need to call a function to the "Read" button so I can choose the directory to save the Word file! Any ideas? Thanks!
@@CodingIsFun No worries, figured it out thanks to your replies in the comments. Thank you so much, I respect the fact that you actually reply and try to help people out. Appreciate it.
Is there a way to use checkboxes to delete certain parts of a word document? I know you can’t make a new video for this, but any general guidance if possible would be great
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hi there Sven,I've been trying to follow along with your tutorial and create my own document. So far I managed to do all right, but now I am on a stage of turning .py to .exe file and it did turn out well, but it doesn't generate a document stating that there is no such .docx file in _MEIxxxxx directory. (I tried to look up for directory and put the file in it but it turns out it just a temporary directory, which disappears once you exit .exe file) I even took your example and tried to use it as .exe file and it returns the same error.
@@CodingIsFun My man, thank you so much! It did help: I changed both in document_path and output_path and it returned as expected. Thank you once again!
HI! thanks for the video, you're very good and I'm learning a lot from you, I would still like to ask you how to change the destination folder for saving the Word file, I can't solve this problem, and I can't find much material on the net, I thank you and I'll take advantage of it to say hello to you and everyone!!
Thanks for the video. I watched several of your videos. How can I use docxtpl in flask. I'm breeaking my head for 5 days. I've searched a lot but I haven't been able to work.
Thanks for watching. That sounds possible, yet I do not have a code example. You could try to load the content of your word document (e.g. using textract textract.readthedocs.io/en/stable/ ) and then display the content in a PySimpleGUI element. I hope it helps! Happy Coding!
Thank you! You could also save it as a pdf. I have done something very similar in the following video: th-cam.com/video/T3meVMaV8AA/w-d-xo.html I hope it helps! Happy Coding!
so in addition to this, would it be possible to set up a method of adding an email to this form and emailing it to the person who fills it out ? is this a video you could make ?
In general, PySimpleGUI is only responsible for the GUI. This means you could include any python action you would like in the GUI. E.g. for sending an email, have a look at the following tutorial: th-cam.com/video/JRCJ6RtE3xU/w-d-xo.html Once you understand how to send emails using Python, you can define a function and call it from the GUI. I hope this helps! Happy Coding! :)
Is it possible to create a button on GUI where i can select different templates, because i have the same template but in two languages. So for this reason i want to create a button to Select the Language of the template ( i have created it as a differenc document ) and after that i want to fill the fields needed. Thank you.
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hey Sven, I tried doing this using IDLE python, does using different python IDLE matters? because it is not working for me. Perhaps I can ask what kind of python you are using?
Hi Renzie! The IDE or text editor shouldn't matter. In the video, I used Atom, but you can use any other text editor or IDE. Good luck debugging your code! 🍀
Hello, great video. I am using your tutorial to build the form in a MacOS. All working fine, however, when trying to generate the EXE using PSG Compiler (I want to generate the EXE and then share it with a Windows machine), I get "The output directory is not empty. Please remove all its contents or use the -y option (remove output directory without confirmation)", any idea why this error appears?
@@CodingIsFun thankyou so much for your reply. with do respect I wanna complete my question. how can I add a (.png) file in this created (.docx) file which created by this code? i need the command as to add a (.png) file in this (.docx) document. either Automatically or by using a checkbox button. it doesn't matter. i need to know by using which command I can add the .png file in this .docx which created by this code
@@ahmadmureed4739 Please check out the following video: th-cam.com/video/T3meVMaV8AA/w-d-xo.html In the video, I am going through the steps to insert images into the Word document.
@@CodingIsFun i have checked the video. but I cant build a command that insert a .png in this docx which created by this code. i also want to ask how can I add another entry widget in this window as to give the name of created file. please give me the command code if its possible.
@@CodingIsFun thanks for the wonderfull toturials. i am trying to work with this. i have a question about. i want to save the file each time in a different name. can you please write me by which command can I define name of the saved file? i am using pycharm to run this code.
Hi Sven, I've run into a problem in converting my py to exe using Mike's psgcompiler. My bitdefender goes nuts and detects Trojan temporary files during the process and blocks them, causing the conversion to fail. Is this normal behaviour for bitdefender? Please can you advise on this? Many thanks, Matthew
Hi Matthew, Thank you for watching. Under the hood, the psgcompiler uses the PyInstaller package. I have experienced something similar when trying to distribute the packaged .exe online. It then gets flagged by browsers and also local antivirus software on the end users' devices. Unfortunately, I do not have a solution to this. If you just want to use it on your personal device, one quick workaround would be to deactivate the Bitdefender software for the time being while compiling the Python project to an executable. And perhaps, once done, add an exception to Bitdefender so that it is not going to be flagged. I know this might not be the answer you are looking for, but unfortunately, I do not know another workaround.
hi, your video tutorial is really a handy one for any code developer. I have a doubt. We try to develop an entry form with nearly 30 details with character length around 50 each. When we try to run with your code model, layout did not fit in the window. alternatively we tried to run through 'sg.Column' with scrollable bar. Despite scrollable window appear with read and exit option, values entered could not be linked with word document and python window returns following error - "jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'OTHER' is it right to use this column option? following is the structure import... . . . column = [ . sg.text [...] ' ' ] layout = [ [sg.Column (column, scrollable = True, vertical_scroll_only = True,key ='COLUMN')], [sg.Button ("Generate"), sg.Exit("Exit")], ] Window = sg.Window("PAT", layout, element_justification="Center") while True: event, values = Window.read() if event == sg.WIN_CLOSED or event == "Exit": break if event == "Generate": doc.render(values) print(event, values) output_path = Path(__file__).parent / f"PAT_{values['PATNO']}_{values['YEAR']}.docx" doc.save(output_path) sg.popup ("File saved", f"File has been saved here:{output_path}") Window.close ( ) Provide your insight into this doubt.. Thanks ..
Hi Sven, When I try to put my fields into tabs my create button stops working and I get an error saying keywords must be strings. Without the tabs it seems to work but since I have many fields I need to use them. The logic remains constant but I'm getting that error in the console
Thanks for watching! It's hard to diagnose the issue without more context, but the error message you received typically indicates that a non-string value was used for a keyword argument. Please review the line of code where the error occurred and ensure that all keywords are specified as strings. Happy Debugging! :)
Sorry, but I do not understand your question. It is explained at 1:46 min It will just return the folder of the current Python file. Have also a look at the documentation: docs.python.org/3/library/pathlib.html Happy Coding!
@@CodingIsFun i think i have the same problem as the commentor. Mine shows that "NameError: name '__file__' is not defined". What should i do to resolve this?
hi there, why the created docx is on tmp folder when I created .exe, not on the specified output_path .. Is it connected with __pycache__ ?? thanks a bunch
I learn a lot from you bro! Tried this code. Awesome. Regarding the docxtpl, how could I change the output path for newly created document file? What if I want to save it in another folder that is different where my python fille is located? What code should I use? Will really appreciate your input here bro
Thanks for watching. Happy to hear that you learned a lot. Regarding your question, I recommend 'pathlib' for dealing/specifying the output file path. Have a look here: th-cam.com/video/iqZ2V8qTYq8/w-d-xo.html I hope it helps! Happy Coding!
@@taruku_luca Hard to tell from a distance. My closest guess is that you are getting this issue because you are trying to import a module of a library which is not installed in your virtual environment. If you have run 'pip install psgcompiler' already, ensure to call psgcompiler from the same environment in which you installed the package. For example, in your IDE/text editor, you might have set a different Python environment for executing your script. Therefore, try to run psgcompiler also from the command prompt. If that does not work, try searching for the text of your error message on Google/StackOverflow. Happy Debugging!
@@CodingIsFun Already solved this issue bro. thanks. I also watched your PathLIb lectures. Downloaded the cheatsheet. Very comprehensive bro. Thanks so much. One thing I haven't seen in the PathLib tutorial is what if I want to save file on the desktop? And if I convert it into .exe file, what path should I write so that the output path will be universal in desktop of any user? for example: This is my output path. C:\Users\username\Documents\pycharm\learning phyton\sample If I convert this into .exe , then pass it to my colleagues, can they save it on the same output path regardless of the username?
Hi, I loved your video and thank you for guiding us in the right direction. I'm stuck where I get an error, Undefined File "", line 22, in top-level template code jinja2.exceptions.UndefinedError: 'S' is undefined How do I fix this? I do not have anything like that in my code and I followed exactly yours. Any inputs would be highly appreciated!
very educative. everything runs smoothly just one concern. the .exe file is big. the .py is a few kbs but the .exe is more than 100mbs. any fix for that or it's all good?
Thanks for watching! I'm glad you found it educational. As for the size of the .exe file, it's normal for executables to be larger in size compared to the source code. This is because the executable includes all the dependencies required to run the code, even if they are not used in the project. One way to reduce the size of the executable is to create a separate virtual environment and only include the packages needed for the project. This way, you can ensure that only the necessary files are included in the build process.
@@georgejunior7556 Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
Your video great, i found very late, really good... Thanks for sharing knowledge. One query, i m fetching live nse share market data of stock from morning 9.15 to 3.30 in excel. 1. Can't open excel while recording. 2. If I want to visualisation while recording data means = 9.15, 9.20,9.25 same data i want in visualize form (webpage/or else) till 3.30 while recording in excel. How to do it... Im digging but search brought me to u.. Plz help...
Dear Sir, all is nice. But when I try to run exe file, the error show: Failed to execute script due to unhandled exception. No such file or directory. I checked path, it try to load ..\\AppData\\Local\\Temp\\... Not load my current working directory. All docxtpl required files could not be loaded. How to fix this. I install python using venvture enviroment. Do you have a good idea? Thank you so much
Sorry sir, I have a question. Let say I have 2 AMOUNT (AMOUNT A & AMOUNT B), what should I do to have it sum up automatically? (like the one you did for nonrefundable). Thanks in advance
That should be possible. An easy way would be to simply to convert the created Word Document to PDF (as shown here: th-cam.com/video/T3meVMaV8AA/w-d-xo.html) Happy Coding!
Can i run the gui app when i open My Microsoft word app ? So if i fill data and press "submit" in gui, i can see my data in Microsoft word change. without i close and reopen my Microsoft word
Have you tried to isolate your dependencies in a separate environment before converting the script to an exe file? Please create a virtual environment, install the packages for your project in that environment and then try to convert the py to exe again.
Hi sir. Can we convert the user input text into uppercase? Even if the user type in lowercase, I want the input to appear as uppercase in the template. If it possible, can you share the code on how to do that? Thanks in advance
Just a heads up, if the user inputs letters instead of number in the 'Amount' field, the code gives an error, and the stops running, therefore the user cant correct it and try again.
Thank you for watching. I understand your point. It's not always possible to build a foolproof application in a 10-minute video. The goal of the video is to provide a starting point for viewers to enhance and develop their own application (including error handling)
@@CodingIsFun I have some CSV files which I want to extract data from them and put it at one docx file .I need a script that make this automatically Thanks for your interest ☺️
@@mohussein4699 I have a similar tutorial on that topic. Find it here: th-cam.com/video/Zy9sx4GvjUY/w-d-xo.html It should give you a good starting point. Happy Coding!
is it possible to add image to the doc? any tips? hehe i want to help my mom with her multiple lesson plan that need to submit every week omg, hope i can help her withthis apps
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hello sir thank you so much, it's really helpful.🧡 How can I build different layouts for a larger contract with more fields and multiple windows while saving the information in the same ms-word? I made a rental deed template, and because my deed has a lot of fields to fill in, I made a function for each section that contains: layout, a window, a while loop with an event button, and context. When I save the information, it only fills the last section that I enter. I have, for example, an owner function, a tenant function, and functions for payment, term, designation, and so on. When I click the owner button, a window appears to allow me to enter owner information; when I click the tenant button, a window appears to allow me to enter tenant information. When I open the template, however, only the tenant informations are filled in. Do you have any ideas on how to do it?☺
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
While using the executable file thru psgcompiler, I get the error: Errno2: no such file or directory (the directory listed in the error is not where I placed my file. I am using spyder by the way)
@@CodingIsFun that worked, but I’m not sure where it saved the file. I tried looking through my documents. Do I need to change the output path as well? Appreciate the help
Beginner here: When I run the script, I get the error: ModuleNotFoundError: No module named 'docxtpl'. I uninstalled and reinstalled docxtpl via the console with pip install / uninstall multiple times, but I still get the error. How can docxtpl be missing when it is istalled? Thx for the video :)
Hard to tell from a distance. My closest guess is that you are getting this issue because you are trying to import a module of a library which is not installed in your virtual environment. If you have run 'pip install docxtpl' already, ensure to call your Python file from the same environment in which you installed the package. For example, in your IDE/text editor, you might have set a different Python environment for executing your script. Therefore, try to run your Python file also from the command prompt. If that does not work, try searching for the text of your error message on Google/StackOverflow. Happy Debugging!
@@CodingIsFun Thx for your reply, like you said I bypassed the whole search by installing Anaconda and installing docxtpl there. N.B. for this problem with the different environments there is no good answer on the internet a beginner might understand :/
@CodingIsFun you showed us how to save the values from the input fields into a word file. could you please show us how to do it vice versa? so that when I press a 'load' button the stored values from the .docx-file get inserted back to the proper text fields. I only get back the word "end" into all my text input fields. I must admit I used Tkinter but this shouldn't be the problem. Instead of 'doc.render(values)' I used for Tkinter 'doc.render(context)' and created a context like 'context = { "TextField1": entryExample1.get(1.0, END) }'to make a reference for the Word-Application. This works so far to save something. But when I use 'context = { "TextField1": entryExample1.insert(1.0, END) }' I only get back the strings "end" into my input fields?
I am unsure if that is possible, as I assume that the rendered Word Document has no 'connection/memory' to the original template. I might be mistaken, but I am missing the time to search the internet for a solution. Thanks for your understanding!
hi ...... im getting an error in this one but i couldnt rectify it..... i took ah screenshot of the error. In it its given that line 2, in event, values = window.read() you have tried 100 times to read a closed window you need to DD check for event == WIN_CLOSED can you help me out?
Thanks for watching. Unfortunately, with that bit of information, I cannot help you. You might want to take some time to write down which line of code is causing the error; let me know if you have modified the code from the tutorial, explain in more depth what you did to troubleshoot the problem and provide some more context. Thanks!
@@CodingIsFunThis where the error comes..... its shows " trying to open a closed file ... you need to add a check event == WIN_CLOSED" like that window = sg.Window("ECS FORM", layout, element_justification="right") while True: event, values = window.read() if event == sg.WIN_CLOSED or event == "Exit": break if event == "Create Contract": values["DATE"] = today.strftime("%Y %m %d") doc.render(values) output_path = Path(__file__).parent / f"{values['PHONE']}.docx" doc.save(output_path) sg.popup("File saved", f"File has been saved here: {output_path}") Balance code is same as your ..... only the heading changes........ its showing error in reading the input from user and updating it......
Ciao! grazie per il video , sei bravissimo e sto imparando molto da te ,vorrei comunque chiederti come fare a cambiare la cartella di destinazione del salvataggio del file word,non riesco a risolvere questo problema ,e non trovo molto materiale in rete ,ti ringrazio e approfitto per salutarti e salutare tutti!!
Hey there, thanks for watching the video! I'm sorry I can't help you with your problem based on the information you provided. To give me a better idea of what's going on, it would be super helpful if you could write down which line of code is causing the error, let me know if you modified the code from the tutorial, and explain in more detail what you did to troubleshoot the problem. Don't forget to also give me some context about your setup and environment. If you're having trouble figuring things out, another option is to join our Discord server at pyhtonandvba.com/discord. You can ask your question there and maybe someone in the community can help out. Thanks for understanding.
@@CodingIsFun thanks for the reply.im trying to create my own entry form software for work,and i cant seem to make it read my input in the input field,hence not replacing the placeholders.any tips(im new to coding.😅)
@@lennycecile3775 Unfortunately, with that bit of information, I cannot help you. You might want to take some time to write down which line of code is causing the error; let me know if you have modified the code from the tutorial, explain in more depth what you did to troubleshoot the problem and provide some more context. Thanks!
I keep getting 'psgcompiler : The term 'psgcompiler' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.' when I try to run psg compiler. When I pip install psg it says it's already satisfied in the following location: users ame\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\etcetera. I've tried manually opening this file location, but I can't find the file 'appdata'. What do I do?
Hello! I am having just one problem with the last step: When I try to run the .exe file, this error pop-up appears: drive.google.com/file/d/1u7Kj3fNmMfFJlTeZAeSdnPtlYyxAwAjN/view?usp=sharing All the other steps worked perfectly, I can even run the program with Python. Can you please help me? I would really appreciate it :)
Thank you for watching my video! I'm sorry that the Python code I provided doesn't seem to be working on your machine. I suggest creating a separate virtual environment and installing the required libraries there. This will ensure that you have a clean, isolated environment for running your Python code, which can help avoid conflicts with any other libraries that you have installed on your machine. If that doesn't work, another thing you could try is using a different version of Python. For example, you could try using Python 3.8.5 instead of the version of Python that you are currently using. This might help resolve any compatibility issues that you are experiencing.
Hi reference [vendor-contract-gui.py] My Doc [output_path] File Ends up in a Temp folder when I create the exe file. As soon as the script stop running it get deleted. Can you help me with this problem I think the problem is with the .. [output_path = Path(__file__).parent] when the exe is excuted it goes to my Temp folder and then get deleted by Windows. ps it works fine when I run it as a script but te exe file save it to a temp folder.
Hi thanks for taking the time to reply to my query. I have replaced the code you suggested and it now works fine. I am just started to learn Python having coded in VBA for years and was looking for a new challenge. Keep up the good work, your videos and really helpful Regards Phil
*I will be here in the comments section. If you have any questions, please let me know.*
how to make checkbox title to be a value in that
@@achyarfauzan4880 Thanks for your question, but I am not sure I understand you correctly. Can you perhaps elaborate on what it is you're actually trying to achieve?
Please provide some additional info. Thanks!
Hey. keep up the great work. I've just subscribed to your channel. Can you do a tutorial on how to generate a .pdf file in python if you don't already have such a tutorial?
You provide such a great support!! :D 👌👍... Much appreciated!
Can i run the gui app when i open My Microsoft word app ?
So if i fill data and press "submit" in gui, i can see my data in Microsoft word change. without i close and reopen my Microsoft word
This is one of the best programming tutorials I have ever seen
Thanks for the kind words! I am glad you enjoyed it.
You are a genius. What a wonderful tutorial. Easy to understand, well explained, and to the point. I hope to post full projects using Python Tkinter and PySimpleGUI.
You really deserve TEN STARS
Thanks for the kind words! I am glad you enjoyed it. ❤️👍
Most useful programming tutorial I have ever seen!
Wow, thanks! Cheers, Sven ✌️
The way of your explining is great. People can learn a lot in a very short time. And all of your topics are very useful. Thank You.
Thank you for your kind feedback!
Wow! So amazing and easy explained! Exactly what I was looking for. Thank you
Glad you liked the video. Thanks for watching! :)
Simple and to the point.
Thank you very much and keep with your fantastic work!
I'm thrilled you enjoyed it! Thanks for commenting and watching. Cheers, Sven ✌️
Thank you for this video, you have turned an hour long chore into a 5 minute giggle fest. I could not get the gui working, but the app in vs code is enough for me.
Thanks for watching the video & taking the time to leave a comment! Well, at least the word template generator (w/o GUI) is working :)
Very practical and useful. You make coding fun! 😊👍
Glad to hear you liked it! Thank you for commenting and watching.
If I do not run exe python, every thing is perfect. Great video!
Glad you liked it!
Самый лучший урок!!!
Glad to hear you liked it! Thank you for commenting and watching. Cheers, Sven ✌️
That's very good tutorial, direct to the point...👏🏻👏🏻👏🏻
Glad you liked it. Thanks for watching and taking the time to leave a comment! 👍
I was badly looking for a method to create the contract document. Thank you very much for this easy tutorial.
Fantastic! Hope you can you this tutorial as a starting point to create your desired application :)
Great tutorial sir keep it up with this incredible work!
Thank you! :)
Thank you for sharing. It was very helpful for my CRM project.
Glad it was helpful! Thanks for watching and taking the time to leave a comment 👍
Life changing.. amazing!
Glad to hear you liked it, Ricardo! Thank you for commenting and watching. 👍
Fantastic stuff !!! ❤
Glad to hear you liked it! Thank you for commenting and watching. 👍
It is a great tutoril. it is short but very useful. Thank you so much!
Thanks for the kind words! I am glad you enjoyed it.
As always invaluable. I was thinking of adding Pandas also, so for a company with say 100 employees can have this template and read the data from an excel file, and generate all the empoloyees contracts in matter of seconds.
Thank you! That is a fantastic idea. 👍
I went ahead and created the following solution for you:
Code: github.com/Sven-Bo/word-generator-based-on-excel-list
Demo: raw.githubusercontent.com/Sven-Bo/word-generator-based-on-excel-list/master/demo.jpg
I hope you like the solution :)
@@CodingIsFun Omg, your rock man.
Awesome project!! Helped a lot
Happy to hear that, Alexandre! Thanks for watching & leaving a comment! :)
This is great man. Thank you
Glad you liked it. Thanks for tuning in!
This is cool. I wonder if booleans are possible, like using certain values if a checkbox is ticked. Or choosing from drop-down lists.
Thanks for watching.
Sure, that is possible with PySimpleGUI.
Regarding the dropdown list, have a look at the documentation under list-box:
pysimplegui.readthedocs.io/en/latest/call%20reference/#listbox-element
In my other tutorial (entry form for Excel), you can see how to implement those elements incl. the checkbox (returns TRUE/FALSE):
th-cam.com/video/svcv8uub0D0/w-d-xo.html
I hope this helps!
Happy Coding!
This was super helpful Sven! Thanks so much!
But I've got a question, Can you please help?
Is it possible to duplicate the template with DIFFERENT VARIABLES, and add it as another Page?
I'd really appreciate your help on this Sven :)!
Thanks!
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Thank you for subtitles Arabic and thank you for informations 😍😍
You're very welcome! Thank you for watching and for the comment!
I really like how you implemented a process to distribute this program with non technical people to use with the psg compiler
Happy to hear that it was useful; thank you for taking the time to leave a comment and for watching the video!
I like your little clay buddy 👍
Yeah, I like him too 😅
Good work! Thanks!
Thank you!
Hello! Great tutorial!
May I ask if its possible to do reverse in this? Taking the data from the saved doc file to the program we made?
Like using [Open] button to get data from a document previously produced with this? Thank you!
Maybe like adding a field code/reference on word so we have strings to capture? Thanks!
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Love your videos!! What tools do you use to make these wonderful videos with all the animations?
*I am glad to hear you are enjoying them, thanks for watching and for the comment!* I am using Camtasia to edit my videos.
another question. after execute i have this error: No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI37762\\document.docx' , why? and what can i do?
Instead of:
document_path = Path(__file__).parent / "document.docx'"
Try:
document_path = Path.cwd() / "document.docx'"
@@CodingIsFun i love u dude
Excelente!!! 👍👍👍👍👍👍👍👍
Thanks! 😃
Very good but the Main Part is missing 😅 how you can change + Save different docx files (version1.docx, version2.docx,..) with the same named fields inside of the docx files?
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Very good tutorial, but I have a question if we use a {Client} or [Name] or , how can we do this, as financial contracts are much more complex Example:
{TermTitle}
{Senior} {Currency} {AggPrinAmount} {Collared}{Type} Notes due {MaturityDate format “yyyy”}
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
hi, great vid. may i know if i could make it as the generated documents are saved to a different folder?
Thanks for watching. I have created the following version for you: gist.github.com/Sven-Bo/bfaff775394579d4915aab9c43700633
Please adjust the output folder(path) [Line 30] to your needs. I hope you like the solution.
Happy Coding!
@@CodingIsFun thank you so much. you're a lifesaver
Hey Sven, great tutorial, thank you so much! How can I make a value print in the Word template file (just like you showed in the non-GUI part) using the user data input?
Thanks for watching. Can you let me know the timestamp? I am not sure to which print command you are referring to. Thanks!
@@CodingIsFun I got it! Now my problem is I need to call a function to the "Read" button so I can choose the directory to save the Word file! Any ideas? Thanks!
I love it! if possible, help to advise why file has been save to AppData\Local\Temp like that? I'm using .exe file after compile.
Thanks!
Try to change the following:
current_dir = Path(__file__).parent if '__file__' in locals() else Path.cwd()
to this:
current_dir = Path.cwd()
@@CodingIsFun How do you do this?
@@manlikecapitan What do you mean?
@@CodingIsFun No worries, figured it out thanks to your replies in the comments. Thank you so much, I respect the fact that you actually reply and try to help people out. Appreciate it.
Really nice, thank you for this video, as always perfectly explained !
Thank you very much! As always, thanks for your support and comments! :)
Is there a way to use checkboxes to delete certain parts of a word document? I know you can’t make a new video for this, but any general guidance if possible would be great
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
That's so cool!
Thanks!
Hi there Sven,I've been trying to follow along with your tutorial and create my own document. So far I managed to do all right, but now I am on a stage of turning .py to .exe file and it did turn out well, but it doesn't generate a document stating that there is no such .docx file in _MEIxxxxx directory. (I tried to look up for directory and put the file in it but it turns out it just a temporary directory, which disappears once you exit .exe file)
I even took your example and tried to use it as .exe file and it returns the same error.
Please change the following:
Delete: document_path = Path(__file__).parent / "vendor-contract.docx"
Add: document_path = Path.cwd() / "vendor-contract.docx"
..and try again. Happy Coding!
@@CodingIsFun My man, thank you so much! It did help: I changed both in document_path and output_path and it returned as expected. Thank you once again!
HI! thanks for the video, you're very good and I'm learning a lot from you, I would still like to ask you how to change the destination folder for saving the Word file, I can't solve this problem, and I can't find much material on the net, I thank you and I'll take advantage of it to say hello to you and everyone!!
Thanks for watching. It is explained in the video: 7:55 min
@@CodingIsFun Grazie!!!
AMAZINGGGGG
Thanks!
Thanks for the video. I watched several of your videos.
How can I use docxtpl in flask. I'm breeaking my head for 5 days.
I've searched a lot but I haven't been able to work.
Thanks for watching the video. Unfortunately, I have not tried to use docxtpl in flask yet. Hence, I cannot provide much support here.
Is it possible to make something like a document preview window? if yes, how? thanks for answers
Thanks for watching.
That sounds possible, yet I do not have a code example.
You could try to load the content of your word document (e.g. using textract textract.readthedocs.io/en/stable/ ) and then display the content in a PySimpleGUI element. I hope it helps! Happy Coding!
Amazing.
Glad you liked it. Thanks for watching.
very good video and well explained, but I wish it could be saved in pdf
Thank you! You could also save it as a pdf. I have done something very similar in the following video:
th-cam.com/video/T3meVMaV8AA/w-d-xo.html
I hope it helps! Happy Coding!
Thanks
so in addition to this, would it be possible to set up a method of adding an email to this form and emailing it to the person who fills it out ? is this a video you could make ?
In general, PySimpleGUI is only responsible for the GUI. This means you could include any python action you would like in the GUI.
E.g. for sending an email, have a look at the following tutorial: th-cam.com/video/JRCJ6RtE3xU/w-d-xo.html
Once you understand how to send emails using Python, you can define a function and call it from the GUI.
I hope this helps! Happy Coding! :)
Is it possible to create a button on GUI where i can select different templates, because i have the same template but in two languages. So for this reason i want to create a button to Select the Language of the template ( i have created it as a differenc document ) and after that i want to fill the fields needed. Thank you.
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hey Sven, I tried doing this using IDLE python, does using different python IDLE matters? because it is not working for me. Perhaps I can ask what kind of python you are using?
Hi Renzie! The IDE or text editor shouldn't matter. In the video, I used Atom, but you can use any other text editor or IDE. Good luck debugging your code! 🍀
Hello, great video. I am using your tutorial to build the form in a MacOS. All working fine, however, when trying to generate the EXE using PSG Compiler (I want to generate the EXE and then share it with a Windows machine), I get "The output directory is not empty. Please remove all its contents or use the -y option (remove output directory without confirmation)", any idea why this error appears?
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
You need to remake the EXE on a windows machine
Great !!!!
Thanks!
Im followed along with your tutorial, but when i generate the output doc the name does not appear on the doc it leaves it blank.
Thanks for watching. Please clone the GitHub repo and try again. Thanks!
Thanks so much, you are an awesome teacher... loved this tutorial a lot
Thanks for the kind words! I am glad you enjoyed it.
@@CodingIsFun Looking forward to more videos... may be longer tutorials series... hahaha ... all the best 👍
Hi, thanks for wonderfull explaination. can you please werite me by which code can I add an image (.png) in this document ?
@@CodingIsFun thankyou so much for your reply. with do respect I wanna complete my question. how can I add a (.png) file in this created (.docx) file which created by this code?
i need the command as to add a (.png) file in this (.docx) document. either Automatically or by using a checkbox button. it doesn't matter. i need to know by using which command I can add the .png file in this .docx which created by this code
@@ahmadmureed4739 Please check out the following video: th-cam.com/video/T3meVMaV8AA/w-d-xo.html
In the video, I am going through the steps to insert images into the Word document.
@@CodingIsFun i have checked the video. but I cant build a command that insert a .png in this docx which created by this code. i also want to ask how can I add another entry widget in this window as to give the name of created file. please give me the command code if its possible.
@@CodingIsFun thanks for the wonderfull toturials. i am trying to work with this. i have a question about. i want to save the file each time in a different name. can you please write me by which command can I define name of the saved file? i am using pycharm to run this code.
Hi Sven, I've run into a problem in converting my py to exe using Mike's psgcompiler. My bitdefender goes nuts and detects Trojan temporary files during the process and blocks them, causing the conversion to fail. Is this normal behaviour for bitdefender? Please can you advise on this? Many thanks, Matthew
Hi Matthew,
Thank you for watching. Under the hood, the psgcompiler uses the PyInstaller package. I have experienced something similar when trying to distribute the packaged .exe online. It then gets flagged by browsers and also local antivirus software on the end users' devices. Unfortunately, I do not have a solution to this. If you just want to use it on your personal device, one quick workaround would be to deactivate the Bitdefender software for the time being while compiling the Python project to an executable. And perhaps, once done, add an exception to Bitdefender so that it is not going to be flagged. I know this might not be the answer you are looking for, but unfortunately, I do not know another workaround.
hi, your video tutorial is really a handy one for any code developer. I have a doubt. We try to develop an entry form with nearly 30 details with character length around 50 each. When we try to run with your code model, layout did not fit in the window. alternatively we tried to run through 'sg.Column' with scrollable bar. Despite scrollable window appear with read and exit option, values entered could not be linked with word document and python window returns following error -
"jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'OTHER'
is it right to use this column option? following is the structure
import...
.
.
.
column = [
.
sg.text [...]
'
'
]
layout = [
[sg.Column (column, scrollable = True, vertical_scroll_only = True,key ='COLUMN')],
[sg.Button ("Generate"), sg.Exit("Exit")],
]
Window = sg.Window("PAT", layout, element_justification="Center")
while True:
event, values = Window.read()
if event == sg.WIN_CLOSED or event == "Exit":
break
if event == "Generate":
doc.render(values)
print(event, values)
output_path = Path(__file__).parent / f"PAT_{values['PATNO']}_{values['YEAR']}.docx"
doc.save(output_path)
sg.popup ("File saved", f"File has been saved here:{output_path}")
Window.close ( )
Provide your insight into this doubt.. Thanks ..
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
How do you make everything in your word document in these brackets {} highlighted by default?
I just marked it manually yellow
Hi Sven,
When I try to put my fields into tabs my create button stops working and I get an error saying keywords must be strings. Without the tabs it seems to work but since I have many fields I need to use them. The logic remains constant but I'm getting that error in the console
Thanks for watching! It's hard to diagnose the issue without more context, but the error message you received typically indicates that a non-string value was used for a keyword argument. Please review the line of code where the error occurred and ensure that all keywords are specified as strings. Happy Debugging! :)
I don't understand the file path you mentioned in the start. What are we supposed to write it path(__file__) part. Just that or the actual path?
Sorry, but I do not understand your question. It is explained at 1:46 min
It will just return the folder of the current Python file.
Have also a look at the documentation: docs.python.org/3/library/pathlib.html
Happy Coding!
@@CodingIsFun i think i have the same problem as the commentor. Mine shows that "NameError: name '__file__' is not defined". What should i do to resolve this?
It works with libreoffice writer?
I like pysimplegui also
Thanks for watching. I have not tried it with LibreOffice yet.
hi there, why the created docx is on tmp folder when I created .exe, not on the specified output_path .. Is it connected with __pycache__ ?? thanks a bunch
Instead of:
document_path = Path(__file__).parent / "document.docx'"
Try:
document_path = Path.cwd() / "document.docx'"
@@CodingIsFun it worked thank you ... as i checked you have made the lesson about pathlib too ... thank you again
@@nusantara8508 Happy to hear that it worked.
I learn a lot from you bro! Tried this code. Awesome.
Regarding the docxtpl, how could I change the output path for newly created document file? What if I want to save it in another folder that is different where my python fille is located?
What code should I use?
Will really appreciate your input here bro
Thanks for watching. Happy to hear that you learned a lot.
Regarding your question, I recommend 'pathlib' for dealing/specifying the output file path. Have a look here: th-cam.com/video/iqZ2V8qTYq8/w-d-xo.html
I hope it helps! Happy Coding!
@@CodingIsFun Another query bro. why is my psgcompiler not recognized as command in cmd?
@@taruku_luca Hard to tell from a distance. My closest guess is that you are getting this issue because you are trying to import a module of a library which is not installed in your virtual environment. If you have run 'pip install psgcompiler' already, ensure to call psgcompiler from the same environment in which you installed the package. For example, in your IDE/text editor, you might have set a different Python environment for executing your script. Therefore, try to run psgcompiler also from the command prompt. If that does not work, try searching for the text of your error message on Google/StackOverflow. Happy Debugging!
@@CodingIsFun Already solved this issue bro. thanks. I also watched your PathLIb lectures. Downloaded the cheatsheet. Very comprehensive bro. Thanks so much.
One thing I haven't seen in the PathLib tutorial is what if I want to save file on the desktop? And if I convert it into .exe file, what path should I write so that the output path will be universal in desktop of any user?
for example: This is my output path.
C:\Users\username\Documents\pycharm\learning phyton\sample
If I convert this into .exe , then pass it to my colleagues, can they save it on the same output path regardless of the username?
If not, what code should I use so that the output path will disregard the username?
Hi, I loved your video and thank you for guiding us in the right direction.
I'm stuck where I get an error, Undefined File "", line 22, in top-level template code
jinja2.exceptions.UndefinedError: 'S' is undefined
How do I fix this? I do not have anything like that in my code and I followed exactly yours.
Any inputs would be highly appreciated!
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
very educative. everything runs smoothly just one concern. the .exe file is big. the .py is a few kbs but the .exe is more than 100mbs. any fix for that or it's all good?
Thanks for watching! I'm glad you found it educational. As for the size of the .exe file, it's normal for executables to be larger in size compared to the source code. This is because the executable includes all the dependencies required to run the code, even if they are not used in the project. One way to reduce the size of the executable is to create a separate virtual environment and only include the packages needed for the project. This way, you can ensure that only the necessary files are included in the build process.
@@CodingIsFun thank you for your response. how about a line of code to format the currency to append a comma after every thousand?
@@georgejunior7556 Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
Your video great, i found very late, really good...
Thanks for sharing knowledge.
One query, i m fetching live nse share market data of stock from morning 9.15 to 3.30 in excel.
1. Can't open excel while recording.
2. If I want to visualisation while recording data means = 9.15, 9.20,9.25 same data i want in visualize form (webpage/or else) till 3.30 while recording in excel.
How to do it...
Im digging but search brought me to u..
Plz help...
Sounds like an exciting project, but I cannot answer as I do not know your code (base), and I am not entirely sure what you are trying to achieve.
@@CodingIsFun thanks for reply...
Give me your email ID or else, i will pass code, so u can understand.
Dear Sir, all is nice. But when I try to run exe file, the error show: Failed to execute script due to unhandled exception. No such file or directory.
I checked path, it try to load ..\\AppData\\Local\\Temp\\... Not load my current working directory. All docxtpl required files could not be loaded.
How to fix this. I install python using venvture enviroment. Do you have a good idea?
Thank you so much
Please change the following:
Replace this:
document_path = Path(__file__).parent / "vendor-contract.docx"
With this:
document_path = Path.cwd() / "vendor-contract.docx"
..and try again! Thanks!
Sorry sir, I have a question. Let say I have 2 AMOUNT (AMOUNT A & AMOUNT B), what should I do to have it sum up automatically? (like the one you did for nonrefundable). Thanks in advance
Thanks for watching. I would be great if you could provide an actual code snippet and explain what you have tried so far.
Hi great video! Can I do this with a PDF file?
That should be possible. An easy way would be to simply to convert the created Word Document to PDF (as shown here: th-cam.com/video/T3meVMaV8AA/w-d-xo.html)
Happy Coding!
Can i run the gui app when i open My Microsoft word app ?
So if i fill data and press "submit" in gui, i can see my data in Microsoft word change. without i close and reopen my Microsoft word
I have not tried it out yet, but feel free to give it a try :)
Im getting an error like ..failed to execute script 'vendor-contract-gui' due to unhandle exception..while converting it to .exe file
Have you tried to isolate your dependencies in a separate environment before converting the script to an exe file?
Please create a virtual environment, install the packages for your project in that environment and then try to convert the py to exe again.
Is possibile insert images with the same process?
Yes, that is possible. Have a look here: th-cam.com/video/T3meVMaV8AA/w-d-xo.htmlsi=_vPhVryYXpHdvHDk
Happy Coding! Cheers, Sven ✌️
Hi sir. Can we convert the user input text into uppercase? Even if the user type in lowercase, I want the input to appear as uppercase in the template.
If it possible, can you share the code on how to do that? Thanks in advance
Yes, it is possible. Example:
values["CLIENT"] = str(values["CLIENT"] ).upper()
@@CodingIsFun yeayy it works. Thanks a lot sir😊
How we can insert the picture or .txt file in word?
Thanks for watching. Please check out this video: th-cam.com/video/T3meVMaV8AA/w-d-xo.html
Happy Coding! Cheers, Sven ✌️
Is there any option to print automatically those documents after Save?
Yes, should be possible. Have a look here: stackoverflow.com/a/8413374
@@CodingIsFun Thanks!!
When I run exe file, the window popup, all data could be input. But when I generate word document, fail to run. No such file or directory...
Please change the following:
Replace this:
document_path = Path(__file__).parent / "vendor-contract.docx"
With this:
document_path = Path.cwd() / "vendor-contract.docx"
..and try again! Thanks!
Hi Sven, here is an idea for a new video... Python + Outlook + SimpleGUI to get values for Subject and Body
Thanks for the suggestion!
Just a heads up, if the user inputs letters instead of number in the 'Amount' field, the code gives an error, and the stops running, therefore the user cant correct it and try again.
Thank you for watching. I understand your point. It's not always possible to build a foolproof application in a 10-minute video. The goal of the video is to provide a starting point for viewers to enhance and develop their own application (including error handling)
Nice video
But how can I extract table from xlsx file to automated docx??
Thanks for watching the video. Can you perhaps elaborate on what it is you're trying to achieve? Please provide some additional info. Thanks!
@@CodingIsFun I have some CSV files which I want to extract data from them and put it at one docx file .I need a script that make this automatically
Thanks for your interest ☺️
@@mohussein4699 I have a similar tutorial on that topic. Find it here: th-cam.com/video/Zy9sx4GvjUY/w-d-xo.html
It should give you a good starting point. Happy Coding!
whenever I run the exe file, it says no such file or directory [Errno 2] :(
Change this:
document_path = Path(__file__).parent / "vendor-contract.docx"
to this:
document_path = Path.cwd() / "vendor-contract.docx"
and try again. Thanks!
@@CodingIsFun Worked like a charm thank you!
is it possible to add image to the doc? any tips? hehe i want to help my mom with her multiple lesson plan that need to submit every week omg, hope i can help her withthis apps
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
thank you
My pleasure! Appreciate you taking the time to watch and leave a comment.
Hello sir thank you so much, it's really helpful.🧡
How can I build different layouts for a larger contract with more fields and multiple windows while saving the information in the same ms-word? I made a rental deed template, and because my deed has a lot of fields to fill in, I made a function for each section that contains: layout, a window, a while loop with an event button, and context. When I save the information, it only fills the last section that I enter.
I have, for example, an owner function, a tenant function, and functions for payment, term, designation, and so on. When I click the owner button, a window appears to allow me to enter owner information; when I click the tenant button, a window appears to allow me to enter tenant information. When I open the template, however, only the tenant informations are filled in.
Do you have any ideas on how to do it?☺
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
@@CodingIsFun Thanks, Of sure, I understand, no problem. Best of luck.
While using the executable file thru psgcompiler, I get the error: Errno2: no such file or directory (the directory listed in the error is not where I placed my file. I am using spyder by the way)
Thanks for watching. Try to change this:
document_path = Path(__file__).parent / "vendor-contract.docx"
to this:
document_path = Path.cwd() / "vendor-contract.docx"
@@CodingIsFun that worked, but I’m not sure where it saved the file. I tried looking through my documents. Do I need to change the output path as well? Appreciate the help
@@CodingIsFun that works, but now I don’t know where the output file is saved. Do I need to edit the output path as well? I appreciate your help
Beginner here: When I run the script, I get the error: ModuleNotFoundError: No module named 'docxtpl'. I uninstalled and reinstalled docxtpl via the console with pip install / uninstall multiple times, but I still get the error. How can docxtpl be missing when it is istalled? Thx for the video :)
Hard to tell from a distance. My closest guess is that you are getting this issue because you are trying to import a module of a library which is not installed in your virtual environment. If you have run 'pip install docxtpl' already, ensure to call your Python file from the same environment in which you installed the package. For example, in your IDE/text editor, you might have set a different Python environment for executing your script. Therefore, try to run your Python file also from the command prompt. If that does not work, try searching for the text of your error message on Google/StackOverflow. Happy Debugging!
@@CodingIsFun Thx for your reply, like you said I bypassed the whole search by installing Anaconda and installing docxtpl there. N.B. for this problem with the different environments there is no good answer on the internet a beginner might understand :/
@CodingIsFun
you showed us how to save the values from the input fields into a word file.
could you please show us how to do it vice versa? so that when I press a 'load'
button the stored values from the .docx-file get inserted back to the proper text fields.
I only get back the word "end" into all my text input fields. I must admit I used Tkinter but this
shouldn't be the problem. Instead of 'doc.render(values)' I used for Tkinter 'doc.render(context)'
and created a context like 'context = { "TextField1": entryExample1.get(1.0, END) }'to make a reference for the Word-Application. This works so far to save something. But when I use 'context = { "TextField1": entryExample1.insert(1.0, END) }' I only get back the strings "end" into my input fields?
I am unsure if that is possible, as I assume that the rendered Word Document has no 'connection/memory' to the original template. I might be mistaken, but I am missing the time to search the internet for a solution. Thanks for your understanding!
@@CodingIsFun OK. Nevertheless thank you very much for your kindness and answer!
How do you list items
Do you mean how to implement a drop down list? Please provide more details. Thanks!
Its not working to create different muliple doc template with same data. if possible make a video on that bro.
What does not work? Please provide more information! Thanks!
hi ...... im getting an error in this one but i couldnt rectify it..... i took ah screenshot of the error. In it its given that
line 2, in
event, values = window.read()
you have tried 100 times to read a closed window
you need to DD check for event == WIN_CLOSED
can you help me out?
Thanks for watching. Unfortunately, with that bit of information, I cannot help you. You might want to take some time to write down which line of code is causing the error; let me know if you have modified the code from the tutorial, explain in more depth what you did to troubleshoot the problem and provide some more context. Thanks!
Do you have any social media to text.... If yes I can send you screenshots
@@j_a_g_g_u Feel free to join our discord. The link is in the description
@@CodingIsFunThis where the error comes..... its shows " trying to open a closed file ... you need to add a check event == WIN_CLOSED" like that
window = sg.Window("ECS FORM", layout, element_justification="right")
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == "Exit":
break
if event == "Create Contract":
values["DATE"] = today.strftime("%Y %m %d")
doc.render(values)
output_path = Path(__file__).parent / f"{values['PHONE']}.docx"
doc.save(output_path)
sg.popup("File saved", f"File has been saved here: {output_path}")
Balance code is same as your ..... only the heading changes........ its showing error in reading the input from user and updating it......
@@j_a_g_g_u you forgot window.close() at the bottom
Ciao! grazie per il video , sei bravissimo e sto imparando molto da te ,vorrei comunque chiederti come fare a cambiare la cartella di destinazione del salvataggio del file word,non riesco a risolvere questo problema ,e non trovo molto materiale in rete ,ti ringrazio e approfitto per salutarti e salutare tutti!!
Thanks for watching. It is explained in the video: 7:55 min
@@CodingIsFun Grazie!!
pip is not recognized ? why
Do you have Python and pip installed?
@@CodingIsFunOuch I understand now thanks
I cant imstall pip docxtpl
Why?
simple example .py did not work ? did not turn ?
Hey there, thanks for watching the video! I'm sorry I can't help you with your problem based on the information you provided. To give me a better idea of what's going on, it would be super helpful if you could write down which line of code is causing the error, let me know if you modified the code from the tutorial, and explain in more detail what you did to troubleshoot the problem. Don't forget to also give me some context about your setup and environment.
If you're having trouble figuring things out, another option is to join our Discord server at pyhtonandvba.com/discord. You can ask your question there and maybe someone in the community can help out.
Thanks for understanding.
I mean 1:27
Great video,but is it possible to replicate these funtions using tkinter?tnk u
Thannks! Yes, of course! In fact, PySImpleGUI is built on top of Tkinter.
@@CodingIsFun thanks for the reply.im trying to create my own entry form software for work,and i cant seem to make it read my input in the input field,hence not replacing the placeholders.any tips(im new to coding.😅)
@@lennycecile3775 Unfortunately, with that bit of information, I cannot help you. You might want to take some time to write down which line of code is causing the error; let me know if you have modified the code from the tutorial, explain in more depth what you did to troubleshoot the problem and provide some more context. Thanks!
Hello sir ! your video is very impressive . could you please paste all above code here
Hello Sir. Please find it on GitHub. The links are in the description of the video. Happy Coding!
I am getting an error typing in: pip install docxtpl. SyntaxError: invalid syntax
>>> pip install docxtpl
File "", line 1
pip install docxtpl
^^^^^^^
Thanks for watching. Where did you execute that command?
@@CodingIsFun From Python 3.11.4 and I tried pycharm.
@@Lyleb1231 Try to install the library via Terminal/CMD as shown in the video
Good. But better use excel file, as data base....
Thanks for watching. Then you might want to check out the following video: th-cam.com/video/Zy9sx4GvjUY/w-d-xo.html
I keep getting 'psgcompiler : The term 'psgcompiler' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.' when I try to run psg compiler. When I pip install psg it says it's already satisfied in the following location: users
ame\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\etcetera. I've tried manually opening this file location, but I can't find the file 'appdata'. What do I do?
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
Hello! I am having just one problem with the last step:
When I try to run the .exe file, this error pop-up appears:
drive.google.com/file/d/1u7Kj3fNmMfFJlTeZAeSdnPtlYyxAwAjN/view?usp=sharing
All the other steps worked perfectly, I can even run the program with Python. Can you please help me? I would really appreciate it :)
Thank you for watching my video! I'm sorry that the Python code I provided doesn't seem to be working on your machine.
I suggest creating a separate virtual environment and installing the required libraries there. This will ensure that you have a clean, isolated environment for running your Python code, which can help avoid conflicts with any other libraries that you have installed on your machine.
If that doesn't work, another thing you could try is using a different version of Python. For example, you could try using Python 3.8.5 instead of the version of Python that you are currently using. This might help resolve any compatibility issues that you are experiencing.
Hi reference [vendor-contract-gui.py] My Doc [output_path] File Ends up in a Temp folder when I create the exe file. As soon as the script stop running it get deleted. Can you help me with this problem I think the problem is with the ..
[output_path = Path(__file__).parent]
when the exe is excuted it goes to my Temp folder and then get deleted by Windows.
ps it works fine when I run it as a script but te exe file save it to a temp folder.
Thanks for watching. Please replace "Path(__file__).parent" with "Path.cwd()" and try again. Hope it helps! Happy Coding!
Hi thanks for taking the time to reply to my query. I have replaced the code you suggested and it now works fine. I am just started to learn Python having coded in VBA for years and was looking for a new challenge. Keep up the good work, your videos and really helpful Regards Phil