def __init__(self, title, dataFetch, displayFormat, titleDisplay, anchor,
                 wrapLength, font, headerPadX, headerPadY, entryPadX,
                 entryPadY):
        self.title = title
        self._setFetch(dataFetch)
        self.displayFormat = displayFormat
        self.display = True
        self.anchor = anchor
        self.titleDisplay = titleDisplay
        if headerPadX == None:
            headerPadX = 0
        if headerPadY == None:
            headerPadY = 0
        if entryPadX == None:
            textPadX = ".05i"
            wellPadX = checkButtonPadX = 0
        else:
            textPadX = wellPadX = checkButtonPadX = entryPadX
        if entryPadY == None:
            textPadY = wellPadY = checkButtonPadY = 0
        else:
            textPadY = wellPadY = checkButtonPadY = entryPadY

        # find the family and size of the default fixed font
        import tkFont
        fontInfo = tkFont.Font(font=font).actual()
        family, size = fontInfo['family'], fontInfo['size']
        if isinstance(font, basestring):
            self.font = font
        else:
            self.font = (family, size)
        import Tix
        self.textStyle = Tix.DisplayStyle("text",
                                          anchor=anchor,
                                          font=(family, size),
                                          wraplength=wrapLength,
                                          padx=textPadX,
                                          pady=textPadY)
        self.highlightStyle = Tix.DisplayStyle("text",
                                               anchor=anchor,
                                               font=(family, size, "bold"),
                                               wraplength=wrapLength,
                                               padx=textPadX,
                                               pady=textPadY)
        self.checkButtonStyle = Tix.DisplayStyle("window",
                                                 anchor=anchor,
                                                 padx=checkButtonPadX,
                                                 pady=checkButtonPadY)
        self.colorWellStyle = Tix.DisplayStyle("window",
                                               anchor=anchor,
                                               padx=wellPadX,
                                               pady=wellPadY)
        self.headerStyle = Tix.DisplayStyle("window",
                                            anchor=anchor,
                                            padx=headerPadX,
                                            pady=headerPadY)
    def _buildTable(self):
        if hasattr(self, 'modelTable'):
            # can't dynamically add columns to Tix widget;
            # destroy and recreate
            selected = self.selected()
            self.modelTable.grid_forget()
            self.modelTable.destroy()
        else:
            selected = None

        self.modelTable = Tix.ScrolledHList(self.parent,
                                            width="%d" %
                                            self.parent.winfo_pixels("3i"),
                                            options="""hlist.columns %d
			hlist.header 1
			hlist.selectMode extended
			hlist.indicator 0""" % len(filter(lambda s: s == 1, self.shownColumns)))
        help.register(self.modelTable, balloon=self.modelTableHelp)
        self.modelTable.hlist.config(browsecmd=self._selChange,
                                     command=self._dblClick)
        self.textStyle = Tix.DisplayStyle("text", refwindow=self.modelTable)
        # get a style for checkbutton columns...
        self.checkButtonStyle = Tix.DisplayStyle("window",
                                                 refwindow=self.modelTable,
                                                 anchor="center")
        self.colorWellStyle = Tix.DisplayStyle("window",
                                               refwindow=self.modelTable,
                                               anchor="center")
        colNum = 0
        self.columnMap = []
        showFullTitles = False
        last = self._confDialog.prefs["lastUse"]
        from time import time
        now = self._confDialog.prefs["lastUse"] = time()
        if last is None or now - last > 777700:  # about 3 months
            showFullTitles = True
        for index in range(len(_columnNames)):
            if not self.shownColumns[index]:
                continue
            self.columnMap.append(index)
            text = _columnNames[index]
            if _valueTypes[index] == 'toggle' \
            and not showFullTitles:
                text = text[:1]
            self.modelTable.hlist.header_create(colNum,
                                                itemtype='text',
                                                text=text)
            colNum = colNum + 1

        self.parent.columnconfigure(10, weight=1)
        self.parent.rowconfigure(10, weight=1)
        self.modelTable.grid(row=10, column=10, sticky='nsew', rowspan=11)
        self._fillTable(selected=selected, fromScratch=1)
Esempio n. 3
0
    def _buildTable(self):
        if hasattr(self, 'groupsTable'):
            # can't dynamically add columns to Tix widget;
            # destroy and recreate
            selected = self.selected()
            self.groupsTable.grid_forget()
            self.groupsTable.destroy()
        else:
            selected = None

        self.groupsTable = Tix.ScrolledHList(self.parent,
                                             width="%d" %
                                             self.parent.winfo_pixels("3i"),
                                             options="""hlist.columns %d
			hlist.background #0000bfffffff
			hlist.header 1
			hlist.selectMode extended
			hlist.indicator 0""" % len(filter(lambda s: s == 1, self.shownColumns)))
        help.register(self.groupsTable, balloon=self.groupsTableHelp)
        self.groupsTable.hlist.config(browsecmd=self._selChange,
                                      command=self._dblClick)
        self.textStyle = Tix.DisplayStyle("text",
                                          background="#0000bfffffff",
                                          refwindow=self.groupsTable)
        # get a style for checkbutton columns...
        self.checkButtonStyle = Tix.DisplayStyle("window",
                                                 background="#0000bfffffff",
                                                 refwindow=self.groupsTable,
                                                 anchor="center")
        colNum = 0
        self.columnMap = []
        for index in range(len(_columnNames)):
            if not self.shownColumns[index]:
                continue
            self.columnMap.append(index)
            self.groupsTable.hlist.header_create(colNum,
                                                 itemtype='text',
                                                 text=_columnNames[index])
            colNum = colNum + 1

        self.parent.columnconfigure(10, weight=1)
        self.parent.rowconfigure(10, weight=1)
        self.groupsTable.grid(row=10, column=10, sticky='nsew')
        self._fillTable(selected=selected, fromScratch=1)
Esempio n. 4
0
 def __init__(self,toplevel,chief):
     ListPanel.__init__(self,toplevel,chief,"Log",(60,8),2,[],"widgets/icons/log.png")
     self._l = threading.Lock()                              # lock on writing
     self._n = 0                                             # current number of entries
     self._LC = [Tix.DisplayStyle(Tix.TEXT,                  # display styles
                                 refwindow=self.list,
                                 foreground='Green',
                                 selectforeground='Green'),
                Tix.DisplayStyle(Tix.TEXT,
                                 refwindow=self.list,
                                 foreground='Yellow',
                                 selectforeground='Yellow'),
                Tix.DisplayStyle(Tix.TEXT,
                                 refwindow=self.list,
                                 foreground='Red',
                                 selectforeground='Red'),
                Tix.DisplayStyle(Tix.TEXT,
                                 refwindow=self.list,
                                 foreground='Blue',
                                 selectforeground='Blue')]
     self._symbol = ["[+] ","[?] ","[-] ","[!] "]           # type symbols
Esempio n. 5
0
 def update_hlist(self):
     while True:
         try:
             mod = self._modq.get_nowait()
         except Queue.Empty:
             return
         self.mods.append(mod)
         # add mod to HList
         root, mod_fn, mpg_fn, md, mod_mtime, mod_size_bytes = mod
         mtime_str = "%s" % mod_mtime.strftime("%Y-%m-%d %H:%M:%S")
         mod_size_str = "%i MB" % (mod_size_bytes / 1000000)
         if md["video_format"] > 0:
             dar = "16:9"
         else:
             dar = "4:3"
         try:
             key = "%i" % (self.hl3_keys.index(root), )
         except ValueError:
             # add a new directory row
             key = "%i" % (len(self.hl3_keys), )
             self.hl3_keys.append(root)
             self.hl3.add(key, text=root)
             # LOG.debug("new root with (%s, %s)", key, root)
         # add child row
         child_key = self.hl3.add_child(key, text=mod_fn)
         # LOG.debug("child with (%s, %s)", child_key, mod_fn)
         size_style = Tix.DisplayStyle(Tix.TEXT,
                                       refwindow=self.hl3,
                                       anchor="e")
         dar_style = Tix.DisplayStyle(Tix.TEXT,
                                      refwindow=self.hl3,
                                      anchor="c")
         self.hl3.item_create(child_key, 1, text=mtime_str)
         self.hl3.item_create(child_key,
                              2,
                              text=mod_size_str,
                              style=size_style)
         self.hl3.item_create(child_key, 3, text=dar, style=dar_style)
Esempio n. 6
0
    def __init__(self,toplevel,chief,ttl,sz,cols=1,httl=None,iconPath=None):
        SlavePanel.__init__(self,toplevel,chief,iconPath)
        self.master.title(ttl)
        self.pack(expand=True,fill=Tix.BOTH,side=Tix.TOP)

        # create and allow derived classes to setup top frame
        frmTop = Tix.Frame(self)
        if self.topframe(frmTop): frmTop.pack(side=Tix.TOP,expand=False)

        # need hdr value for HList init
        hdr = True
        if not httl: hdr = False

        # setup the hlist
        self.frmMain = Tix.Frame(self)
        self.frmMain.pack(side=Tix.TOP,fill=Tix.BOTH,expand=True)

        # create the scrolled hlist
        # NOTE: if necessary, should be able to use Tree as below
        # self.slist = Tree(self.frmMain,options='hlist.columns %d hlist.header %d' % (cols,hdr))
        self.slist = Tix.ScrolledHList(self.frmMain,
                                       options='hlist.columns %d hlist.header %d' % (cols,hdr))

        # configure the hlist
        self.list = self.slist.hlist                       # get the hlist
        if sz: self.list.config(width=sz[0],height=sz[1])  # set the width/height
        self.list.config(selectforeground='black')         # set to black or it dissappears
        self.list.config(selectmode='extended')            # allow multiple selects
        self.list.config(separator='\t')                   # use tab ignoring special chars

        style = {}
        style['header'] = Tix.DisplayStyle(Tix.TEXT,
                                           refwindow=self.list,
                                           anchor=Tix.CENTER)
        for i in range(len(httl)):
            self.list.header_create(i,itemtype=Tix.TEXT,text=httl[i],
                                      style=style['header'])

        # and pack the scrolled list
        self.slist.pack(expand=True,fill=Tix.BOTH,side=Tix.LEFT)

        # allow a bottom frame
        frmBottom = Tix.Frame(self)
        if self.bottomframe(frmBottom):
            frmBottom.pack(side=Tix.TOP,expand=False)
Esempio n. 7
0
 def color_table(self, table, color):
     if table.tixTable is None:
         return
     for i, row in enumerate(table._sortedData()):
         row_color = color(row)
         if not row_color:
             continue
         for j, col in enumerate(table.columns):
             col_style = {
                 'anchor': getattr(col, 'anchor', None),
                 'wraplength': getattr(col, 'wrapLength', None),
                 'padx': col.textStyle['padx'],
                 'pady': col.textStyle['pady'],
                 'font': (col.fontFamily, col.fontSize)
             }
             style = Tix.DisplayStyle('text',
                                      foreground=row_color,
                                      **col_style)
             table.tixTable.subwidget_list['hlist'].item_configure(
                 i, j, style=style)
 def createUI(self, master):
     import Pmw
     w = Pmw.Group(master, tag_text="Settings")
     w.pack(side=Tkinter.TOP, expand=Tkinter.TRUE, fill=Tkinter.BOTH)
     g = ScrolledGrid(w.interior(), bd=0)
     g.pack(fill=Tkinter.BOTH, expand=Tkinter.TRUE)
     grid = g.tixGrid
     self.settingsGrid = grid
     grid.config(formatcmd=self.formatGrid)
     w = Pmw.Group(master, tag_text="Locations")
     w.pack(side=Tkinter.TOP, fill=Tkinter.BOTH)
     self.dirList = OrderedDirList(self, w.interior())
     self.dirList.pack(fill=Tkinter.BOTH)
     self.imageUnchecked = grid.tk.call("tix", "getimage", "ck_off")
     self.imageChecked = grid.tk.call("tix", "getimage", "ck_on")
     self.settingsStyle = Tix.DisplayStyle("window",
                                           refwindow=grid,
                                           anchor="center")
     self.remakeSettings()
     self.remakeLocations()
    def _switchHisList(self):
        self.hisChanged = True
        if not hasattr(self, 'hisListing'):
            if self.hisProtVar.get() != "pick":
                return
            self.hisListingData = {}
            import Tix, Tkinter
            self.hisFrame = Tkinter.Frame(self.hisGroup.interior())
            self.hisListing = Tix.ScrolledHList(self.hisFrame,
                                                width="3i",
                                                options="""hlist.columns 4
						hlist.header 1
						hlist.indicator 1""")
            self.hisListing.hlist.configure(
                selectbackground=self.hisListing['background'],
                selectborderwidth=0)
            self.hisListing.grid(row=0, column=0, columnspan=3, sticky="nsew")
            self.hisFrame.rowconfigure(1, weight=1)
            self.hisFrame.columnconfigure(0, weight=1)
            self.hisFrame.columnconfigure(1, weight=1)
            hlist = self.hisListing.hlist
            hlist.header_create(0, itemtype="text", text="Model")
            hlist.header_create(1, itemtype="text", text="Residue")
            hlist.header_create(2, itemtype="text", text="Delta")
            hlist.header_create(3, itemtype="text", text="Epsilon")
            self._checkButtonStyle = Tix.DisplayStyle(
                "window",
                background=hlist['background'],
                refwindow=self.hisListing,
                anchor='center')
            self._updateHisListing()

            Tkinter.Button(self.hisFrame,
                           text="All Delta",
                           pady=0,
                           highlightthickness=0,
                           command=lambda p="delta": self._select(p)).grid(
                               row=1, column=0)
            Tkinter.Button(self.hisFrame,
                           text="All Epsilon",
                           pady=0,
                           highlightthickness=0,
                           command=lambda p="epsilon": self._select(p)).grid(
                               row=1, column=1)
            Tkinter.Button(self.hisFrame,
                           text="All Both",
                           pady=0,
                           highlightthickness=0,
                           command=lambda p="both": self._select(p)).grid(
                               row=1, column=2)

        if self.hisProtVar.get() == "pick":
            self._pickText.set("Specified individually:")
            self.hisFrame.grid(row=4, sticky="nsew")
            interior = self.hisGroup.interior()
            interior.rowconfigure(4, weight=1)
            self.uiMaster().rowconfigure(6, weight=4)
        else:
            self._pickText.set("Specified individually...")
            self.hisFrame.grid_forget()
            interior = self.hisGroup.interior()
            interior.rowconfigure(4, weight=0)
            self.uiMaster().rowconfigure(6, weight=0)
Esempio n. 10
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        # We create the frame and the ScrolledHList widget
        # at the top of the dialog box
        #
        top = Tix.Frame(w, relief=Tix.RAISED, bd=1)

        # Put a simple hierachy into the HList (two levels). Use colors and
        # separator widgets (frames) to make the list look fancy
        #
        top.a = Tix.ScrolledHList(top,
                                  options='hlist.columns 3 hlist.header 1')
        top.a.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)

        hlist = top.a.hlist

        # Create the title for the HList widget
        #       >> Notice that we have set the hlist.header subwidget option to true
        #      so that the header is displayed
        #

        boldfont = hlist.tk.call('tix', 'option', 'get', 'bold_font')

        # First some styles for the headers
        style = {}
        style['header'] = Tix.DisplayStyle(Tix.TEXT,
                                           refwindow=hlist,
                                           anchor=Tix.CENTER,
                                           padx=8,
                                           pady=2,
                                           font=boldfont)

        hlist.header_create(0,
                            itemtype=Tix.TEXT,
                            text='Name',
                            style=style['header'])
        hlist.header_create(1,
                            itemtype=Tix.TEXT,
                            text='Position',
                            style=style['header'])

        # Notice that we use 3 columns in the hlist widget. This way when the user
        # expands the windows wide, the right side of the header doesn't look
        # chopped off. The following line ensures that the 3 column header is
        # not shown unless the hlist window is wider than its contents.
        #
        hlist.column_width(2, 0)

        # This is our little relational database
        #
        boss = ('doe', 'John Doe', 'Director')

        managers = [('jeff', 'Jeff Waxman', 'Manager'),
                    ('john', 'John Lee', 'Manager'),
                    ('peter', 'Peter Kenson', 'Manager')]

        employees = [('alex', 'john', 'Alex Kellman', 'Clerk'),
                     ('alan', 'john', 'Alan Adams', 'Clerk'),
                     ('andy', 'peter', 'Andreas Crawford', 'Salesman'),
                     ('doug', 'jeff', 'Douglas Bloom', 'Clerk'),
                     ('jon', 'peter', 'Jon Baraki', 'Salesman'),
                     ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'),
                     ('chuck', 'jeff', 'Chuck McLean', 'Cleaner')]

        style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)

        style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist)

        style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)

        style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT,
                                              padx=8,
                                              refwindow=hlist)

        # Let configure the appearance of the HList subwidget
        #
        hlist.config(separator='.', width=25, drawbranch=0, indent=10)
        hlist.column_width(0, chars=20)

        # Create the boss
        #
        hlist.add('.',
                  itemtype=Tix.TEXT,
                  text=boss[1],
                  style=style['mgr_name'])
        hlist.item_create('.',
                          1,
                          itemtype=Tix.TEXT,
                          text=boss[2],
                          style=style['mgr_posn'])

        # Create the managers
        #

        for key, name, posn in managers:
            e = '.' + key
            hlist.add(e, itemtype=Tix.TEXT, text=name, style=style['mgr_name'])
            hlist.item_create(e,
                              1,
                              itemtype=Tix.TEXT,
                              text=posn,
                              style=style['mgr_posn'])

        for key, mgr, name, posn in employees:
            # "." is the separator character we chose above

            entrypath = '.' + mgr + '.' + key

            #           ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^
            #       parent entryPath / child's name

            hlist.add(entrypath, text=name, style=style['empl_name'])
            hlist.item_create(entrypath,
                              1,
                              itemtype=Tix.TEXT,
                              text=posn,
                              style=style['empl_posn'])

        # Use a ButtonBox to hold the buttons.
        #
        box = Tix.ButtonBox(top, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6, command=self.okcmd)

        box.add('cancel',
                text='Cancel',
                underline=0,
                width=6,
                command=self.quitcmd)

        box.pack(side=Tix.BOTTOM, fill=Tix.X)
        top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Esempio n. 11
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
    def createPanelTwo(self):
        self.createTitle(1, "File Types")
        self.createExplanation(1, "Chimera currently supports the following file types.\n" \
                               "Click on the appropriate boxes to enable Chimera to open " \
                               "the corresponding file types from a web browser.")

        self.desc_txt = Tkinter.Text(self.pInterior(1),
                                     relief='flat',
                                     wrap='word',
                                     pady=15,
                                     height=1,
                                     width=50)
        self.desc_txt.pack(side='bottom', anchor='w', fill='x', padx=10)
        self.desc_txt.insert(0.0, "No type selected")
        self.desc_txt.configure(
            state="disabled", background=self.pInterior(1).cget('background'))

        desc_lbl = Tkinter.Label(self.pInterior(1),
                                 text="Description:",
                                 font=("arial", 10, 'bold'),
                                 relief="flat")
        desc_lbl.pack(side='bottom', anchor='w', padx=10)

        ### added - dmg - 2/2/04 ###
        displayStyle = {}

        self.scrTypeList = Tix.ScrolledHList(self.pInterior(1),
                                             options = \
                                             """
                                             hlist.width 65
                                             hlist.columns 4
                                             hlist.header 1
                                             hlist.selectMode single
                                             """
                                             )

        displayStyle['string'] = Tix.DisplayStyle(
            'text',
            refwindow=self.scrTypeList,
            selectforeground='black',
            activebackground='red',
            #state='disabled',
            background=self.pInterior(1).cget("background"),
            anchor='w')

        displayStyle['checkbutton'] = Tix.DisplayStyle(
            "window",
            refwindow=self.scrTypeList,
            background=self.pInterior(1).cget("background"),
        )

        self.scrTypeList.pack(side='bottom',
                              anchor='n',
                              fill='x',
                              expand=True,
                              pady=15,
                              padx=10)
        self.tList = self.scrTypeList.hlist
        self.tList.config(browsecmd=self.updateTypeDesc)
        self.tList.configure(background=self.pInterior(1).cget("background"))

        columnTitles = ["", "Type", "Extensions", "Current handler"]
        columnTypes = ['checkbutton', 'string', 'string', 'string']

        for i in range(len(columnTitles)):
            c = ColumnHeader(self.tList, columnTitles[i])
            self.tList.header_create(i, itemtype='window', window=c)

        ### END added ###

        fi = fileInfo
        self.types = [t for t in fi.types() if fi.mimeType(t) != None]

        ## decided not to use this file type
        del self.types[self.types.index("Gaussian formatted checkpoint")]

        self.typeDescs = {}

        for t in self.types:
            try:
                self.typeDescs[t] = FileTypeDescs[t]
            except KeyError:
                self.typeDescs[t] = "No Description Available"

        self.handledBy = [None] * len(self.types)
        self.check_vars = []

        ### ADDED dmg - 2/2/2004 ###

        ## columns should be checkbutton, type, extensions, handler

        val_map = {}

        for t in self.types:

            idx = self.types.index(t)

            val_map[idx] = []

            check_var = Tkinter.IntVar(self.pInterior(1))
            check_var.set(0)
            self.check_vars.append(check_var)

            ## check button for this row
            ck = Tkinter.Checkbutton(self.tList, variable=check_var)
            val_map[idx].append(ck)

            ## type label for this row...
            type_lbl = t
            val_map[idx].append(type_lbl)

            ## extensions for this row
            ext_lbl = "[ %s ]" % (" , ".join(fi.extensions(t)))
            val_map[idx].append(ext_lbl)

            mime_types = fileInfo.mimeType(t)
            exts = fileInfo.extensions(t)
            cur_handler = self.ftm.getCurrentHandler(mime_types, exts)
            val_map[idx].append(cur_handler)

        for row in range(len(self.types)):
            self.tList.add(row)
            values = val_map[row]

            for col in range(len(values)):
                colType = columnTypes[col]
                if colType == 'string':
                    self.tList.item_create(row,
                                           col,
                                           text=values[col],
                                           style=displayStyle[colType])
                elif colType == 'checkbutton':
                    self.tList.item_create(row,
                                           col,
                                           itemtype='window',
                                           window=values[col],
                                           style=displayStyle[colType])
    def _hlistKw(self, model, colNum):
        vt = _valueTypes[self.columnMap[colNum]]
        vf = _valueFuncs[self.columnMap[colNum]]
        kw = {'itemtype': vt}
        txt = None
        img = None
        if vt == 'text':
            txt = vf(model)
            if not isinstance(txt, basestring):
                txt, bcolor = txt
                if bcolor is not None:
                    if not isinstance(bcolor, basestring):
                        if hasattr(bcolor, 'rgba'):
                            rgba = bcolor.rgba()
                        else:
                            rgba = bcolor
                        from CGLtk.color import rgba2tk
                        bcolor = rgba2tk(rgba)
                        fcolor = CGLtk.textForeground(bcolor, self.modelTable)
                    kw['style'] = Tix.DisplayStyle("text",
                                                   refwindow=self.modelTable,
                                                   background=bcolor,
                                                   foreground=fcolor,
                                                   selectforeground=bcolor)
            else:
                kw['style'] = self.textStyle
        elif vt == 'image':
            img = vf(model)
        elif vt == 'imagetext':
            img, txt = vf(model)
        elif vt == 'toggle':
            kw['itemtype'] = 'window'
            bool, cb = vf(model)
            togKw = {
                'command':
                # avoid holding references to model
                lambda cb=cb, i=self.models.index(model), b=not bool: cb(
                    self.models[i], b),
                'indicatoron':
                0,
                'borderwidth':
                0
            }
            if bool:
                togKw['image'] = self.modelTable.tk.call(
                    'tix', 'getimage', 'ck_on')
            else:
                togKw['image'] = self.modelTable.tk.call(
                    'tix', 'getimage', 'ck_off')
            toggle = Tkinter.Checkbutton(self.modelTable.hlist, **togKw)
            kw['window'] = toggle
            kw['style'] = self.checkButtonStyle
        elif vt == 'well':
            color, noneOkay, alphaOkay, cb = vf(model)
            if color is False:
                kw['itemtype'] = 'text'
                txt = ""
            else:
                kw['itemtype'] = 'window'
                if isinstance(color, chimera.MaterialColor):
                    color = color.rgba()

                def wellCB(clr, cb=cb, mdl=model):
                    if clr is not None:
                        clr = chimera.MaterialColor(*clr)
                    cb(mdl, clr)

                from CGLtk.color.ColorWell import ColorWell
                kw['window'] = ColorWell(self.modelTable.hlist,
                                         color,
                                         callback=wellCB,
                                         width=18,
                                         height=18,
                                         noneOkay=noneOkay,
                                         wantAlpha=alphaOkay)
                kw['style'] = self.colorWellStyle
        else:
            raise ValueError("Unknown column type: '%s'" % vt)

        if txt != None:
            kw['text'] = str(txt)
        if img != None:
            kw['image'] = self.modelTable.tk.call('tix', 'getimage', img)
        return kw
Esempio n. 14
0
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
	def fillInUI(self, parent):
		# the topmost text is done last since we make it's width the
		# same as the side-by-side radio selectors

		parent.columnconfigure(0, weight=1)
		parent.columnconfigure(1, weight=1)
		parent.rowconfigure(25, weight=1)

		# put in a horizontal bar for esthetics
		hr = Tkinter.Frame(parent, relief='raised', borderwidth=1,
								height=2)
		hr.grid(row=20, columnspan=2, pady=5, sticky='ew')

		self.unknownsLB = Tix.ScrolledHList(parent, options=
		"hlist.background #000099 hlist.columns 4 hlist.header 1")
		hlist = self.unknownsLB.hlist
		hlist.config(separator='|') # hopefully not found in res names
		hlist.config(browsecmd=self.selectAtomCB)
		hlist.header_create(0, itemtype=Tix.TEXT, text='Residue')
		hlist.header_create(1, itemtype=Tix.TEXT, text='Atom')
		hlist.header_create(2, itemtype=Tix.TEXT, text='#')
		hlist.header_create(3, itemtype=Tix.TEXT, text='Assigned')
		self.unknownsLB.grid(row=25, columnspan=2, sticky='ewns')

		boldfont = hlist.tk.call('tix','option','get','bold_font')
		self._regStyle = Tix.DisplayStyle(Tix.TEXT,
			refwindow=self.unknownsLB, fg='#ffff00',
			selectforeground='#7f7f00', bg='#000099', font=boldfont)
		self._okStyle = Tix.DisplayStyle(Tix.TEXT,
			refwindow=self.unknownsLB, fg='#00ff00',
			selectforeground='#00ff00', bg='#000099', font=boldfont)
		self._emphStyle = Tix.DisplayStyle(Tix.TEXT,
			refwindow=self.unknownsLB, bg='#000099',
		        fg='#ff0000', selectforeground='#ff0000',
			font=boldfont)

		self._geometriesList = Pmw.RadioSelect(parent,
		  buttontype='radiobutton', command=self.selectGeometryCB,
		  labelpos='n', orient='vertical', pady=0,
		  label_text="Substituent\nGeometry")
		self._geometriesList.add("unassigned")
		for geom in geometryName:
			self._geometriesList.add(geom)
		self._geometriesList.grid(row=30, column=0, sticky='n')

		self._substituentsList = Pmw.RadioSelect(parent,
		  buttontype='radiobutton', command=self.selectSubstituentsCB,
		  labelpos='n', orient='vertical', pady=0,
		  label_text="Number of\nSubstituents")
		for subs in range(5):\
			self._substituentsList.add(str(subs))
		self._substituentsList.grid(row=30, column=1, sticky='n')

		tkgui.app.update_idletasks() # so winfo calls work right
		self._intro = Tkinter.Label(parent, justify="left",
		  wraplength=self._geometriesList.winfo_reqwidth()
		  + self._substituentsList.winfo_reqwidth(),
		  font=tkFont.Font(weight="normal", size=10),
		  text="The geometries and expected number of substituents for some atoms in the current models are unknown.  These atoms are listed below.  For each, please indicate the expected geometry and number of substituents.  When done, click 'OK'.")
		self._intro.grid(row=10, columnspan=2, sticky="ew")

		self._noSelection()
		self.buttonWidgets['OK'].config(state="disabled")
Esempio n. 16
0
    def _switchHisList(self):
        if not hasattr(self, 'hisListing'):
            if self.hisProtVar.get() != "pick":
                return
            self.hisListingData = {}
            import Tix, Tkinter
            self.hisFrame = Tkinter.Frame(self.hisGroup.interior())
            Tkinter.Label(self.hisFrame,
                          text="If neither delta"
                          " nor epsilon is selected\nthen chosen method"
                          " determines protonation").grid(row=0,
                                                          column=0,
                                                          columnspan=2)
            self.hisListing = Tix.ScrolledHList(self.hisFrame,
                                                width="3i",
                                                options="""hlist.columns 4
						hlist.header 1
						hlist.indicator 1""")
            self.hisListing.hlist.configure(
                selectbackground=self.hisListing['background'],
                selectborderwidth=0)
            self.hisListing.grid(row=1, column=0, columnspan=2, sticky="nsew")
            self.hisFrame.rowconfigure(1, weight=1)
            self.hisFrame.columnconfigure(0, weight=1)
            self.hisFrame.columnconfigure(1, weight=1)
            hlist = self.hisListing.hlist
            hlist.header_create(0, itemtype="text", text="Model")
            hlist.header_create(1, itemtype="text", text="Residue")
            hlist.header_create(2, itemtype="text", text="Delta")
            hlist.header_create(3, itemtype="text", text="Epsilon")
            self._checkButtonStyle = Tix.DisplayStyle(
                "window",
                background=hlist['background'],
                refwindow=self.hisListing,
                anchor='center')
            self._updateHisListing()

            Tkinter.Button(self.hisFrame,
                           text="Select All",
                           pady=0,
                           highlightthickness=0,
                           command=self._selectAll).grid(row=2, column=0)
            Tkinter.Button(self.hisFrame,
                           text="Clear All",
                           pady=0,
                           highlightthickness=0,
                           command=self._clearAll).grid(row=2, column=1)

        if self.hisProtVar.get() == "pick":
            self._pickText.set("Individually chosen:")
            self.hisFrame.grid(row=2, sticky="nsew")
            interior = self.hisGroup.interior()
            interior.columnconfigure(0, weight=1)
            interior.rowconfigure(2, weight=1)
            self.uiMaster().rowconfigure(2, weight=4)
        else:
            self._pickText.set("Individually chosen...")
            self.hisFrame.grid_forget()
            interior = self.hisGroup.interior()
            interior.columnconfigure(0, weight=0)
            interior.rowconfigure(2, weight=0)
            self.uiMaster().rowconfigure(2, weight=0)