コード例 #1
0
ファイル: dialogs.py プロジェクト: Arzaroth/CelestiaSunrise
    def __init__(self, master):
        BaseDiablog.__init__(self, master, "Downloading...")
        self.protocol('WM_DELETE_WINDOW', lambda *args: None)
        self._curbytes = 0
        self._maxbytes = 0
        self.start = monotonic()
        self.update_percent()
        self.cancel = False

        self.label = ttk.Label(self.body,
                               text="The new version is currently downloading, please wait...",
                               font=20)
        self.progressframe = ttk.Frame(self.body)
        self.pb = ttk.Progressbar(self.progressframe,
                                  mode="determinate",
                                  length=250,
                                  orient=HORIZONTAL)
        self.pblabel = ttk.Label(self.progressframe,
                                 textvariable=DownloadDialog.percent.raw_klass(self))
        self.cancel_button = ttk.Button(self.body,
                                        text="Cancel",
                                        command=lambda: DownloadDialog.cancel.__set__(self, True))

        options = dict(padx=3, pady=4)
        self.label.pack(side=TOP, fill=X, expand=False, **options)
        self.cancel_button.pack(side=BOTTOM, expand=False, **options)
        self.progressframe.pack(side=BOTTOM, fill=BOTH, expand=True, **options)
        self.pb.pack(side=LEFT, **options)
        self.pblabel.pack(side=LEFT, **options)
コード例 #2
0
    def __init__(self, *args, **kwargs):
        tk.Toplevel.__init__(self, *args, **kwargs)
        self.transient()
        self.title("Downloading...")
        self.protocol('WM_DELETE_WINDOW', lambda *args: None)
        self._curbytes = 0
        self._maxbytes = 0
        self.start = monotonic()
        self.update_percent()

        self.mainframe = ttk.Frame(self)
        self.mainframe.pack(side=TOP, fill=BOTH, expand=True)

        self.label = ttk.Label(self.mainframe,
                               text="The new version is currently downloading, please wait...",
                               font=20)
        self.progressframe = ttk.Frame(self.mainframe)
        self.pb = ttk.Progressbar(self.progressframe,
                                  mode="determinate",
                                  length=200,
                                  orient=HORIZONTAL)
        self.pblabel = ttk.Label(self.progressframe,
                                 textvariable=DownloadDialog.percent.raw_klass(self))

        options = dict(padx=3, pady=4)
        self.label.pack(side=TOP, fill=X, expand=False, **options)
        self.progressframe.pack(side=BOTTOM, fill=BOTH, expand=True, **options)
        self.pb.pack(side=LEFT, **options)
        self.pblabel.pack(side=LEFT, **options)
コード例 #3
0
    def __init__(self, master):
        BaseDiablog.__init__(self, master, "Downloading...")
        self.protocol('WM_DELETE_WINDOW', lambda *args: None)
        self._curbytes = 0
        self._maxbytes = 0
        self.start = monotonic()
        self.update_percent()
        self.cancel = False

        self.label = ttk.Label(
            self.body,
            text="The new version is currently downloading, please wait...",
            font=20)
        self.progressframe = ttk.Frame(self.body)
        self.pb = ttk.Progressbar(self.progressframe,
                                  mode="determinate",
                                  length=250,
                                  orient=HORIZONTAL)
        self.pblabel = ttk.Label(
            self.progressframe,
            textvariable=DownloadDialog.percent.raw_klass(self))
        self.cancel_button = ttk.Button(
            self.body,
            text="Cancel",
            command=lambda: DownloadDialog.cancel.__set__(self, True))

        options = dict(padx=3, pady=4)
        self.label.pack(side=TOP, fill=X, expand=False, **options)
        self.cancel_button.pack(side=BOTTOM, expand=False, **options)
        self.progressframe.pack(side=BOTTOM, fill=BOTH, expand=True, **options)
        self.pb.pack(side=LEFT, **options)
        self.pblabel.pack(side=LEFT, **options)
コード例 #4
0
 def update_percent(self):
     try:
         percent = (self.current / self.total) * 100
     except ZeroDivisionError:
         percent = 0
     try:
         kbps = self.current / (monotonic() - self.start) / 1024
     except ZeroDivisionError:
         kbps = 0
     self.percent = "{:.2f}% ({:.2f} KiB/s)".format(percent, kbps)