⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ide.py

📁 skyeye-1.2-RC7-3的源代码
💻 PY
📖 第 1 页 / 共 2 页
字号:
import os, os.path, sys, Tix
from Tkconstants import *
import traceback, tkMessageBox
from Tkinter import *
import subprocess 
import win32process 
import win32api

class skyeye:
  cpu = ""
  board=""
  net = ""
  lcd = ""
  flash = ""
  map = ""
  type = ""
  addr = ""
  size = ""
  file = ""
  membank = []
  memory_info = ""
  cpu_once = 0
  device_once = 0
  memory_once = 0
  image_path = None
  conf_path = None
  run = None
  kill = None
  is_running = 0
  skyeye_id = 0
  
  
  def __init__(self, top):
    self.root = top
    self.build()
  
  def skyeye_mainmenu(self):
    top = self.root
    w = Tix.Frame(top, bd=2, relief=RAISED)
    file = Tix.Menubutton(w, text='File', underline=0, takefocus=0)
    view = Tix.Menubutton(w, text='Setting', underline=0, takefocus=0)
    project = Tix.Menubutton(w, text='Project', underline=0, takefocus=0)
    execute = Tix.Menubutton(w, text='Execute', underline=0, takefocus=0)
    tools = Tix.Menubutton(w, text='Tools', underline=0, takefocus=0)
    window = Tix.Menubutton(w, text='Window', underline=0, takefocus=0)
    help = Tix.Menubutton(w, text='Help', underline=0, takefocus=0)

    file.pack(side=LEFT)
    project.pack(side=LEFT)
    view.pack(side=LEFT)    
    execute.pack(side=LEFT)
    tools.pack(side=LEFT)
    window.pack(side=LEFT)
    help.pack(side=RIGHT)
    
    file_m = Tix.Menu(file, tearoff=0)
    file['menu'] = file_m
    view_m = Tix.Menu(view, tearoff=0)
    view['menu'] = view_m
    project_m = Tix.Menu(project, tearoff=0)
    project['menu'] = project_m
    execute_m = Tix.Menu(execute, tearoff=0)
    execute['menu'] = execute_m
    tools_m = Tix.Menu(tools, tearoff=0)
    tools['menu'] = tools_m
    window_m = Tix.Menu(window, tearoff=0)
    window['menu'] = window_m
    help_m = Tix.Menu(help, tearoff=0)
    help['menu'] = help_m

    file_m.add_command(label='Open file', underline=1,
                   command = self.file_openfile)
    file_m.add_command(label='Close file', underline=1,
                   command = self.file_closefile)
    file_m.add_command(label='Exit', underline=1,
                   command = self.file_exit)
    
    view_m.add_radiobutton(label='Cpu', underline =1,
                       command = self.view_cpu)
    view_m.add_radiobutton(label='Device', underline =1,
                       command = self.view_device)
    view_m.add_radiobutton(label='Memory', underline =1,
                       command = self.view_memory)
    view_m.add_radiobutton(label='System Info', underline =1,
                       command = self.view_info)
    
    project_m.add_command(label='New', underline =1,
                          command = self.project_new)
    project_m.add_command(label='Save', underline =1,
                          command = self.project_save)
    
    execute_m.add_command(label='Compile', underline =1,
                          command = self.execute_compile)
    execute_m.add_command(label='Compile current file', underline =1,
                          command = self.execute_compilecurrentfile)
    execute_m.add_command(label='Run', underline =1,
                          command = self.execute_run)
    execute_m.add_command(label='Compile & Run', underline =1,
                          command = self.execute_compileandrun)
    execute_m.add_command(label='Rebuild All', underline =1,
                          command = self.execute_rebuildall)
    execute_m.add_command(label='Clean', underline =1,
                          command = self.execute_clean)
    
    tools_m.add_command(label='Compiler Option', underline =1,
                          command = self.tools_compileroption)
    tools_m.add_command(label='Linker Option', underline =1,
                          command = self.tools_linkeroption)
    tools_m.add_command(label='Makefile Option', underline =1,
                          command = self.tools_makefileoption)
    
    
    
    window_m.add_command(label='Max', underline=0, 
                       command=self.window_max)
    window_m.add_command(label='Restore', underline=0, 
                       command=self.window_restore)
    
    help_m.add_command(label='about',underline =0,
                       command=self.help_about)
    return w

  def skyeye_body(self, str):
    top = self.root
    try:
      self.body.destroy()
    except:
      pass
    
    self.body = Tix.LabelFrame(top, label=str, labelside="acrosstop")
    self.body.pack(fill=Tix.BOTH, padx=8, pady=20)
    return self.body
  
  def skyeye_messagebox(self):
    top = self.root
    pane = Tix.LabelFrame(top, label='Message Area',labelside="acrosstop")
    text = Tix.ScrolledText(pane,height=100,scrollbar="y")
    text.text.insert(Tix.END,"Welcome to skyeye")
    text.pack(fill=Tix.BOTH, padx=8, pady=20)
    self.messagebox = text
    return pane
  
  def message(self, msg):
    self.messagebox.text.delete("0.0",Tix.END)
    self.messagebox.text.insert(Tix.END,msg)
    
  def build(self):
    root = self.root
    z = root.winfo_toplevel()
    z.wm_title('skyeye for windows')
        
    frame1 = self.skyeye_mainmenu()
    frame1.grid(row=0,sticky=N+W+E)
    frame2 = self.skyeye_messagebox()
    frame2.grid(row=2,sticky=S+W+E)
    self.welcome()

    
    self.message("hello renjie")

  def file_openfile(self):
    tmp = Tix.ExFileSelectBox(self.skyeye_body("Open file for reading"),command=self.file_openfile_command)
    tmp.pack(fill=Tix.BOTH, padx=8, pady=20)
    self.skyeye_redobody()
    
  
  def file_openfile_command(self,event=None):
    
    text = Tix.ScrolledText(self.skyeye_body("Reading file : %s"%str(event)),height=300,scrollbar="y")
    try:
      fd = open(str(event),"r")
      for x in fd.readlines():
        text.text.insert(Tix.END,x)
        self.message("Open file <%s> for reading"%str(event))
    except:
      self.message("Cannot open file: %s"%str(event))
    text.pack(fill=Tix.BOTH, padx=8, pady=20)
    self.skyeye_redobody()
    
  def welcome(self):
    tmp = Tix.Label(self.skyeye_body("Welcome"),text="koodialar",height=30)
    tmp.pack(fill=Tix.BOTH, padx=8, pady=20)
    self.skyeye_redobody()

  def skyeye_redobody(self):
    self.body.grid(row=1,sticky=N+S+W+E)
    
  def file_closefile(self):
    self.welcome()
  
  def file_exit(self):
    self.destroy()
    self.message("File is closed")
    
  def view_cpu(self):
    self.message("You are now setting the cpu and mainboard information")
    if self.cpu_once == 1:
      self.cpu_board_ok()
      return
    
    cpu_list = ["arm","bfin"]
    board_list =["at91",
                  "at91rm92",
                  "clps7110",
                  "clps9312",
                  "cs89712"
                  "ep7212",
                  "ep9312",
                  "lh79520",
                  "lh79520-hardware",
                  "lh79520-irqs",
                  "lpc",
                  "ns9750",
                  "pxa",
                  "s3c44b0",
                  "s3c2410x",
                  "s3c4510b",
                  "sa1100",
                  "serial_amba",
                  "serial_amba_pl011",
                  "sharp"]
    top = self.skyeye_body("Cpu & Mainboard")
    cpu = Tix.LabelFrame(top, label='Cpu',labelside="acrosstop",padx=5,pady=10)
    board = Tix.LabelFrame(top, label='Mainboard',labelside="acrosstop",padx=5,pady=10)
    
    cpu_s = Tix.OptionMenu(cpu, label="Cpu:   ",command=self.cpu_select)
    
    board_s = Tix.OptionMenu(board, label="Mainboard:    ",command=self.board_select)
    
    ok = Tix.Button(top, text="OK", command=self.cpu_board_ok)
    
    for x in cpu_list:
      cpu_s.add_command(x,label=x)
    for x in board_list:
      board_s.add_command(x,label=x)
      
    cpu_s.pack(padx=5,pady=10)
    cpu.grid(row = 0, column=0,padx=5,pady=10)
    board_s.pack(padx=5,pady=10)
    board.grid(row = 0, column=1,padx=5,pady=10)
    ok.grid(row=1, column=0, columnspan=2,padx=5,pady=10)

    self.skyeye_redobody()
  
  def cpu_select(self, event=None):
    self.cpu = str(event)
    self.message("Cpu <%s> is chosen"%str(event))
    
  def board_select(self, event=None):
    self.board = str(event)
    self.message("Mainboard <%s> is chosen"%str(event))
    
  def cpu_board_ok(self, event=None):
    self.cpu_once = 1
    top = self.skyeye_body("Cpu & Mainboard")
    
    tmp = Tix.Frame(top)
    
    b = Tix.Message(tmp, 
                relief=Tix.FLAT, width=240, anchor=Tix.N,
                text='Below are the information of Cpu and Mainboard:')
    b.grid( row =0 ,padx=5,pady=3,sticky=W+E)
    
    
    b = Tix.Message(tmp, 
                relief=Tix.FLAT, width=240, anchor=Tix.N,
                text='\tCpu\t\t: %s\n\tMainboard\t: %s'%(self.cpu,self.board))
    b.grid( row =1 ,padx=5,pady=3,sticky=W+E)
    
    b = Tix.Message(tmp, 
                relief=Tix.FLAT, width=240, anchor=Tix.N,
                text='Would you want to reset?')
    b.grid( row =2 ,padx=5,pady=3,sticky=W+E)
    
    reset = Tix.Button(tmp, text="OK", command=self.reset_cpu, width = 5, bg="red",fg="white")
    reset.grid( row = 3,padx=5,pady=3)
    
    tmp.grid(padx=5,pady=10)
    
    self.message("You choose:\n\tCpu\t\t: %s\n\tMainboard\t: %s"%(self.cpu,self.board))
    
    self.skyeye_redobody() 
    
  def reset_cpu(self):
    self.cpu_once = 0
    self.view_cpu()
    
  def view_device(self):
    self.message("You are now setting the peripherial information")
    if self.device_once == 1:
      self.net_lcd_flash_ok()
      return 
    
    net_list=["cs8900a",
              "rtl8091",
              "s3c4510b"]
    
    lcd_list=["ep7312",
              "pxa",
              "s3c2410"]
    flash_list=["ibm"]
  
    top = self.skyeye_body("Peripherial")
    net = Tix.LabelFrame(top,labelside="acrosstop",padx=5,pady=10)
    lcd = Tix.LabelFrame(top,labelside="acrosstop",padx=5,pady=10)
    flash = Tix.LabelFrame(top,labelside="acrosstop",padx=5,pady=10)
    
    self.net_v = Tix.StringVar()
    self.lcd_v = Tix.StringVar()
    self.flash_v = Tix.StringVar()
    
    net_s = Tix.Select(net, label='Net Adapter', allowzero=1, radio=1,
                      orientation=Tix.VERTICAL,
                      labelside=Tix.TOP,
                      command=self.net_select,
                       variable=self.net_v)
    
    lcd_s = Tix.Select(lcd, label='Lcd', allowzero=1, radio=1,
                       orientation=Tix.VERTICAL,
                       labelside=Tix.TOP,
                       command=self.lcd_select,
                       variable=self.lcd_v)
     
    flash_s = Tix.Select(flash, label='Flash', allowzero=1, radio=1,
                      orientation=Tix.VERTICAL,
                      labelside=Tix.TOP,
                      command=self.flash_select,
                         variable=self.flash_v)
    
    ok = Tix.Button(top, text="OK", command=self.net_lcd_flash_ok)
    
    for x in net_list:
      net_s.add(x,text=x)
    for x in lcd_list:
      lcd_s.add(x,text=x)
    for x in flash_list:
      flash_s.add(x,text=x)      
      
    net_s.pack(padx=5,pady=10)
    net.grid(row = 0, column=0,padx=5,pady=10)
    lcd_s.pack(padx=5,pady=10)
    lcd.grid(row = 0, column=1,padx=5,pady=10)
    flash_s.pack(padx=5,pady=10)
    flash.grid(row = 0, column=2,padx=5,pady=10)
    ok.grid(row=1, column=1, columnspan=1,padx=5,pady=10)

    self.skyeye_redobody() 
    
  def net_select(self,event=None,test=None):
    if str(test) != "0":
      self.net_tmp = self.net_v
      self.message("Net adapter <%s> is chosen"%str(event))
    else:
      self.message("No net adapter is chosen")
    
  def lcd_select(self,event=None,test=None):
    if str(test) != "0":
      self.lcd_tmp = self.lcd_v
      self.message("Lcd <%s> is chosen"%str(event))
    else:
      self.message("No Lcd is chosen")
    
  def flash_select(self,event=None,test=None):
    
    if str(test) != "0":
      self.flash_tmp = self.flash_v
      self.message("Flash <%s> is chosen"%str(event))
    else:
      self.message("No Flash is chosen")
    
  def net_lcd_flash_ok(self,event=None):
    self.device_once = 1
    top = self.skyeye_body("Peripherial")
    
    tmp = Tix.Frame(top)
    
    b = Tix.Message(tmp, 
                relief=Tix.FLAT, width=240, anchor=Tix.N,
                text='Below are the information of peripherials:')
    b.grid( row =0 ,padx=5,pady=3,sticky=W+E)
    
    self.net = self.net_v.get()[2:-3]
    str = ""
    if self.net !="":
      str +="\tNet\t: %s\n"%self.net
    else:
      str +="\tNet\t: disabled\n"
      
    self.lcd = self.lcd_v.get()[2:-3]
    if self.lcd !="":
      str +="\tLcd\t: %s\n"%self.lcd
    else:
      str +="\tLcd\t: disabled\n"
      
    self.flash = self.flash_v.get()[2:-3]
    if self.flash !="":
      str +="\tFlash\t: %s\n"%self.flash
    else:
      str +="\tFlash\t: disabled\n"
    
    b = Tix.Message(tmp, 
                relief=Tix.FLAT, width=240, anchor=Tix.N,
                text='%s'%str)
    b.grid( row =1 ,padx=5,pady=3,sticky=W+E)
    
    b = Tix.Message(tmp, 
                relief=Tix.FLAT, width=240, anchor=Tix.N,
                text='Would you want to reset?')
    b.grid( row =2 ,padx=5,pady=3,sticky=W+E)
    
    reset = Tix.Button(tmp, text="OK", command=self.reset_device, width = 5, bg="red",fg="white")
    reset.grid( row = 3,padx=5,pady=3)
    
    tmp.grid(padx=5,pady=10)
    
    self.message("Peripherial information:\n"+str)
    self.skyeye_redobody() 
    
  def reset_device(self):
    self.device_once = 0
    self.view_device()
    
  def view_memory(self):
    self.message("You are now setting memory information")
    if self.memory_once == 1:
      self.memory_ok()
      return
    
    top = self.skyeye_body("Cpu & Mainboard")
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -