Created
November 1, 2009 19:19
-
-
Save lqc/223670 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
import threading | |
import wx | |
class Okno(wx.Frame): | |
def __init__(self): | |
wx.Frame.__init__(self, None, -1, "Test", size=(600, 80)) | |
self.panel = wx.Panel(self, -1) | |
self.btn = wx.Button(self.panel, -1, "Generuj ISO!", size=(200, 45)) | |
self.Bind(wx.EVT_BUTTON, self.start, self.btn) | |
self.progressBar = wx.Gauge(self.panel, -1, size=(350, 15), pos=(0, 25)) | |
self.sizer = wx.BoxSizer(wx.VERTICAL) | |
self.sizer.Add(self.btn, 0, wx.ALIGN_RIGHT, 1) | |
self.sizer.Add(self.progressBar, 0, wx.ALIGN_LEFT, 1) | |
self.panel.SetSizer(self.sizer) | |
def start(self, event): | |
bar = threading.Thread(target=self.runm) | |
bar.start() | |
def runm (self): | |
process = subprocess.Popen(['/opt/schily/bin/mkisofs', '-v', '--gui', '-o', 'output.iso', '_test'], stderr=subprocess.PIPE) | |
wx.CallAfter(self.update_progress, 0) | |
while True: | |
data = process.stderr.readline() | |
if data == '': break | |
token = data.split()[0] | |
if token[-1] != '%': continue | |
try: | |
wx.CallAfter( self.update_progress, float(token[:-1]) ) | |
except ValueError: | |
# ignoruj linie nie dotyczace postepu | |
pass | |
wx.CallAfter(self.update_progress, 100) | |
def update_progress(self, value): | |
self.progressBar.SetValue(value) | |
if value < 100: | |
self.SetTitle("Postep: %d%%" % value) | |
else: | |
self.SetTitle("Zrobiono !!!") | |
class Aplikacja (wx.App): | |
def OnInit(self): | |
ramka = Okno() | |
self.SetTopWindow(ramka) | |
ramka.Show() | |
return True | |
if __name__ == '__main__': | |
app = Aplikacja(redirect=False) | |
app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment