I plan to make a simple app with python3.
Watch the folder and create a new text file
It is to do some processing in that file.
To monitor the folder there
Usewhile
to monitor folders
Variable to updateupdate_intarbal
watch_mode
Ifwatch_mode
is 1, watch it, and exit if 0
I'm thinking of assembling it.
is
Launch the app
[App launch]
↓
[Start tkinter frame (Label
: Monitor mode andButton
: STOP)]
↓
[while looping (watch_mode = 1
for monitoring)]
Exit the app
[Update towatch_mode = 0
by pressingButton
: STOP in the tkinter frame]
↓
[Exit the while loop (watch_mode = 0
)]
↓
[App stop]
If I want to stop, press tkinter's STOP button
It feels likewatch_mode
is updated to 0 and exits the while loop
I managed to write the following code, but it was far from ideal ...
For now,tkinter
andwhile
don't work together
Also, even if you press the stop button, watch_mode is not updated and it becomes an infinite loop.
If i have any knowledge, please give me advice.
import tkinter as tk
from time import sleep
def main ():
watch_mode = 1 #Automatic conversion mode
while_loop = 0 #Manage initial behavior
update_intarval = 5 #Update time (s)
while watch_mode == 1:
if while_loop == 0: Only run # 1
while_loop = 1
showinfo = tk.Tk ()
frame_top = tk.Frame (showinfo, bd = 2, relief = "ridge")
frame_top.pack (fill = "x", pady = 2)
label1 = tk.Label (frame_top, text = "It is a monitoring mode")
label1.pack (side = "left")
frame_bottom = tk.Frame (showinfo, bd = 2)
frame_bottom.pack (fill = "x")
def stop_convert ():
watch_mode = 0
showinfo.destroy ()
button1 = tk.Button (frame_bottom, text = "STOP", bg = "# f0e68c", fg = "# ff0000", command = stop_convert)
button1.pack ()
showinfo.mainloop ()
sleep (update_intarval)
print (watch_mode)
if __name__ == '__main__':
main ()
-
Answer # 1
Related articles
- python - how to escape a while loop with tkinter
- python 3x - button execution action in tkinter when executing code
- python - i want to buy a tkinter button layout
- python - image is not displayed in tkinter module
- python 3x - change font size for python3 tkinter entry
- python - while syntax processing
- python 3x - tkinter i want to write code concisely
- i want to output the entry result of tkinter with python
- python - pltshow does not run unless you close the tkinter window
- python 3x - python3 tkinter treeview data update
- python - i want to display the next window when i press the button!
- python - i shouldn't be out of the while loop, but it doesn't print
- python 3x - python3 tkinter no response when closing window
- python - [tkinter] multiple selectable combobox
- website button clicks in selenium and python
- python - [ajax] i want to get and send the value of the button element in the form
- python - [selenium] click the radio button
- python - i want to implement scrolled text in tkinter
- [python] [tkinter] i want to change the acquisition contents of the second and subsequent menu lists by selecting the previous p
- python 3x - i want to extract data from a python3 tkinter list
I tried using
.after
oftkinter
as advised.It became the movement that I thought of for the time being.
Here's the code.
Please give me any advice. m (_ _) m