How to replace while loop with Tkinter loop [closed] - python

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I was wandering if anyone was able to help me properly add Tkinker into my existing script?. The Tkinker code works fine outside of the current script as does the script without the Tkinter code, but I am having trouble merging it together. been doing alot of searching and i cant seem to fine the answer i am looking for. Here is the link to my script:
https://github.com/Octane70/Code/blob/master/Garden/Garden_v0.3.py
Line 50 #GUI_window is the code i am trying to add.
Thanks

You need to call root.mainloop() exactly once. You need to convert your while True loop into a function, and at the end of the function you need to call itself again with after. This function should also update the GUI, though you could put that in a separate function if you wish.
You do not want to call your gui_display function more than once. As it stands now, you are creating six new widgets every second. Instead, you want to create them once and then update them every second.

Related

Get last execution time of script python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Im writting a script in Python that takes as an input a timestamp. For the first execution, it should be something as the now() function. However, for further executions, the input parameter should be the last execution time of the same script. This is being done to avoid getting duplicates results.
Can anyone give me a clue please?
As far as I know, there is no "last executed" attribute for files. Some operating systems have a "last accessed" attribute, but even if that's updated on execution, it would also be updated any time the file was read, which is probably not what you want.
If you need to be able to store information between runs, you'll need to save that data somewhere. You could write it to a file, save it to a database, or write it to a caching service, such as memcached.

Two functional functions when called together creates an error [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have this code related with the download, unzip, search and upload to a AWS S3.
I have a function to download, another to unzip, another to make the searches and another function to upload the found files; to finally call all this functions into one function.
The problem it's that at some point (specifically in the last function) the execution gets an error.
The code has 1684 lines of code, and could take even 4 hours to execute.
If an error is found in a function, the try/catches guarantee the final return.
I've tried to call every function sequentially and they work.
If trying to call all the functions, except the last one it still works.
If trying to call the last function (the upload to S3), it works.
I believe it could be related with the RAM
Trust me, it's huge
Basically, my problem was solved through the creation of a ".sh" format script that calls all the functions sequentially.

I have two lines of code, that i'm trying to get into one single line [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a code that I should get into one line, but i just simply can't solve it
Here is the code:
import random
for i in range(10): print sorted(random.sample(range(1,40), 7))
I have tried different versions, like trying to put the import into the same line, without any results.
This is the website im using: https://www.tutorialspoint.com/execute_python_online.php
So I was wondering, how could I get it into a single line.
Multiple statements in one line makes code dirty and reduce code readability and not recommended. But it's possible.
Normally each statement is written on separate physical line in editor. However, statements in a block can be written in one line if they are separated by semicolon.Refrence
import random ; ([(print (sorted(random.sample(range(1,40), 7))))for i in range(10)])
If putting two or more statements on a single line improves program clarity, then do so.When using more than one statement per line, organize the statement into columns. You can see here

list clears when i end my app and re run it [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How can I define a list that is empty at first and append to it but not have it clear when I restart my app? I am using python language
The list has the proper values in it when the app is first ran, it is only when I restart my app that the list clears because of the empty list variable over rides the list that was just created. Thanks in advance
A list doesn’t get saved when closing a python program. If you want this you should save the list in a specific file and load this file everytime your python program opens. One of the basics of python is that lists, dictionairies etc don’t get saved on change or exit.

Display a file to the user with Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying to find a way to display a txt/csv file to the user of my Python script. Everytime I search how to do it, I keep finding information on how to open/read/write etc ... But I just want to display the file to the user.
Thank you in advance for your help.
if you want the file to open with its associated default program, use startfile.
os.startfile("path/to/file") # may only work on Windows
It really depends what you mean by "display" the file. When we display text, we need to take the file, get all of its text, and put it onto the screen. One possible display would be to read every line and print them. There are certainly others. You're going to have to open the file and read the lines in order to display it, though, unless you make a shell command to something like vim file.txt.

Categories

Resources