Python tkinter.ttk 模块,Progressbar() 实例源码

我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用tkinter.ttk.Progressbar()

项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__(master, text="Levels", padding=4)
        self.lowest_level = Player.levelmeter_lowest
        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        # pbstyle.theme_use("classic")  # clam, alt, default, classic
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        ttk.Label(self, text="dB").pack(side=tkinter.TOP)
        frame = ttk.LabelFrame(self, text="L.")
        frame.pack(side=tk.LEFT)
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level, variable=self.pbvar_left, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = ttk.LabelFrame(self, text="R.")
        frame.pack(side=tk.LEFT)
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level, variable=self.pbvar_right, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_right.pack()
项目:Scoary    作者:AdmiralenOla    | 项目源码 | 文件源码
def initialize_statusframe(self):
        """
        Initialize the frame and statusbar occupying the bottom
        """
        frame = self.bottompart

        frame.pb = ttk.Progressbar(frame,
                                   orient='horizontal',
                                   mode='determinate',
                                   maximum=100)
        frame.pb.pack(fill='both',expand=True,side='top')

        frame.lab = Tkinter.Label(frame,text=u"Awaiting input options")
        frame.lab.pack(in_=frame.pb,expand=True)
        #sys.stdout = StdoutToLabel(frame.lab, progressbar=frame.pb)
        sys.stdout = StdoutToLabel(frame.lab,
                                   progressbar=frame.pb,
                                   width=frame.cget('width'))
项目:IAAT    作者:rfrugte    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller

        label = tk.Label(self, text="Converting", font=TITLE_FONT)
        label.pack(side="top", fill="x", pady=10)
        button2 = tk.Button(self,text="start", command=self.start, font=BUTTON_FONT, bg="white")
        button2.pack()
        self.labels = tk.Label(self, text="", font=TEXT_FONT)
        self.labels.pack(side="top", fill="x", pady=10)
        self.progress = ttk.Progressbar(self, orient="horizontal",
                                        length=200, mode="determinate")
        self.progress.pack()
        self.bytes = 0
        self.maxbytes = 0
        self.label2 = tk.Label(self, text="", font=TEXT_FONT)
        self.label2.pack(side="top", fill="x", pady=10)
        self.label3 = tk.Label(self, text="", font=TITLE_FONT)
        self.label3.pack(side="top", fill="x", pady=10)
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def make_please_wait_window(self):
        window = self.please_wait_window = tkinter.Toplevel()
        window.transient(porcupine.get_main_window())
        window.title("Pasting...")
        window.geometry('350x150')
        window.resizable(False, False)

        # disable the close button, there's no good way to cancel this
        # forcefully :(
        window.protocol('WM_DELETE_WINDOW', (lambda: None))

        content = ttk.Frame(window)
        content.pack(fill='both', expand=True)

        label = ttk.Label(
            content, font=('', 12, ''),
            text=("Pasting to %s, please wait..." % self.pastebin_name))
        label.pack(expand=True)

        progressbar = ttk.Progressbar(content, mode='indeterminate')
        progressbar.pack(fill='x', padx=15, pady=15)
        progressbar.start()
项目:guetzli-recursively-gui    作者:tanrax    | 项目源码 | 文件源码
def create_widgets(self):
        # Button select folder
        self.button_select_folder = Button(self)
        self.button_select_folder['text'] = 'Choose folder'
        self.button_select_folder['pady'] = 10
        self.button_select_folder['font'] = self.font_general
        self.button_select_folder['command'] = self.open_folder
        self.button_select_folder.pack(side='top')
        # Label path folder
        self.label_path = Label(self)
        self.label_path['text'] = ''
        self.label_path['pady'] = 10
        self.label_path['font'] = self.font_general
        # Button run
        self.button_run = Button(self)
        self.button_run['text'] = 'Optimize'
        self.button_run['font'] = self.font_run
        self.button_run['pady'] = 10
        self.button_run['state'] = 'disabled'
        self.button_run['command'] = self._start_optimize
        self.button_run.pack(side='top')
        # Progressbar
        self.progress_bar = ttk.Progressbar(self)
        self.progress_bar['length'] = 500
项目:guetzli-recursively-gui    作者:tanrax    | 项目源码 | 文件源码
def create_widgets(self):
        # Button select folder
        self.button_select_folder = Button(self)
        self.button_select_folder['text'] = 'Choose folder'
        self.button_select_folder['pady'] = 10
        self.button_select_folder['font'] = self.font_general
        self.button_select_folder['command'] = self.open_folder
        self.button_select_folder.pack(side='top')
        # Label path folder
        self.label_path = Label(self)
        self.label_path['text'] = ''
        self.label_path['pady'] = 10
        self.label_path['font'] = self.font_general
        # Button run
        self.button_run = Button(self)
        self.button_run['text'] = 'Optimize'
        self.button_run['font'] = self.font_run
        self.button_run['pady'] = 10
        self.button_run['state'] = 'disabled'
        self.button_run['command'] = self._start_optimize
        self.button_run.pack(side='top')
        # Progressbar
        self.progress_bar = ttk.Progressbar(self)
        self.progress_bar['length'] = 500
项目:gophersnake    作者:felixplesoianu    | 项目源码 | 文件源码
def load_with_status(entry, callback):
    prog_win = Toplevel(top, padx=8, pady=8)
    prog_win.title = "Loading..."
    prog_win.transient(top)
    prog_win.resizable(FALSE, FALSE)

    prog_bar = ttk.Progressbar(
        prog_win, orient=HORIZONTAL, length=300, mode="indeterminate")
    prog_bar.pack()

    data = b""
    try:
        for i in fetch_data(entry[2], entry[3], int(entry[4])):
            data += i
            prog_bar.step()
        callback(entry2url(entry), data)
    except Exception as e:
        showerror(
            parent=top,
            title="Error loading content",
            message=str(e))
    finally:
        prog_win.destroy()
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def body(self, master):
        ttk.Style().configure("White.TLabel", background="white")

        self.variable_name = tk.StringVar()
        name = ttk.Label(master, textvariable=self.variable_name, style="White.TLabel")
        name.pack(anchor="w", padx=20, pady=[10, 0])

        self.variable_percent = tk.StringVar()
        percent = ttk.Label(master, textvariable=self.variable_percent, style="White.TLabel")
        percent.pack(anchor="w", padx=20, pady=[0, 10])

        self.variable_progress = tk.IntVar()
        progress = ttk.Progressbar(master, variable=self.variable_progress, maximum=self.maximum)
        progress.pack(fill="x", padx=20, pady=[0, 10])
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Progressbar(self.root, **kwargs)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Progressbar(self.root, **kwargs)
项目:ransomware    作者:xiaozhouas    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = ttk.Label(self, text="Checking System Configuration...\nPlease be patient", font=LARGE_FONT)
        label.pack(pady=10,padx=10)

        self.progress = ttk.Progressbar(self, orient="horizontal",
                                        length=200, mode="determinate")
        self.progress.pack()

        self.bytes = 0
        self.maxbytes = 0
        self.start()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Progressbar(self.root, **kwargs)
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_ttk_progressbar(self, orient: str="horizontal", length: int=None, mode: str="determinate", maximum: int=100, value: int=0, variable: tk.IntVar=None, phase: int=0, index: int or str="end", **kwargs):
        """Insert a ttk.Progressbar into the game."""
        widget = ttk.Progressbar(self.text, orient=orient, length=length, mode=mode, maximum=maximum, value=value, variable=variable, phase=phase, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
项目:BioDataSorter    作者:BioDataSorter    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        super().__init__(parent)

        self.tasks = ["Idle", "Getting counts", "Getting descriptions"]
        self.current_task = self.tasks[0]

        self.pb = ttk.Progressbar(parent, orient='horizontal', length=400,
                                  mode='determinate')  # grid in start
        self.pb.bind('<Enter>',
                     lambda e: controller.status_bar.set(self.current_task))
        self.pb.bind('<Leave>', lambda e: controller.status_bar.set('Ready'))

        self.items = 0  # number of queries searched so far
        self.total_items = 0  # the total number of queries to be searched
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Progressbar(self.root, **kwargs)
项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
def __init__(self, audio_source, master=None):
        self.lowest_level = -50
        super().__init__(master)
        self.master.title("Levels")

        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        pbstyle.theme_use("classic")
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        frame = tk.LabelFrame(self, text="Left")
        frame.pack(side=tk.LEFT)
        tk.Label(frame, text="dB").pack()
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=300, maximum=-self.lowest_level, variable=self.pbvar_left, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = tk.LabelFrame(self, text="Right")
        frame.pack(side=tk.LEFT)
        tk.Label(frame, text="dB").pack()
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=300, maximum=-self.lowest_level, variable=self.pbvar_right, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_right.pack()

        frame = tk.LabelFrame(self, text="Info")
        self.info = tk.Label(frame, text="", justify=tk.LEFT)
        frame.pack()
        self.info.pack(side=tk.TOP)
        self.pack()
        self.update_rate = 15   # lower this if you hear the sound crackle!
        self.open_audio_file(audio_source)
        self.after_idle(self.update)
项目:gophersnake    作者:felixplesoianu    | 项目源码 | 文件源码
def save_with_status(selector, host, port):
    fn = asksaveasfilename(parent=top, title="Save file as")
    if fn == "":
        return

    prog_win = Toplevel(top, padx=8, pady=8)
    prog_win.title = "Downloading..."
    prog_win.transient(top)
    prog_win.resizable(FALSE, FALSE)

    prog_bar = ttk.Progressbar(
        prog_win, orient=HORIZONTAL, length=300, mode="indeterminate")
    prog_bar.pack()

    try:
        with open(fn, "wb") as f:
            for i in fetch_data(selector, host, port):
                f.write(i)
                prog_bar.step()
        return True
    except Exception as e:
        showerror(
            parent=top,
            title="Error loading content",
            message=str(e))
        return False
    finally:
        prog_win.destroy()
项目:PyTouch    作者:mNisblee    | 项目源码 | 文件源码
def __init__(self, master):
        super(TrainingWidget, self).__init__(master)

        self.tm = None
        self._tick_id = None

        # text and scrollbar widget
        self._font = font.Font(family='mono', size=-40)

        self._content_frame = Frame(self)
        self._text = Text(self._content_frame, wrap=NONE, exportselection=0, undo=False)
        self._scrollbar = ttk.Scrollbar(self._content_frame, command=self._text.yview)
        # Connect scrollbar and training widget
        self._text['yscrollcommand'] = self._scrollbar.set

        # text tags
        self._text.tag_config('base', font=self._font, spacing1=20, justify=CENTER)
        self._text.tag_config('untyped', foreground='#cccccc')
        self._text.tag_config('hit')
        self._text.tag_config('miss', foreground='#cc0003')
        # text bindings
        self._text.bind('<Configure>', self.on_configure)
        self._text.bind('<FocusOut>', self.on_focus_out)
        self._text.bind('<KeyPress-Escape>', self.on_escape_press)
        self._text.bind('<KeyPress-BackSpace>', self.on_backspace_press)
        self._text.bind('<KeyPress>', self.on_key_press)
        self._text.bind('<Any-Button>', self.on_button)
        self._text.bind('<Motion>', lambda e: 'break')

        # statistics widgets
        self._time_elem = StatsElement(self, 'Elapsed time', ZERO, ZERO)
        self._strokes_elem = StatsElement(self, 'Keystrokes per minute', '0', '0')
        self._accuracy_elem = StatsElement(self, 'Accuracy', '0', '0')
        self._progressbar = ttk.Progressbar(self, orient='horizontal', mode='determinate', value=0)

        # pack and configure master frame
        self._time_elem.grid(column=0, row=0, sticky=N + S + W + E)
        self._strokes_elem.grid(column=1, row=0, sticky=N + S + W + E)
        self._accuracy_elem.grid(column=2, row=0, sticky=N + S + W + E)
        self._progressbar.grid(column=0, row=1, sticky=N + S + W + E, columnspan=3)
        self._content_frame.grid(column=0, row=2, sticky=N + S + W + E, columnspan=3)

        self.columnconfigure(0, weight=1, minsize=self._time_elem.text_width)
        self.columnconfigure(1, weight=1, minsize=self._strokes_elem.text_width)
        self.columnconfigure(2, weight=1, minsize=self._accuracy_elem.text_width)
        self.rowconfigure(2, weight=1)

        # pack and configure text frame
        self._text.grid(column=0, row=0, sticky=N + E + S + W)
        self._scrollbar.grid(column=1, row=0, sticky=N + E + S + W)

        self._content_frame.columnconfigure(0, weight=1, minsize=400)
        self._content_frame.rowconfigure(0, weight=1)
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def __init__(self, master, determinate=True, *args, **kwargs):
        self._queue = queue.Queue()

        super().__init__(master, *args, **kwargs)
        self.withdraw()
        # if master.winfo_viewable():
        #     self.transient(master)
        # style = Style()
        # style.configure('LoadingScreen.TFrame', padding=0, bg='black')

        self.determinate = determinate
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        self.frm_border = Frame(self, borderwidth=2, relief=SOLID)
        self.frm_border.columnconfigure(0, weight=1)
        self.frm_border.rowconfigure(0, weight=1)
        self.frm_border.grid(sticky='nsew')

        self.frm = Frame(self.frm_border)
        self.frm.grid(row=0, column=0, padx=20, pady=20, sticky='nsew')
        self.lbl_info = Label(self.frm)
        self.frm.columnconfigure(0, weight=1, minsize=250)

        self.lbl_info.grid(row=0, column=0, sticky='ew')
        pb_mode = 'determinate' if self.determinate else 'indeterminate'
        self.pb_progress = Progressbar(self.frm, mode=pb_mode)
        self.pb_progress.grid(row=1, column=0, sticky='ew')

        self.update_idletasks()
        self.wm_overrideredirect(1)
        self.master.bind('<Configure>', self.updatePosition, add='+')
        self.updatePosition()

        self.deiconify()
        self.wait_visibility()
        self.grab_set()
        self.focus_set()

        if not self.determinate:
            # self.pb_progress.config(mode='determinate')
            self.pb_progress.start(10)

        self.after(10, self.processMessages)
项目:sorter    作者:giantas    | 项目源码 | 文件源码
def _init_ui(self):
        image_data = base64.b64decode(icon_100)
        image = PhotoImage(data=image_data)

        name_frame = ttk.Frame(self, style="My.TFrame", relief=RAISED)
        name_frame.pack(side=TOP, fill=X)

        top_frame = ttk.Frame(self, style="My.TFrame")
        top_frame.pack(side=TOP, fill=X)

        mid_frame = ttk.Frame(self, style="My.TFrame")
        mid_frame.pack(side=TOP, fill=X)

        bottom_frame = ttk.Frame(self, style="My.TFrame")
        bottom_frame.pack(side=BOTTOM, fill=X)

        name_label = ttk.Label(name_frame, background=self.bg,
                               text='Sorter', justify='center', font="Helvetica 12 bold italic")
        name_label.pack(pady=1)

        image_label = ttk.Label(top_frame, image=image,
                                text='546', background=self.bg)
        image_label.image = image
        image_label.pack(side=LEFT, anchor=CENTER, pady=15, padx=20)

        info = 'Easy file organisation\nand management\nwith Sorter.\n\nCopyright \u00a9 2017\n\nAswa Paul\nAll rights reserved.'
        info_label = Message(top_frame, text=info, justify='center')
        info_label.pack(side=LEFT, pady=5, padx=5)

        self.progress_label = ttk.Label(mid_frame, justify='center',
                                        text='loading', background=self.bg, foreground="#778899")
        self.progress_label.pack(side=BOTTOM)

        status_bar = ttk.Label(bottom_frame)
        status_bar.pack(side=BOTTOM, fill=X)

        self.progress_var = DoubleVar()
        self.progress_bar = ttk.Progressbar(status_bar,
                                            length=400, variable=self.progress_var,
                                            orient=HORIZONTAL, maximum=100, style="blue.Horizontal.TProgressbar")
        self.progress_bar.pack(side=LEFT, fill=X)
        self.progress_var.set(10)
项目:serialplot    作者:crxguy52    | 项目源码 | 文件源码
def __init__(self, parent, root):
        ttk.Frame.__init__(self, parent)
        self.parent = parent
        self.root = root
        self['borderwidth'] = 2
        self['relief'] = 'sunken'

        COMlabel = ttk.Label(self, text= \
            self.root.variables['COMport'][0:5].strip() + ':')
        baudLabel = ttk.Label(self, text= \
            str(self.root.variables['baud'].strip()))
        COMlabel.pack(side='left', padx=0)
        baudLabel.pack(side='left', padx=0) 

        ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5)       

        buffLabel = ttk.Label(self, text='Serial Buffer:')
        buffLabel.pack(side='left', padx=0)

        buffBar = ttk.Progressbar(self, orient='horizontal', length=50,\
            mode='determinate', variable=self.root.variables['buffsize'],\
            maximum=io.DEFAULT_BUFFER_SIZE)
        buffBar.pack(side='left')

        ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5)

        lastLabel = ttk.Label(self, text='Last line Recieved: ')
        lastLabel.pack(side='left')
        lastLine = ttk.Label(self, textvariable=self.root.variables['lastline'], \
            font=('Courier', 8))
        lastLine.pack(side='left')

        ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5)

        updateLabel = ttk.Label(self, text='Data Recieved at: ')
        updateLabel.pack(side='left')
        updateRate = ttk.Label(self, textvariable=self.root.variables['refreshrate'])
        updateRate.pack(side='left')
        ttk.Label(self, text='Hz (Est)').pack(side='left')

        ttk.Separator(self, orient='vertical').pack(side='left', fill='y', padx=5)        

        if self.root.variables['log2file'] == 'on':
            self.root.toggleLogButton = ttk.Button(self, text='Turn Logging Off', command = self.toggleLog)
            self.root.toggleLogButton.pack(side='left')