所以这里的逻辑
为1%="|" 在TLabel和一个"|" 我们需要循环10次
所以达到100%= 100倍"|" 我们需要1000次循环
你可以帮我代码吗?
我开发了一个eclipse插件,我想在工作台窗口的底部创建一个进度条作为eclipse视图.我有一个例子,但这只是片刻.请给我一些想法,谢谢
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
dialog.run(true, true, new IRunnableWithProgress(){
public void run(IProgressMonitor monitor) {
monitor.beginTask("Some nice progress message here ...", 100);
// execute the task ...
monitor.done();
}
});
Run Code Online (Sandbox Code Playgroud) 我正在为旧游戏(Command&Conquer 1,Win95版本)制作补丁,在某些情况下,执行补丁需要通过Pascal脚本编写的函数,这可能需要一段时间.
目前,我在页面更改为"安装"页面时执行此操作,因此,在用户选择所有选项并确认安装之后,在安装程序开始实际添加(和删除)文件之前.
procedure CurPageChanged(CurPageID: Integer);
begin
if (CurPageID = wpInstalling) then
begin
// Rename all saveg_hi.### files to savegame.###
renameSaveGames();
// clean up the ginormous files mess left behind if the game was installed from the 'First Decade' compilation pack
cleanupTFD();
end;
end;
Run Code Online (Sandbox Code Playgroud)
但由于该过程可能相当长,我宁愿以某种方式将其添加到实际的安装进度条.有没有办法实现这个目标?
这是我连接到服务器并在MyUtilitiesActivity中获取响应的方法.
private static response = "";
public static String send(final Activity act, final String url, final String keys[], final String values[])
{
try{
HttpParams httpParameters = new BasicHttpParams();
// Set the timeout in milliseconds until a connection is established.
HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
// Set the default socket timeout (SO_TIMEOUT)
// in milliseconds which is the timeout for waiting for data.
HttpConnectionParams.setSoTimeout(httpParameters, 5000);
HttpClient httpclient = new DefaultHttpClient(httpParameters);
if(keys == null && values == null)
{
HttpGet get = new HttpGet(url);
// …Run Code Online (Sandbox Code Playgroud) 我已经创建了一个C#windows应用程序,我插入了进度条.
单击一个按钮时,应显示进度条,然后它应该启动该过程大约2到3秒,当进程条完成时,它应该被隐藏.
我已经使用此代码来解决这个问题,但它无法正常工作.
当进度条运行时,标签框应该像"生成... 45%"并且在完成标签框之后应该是"生成100%..",但是当我插入标签时它会显示一些错误.
这是单击Generate按钮之前的图片..

在处理我应该得到这样的..

在最终进程ID应该像这样,进度条应该隐藏..

ProgressBar1.Visible = true;
if (isProcessRunning)
{
MessageBox.Show("A process is already running.");
return;
}
Thread backgroundThread = new Thread(
new ThreadStart(() =>
{
isProcessRunning = true;
for (int n = 0; n < 100; n++)
{
Thread.Sleep(1);
progressBar1.BeginInvoke(new Action(() => progressBar1.Value = n));
}
MessageBox.Show("Generated!!!");
if (progressBar1.InvokeRequired)
progressBar1.BeginInvoke(new Action(() => progressBar1.Value = 0));
isProcessRunning = false;
}
));
// Start the background process thread
backgroundThread.Start();
Run Code Online (Sandbox Code Playgroud) 这就是我在条形图上显示的字符串:
public class ProgressBarWithText : ProgressBar
{
const int WmPaint = 15;
SizeF TextSize;
PointF TextPos;
public ProgressBarWithText()
{
this.DoubleBuffered = true;
this.TextChanged += ProgressBarWithText_TextChanged;
this.SizeChanged += ProgressBarWithText_SizeChanged;
}
public override string Text
{
get { return base.Text; }
set { base.Text = value; }
}
void RecalcTextPos()
{
if (string.IsNullOrEmpty(base.Text))
return;
using (var graphics = Graphics.FromHwnd(this.Handle))
{
TextSize = graphics.MeasureString(base.Text, this.Font);
TextPos.X = (this.Width / 2) - (TextSize.Width / 2);
TextPos.Y = (this.Height / 2) - (TextSize.Height / 2); …Run Code Online (Sandbox Code Playgroud) #!/usr/bin/env python
import time
import sys
import os
for i in range(10):
progress_bar = \
"""
<!DOCTYPE html>
<html>
<body>
<p>Display a gauge:</p>
<meter value="%s" min="0" max="10">2 out of 10</meter><br>
</body>
</html>
"""%(i)
print progress_bar
sys.stdout.flush() # do this after the print
time.sleep(1.0)
Run Code Online (Sandbox Code Playgroud)
在这里,我试图创建一个进度条,其中'i'是进度指示器.
.屏幕截图如下.我所期望的是,通过使用sys.stdout.flush(),可以消除以前的HTML打印,仅保留当前"i"的进度,但它不起作用.任何想法如何实现我的目标?
是否可以在 Tkinter-Python 中改进我的进度条,在中间添加一个标签(例如:读取文件)?
我试图找到一个优雅的编码解决方案,但没有真正的结果
from Tkinter import *
import ttk
import tkFileDialog
import time
class MainWindow(Frame):
def __init__(self):
Frame.__init__(self)
self.master.title("ProgressBar example")
self.master.minsize(200, 100)
self.grid(sticky=E+W+N+S)
top = self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
self.start_ind = Button(self, text='Start indeterminate', command=self.start_ind, activeforeground="red")
self.start_ind.grid(row=0, column=0, pady=2, padx=2, sticky=E+W+N+S)
self.pbar_ind = ttk.Progressbar(self, orient="horizontal", length=300, mode="indeterminate")
self.pbar_ind.grid(row=1, column=0, pady=2, padx=2, sticky=E+W+N+S)
def start_ind(self):
for i in xrange(50):
self.pbar_ind.step(1)
self.update()
# Busy-wait
time.sleep(0.1)
if __name__=="__main__":
d = MainWindow()
d.mainloop()
Run Code Online (Sandbox Code Playgroud) 我有一个简单的程序,它有两个长时间运行的任务要执行:
我想要做的是:这些长时间运行的进程在一个额外的线程中运行,其中包含更新我的 GUI 的不同变量 - 例如当前的进度条正在工作,还有我需要在 GUI 上显示的所有消息。但是,目前,我只能将进度条用于第二个任务(使用数据库) - 文件夹和文件的复制以递归方式完成(为每个需要复制的子文件夹调用自身)我不知道会复制多少文件夹。因此,在复制进行时,我希望进度条显示忙碌指示(像这样),完成后它应该是 dbs 上工作的标准进度条。
这样的解决方案是否可能以一种干净的方式出现?
我有以下代码来报告进度。该函数CalculateMandelbrot()似乎是异步工作的,但我的进度条什么也没显示。
Public Class Form1
Private Async Function Button1_Click(sender As Object, e As EventArgs) As Task Handles Button1.Click
Dim prog As Progress(Of Integer) = New Progress(Of Integer)(Function(x) ProgressBar1.Value = x)
Await Task.Run(Function() CalculateMandelbrot(prog))
Dim ende As Boolean = True
End Function
Private Function CalculateMandelbrot(ByVal progress As IProgress(Of Integer))
For xi = 0 To 100
Threading.Thread.Sleep(40)
progress.Report(xi)
Next
Return 42
End Function
End Class
Run Code Online (Sandbox Code Playgroud) progress-bar ×10
c# ×3
python ×2
android ×1
async-await ×1
cgi ×1
delphi ×1
flicker ×1
html ×1
inno-setup ×1
installer ×1
pascalscript ×1
text ×1
tkinter ×1
vb.net ×1
vcl ×1
wpf ×1