コード例 #1
0
    def __init__(self, mainhandler):
        Tix.Toplevel.__init__(self)
        self.title("Domain Creation Dialog")

        self.mainhandler = mainhandler

        self.name = Tix.LabelEntry(self, label="Domain name")
        self.name.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        bbox = Tix.ButtonBox(self)
        bbox.add("cancel", text="Cancel", command=lambda w=self: w.cancel())
        bbox.add("ok", text="Ok", command=lambda w=self: w.ok())
        bbox.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

        self.status = gui_errstr.ErrStr(self)
        self.status.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

        self.conn = [
            ConnInfo(self, mainhandler),
            ConnInfo(self, mainhandler, False)
        ]
        self.conn[0].pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.conn[1].pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.name.entry.focus()

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

        return
コード例 #2
0
    def __init__(self, name, root, columns):
        Tix.Toplevel.__init__(self)
        self.title(name)

        self.numcolumns = len(columns)

        stree = Tix.Tree(self,
                         options=("hlist.columns " + str(self.numcolumns) +
                                  " hlist.itemtype text" + " hlist.header 1" +
                                  " hlist.selectForeground black" +
                                  " hlist.selectBackground beige"),
                         width=500,
                         height=500)
        self.stree = stree
        tree = stree.hlist
        i = 0
        for c in columns:
            tree.header_create(i, text=c[0])
            tree.column_width(i, c[1])
            i += 1
            pass
        stree.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        self.errstr = gui_errstr.ErrStr(self)
        self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        bbox = Tix.ButtonBox(self)
        if hasattr(self, "ok"):
            bbox.add("ok", text="Ok", command=self.ok)
            pass
        if hasattr(self, "save"):
            bbox.add("save", text="Save", command=self.save)
            pass
        if hasattr(self, "cancel"):
            bbox.add("cancel", text="Cancel", command=self.cancel)
            pass
        if hasattr(self, "refresh"):
            bbox.add("refresh", text="Refresh", command=self.refresh)
            pass
        if hasattr(self, "clear"):
            bbox.add("clear", text="Clear", command=self.clear)
            pass
        bbox.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        tree.bind("<Button-3>", self.TreeMenu)

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

        self.bind("<MouseWheel>", self.Wheel)
        if (gui_winsys.winsys == "x11"):
            self.bind("<Button-4>", self.ButtonUp)
            self.bind("<Button-5>", self.ButtonDown)
            pass

        self.treeroot = ""
        self.tree = tree
        self.treehash = {}
        self.currkey = 0
        return
コード例 #3
0
    def __init__(self, name, columns):
        Tix.Toplevel.__init__(self)
        self.title(name)

        slist = SubList(self,
                        columns,
                        options=("hlist.header 1" + " hlist.itemtype text" +
                                 (" hlist.columns " + str(len(columns))) +
                                 " hlist.selectForeground black" +
                                 " hlist.selectBackground beige"),
                        width=600,
                        height=500)
        slist.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.slist = slist

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

        bbox = Tix.ButtonBox(self)
        if hasattr(self, "ok"):
            bbox.add("ok", text="Ok", command=self.ok)
            pass
        if hasattr(self, "save"):
            bbox.add("save", text="Save", command=self.save)
            pass
        if hasattr(self, "cancel"):
            bbox.add("cancel", text="Cancel", command=self.cancel)
            pass
        if hasattr(self, "clear"):
            bbox.add("clear", text="Clear", command=self.clear)
            pass
        bbox.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

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

        return
コード例 #4
0
    def __init__(self, contype, parent):
        Tix.Frame.__init__(self, parent)
        self.contype = contype
        self.fields = []

        args = OpenIPMI.alloc_empty_args(str(contype))
        self.args = args

        self.errstr = gui_errstr.ErrStr(self)
        self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        i = 0
        rv = 0
        frame = None
        while (rv == 0):
            name = [""]
            vtype = [""]
            vrange = [""]
            vhelp = [""]
            value = [""]
            rv = args.get_val(i, name, vtype, vhelp, value, vrange)
            if (rv == 0):
                if (vhelp[0][0] == '*'):
                    optional = False
                    vhelp[0] = vhelp[0][1:]
                else:
                    optional = True
                    pass
                if (vhelp[0][0] == '!'):
                    password = True
                    vhelp[0] = vhelp[0][1:]
                else:
                    password = False
                    pass

                if (vtype[0] == "bool"):
                    if (frame == None):
                        didframe = True
                        frame = Tix.Frame(self)
                        frame.pack(side=Tix.TOP)
                        newframe = frame
                        pass
                    else:
                        newframe = None
                        pass
                    fw = Tix.BooleanVar()
                    w = Tix.Checkbutton(frame, text=name[0], variable=fw)
                    w.pack(side=Tix.LEFT, padx=10)
                    if ((value[0] != None) and (value[0] == "true")):
                        fw.set(True)
                        pass
                    pass
                elif (vtype[0] == "enum"):
                    do_box = False
                    fw = EnumHolder()
                    if (value[0] != None):
                        fw.set(value[0])
                        pass
                    else:
                        fw.set(vrange[0])
                        pass
                    w = Tix.Select(self,
                                   label=name[0],
                                   allowzero=0,
                                   radio=1,
                                   command=fw.SelectType)
                    for v in vrange:
                        w.add(v, text=v)
                        pass
                    newframe = None
                    w.invoke(fw.get())
                    w.pack()
                    pass
                elif (vtype[0] == "str") or (vtype[0] == "int"):
                    if (frame == None):
                        didframe = True
                        frame = Tix.Frame(self)
                        frame.pack(side=Tix.TOP)
                        newframe = frame
                        pass
                    else:
                        newframe = None
                        pass

                    if (value[0] == None):
                        value[0] = ""
                        pass
                    if (password):
                        options = "entry.show '*' entry.width 20"
                    else:
                        options = "entry.width 20"
                        pass
                    w = Tix.LabelEntry(frame, label=name[0], options=options)
                    w.entry.insert(Tix.END, value[0])
                    w.pack(side=Tix.LEFT, padx=10)
                    fw = w.entry
                    pass
                else:
                    i += 1
                    continue
                frame = newframe
                self.fields.append((i, name[0], vtype[0], fw))
                pass
            i += 1
            pass

        return
コード例 #5
0
    def __init__(self,
                 name,
                 default,
                 count,
                 handler,
                 labels=None,
                 longtext=False):
        self.handler = handler
        Tix.Toplevel.__init__(self)
        self.title(name)
        self.longtext = longtext

        sw = Tix.ScrolledWindow(self)
        self.values = sw.window
        if (labels == None):
            if (count == 1):
                label = Tix.Label(self.values, text="Value:")
            else:
                label = Tix.Label(self.values, text="Value(s):")
                pass
            label.grid(row=0, column=0, sticky="e")
            self.fields = []
            row = 0
            for i in range(0, count):
                if (isbool(default[i])):
                    field = Tix.BooleanVar()
                    field.set(default[i])
                    w = Tix.Checkbutton(self.values, variable=field)
                    pass
                elif longtext:
                    field = Tix.Text(self.values)
                    field.insert("1.0", str(default[i]))
                    w = field
                else:
                    field = Tix.Entry(self.values)
                    field.insert("0", str(default[i]))
                    w = field
                    pass
                w.grid(row=row, column=1, sticky="ew")
                row += 1
                self.fields.append(field)
                pass
            pass
        else:
            self.fields = []
            row = 0
            for i in range(0, count):
                label = Tix.Label(self.values, text=labels[i])
                label.grid(row=row, column=0)
                if (isbool(default[i])):
                    field = Tix.BooleanVar()
                    field.set(default[i])
                    w = Tix.Checkbutton(self.values, variable=field)
                    pass
                elif longtext:
                    field = Tix.Text(self.values)
                    field.insert("1.0", str(default[i]))
                    w = field
                else:
                    field = Tix.Entry(self.values)
                    field.insert("0", str(default[i]))
                    w = field
                    pass
                self.fields.append(field)
                w.grid(row=row, column=1, sticky="ew")
                row += 1
                pass
            pass

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

        self.errstr = gui_errstr.ErrStr(self)
        self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        bbox = Tix.ButtonBox(self)
        bbox.add("cancel", text="Cancel", command=lambda w=self: w.cancel())
        bbox.add("ok", text="Ok", command=lambda w=self: w.ok())
        bbox.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

        self.bind("<Destroy>", self.OnDestroy)
        return
コード例 #6
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
コード例 #7
0
ファイル: gui_SoL.py プロジェクト: xiar/openipmi
    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