Pysimplegui:当达到MAX_VALUE时,如何保持进度表的打开?

发布于 2025-01-21 22:32:01 字数 850 浏览 0 评论 0原文

来自Pysimplegui的简单进度表用于通过文件列表运行:

sg_gui.OneLineProgressMeter("Actual:", act_number, total_number, '_M_', actual_Filename)

如何保持窗口打开,在达到MAX_VALUE = total_number之后?

更多的外观:我的问题是,处理最后一个文件时窗口不会保持打开状态,但对于第一个文件来说绝对可以。这是我的代码:

import time
file_count = 1
for scan_file in scan_files:
   analyze_file  = scan_file.name
   mod_gui.OneLineProgressMeter("Actual File:", file_count, files_count, '_M_', analyze_file)
   result_file = analyze(analyze_dir, analyze_file)                                                                                     
   time.sleep(2)
   file_count += 1

我有两个要处理的文件:

  • 第一个文件具有file_count = 1,仪表可见。
  • 最终确定此之后,file_count上升= 2,仪表消失了。

可能是,我需要从第二行中的file_count = 0开始?

A simple ProgressMeter from PySimpleGui is used to run through a list of files:

sg_gui.OneLineProgressMeter("Actual:", act_number, total_number, '_M_', actual_Filename)

How to keep the window open, after max_value = total_number is reached?

MORE EXPLANTION: My problem is that the window does not stay open when the last file is processed but it's absolutely fine for the first ones; this is my code:

import time
file_count = 1
for scan_file in scan_files:
   analyze_file  = scan_file.name
   mod_gui.OneLineProgressMeter("Actual File:", file_count, files_count, '_M_', analyze_file)
   result_file = analyze(analyze_dir, analyze_file)                                                                                     
   time.sleep(2)
   file_count += 1

I have two files for processing:

  • The first one has file_count = 1, meter is visible.
  • After this is finalized, file_count raises = 2, meter disappears.

May be, I need to start with file_count = 0 in the second line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欲拥i 2025-01-28 22:32:01

如果Currence> Current_value> = Max_valueOne_line_progress_meter的窗口将被关闭。也许您可以构建进度表窗口,如果您有特殊要求,请自己确定并自行更新,请在必要时通过方法删除它。

由文本元素模拟的简单进度仪表。

from random import randint
import PySimpleGUI as sg

sg.theme('DarkBlue')

layout = [[sg.Text('', size=(50, 1), relief='sunken', font=('Courier', 11),
    text_color='yellow', background_color='black',key='TEXT')]]
window = sg.Window('Title', layout, finalize=True)
text = window['TEXT']
state = 0
while True:

    event, values = window.read(timeout=100)

    if event == sg.WINDOW_CLOSED:
        break
    state = (state+1)%51
    text.update('█'*state)

window.close()

The window for one_line_progress_meter will be closed if current_value >= max_value. Maybe you can build the progress meter window, finalize and update it by yourself if you have special requirement, delete it by method close when necessary.

A simple progress meter simulated by Text element.

from random import randint
import PySimpleGUI as sg

sg.theme('DarkBlue')

layout = [[sg.Text('', size=(50, 1), relief='sunken', font=('Courier', 11),
    text_color='yellow', background_color='black',key='TEXT')]]
window = sg.Window('Title', layout, finalize=True)
text = window['TEXT']
state = 0
while True:

    event, values = window.read(timeout=100)

    if event == sg.WINDOW_CLOSED:
        break
    state = (state+1)%51
    text.update('█'*state)

window.close()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文