Update UI.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2499 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com 2012-12-19 13:48:10 +00:00
parent 7672426550
commit ba4aa585a4
1 changed files with 61 additions and 21 deletions

View File

@ -46,32 +46,37 @@ class CmdExecutor(threading.Thread):
global executor, builder, lock global executor, builder, lock
if platform.system() == 'Windows': if platform.system() == 'Windows':
from win32spawn import Win32Spawn try:
from win32spawn import Win32Spawn
subprocess = Win32Spawn(self.cmd) subprocess = Win32Spawn(self.cmd)
subprocess.start_pipe() subprocess.start_pipe()
builder.progressbar.start() builder.progressbar.start()
while not subprocess.is_terminated or subprocess.qsize() > 0: while not subprocess.is_terminated or subprocess.qsize() > 0:
try: try:
line = subprocess.get(timeout=1) line = subprocess.get(timeout=1)
line = line.replace('\r', '') line = line.replace('\r', '')
if line: if line:
lock.acquire() lock.acquire()
builder.output.see(END) builder.output.see(END)
builder.output.insert(END, line) builder.output.insert(END, line)
lock.release() lock.release()
except: except:
pass pass
builder.progressbar.stop() builder.progressbar.stop()
except:
pass
executor = None executor = None
if builder.is_makeing_project:
builder.output.insert(END, 'Done')
builder.is_makeing_project = False
def ExecCmd(cmd): def ExecCmd(cmd):
global executor global executor
if executor: if executor:
print 'cmd not exit, return' print 'last task does not exit'
return return
executor = CmdExecutor(cmd, builder) executor = CmdExecutor(cmd, builder)
@ -127,26 +132,33 @@ class SconsUI():
notebook.add(page_building, padding=3) notebook.add(page_building, padding=3)
notebook.tab(0, text='Build', underline="-1") notebook.tab(0, text='Build', underline="-1")
self.setup_building_ui(page_building) self.setup_building_ui(page_building)
self.building_page = page_building
# make project page # make project page
page_project = ttk.Frame(notebook) page_project = ttk.Frame(notebook)
notebook.add(page_project, padding = 3) notebook.add(page_project, padding = 3)
notebook.tab(1, text = 'Project', underline = '-1') notebook.tab(1, text = 'Project', underline = '-1')
self.setup_project_ui(page_project) self.setup_project_ui(page_project)
self.project_page = page_project
# setting page # setting page
page_setting = ttk.Frame(notebook) page_setting = ttk.Frame(notebook)
notebook.add(page_setting, padding = 3) notebook.add(page_setting, padding = 3)
notebook.tab(2, text = 'Setting', underline = '-1') notebook.tab(2, text = 'Setting', underline = '-1')
self.setup_setting_ui(page_setting) self.setup_setting_ui(page_setting)
self.setting_page = page_setting
padding = ttk.Frame(master) padding = ttk.Frame(master)
padding.pack(fill=X) padding.pack(fill=X)
quit = ttk.Button(padding, text='Quit', command = self.quit) quit = ttk.Button(padding, text='Quit', command = self.quit)
quit.pack(side=RIGHT) quit.pack(side=RIGHT)
# set notebook to self
self.notebook = notebook
# read setting # read setting
self.read_setting() self.read_setting()
self.is_makeing_project = False
def read_setting(self): def read_setting(self):
import platform import platform
@ -359,11 +371,29 @@ class SconsUI():
os.environ['RTT_EXEC_PATH'] = exec_path os.environ['RTT_EXEC_PATH'] = exec_path
return command return command
def check_path(self):
result = True
if self.BSPRoot.get_path() == '':
result = False
if self.RTTRoot.get_path() == '':
result = False
if not result:
tkMessageBox.showinfo("RT-Thread SCons UI",
"Folder is empty, please choose correct directory.")
return result
def do_build(self): def do_build(self):
self.prepare_build() self.prepare_build()
command = 'scons' command = 'scons'
if not self.check_path():
return
bsp = self.BSPRoot.get_path() bsp = self.BSPRoot.get_path()
os.chdir(bsp) os.chdir(bsp)
@ -375,6 +405,9 @@ class SconsUI():
self.prepare_build() self.prepare_build()
command = 'scons -c' command = 'scons -c'
if not self.check_path():
return
bsp = self.BSPRoot.get_path() bsp = self.BSPRoot.get_path()
os.chdir(bsp) os.chdir(bsp)
@ -387,11 +420,18 @@ class SconsUI():
self.prepare_build() self.prepare_build()
command = 'scons --target=%s -s' % ide command = 'scons --target=%s -s' % ide
if not self.check_path():
return
# select build page
self.notebook.select(self.building_page)
bsp = self.BSPRoot.get_path() bsp = self.BSPRoot.get_path()
os.chdir(bsp) os.chdir(bsp)
self.output.delete(1.0, END) self.output.delete(1.0, END)
self.output.insert(END, 'make project ...\n') self.output.insert(END, 'Generate project ...\n')
self.is_makeing_project = True
ExecCmd(command) ExecCmd(command)
def quit(self): def quit(self):