Ejemplo n.º 1
0
    def MkMainMenu(self):
        top = self.root
        w = Tix.Frame(top, bd=2, relief=RAISED)
        file = Tix.Menubutton(w, text='File', underline=0, takefocus=0)
        help = Tix.Menubutton(w, text='Help', underline=0, takefocus=0)
        file.pack(side=LEFT)
        help.pack(side=RIGHT)
        fm = Tix.Menu(file, tearoff=0)
        file['menu'] = fm
        hm = Tix.Menu(help, tearoff=0)
        help['menu'] = hm

        if w.tk.eval('info commands console') == "console":
            fm.add_command(label='Console',
                           underline=1,
                           command=lambda w=w: w.tk.eval('console show'))

        fm.add_command(label='Exit',
                       underline=1,
                       command=lambda self=self: self.quitcmd())
        hm.add_checkbutton(label='BalloonHelp',
                           underline=0,
                           command=self.ToggleHelp,
                           variable=self.useBalloons)
        # The trace variable option doesn't seem to work, instead I use 'command'
        #apply(w.tk.call, ('trace', 'variable', self.useBalloons, 'w',
        #             ToggleHelp))
        return w
Ejemplo n.º 2
0
def popup(ui, event, handlers, point=None):
    menu = Tix.Menu(ui, tearoff=0)
    pd = PopupDone()
    for h in handlers:
        if (len(h) >= 3):
            p = PopupSelector(h[1], h[2], pd)
            pass
        else:
            p = PopupSelector(h[1], None, pd)
            pass
        menu.add("command", command=p.handle, label=h[0])
        pass
    if (point == None):
        point = event
        pass
    menu.post(point.x_root, point.y_root)
    menu.grab_set_global()
    menu.bind("<FocusOut>", pd.setdone)
    menu.bind("<ButtonRelease-3>", pd.setdone)
    while (not pd.done):
        event.widget.tk.dooneevent()
        pass
    menu.grab_release()
    menu.destroy()
    return
Ejemplo n.º 3
0
def create_help_menu(master):
    menu = Tix.Menu(master)
    menu.add_command(
        label=_("Getting started"),
        command=lambda: open_document("getting-started.html"),
    )
    menu.add_command(
        label=_("User Guide"),
        command=lambda: open_document("user-guide.html"),
    )
    menu.add_separator()
    menu.add_command(
        label=_("Register Product"),
        command=lambda w=master: register_product(w),
    )
    # menu.add_command(
    #     label=_("Verify Serial Number"),
    #     command=lambda w=master : verify_serial_number(w),
    #     )
    menu.add_separator()
    menu.add_command(
        label=_("About..."),
        command=lambda w=master: open_about_dialog(w),
    )
    return menu
Ejemplo n.º 4
0
 def auto_symbol_complete(self, event):
     """自动补齐功能。 """
     part = self.editor.get("insert -1c wordstart", "insert")
     if part:
         # 补齐功能
         k = len(part)
         symbols = []
         for i in range(3):
             symbols += filter(lambda x:x.startswith(part), self.symbol_list[i])
         n = len(symbols)
         if n == 1:
             self.editor.insert("insert", symbols[0][k:])
         elif n > 1:
             symbols.sort()
             r = self.editor.bbox("insert")
             if r:
                 pm = Tix.Menu(self)
                 for name in symbols:
                     pm.add_command(
                         label=name,
                         command=lambda x=name, k=k:(
                             self.editor.insert("insert", x[k:])
                             ),
                         )
                 pm.post(r[0] + 2, r[1] + 2)
     return "break"
Ejemplo n.º 5
0
    def __init__(self, master):
        # control panel
        conf = tix.Frame(master, bg="lightblue", width=300, padx=1, pady=1)
        conf.grid(row=0, column=0, sticky="nw")
        conf.pack(fill="both", expand=1, side="left")

        # file list window
        self.files = tix.FileSelectBox(conf,
                                       bg='white',
                                       width=300,
                                       height=760,
                                       command=self.dispfile)
        self.files.grid(row=1, column=1, sticky="nw")
        self.files.pack(fill='both', expand=1, side="bottom")

        # text window
        textw = tix.Frame(master,
                          bg="lightblue",
                          width=900,
                          height=960,
                          padx=5,
                          pady=1)
        textw.grid(row=0, column=1, columnspan=2, sticky="ne")
        textw.pack(fill='both', expand=1, side="right")

        self.edit = tix.ScrolledText(textw,
                                     bg='lightblue',
                                     width=900,
                                     height=960)
        self.edit.pack()

        # Menu
        menu = tix.Menu(master)
        root.config(menu=menu)
        # file menu
        filemenu = tix.Menu(menu, tearoff=0)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="New", command=self.new_text)
        filemenu.add_command(label="Open", command=self.file_open)
        filemenu.add_command(label="SaveAs", command=self.file_saveas)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.do_exit)

        # start with cursor in the editor area
        self.edit.focus()
Ejemplo n.º 6
0
    def make_menu(self, tag, segment, valid_parses, limit=20):
        popup = Tk.Menu(self, tearoff=0)
        tagnum = int(tag[3:])

        def select(parse):
            if parse is None:
                self.text.tag_config(tag,
                                     background=self.parsed_color,
                                     borderwidth=1,
                                     relief='raised')
            else:
                self.text.tag_config(tag,
                                     background=self.selected_color,
                                     borderwidth=1,
                                     relief='raised')
            # remember our selection
            self.selections[str(segment)] = parse
            dispatcher.send("selection made",
                            segment=segment,
                            selection=parse,
                            tag=tag,
                            segmentnum=tagnum,
                            sender=self)

        def hover(mouseisover=False):
            if mouseisover:
                self.text.tag_config(tag, relief='sunken')
            else:
                self.text.tag_config(tag, relief='raised')

        for parse, score in valid_parses[:limit]:
            popup.add_command(label="%s (%s)" % (parse, score),
                              command=lambda parse=parse: select(parse))

        for sym in self.special_symbols:
            popup.add_command(label=str(sym), command=lambda: select(sym))
        popup.add_command(label='(Ignore)', command=lambda: select(None))

        def do_popup(event):
            # display the popup menu
            try:
                popup.tk_popup(event.x_root, event.y_root, 0)
            finally:
                # make sure to release the grab (Tk 8.0a1 only)
                popup.grab_release()

        self.text.tag_bind(tag, "<ButtonPress-3>", do_popup)
        self.text.tag_bind(tag, "<Enter>", lambda evt: hover(True))
        self.text.tag_bind(tag, "<Leave>", lambda evt: hover(False))

        return popup
Ejemplo n.º 7
0
def MkMainMenu(top):
    global demo

    w = Tix.Frame(top, bd=2, relief=Tix.RAISED)
    file = Tix.Menubutton(w, text='File', underline=0, takefocus=0)
    help = Tix.Menubutton(w, text='Help', underline=0, takefocus=0)
    file.pack(side=Tix.LEFT)
    help.pack(side=Tix.RIGHT)
    fm = Tix.Menu(file)
    file['menu'] = fm
    hm = Tix.Menu(help)
    help['menu'] = hm

    fm.add_command(label='Exit', underline=1, accelerator='Ctrl+X',
		   command=exit_cmd)
    hm.add_checkbutton(label='BalloonHelp', underline=0, command=ToggleHelp,
		       variable=demo.useBalloons)
    # The trace variable option doesn't seem to work, instead I use 'command'
    #apply(w.tk.call, ('trace', 'variable', demo.useBalloons, 'w',
    #		      ToggleHelp))
    top.bind_all("<Control-x>", exit_cmd)
    top.bind_all("<Control-X>", exit_cmd)
    return w
Ejemplo n.º 8
0
def RunSample(w):
    # We create the frame and the button, then we'll bind the PopupMenu
    # to both widgets. The result is, when you press the right mouse
    # button over $w.top or $w.top.but, the PopupMenu will come up.
    #
    top = Tix.Frame(w, relief=Tix.RAISED, bd=1)
    but = Tix.Button(
        top,
        text=
        'Press the right mouse button over this button or its surrounding area'
    )
    but.pack(expand=1, fill=Tix.BOTH, padx=50, pady=50)

    p = Tix.PopupMenu(top, title='Popup Test')
    p.bind_widget(top)
    p.bind_widget(but)

    # Set the entries inside the PopupMenu widget.
    # [Hint] You have to manipulate the "menu" subwidget.
    #        $w.top.p itself is NOT a menu widget.
    # [Hint] Watch carefully how the sub-menu is created
    #
    p.menu.add_command(label='Desktop', underline=0)
    p.menu.add_command(label='Select', underline=0)
    p.menu.add_command(label='Find', underline=0)
    p.menu.add_command(label='System', underline=1)
    p.menu.add_command(label='Help', underline=0)
    m1 = Tix.Menu(p.menu)
    m1.add_command(label='Hello')
    p.menu.add_cascade(label='More', menu=m1)

    but.pack(side=Tix.TOP, padx=40, pady=50)

    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    box.add('ok',
            text='Ok',
            underline=0,
            width=6,
            command=lambda w=w: w.destroy())
    box.add('cancel',
            text='Cancel',
            underline=0,
            width=6,
            command=lambda w=w: w.destroy())
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Ejemplo n.º 9
0
 def __init__(self, parent, goal_setter, gain_setter):
     Tix.Frame.__init__(self, parent)
     self.goal_setter = goal_setter
     self.gain_setter = gain_setter
     self.mbtext = Tix.StringVar(self)
     self.mbtext.set('controller: (none selected)')
     self.mbtext = Tix.StringVar(self)
     self.mb = Tix.Menubutton(self,
                              textvariable=self.mbtext,
                              relief=Tix.RAISED)
     self.mb.pack(side=Tix.TOP, expand=True, fill=Tix.X)
     self.menu = Tix.Menu(self.mb, tearoff=0)
     self.mb["menu"] = self.menu
     self.statustext = Tix.StringVar(self)
     self.statustext.set('(no status yet)')
     self.status = Tix.Label(self, textvariable=self.statustext)
     self.status.pack(side=Tix.TOP, expand=True, fill=Tix.X)
     self.select_controller = None
     self.get_state = None
Ejemplo n.º 10
0
    def __init__(self, top, mainhandler):
        Tix.Frame.__init__(self, top, bd=2, relief=Tix.RAISED)

        self.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        self.top = top

        self.mainhandler = mainhandler

        self.inactive_style = Tix.DisplayStyle(Tix.TEXT, fg="dark grey",
                                               selectforeground="dark grey",
                                               selectbackground="beige",
                                               refwindow=top)
        self.active_style = Tix.DisplayStyle(Tix.TEXT, fg="black",
                                             selectforeground="black",
                                             selectbackground="beige",
                                             refwindow=top)
        self.critical_style = Tix.DisplayStyle(Tix.TEXT, fg="blue",
                                               selectforeground="blue",
                                               selectbackground="beige",
                                               refwindow=top)
        self.severe_style = Tix.DisplayStyle(Tix.TEXT, fg="red",
                                             selectforeground="red",
                                             selectbackground="beige",
                                             refwindow=top)
        self.warn_style = Tix.DisplayStyle(Tix.TEXT, fg="burlywood4",
                                           selectforeground="burlywood4",
                                           selectbackground="beige",
                                           refwindow=top)
        
        self.logeventsv = Tix.IntVar()
        self.logeventsv.set(init_logevents)
        self.logevents = init_logevents
        self.fulleventsv = Tix.IntVar()
        self.fulleventsv.set(init_fullevents)
        OpenIPMI.cmdlang_set_evinfo(self.fulleventsv.get())
        
        fileb = Tix.Menubutton(self, text="File", underline=0, takefocus=0)
        filemenu = Tix.Menu(fileb, tearoff=0)
        fileb["menu"] = filemenu
        filemenu.add_command(label="Exit", underline=1, accelerator="Ctrl+Q",
                             command = lambda self=self: self.quit() )
        top.bind_all("<Control-Q>", self.quit)
        top.bind_all("<Control-q>", self.quit)
        filemenu.add_command(label="Open Domain", underline=1,
                             accelerator="Ctrl+O",
                             command = lambda self=self: self.openDomain() )
        top.bind_all("<Control-O>", self.openDomain)
        top.bind_all("<Control-o>", self.openDomain)
        filemenu.add_command(label="Save Prefs", underline=1,
                             accelerator="Ctrl+S",
                             command = lambda self=self: self.savePrefs() )
        top.bind_all("<Control-S>", self.savePrefs)
        top.bind_all("<Control-s>", self.savePrefs)

        viewb = Tix.Menubutton(self, text="View", underline=0, takefocus=0)
        viewmenu = Tix.Menu(viewb, tearoff=0)
        viewb["menu"] = viewmenu
        viewmenu.add_command(label="Expand All", underline=1,
                             accelerator="Ctrl+E",
                             command = lambda self=self: self.ExpandAll() )
        top.bind_all("<Control-E>", self.ExpandAll)
        top.bind_all("<Control-e>", self.ExpandAll)
        viewmenu.add_command(label="Collapse All", underline=1,
                             accelerator="Ctrl+C",
                             command = lambda self=self: self.CollapseAll() )
        top.bind_all("<Control-C>", self.CollapseAll)
        top.bind_all("<Control-c>", self.CollapseAll)

        setb = Tix.Menubutton(self, text="Settings", underline=0, takefocus=0)
        viewmenu = Tix.Menu(setb, tearoff=0)
        setb["menu"] = viewmenu
        viewmenu.add_checkbutton(label="Enable Events", underline=0,
                                 command=lambda w=self: w.EnableEvents(),
                                 variable=self.logeventsv)
        viewmenu.add_checkbutton(label="Full Event Info", underline=0,
                                 command=lambda w=self: w.FullEventInfo(),
                                 variable=self.fulleventsv)

        vpane = Tix.PanedWindow(self, orientation="vertical",
                                width=init_windowwidth,
                                height=init_windowheight)
        self.vpane = vpane
        objevpane = vpane.add("objectsevents", size=init_sashposition)
        imptobjpane = vpane.add("importantobjects",
                                size = init_isashposition - init_sashposition)
        cmdpane = vpane.add("command")
        hpane = Tix.PanedWindow(objevpane, orientation="horizontal")
        self.hpane = hpane
        objpane = hpane.add("objects", size=init_bsashposition)
        evpane = hpane.add("events")

        self.tree = Tix.Tree(objpane, options="hlist.columns 2")
        # FIXME: This doesn't work, and I don't know why
        self.tree.hlist.configure(selectbackground="beige")
        self.tree.hlist.add("D", itemtype=Tix.TEXT, text="Domains")
        self.tree.setmode("D", "none")
        self.treedata = { }
        self.treedata["D"] = IPMITreeDummyItem("D")
        self.setup_item("D", active=True)
        self.tree.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.tree.hlist.bind("<Button-3>", self.TreeMenu)
        
        self.tree.hlist.bind("<MouseWheel>", self.Wheel)
        if (winsys == "x11"):
            self.tree.hlist.bind("<Button-4>", self.ButtonUp)
            self.tree.hlist.bind("<Button-5>", self.ButtonDown)
            pass

        self.numloglines = 1
        self.maxloglines = 1000
        self.logwindow = Tix.ScrolledText(evpane)
        self.logwindow.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.logwindow.text.insert("end", "GUI Log Window")

        self.imptobjs = gui_list.SubList(imptobjpane,
                                         ( ("Type", 50),
                                           ("Name", 200),
                                           ("Data", 200) ),
                                         options=("hlist.header 1"
                                                  + " hlist.itemtype text"
                                                  + " hlist.columns 3"
                                                  + " hlist.selectForeground black"
                                                  + " hlist.selectBackground beige"),
                                         width=0, height=0)
        self.imptobjs.pack(fill=Tix.BOTH, expand=1)
        
        self.errstr = gui_errstr.ErrStr(cmdpane)
        self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        self.cmdwindow = gui_cmdwin.CommandWindow(cmdpane, self)
        self.cmdwindow.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        hpane.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        vpane.pack(side=Tix.BOTTOM, fill=Tix.BOTH, expand=1)
        fileb.pack(side=Tix.LEFT)
        viewb.pack(side=Tix.LEFT)
        setb.pack(side=Tix.LEFT)
        
        self.itemval = 0

        self.in_destroy = False

        self.bind("<Destroy>", self.OnDestroy)

        self.impt_objs = { }
        self.impt_objs["control"] = { }
        self.impt_objs["sensor"] = { }
        self.impt_objs["entity"] = { }
        
        self.last_scan = None
        self.timer_timeout_ms = 200
        top.after(self.timer_timeout_ms, self.Timeout)

        for i in init_impt_objs:
            self.add_impt_data(i[0], i[1])
            pass
        return
Ejemplo n.º 11
0
    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
Ejemplo n.º 12
0
    def __init__(self, ui, domain_id, cnum):
        Tix.Toplevel.__init__(self)
        self.ui = ui
        self.cnum = cnum;
        self.sol = None
        domain_id.to_domain(self)
        if (self.sol == None):
            return
        self.nack_count = 0
        self.take_input = True
        self.in_destroy = False
        self.title("SoL for " + self.dname + " connection "
                   + str(self.cnum))

        mbar = Tix.Frame(self)
        fileb = Tix.Menubutton(mbar, text="File", underline=0, takefocus=0)
        filemenu = Tix.Menu(fileb, tearoff=0)
        self.filemenu = filemenu
        fileb["menu"] = filemenu
        filemenu.add_command(label="Open", command=self.open)
        filemenu.add_command(label="Close", command=self.close,
                             state="disabled")
        filemenu.add_command(label="Force Close", command=self.forceclose,
                             state="disabled")
        filemenu.add_command(label="Quit", command=self.quit)
        
        ctrlb = Tix.Menubutton(mbar, text="Controls", underline=0, takefocus=0)
        ctrlmenu = Tix.Menu(ctrlb, tearoff=0)
        self.ctrlmenu = ctrlmenu
        ctrlb["menu"] = ctrlmenu

        self.acceptinput = Tix.BooleanVar()
        self.acceptinput.set(True)
        ctrlmenu.add_checkbutton(label="Accept Input",
                                 variable=self.acceptinput,
                                 command=self.AcceptInputToggle)

        self.useenc = Tix.BooleanVar()
        self.useenc.set(self.sol.get_use_encryption())
        ctrlmenu.add_checkbutton(label="Use Encryption",
                                 variable=self.useenc,
                                 command=self.UseEncToggle)

        self.useauth = Tix.BooleanVar()
        self.useauth.set(self.sol.get_use_authentication())
        ctrlmenu.add_checkbutton(label="Use Authentication",
                                 variable=self.useauth,
                                 command=self.UseAuthToggle)

        self.deassert_on_connect = Tix.BooleanVar()
        self.deassert_on_connect.set(
            self.sol.get_deassert_CTS_DCD_DSR_on_connect())
        ctrlmenu.add_checkbutton(label="Deassert CTS/DCD/DSR on connect",
                                 variable=self.deassert_on_connect,
                                 command=self.DeassertOnConnectToggle)

        self.ctsassertable = Tix.BooleanVar()
        self.ctsassertable.set(True)
        ctrlmenu.add_checkbutton(label="CTS Assertable",
                                 variable=self.ctsassertable,
                                 command=self.CTSAssertableToggle,
                                 state="disabled")
        
        self.dcd_dsr = Tix.BooleanVar()
        self.dcd_dsr.set(True)
        ctrlmenu.add_checkbutton(label="DCD/DSR Asserted",
                                 variable=self.dcd_dsr,
                                 command=self.DCDDSRToggle,
                                 state="disabled")
        
        self.ri = Tix.BooleanVar()
        self.ri.set(False)
        ctrlmenu.add_checkbutton(label="RI Asserted",
                                 variable=self.ri,
                                 command=self.RIToggle,
                                 state="disabled")
        
        ctrlmenu.add_command(label="Set Ack Timeout",
                             command=self.SetAckTimeout)
        ctrlmenu.add_command(label="Set Ack Retries",
                             command=self.SetAckRetries)
        ctrlmenu.add_command(label="Send Break",
                             command=self.SendBreak, state="disabled")

        sermenu = Tix.Menu(ctrlmenu, tearoff=0)
        ctrlmenu.add_cascade(label="Serial Rate", menu=sermenu)
        self.servar = Tix.StringVar()
        self.servar.set("default")
        sermenu.add_radiobutton(label="Default", value="default",
                                variable=self.servar, command=self.SetRate)
        sermenu.add_radiobutton(label="9600", value="9600",
                                variable=self.servar, command=self.SetRate)
        sermenu.add_radiobutton(label="19200", value="19200",
                                variable=self.servar, command=self.SetRate)
        sermenu.add_radiobutton(label="38400", value="38400",
                                variable=self.servar, command=self.SetRate)
        sermenu.add_radiobutton(label="57600", value="57600",
                                variable=self.servar, command=self.SetRate)
        sermenu.add_radiobutton(label="115200", value="115200",
                                variable=self.servar, command=self.SetRate)

        serbehavemenu = Tix.Menu(ctrlmenu, tearoff=0)
        ctrlmenu.add_cascade(label="Serial Alert Behavior", menu=serbehavemenu)
        self.serbehave = Tix.StringVar()
        self.serbehave.set("fail")
        serbehavemenu.add_radiobutton(label="Serial Alerts Fail", value="fail",
                                      variable=self.serbehave,
                                      command=self.SetSerialAlerts)
        serbehavemenu.add_radiobutton(label="Serial Alerts Deferred",
                                      value="defer",
                                      variable=self.serbehave,
                                      command=self.SetSerialAlerts)
        serbehavemenu.add_radiobutton(label="Serial Alerts Succeed",
                                      value="succeed",
                                      variable=self.serbehave,
                                      command=self.SetSerialAlerts)

        flushmenu = Tix.Menu(ctrlmenu, tearoff=0)
        self.flushmenu = flushmenu
        ctrlmenu.add_cascade(label="Queue Flush", menu=flushmenu)
        fmenus = [ ]
        flushmenu.add_command(label="Flush BMC Transmit Queue",
                              command=self.FlushBMCXmit,
                              state="disabled")
        fmenus.append("Flush BMC Transmit Queue")
        flushmenu.add_command(label="Flush BMC Receive Queue",
                              command=self.FlushBMCRecv,
                              state="disabled")
        fmenus.append("Flush BMC Receive Queue")
        flushmenu.add_command(label="Flush My Transmit Queue",
                              command=self.FlushMyXmit,
                              state="disabled")
        fmenus.append("Flush My Transmit Queue")
        flushmenu.add_command(label="Flush My Receive Queue",
                              command=self.FlushMyRecv,
                              state="disabled")
        fmenus.append("Flush My Receive Queue")
        flushmenu.add_command(label="Flush BMC Queues",
                              command=self.FlushBMC,
                              state="disabled")
        fmenus.append("Flush BMC Queues")
        flushmenu.add_command(label="Flush My Queues",
                              command=self.FlushMe,
                              state="disabled")
        fmenus.append("Flush My Queues")
        flushmenu.add_command(label="Flush All Queues",
                              command=self.FlushAll,
                              state="disabled")
        fmenus.append("Flush All Queues")
        self.fmenus = fmenus

        mbar.pack(side=Tix.TOP, fill=Tix.X, expand=1)
        fileb.pack(side=Tix.LEFT)
        ctrlb.pack(side=Tix.LEFT)

        self.term = SolTerm(self, self)
        f = Tix.Frame(self)
        f.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)
        self.errstr = gui_errstr.ErrStr(f)
        self.errstr.pack(side=Tix.LEFT, fill=Tix.X, expand=1)
        self.statestr = gui_errstr.ErrStr(f)
        self.statestr.pack(side=Tix.LEFT, fill=Tix.X, expand=1)

        self.statestr.SetError(OpenIPMI.sol_state_string(
            OpenIPMI.sol_state_closed))
        self.state = OpenIPMI.sol_state_closed

        self.bind("<Destroy>", self.OnDestroy)
        return
Ejemplo n.º 13
0
    def _makemenu(self):
        """ make the menu """
        self.menubar = Tix.Menu(self)

        # Wraith Menu
        # all options will always be enabled
        self.mnuWraith = Tix.Menu(self.menubar, tearoff=0)
        self.mnuWraithGui = Tix.Menu(self.mnuWraith, tearoff=0)
        self.mnuWraithGui.add_command(label='Save', command=self.guisave)
        self.mnuWraithGui.add_command(label='Load', command=self.guiload)
        self.mnuWraith.add_cascade(label='Gui', menu=self.mnuWraithGui)
        self.mnuWraith.add_separator()
        self.mnuWraith.add_command(label='Configure',
                                   command=self.configwraith)
        self.mnuWraith.add_separator()
        self.mnuWraith.add_command(label='Exit', command=self.delete)

        # Tools Menu
        # all options will always be enabled
        self.mnuTools = Tix.Menu(self.menubar, tearoff=0)
        self.mnuTools.add_command(label='Convert', command=self.viewconvert)
        self.mnuToolsCalcs = Tix.Menu(self.mnuTools, tearoff=0)
        self.mnuToolsCalcs.add_command(label='EIRP',
                                       command=lambda: self.calc('EIRP'))
        self.mnuToolsCalcs.add_command(label='FSPL',
                                       command=lambda: self.calc('FSPL'))
        self.mnuToolsCalcs.add_command(
            label='Link Budget', command=lambda: self.calc('Link Budget'))
        self.mnuTools.add_cascade(label='Calcuators', menu=self.mnuToolsCalcs)

        # View Menu
        # all options will always be enabled
        self.mnuView = Tix.Menu(self.menubar, tearoff=0)
        self.mnuView.add_command(label='Data Bins', command=self.viewdatabins)
        self.mnuView.add_separator()
        self.mnuView.add_command(label='Data', command=self.viewdata)

        # Storage Menu
        self.mnuStorage = Tix.Menu(self.menubar, tearoff=0)
        self.mnuStorage.add_command(label="Start All",
                                    command=self.storagestart)  # 0
        self.mnuStorage.add_command(label="Stop All",
                                    command=self.storagestop)  # 1
        self.mnuStorage.add_separator()  # 2
        self.mnuStoragePSQL = Tix.Menu(self.mnuStorage, tearoff=0)
        self.mnuStoragePSQL.add_command(label='Start',
                                        command=self.psqlstart)  # 0
        self.mnuStoragePSQL.add_command(label='Stop',
                                        command=self.psqlstop)  # 1
        self.mnuStoragePSQL.add_separator()  # 2
        self.mnuStoragePSQL.add_command(label='Connect',
                                        command=self.connect)  # 3
        self.mnuStoragePSQL.add_command(label='Disconnect',
                                        command=self.disconnect)  # 4      # 1
        self.mnuStoragePSQL.add_separator()  # 5
        self.mnuStoragePSQL.add_command(label='Fix', command=self.psqlfix)  # 6
        self.mnuStoragePSQL.add_command(label='Delete All',
                                        command=self.psqldelall)  # 7
        self.mnuStorage.add_cascade(label='PostgreSQL',
                                    menu=self.mnuStoragePSQL)  # 3
        self.mnuStorageNidus = Tix.Menu(self.mnuStorage, tearoff=0)
        self.mnuStorageNidus.add_command(label='Start',
                                         command=self.nidusstart)  # 0
        self.mnuStorageNidus.add_command(label='Stop',
                                         command=self.nidusstop)  # 1
        self.mnuStorageNidus.add_separator()  # 2
        self.mnuNidusLog = Tix.Menu(self.mnuStorageNidus, tearoff=0)
        self.mnuNidusLog.add_command(label='View',
                                     command=self.viewniduslog)  # 0
        self.mnuNidusLog.add_command(label='Clear',
                                     command=self.clearniduslog)  # 1
        self.mnuStorageNidus.add_cascade(label='Log',
                                         menu=self.mnuNidusLog)  # 3
        self.mnuStorageNidus.add_separator()  # 4
        self.mnuStorageNidus.add_command(label='Config',
                                         command=self.confignidus)  # 5
        self.mnuStorage.add_cascade(label='Nidus',
                                    menu=self.mnuStorageNidus)  # 4

        # DySKT Menu
        self.mnuDySKT = Tix.Menu(self.menubar, tearoff=0)
        self.mnuDySKT.add_command(label='Start', command=self.dysktstart)  # 0
        self.mnuDySKT.add_command(label='Stop', command=self.dysktstop)  # 1
        self.mnuDySKT.add_separator()  # 2
        self.mnuDySKT.add_command(label='Control',
                                  command=self.dysktctrl)  # 3            # 3
        self.mnuDySKT.add_separator()  # 4
        self.mnuDySKTLog = Tix.Menu(self.mnuDySKT, tearoff=0)
        self.mnuDySKTLog.add_command(label='View',
                                     command=self.viewdysktlog)  # 0
        self.mnuDySKTLog.add_command(label='Clear',
                                     command=self.cleardysktlog)  # 1
        self.mnuDySKT.add_cascade(label='Log', menu=self.mnuDySKTLog)  # 5
        self.mnuDySKT.add_separator()  # 6
        self.mnuDySKT.add_command(label='Config',
                                  command=self.configdyskt)  # 7

        # Help Menu
        self.mnuHelp = Tix.Menu(self.menubar, tearoff=0)
        self.mnuHelp.add_command(label='About', command=self.about)
        self.mnuHelp.add_command(label='Help', command=self.help)

        # add the menus
        self.menubar.add_cascade(label='Wraith', menu=self.mnuWraith)
        self.menubar.add_cascade(label="Tools", menu=self.mnuTools)
        self.menubar.add_cascade(label='View', menu=self.mnuView)
        self.menubar.add_cascade(label='Storage', menu=self.mnuStorage)
        self.menubar.add_cascade(label='DySKT', menu=self.mnuDySKT)
        self.menubar.add_cascade(label='Help', menu=self.mnuHelp)
Ejemplo n.º 14
0
def configureGUI():
    global packetHistory, maxSizeControl, toSendEntry, baudRateOptionMenu, timeoutControl, receiveOptionMenu
    global transmitOptionMenu, maxSizeControl, packetHeaderEntry, portStringOptionMenu, transmitButton

    root.title(
        '::: MIT Media Lab ::: Responsive Environments Group ::: Serial Terminal :::'
    )

    # -- window setup
    mainFrame = Tix.Frame(root, width=WIDTH, height=HEIGHT)
    mainFrame.bind(sequence='<Destroy>', func=windowDestroyed)
    mainFrame.pack(fill=Tix.BOTH)

    # -- packet history display setup
    packetHistory = Tix.Text(mainFrame, height=WINDOW_HEIGHT)
    packetHistory.config(state=Tix.DISABLED, font='courier')

    # -- transmit packet entry setup
    transmitFrame = Tix.Frame(mainFrame)
    transmitButton = Tix.Button(master=transmitFrame,
                                text="Transmit packet: ",
                                command=sendUserPacket,
                                state=Tix.DISABLED)
    toSendEntry = Tix.Entry(master=transmitFrame,
                            textvariable=transmitPacketString)
    transmitButton.pack(side=Tix.TOP, fill=Tix.X)
    toSendEntry.pack(side=Tix.TOP, fill=Tix.X)

    # -- conrols setup
    controlsFrame = Tix.Frame(mainFrame)

    # -- serial port controls setup
    serialPortControlsLabelFrame = Tix.LabelFrame(controlsFrame,
                                                  label="Serial Port Settings")
    serialPortControlsFrame = serialPortControlsLabelFrame.frame
    openOrCloseButton = Tix.Button(master=serialPortControlsFrame,
                                   text="Open",
                                   command=openOrCloseConnection,
                                   width=5,
                                   textvariable=openOrCloseString)
    openOrCloseButton.pack(fill=Tix.X, side=Tix.TOP)
    portStringOptionMenu = Tix.OptionMenu(
        master=serialPortControlsFrame,
        label="Serial port: ",
        variable=portString,
        options=
        'label.width 25 label.anchor e menubutton.width 15 menubutton.anchor w'
    )
    for p in range(4):
        portStringOptionMenu.add_command(candidates[p], label=candidates[p])
    portStringOptionMenu.pack(fill=Tix.X, side=Tix.TOP)
    baudRateOptionMenu = Tix.OptionMenu(
        master=serialPortControlsFrame,
        label="Baud rate: ",
        variable=baudRateString,
        options=
        'label.width 25 label.anchor e menubutton.width 15 menubutton.anchor w'
    )
    ## TODO : The enumeration of baud rates should come from the 'serial' module.
    for r in [300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]:
        baudRateOptionMenu.add_command(r, label=r)
    baudRateOptionMenu.pack(fill=Tix.X, side=Tix.TOP)
    timeoutControl = Tix.Control(serialPortControlsFrame,
                                 label="Packet timeout (seconds): ",
                                 variable=packetTimeout,
                                 min=0,
                                 inc=lambda x: float(x) + 0.001,
                                 dec=lambda x: float(x) - 0.001)
    timeoutControl.label.config(width=25, anchor='e')
    timeoutControl.pack(fill=Tix.X, side=Tix.TOP)
    serialPortControlsLabelFrame.pack(side=Tix.LEFT)

    # -- packet controls setup
    packetControlsLabelFrame = Tix.LabelFrame(controlsFrame,
                                              label="Packet Settings")
    packetControlsFrame = packetControlsLabelFrame.frame
    receiveOptionMenu = Tix.OptionMenu(
        master=packetControlsFrame,
        label="Decode receptions as: ",
        variable=receiveMode,
        command=updateHeader,
        options=
        'label.width 25 label.anchor e menubutton.width 15 menubutton.anchor w'
    )
    for choice in receiveFilters.keys():
        receiveOptionMenu.add_command(choice, label=choice)
    receiveOptionMenu.pack(fill=Tix.X, side=Tix.TOP)
    transmitOptionMenu = Tix.OptionMenu(
        master=packetControlsFrame,
        label="Encode transmissions as: ",
        variable=transmitMode,
        options=
        'label.width 25 label.anchor e menubutton.width 15 menubutton.anchor w'
    )
    for choice in transmitFilters.keys():
        transmitOptionMenu.add_command(choice, label=choice)
    transmitOptionMenu.pack(fill=Tix.X, side=Tix.TOP)
    packetHeaderEntry = Tix.LabelEntry(
        packetControlsFrame,
        label="Look for packet header: ",
        options='label.width 25 label.anchor e entry.width 15 entry.anchor w')
    packetHeaderEntry.entry.config(textvariable=packetHeaderString)
    packetHeaderEntry.pack(fill=Tix.X, side=Tix.TOP)
    maxSizeControl = Tix.Control(packetControlsFrame,
                                 label="Max packet size (bytes): ",
                                 variable=maxPacketSize,
                                 min=1)
    maxSizeControl.label.config(width=25, anchor='e')
    maxSizeControl.pack(fill=Tix.X, side=Tix.TOP)
    packetControlsLabelFrame.pack(side=Tix.RIGHT)

    # -- pack the window up
    packetHistory.pack(fill=Tix.BOTH, side=Tix.TOP)
    transmitFrame.pack(fill=Tix.X, side=Tix.TOP)
    controlsFrame.pack(side=Tix.BOTTOM, fill=Tix.X)

    # -- menu bar setup
    mainMenu = Tix.Menu(root)

    # -- file menu
    fileMenu = Tix.Menu(mainMenu, tearoff=0)
    fileMenu.add_separator()
    fileMenu.add_command(label="Quit", command=quit)
    mainMenu.add_cascade(label="File", menu=fileMenu)

    # -- info menu
    infoMenu = Tix.Menu(mainMenu, tearoff=0)
    infoMenu.add_command(label="About...")
    mainMenu.add_cascade(label="Help", menu=infoMenu)

    # -- add menu to frame
    root.config(menu=mainMenu)

    # -- set global variable defaults
    receiveMode.set(oldReceiveMode)
    transmitMode.set(oldTransmitMode)
    maxPacketSize.set(38)
    packetTimeout.set(0.001)
    portString.set(candidates[0])
    baudRateString.set(115200)
    openOrCloseString.set('Open')
Ejemplo n.º 15
0
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
Ejemplo n.º 16
0
# Tix Demostration Program