コード例 #1
0
def generar_menu_dist(*args):
    """
    Subprograma que genera los campos correspondientes al tipo de distribución seleccionada por el distribucion_seleccionada.
    """
    try:
        dic = distribuciones[distribucion_seleccionada.get()].dict_params
    except KeyError:
        distribucion_seleccionada.set("Binomial")
        dic = distribuciones["Binomial"].dict_params

    # busca los widgets que no se ocupan y los destruye
    flush_widgets(app)

    # genera los widgets necesarios de la distribucion
    for campo in dic.keys():
        if modo_seleccionado.get() == "Acumulada" and campo == "x":
            label = Label(app, text="Inicio", font=("sans", "12", "bold"))
            # agregar un form
            txtfld = Entry(app, text="Inicio")
            txtfld.tag = "inicio"
            tooltip = CreateToolTip(txtfld, text="x inicial")
            # vincularlos a la app
            label.pack()
            txtfld.pack()

            label = Label(app, text="Fin", font=("sans", "12", "bold"))
            # agregar un form
            txtfld = Entry(app, text="Fin")
            txtfld.tag = "fin"
            tooltip = CreateToolTip(txtfld, text="x final")
            # vincularlos a la app
            label.pack()
            txtfld.pack()
            continue

        label = Label(app, text=campo, font=("sans", "12", "bold"))
        # agregar un form
        txtfld = Entry(app, text=campo)
        txtfld.tag = campo
        tooltip = CreateToolTip(txtfld, text=dic[campo])
        # vincularlos a la app
        label.pack()
        txtfld.pack()

    button = Button(
        app,
        text="Calcular!",
        command=(lambda e=app.winfo_children(): calcular_distribucion(e)))

    button.pack()
    # texto por defecto para flushear bonito
    txt = '''
Probabilidad: -
Esperanza: -
Varianza: -
'''
    label = Label(app, text=txt, font=("sans", "12", "bold"))
    label.pack()
コード例 #2
0
ファイル: ds_launcher.py プロジェクト: TeamAIRE/MultiTwin
 def openAnnotFile(self, var=None):
     var.set(askopenfilename())
     row = 2
     master = self.master
     try:
         with open(var.get(), 'r') as ANNOT:
             keyList = ANNOT.readline().strip().split("\t")[1:]
             #print(keyList)
             keyList.sort()
             keyString = ",".join(keyList)
     except FileNotFoundError:
         return
     self.optionLabel = Label(master, text="Annotation keys")
     self.optionLabel.grid(row=row, column=0, sticky=W, padx=3)
     self.k = StringVar()
     self.k.set(keyString)
     self.optionEntry = Entry(master, width=WIDTH, textvariable=self.k)
     self.optionEntry.grid(row=row, column=1, padx=3)
     self.optionLabel2 = Label(master, text="comma-separated")
     self.optionLabel2.grid(row=row, column=3, sticky=W, padx=3)
     ann = os.path.basename(self.a.get())
     CreateToolTip(
         self.optionEntry,
         """List of available attributes in file %s.\nIf you wish to remove some, click on line and edit."""
         % ann)
     self.master.update_idletasks()
     RHeight = self.master.winfo_reqheight()
     RWidth = self.master.winfo_reqwidth()
     self.master.geometry(("%dx%d+300+300") % (RWidth, RHeight))
     center(self.master)
コード例 #3
0
ファイル: ds_launcher.py プロジェクト: TeamAIRE/MultiTwin
    def __init__(self, master, title=None, args=None):

        self.master = master
        self.args = args
        self.name = title
        master.title("Startup interface for %s" % title)
        self.arguments = dict()

        style = Style()
        style.configure(".", background="lightgrey")

        labelStyle = Style()
        labelStyle.configure("TLabel", background="lightgrey")
        buttonStyle = Style()
        buttonStyle.configure("TButton", background="lightgrey")
        chkbuttonStyle = Style()
        chkbuttonStyle.configure("TCheckbutton", background="lightgrey")
        rbuttonStyle = Style()
        rbuttonStyle.configure("TRadiobutton", background="lightgrey")

        row = 0
        column = 0

        # Input edge file
        self.inEdgeLabel = Label(master, text="Input edge file")
        self.inEdgeLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.inEdgeFile = StringVar()
        if self.args.i:
            self.inEdgeFile.set(self.args.i)
        self.inEdgeEntry = Entry(master,
                                 width=WIDTH,
                                 textvariable=self.inEdgeFile)
        column += 1
        self.inEdgeEntry.grid(row=row, column=column, padx=3)
        self.inEdgeSelect = Button(master, text = "Select",\
                                   command = lambda: self.setOutputFiles2(IN=self.inEdgeFile,OUT=[(self.configFile,"config"),(self.outFile,"desc"),(self.outFile2,"xml_desc")]))
        column += 1
        self.inEdgeSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="required")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText1 = "Edge file for input graph (two columns, tab-delimited)."
        self.inEdgeTip = CreateToolTip(self.inEdgeEntry, helpText1)
        ##
        row += 1
        column = 0

        self.annotLabel = Label(master, text="Annotation file")
        self.annotLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.a = StringVar()
        if self.args.a:
            self.a.set(os.path.abspath(os.path.normpath(self.args.a)))
        self.annotEntry = Entry(master, width=WIDTH, textvariable=self.a)
        column += 1
        self.annotEntry.grid(row=row, column=column, padx=3)
        self.annotSelect = Button(
            master,
            text="Select",
            command=lambda: self.openAnnotFile(var=self.a))
        column += 1
        self.annotSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="required")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        CreateToolTip(
            self.annotEntry,
            "Common annotation file for genomes and genes.\nTab-delimited, compulsory header with attribute names.\nSpecify empty annotations with '-'."
        )
        row += 1
        column = 0

        self.k = StringVar()
        if self.a.get():
            with open(self.a.get(), 'r') as ANNOT:
                keyList = ANNOT.readline().strip().split("\t")[1:]
                #print(keyList)
                keyList.sort()
                keyString = ",".join(keyList)
            self.optionLabel = Label(master, text="Annotation keys")
            self.optionLabel.grid(row=row, column=0, sticky=W, padx=3)
            self.k = StringVar()
            self.k.set(keyString)
            self.optionEntry = Entry(master, width=WIDTH, textvariable=self.k)
            self.optionEntry.grid(row=row, column=1, padx=3)
            self.optionLabel2 = Label(master, text="comma-separated")
            self.optionLabel2.grid(row=row, column=3, sticky=W, padx=3)
            CreateToolTip(
                self.optionEntry,
                "List of available attributes in file %s.\nIf you wish to remove some, click on line and edit."
                % self.args.a)
        row += 1

        self.configLabel = Label(master, text="Configuration file")
        self.configLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.configFile = StringVar()
        self.generateConfig = BooleanVar()
        self.generateConfig.set(bool(self.args.X))
        self.useConfig = BooleanVar()
        self.useConfig.set(bool(self.args.x))
        if self.args.x or self.args.X:
            if self.args.x and self.args.X:
                if self.args.x == self.args.X:
                    cFile = self.args.x
                    self.configFile.set(cFile)
                else:
                    sys.exit(
                        "Conflicting fields -x and -X. Check and run again.")
            elif self.args.x:
                cFile = self.args.x
            else:
                cFile = self.args.X
            self.configFile.set(cFile)
        else:
            self.configFile.set('')
        self.configEntry = Entry(master,
                                 width=WIDTH,
                                 textvariable=self.configFile)
        column += 1
        self.configEntry.grid(row=row, column=column, padx=3)
        self.configSelect = Button(
            master,
            text="Select",
            command=lambda: self.setFile(var1=self.configFile,
                                         var2=self.outTrailFile))
        column += 1
        self.configSelect.grid(row=row, column=column, sticky=W, padx=3)
        """self.optionLabel2 = Label(master, text = "optional")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                """
        # tip
        helpText3 = "XML file specifying component, trails and annotations for all node types."
        self.configTip = CreateToolTip(self.configEntry, helpText3)
        #
        column += 1
        #row += 1
        #column = 0

        cbFrame = Frame(master)
        chk1 = Checkbutton(cbFrame, text="Generate", var=self.generateConfig)
        chk1.pack(side="left", fill=None, expand=False, padx=3)
        CreateToolTip(chk1,
                      "Generate configuration file %s" % self.configFile.get())
        chk2 = Checkbutton(cbFrame, text="Use", var=self.useConfig)
        chk2.pack(side="left", fill=None, expand=False, padx=3)
        CreateToolTip(chk2,
                      "Use configuration file %s" % self.configFile.get())
        cbFrame.grid(row=row, column=column, sticky=W)
        row += 1
        column = 0

        self.TrailLabel = Label(master, text="Use trail file")
        self.TrailLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.inTrailFile = StringVar()
        self.T = StringVar()
        if self.args.t:
            self.T.set("1")
            self.inTrailFile.set(self.args.t)
        elif self.args.H:
            self.T.set("2")
            self.inTrailFile.set(self.args.H)
        else:
            self.T.set("0")
        MODES = [
            ("No", "0"),
            ("Unique level", "1"),
            ("Follow history", "2"),
        ]
        trailVal = {
            "0": "Toto",
            "1": self.inTrailFile.get(),
            "2": self.inTrailFile.get()
        }
        helpVal = {
            "0":
            "Do not use trail file.\nCheck that annotations refer to IDs of current graph.",
            "1": "Use only level described by trail file.",
            "2": "Use all levels found in the trail history."
        }
        rbFrame = Frame(master)  # create subframe for radiobuttons
        i = 0
        MODE = MODES[0]
        b = Radiobutton(rbFrame,
                        text=MODE[0],
                        variable=self.T,
                        value=MODE[1],
                        command=lambda: self.inTrailFile.set(''))
        # tip
        CreateToolTip(b, helpVal[str(i)])
        ##
        b.pack(side="left", fill=None, expand=False, padx=3)
        for text, mode in MODES[1:]:
            b = Radiobutton(
                rbFrame,
                text=text,
                variable=self.T,
                value=mode,
                command=lambda: self.openFileCheck(var=self.inTrailFile))
            # tip
            CreateToolTip(b, helpVal[mode])
            ##
            b.pack(side="left", fill=None, expand=False, padx=3)
        rbFrame.grid(row=row, column=1)
        row += 1
        column = 0

        self.inTrailLabel = Label(master, text="Trail file")
        self.inTrailLabel.grid(row=row, column=column, sticky=W, padx=18)
        #self.inTrailEntry = Entry(master, width = WIDTH, textvariable = self.inTrailFile)

        self.inTrailEntry = Entry(master,
                                  width=WIDTH,
                                  textvariable=self.inTrailFile,
                                  validate='focusin',
                                  validatecommand=lambda: self.T.set("2"))
        CreateToolTip(
            self.inTrailEntry,
            """Select node type file for multipartite graphs.\nThis will reset the partiteness to "Multipartite"."""
        )

        column += 1
        self.inTrailEntry.grid(row=row, column=column, padx=3)
        self.inTrailSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile2(
                var=self.inTrailFile, var2=self.T, value="2"))
        column += 1
        self.inTrailSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="if option set")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText3 = "Links IDs of current graph to IDs of ROOT graph (two columns, tab-delimited).\nIf skipped, current graph is considered ROOT."
        self.inTrailTip = CreateToolTip(self.inTrailEntry, helpText3)
        #
        """
                cbFrame = Frame(master)
                self.uniqueTrail = BooleanVar()
                chk1 = Checkbutton(cbFrame, text="Unique trail file", var = self.uniqueTrail)
                chk1.pack(side="left", fill=None, expand=False, padx=3) 
                CreateToolTip(chk1, "Consider only level given by %s" % self.inTrailFile.get())
                self.history = BooleanVar()
                chk2 = Checkbutton(cbFrame, text="Use trail history", var = self.history)
                chk2.pack(side="left", fill=None, expand=False, padx=3) 
                CreateToolTip(chk2, "Follow trail history of trail file %s" % self.inTrailFile.get())
                cbFrame.grid(row=row,column=1)
                """
        row += 1
        column = 0

        # Component file
        self.CompLabel = Label(master, text="Component file ")
        self.CompLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.CompFile = StringVar()
        if self.args.c:
            self.CompFile.set(self.args.c)
        self.CompEntry = Entry(master, width=WIDTH, textvariable=self.CompFile)
        column += 1
        self.CompEntry.grid(row=row, column=column, padx=3)
        self.CompSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile(var=self.CompFile))
        column += 1
        self.CompSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="optional")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText3 = "Links a nodeID and its neighbours to the twin class ID.\nThis is usually an overlapping clustering.\nIf left empty, consider nodes of current graph as components."
        self.CompTip = CreateToolTip(self.CompEntry, helpText3)
        ##
        row += 1
        column = 0

        # Partiteness options
        self.inNodeLabel = Label(master, text="Partiteness")
        self.inNodeLabel.grid(row=row, column=column, sticky=W, padx=3)
        column += 1
        MODES = [
            ("Unipartite", "1"),
            ("Bipartite", "2"),
        ]
        self.inNodeType = StringVar()
        self.v = StringVar()
        if str(self.args.N) == '1' or str(self.args.N) == '2':
            self.v.set(self.args.N)  # initialize at value
        elif self.args.N:
            self.v.set("m")
            self.inNodeType.set(self.args.N)
        else:
            self.v.set("2")
        rbFrame = Frame(master)  # create subframe for radiobuttons
        for text, mode in MODES:
            b = Radiobutton(rbFrame,
                            text=text,
                            variable=self.v,
                            value=mode,
                            command=lambda: self.inNodeType.set(''))
            # tip
            CreateToolTip(b, "Select if graph is %s" % text.lower())
            ##
            b.pack(side="left", fill=None, expand=False, padx=3)
        b = Radiobutton(rbFrame,
                        text="Multipartite",
                        variable=self.v,
                        value="m",
                        command=lambda: self.openFile(var=self.inNodeType))
        CreateToolTip(
            b,
            "Select if graph is multipartite.\nThis will open a select box for the node type file."
        )
        b.pack(side="left", fill=None, expand=False, padx=3)
        rbFrame.grid(row=row, column=column, padx=3)
        row += 1
        column = 0
        self.Label = Label(master, text="Node type file")
        self.Label.grid(row=row, column=column, sticky=W, padx=18)
        self.inNodeEntry = Entry(master,
                                 width=WIDTH,
                                 textvariable=self.inNodeType,
                                 validate='focusin',
                                 validatecommand=lambda: self.v.set("m"))
        CreateToolTip(
            self.inNodeEntry,
            """Select node type file for multipartite graphs.\nThis will reset the partiteness to "Multipartite"."""
        )
        column += 1
        self.inNodeEntry.grid(row=row, column=column, padx=3)
        self.inNodeSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile2(
                var=self.inNodeType, var2=self.v, value="m")
        )  # reset value to "multipartite" when type file is chosen.
        column += 1
        self.inNodeSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="for multipartite only")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        CreateToolTip(
            self.inNodeSelect,
            """Select node type file for multipartite graphs.\nThis will reset the partiteness to "Multipartite"."""
        )
        row += 1
        column = 0

        # Output file
        self.outLabel = Label(master, text="Output plain file")
        self.outLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.outFile = StringVar()
        if self.args.o:
            self.outFile.set(self.args.o)
        self.outEntry = Entry(master, width=WIDTH, textvariable=self.outFile)
        column += 1
        self.outEntry.grid(row=row, column=column, padx=3)
        self.outSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile(var=self.outFile))
        column += 1
        self.outSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="required")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText2 = "Set name of the plain text description file"
        self.outTip = CreateToolTip(self.outEntry, helpText2)
        ##
        row += 1
        column = 0

        # Output file
        self.outLabel2 = Label(master, text="Output XML file")
        self.outLabel2.grid(row=row, column=column, sticky=W, padx=3)
        self.outFile2 = StringVar()
        if self.args.O:
            self.outFile.set(self.args.O)
        self.outEntry2 = Entry(master, width=WIDTH, textvariable=self.outFile2)
        column += 1
        self.outEntry2.grid(row=row, column=column, padx=3)
        self.outSelect2 = Button(
            master,
            text="Select",
            command=lambda: self.openFile(var=self.outFile2))
        column += 1
        self.outSelect2.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="optional")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText2 = "Set name of the XML description file"
        self.outTip = CreateToolTip(self.outEntry2, helpText2)
        ##
        row += 1
        column = 0

        self.optionLabel = Label(master, text="Unique node identifier")
        self.optionLabel.grid(row=row, column=0, sticky=W, padx=3)
        self.I = StringVar()
        if self.args.I:
            self.I.set(self.args.I)
        self.optionEntry = Entry(master, width=WIDTH, textvariable=self.I)
        self.optionEntry.grid(row=row, column=1, padx=3)
        CreateToolTip(
            self.optionEntry,
            """Name of first column in annotation %s file.\nCheck that the items in this column match the node IDs in the ROOT graph."""
            % os.path.basename(self.a.get()))
        row += 1
        column = 0

        self.trackLabel = Label(master, text="Missing annotation label")
        self.trackLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.trackName = StringVar()
        if self.args.T:
            self.trackName.set(self.args.T)
        self.trackEntry = Entry(master,
                                width=WIDTH,
                                textvariable=self.trackName)
        column += 1
        self.trackEntry.grid(row=row, column=column, padx=3)
        # tip
        helpText3 = "Name replacing missing annotations"
        self.trackTip = CreateToolTip(self.trackEntry, helpText3)
        #
        column += 2

        self.Track = BooleanVar()
        chk1 = Checkbutton(master, text="Skip", var=self.Track)
        CreateToolTip(chk1, "Skip missing annotations")
        chk1.grid(row=row, column=column, sticky=W, padx=9)
        row += 1
        column = 0

        self.optionLabel = Label(master,
                                 text="Graphic interface for %s" %
                                 self.configFile.get())
        self.optionLabel.grid(row=row, column=0, sticky=W, padx=3)
        self.K = BooleanVar()
        self.K.set(self.args.K)
        self.chk = Checkbutton(master, text="Display?", var=self.K)
        self.chk.grid(row=row, column=1, padx=3, sticky=W)
        CreateToolTip(
            self.chk,
            "Displays graphic customization interface for the last description.py step.\nIf not selected, displays all attributes for all key types and all trail levels."
        )
        row += 1
        column = 0
        # Log
        self.optionLabel = Label(master, text="Log file")
        self.optionLabel.grid(row=row, column=0, sticky=W, padx=3)
        self.l = StringVar()
        try:
            log = self.args.l.name.strip("(<,>")
        except:
            log = log
        self.l.set(log)
        self.optionEntry = Entry(master, width=WIDTH, textvariable=self.l)
        self.optionEntry.grid(row=row, column=1, padx=3)
        row += 2

        # Populate outFiles if edge file given
        if self.args.i:
            self.setOutputFiles2(IN=self.inEdgeFile,
                                 OUT=[(self.configFile, "config"),
                                      (self.outFile, "desc"),
                                      (self.outFile2, "xml_desc")],
                                 OPEN=False)

        cbFrame = Frame(master)  # create subframe for command buttons

        self.run_button = Button(cbFrame, text="Run", command=self.run)
        self.run_button.grid(row=row, column=0, padx=12)

        self.close_button = Button(cbFrame, text="Close", command=self.Quit)
        self.close_button.grid(row=row, column=1, padx=12)

        cbFrame.grid(row=row, column=1, columnspan=2, sticky=E + W)

        helpText = description.processArgs().format_help()
        self.helpbutton = Button(
            master,
            text="Help",
            command=lambda: HelpWindow(text=helpText, name=self.name))
        self.helpbutton.grid(row=row, column=2, sticky=W, padx=3)
コード例 #4
0
    def widget(self):
        Info(
            self,
            text="Updates to settings require the script to be restarted.",
            center=True,
        )._pack(pady=5)

        settings_frame = tk.Frame(self)
        settings_frame.grid_columnconfigure(1, weight=1)
        inputs = []  # may be better known as entries

        def on_change(_):
            if list(self.settings.values()) == [
                    _entry.sv.get() for _entry in inputs
            ]:
                save["state"] = "disabled"
            else:
                save["state"] = "normal"

        ## CREATE INPUT WIDGETS
        for i, (name, setting) in enumerate(self.settings.items()):
            ### CREATE LABEL WIDGET
            label = tk.Label(settings_frame, text=name)
            label.grid(row=i, column=0, padx=10)
            CreateToolTip(label, self.tooltips[name])

            ### CREATE ENTRY WIDGET
            if (name == "Pause When Locked" or name == "Push To Back"
                    or name == "Create Shortcut"):
                entry = Dropdown(
                    settings_frame,
                    name,
                    self.yes_no_options,
                    self.yes_no_options.index(setting),
                )
            elif name == "Spotify Path":
                entry = FileSelector(settings_frame,
                                     name,
                                     setting,
                                     on_change=on_change)

            else:
                entry = Input(settings_frame, name=name, value=setting)
            CreateToolTip(entry, self.tooltips[name])
            entry.grid(
                row=i,
                column=1,
                padx=15,
                sticky=tk.W + tk.E,
                pady=2 if name == "Spotify Path" else 0,
            )
            inputs.append(entry)
            entry.on_change = on_change

        ### CREATE SAVE BUTTON WIDGET
        def on_click():
            settings = {}
            for input in inputs:
                value = input.sv.get()
                if value:
                    settings[input.name] = value
                else:
                    settings[input.name] = self.settings[input.name]

            self.settings = settings
            save_settings(settings)
            save["state"] = "disabled"
            self.master.focus()

        save = tk.Button(
            settings_frame,
            text="Save Settings",
            command=on_click,
            state="disabled",
        )
        save.grid(row=i + 1,
                  column=0,
                  columnspan=2,
                  pady=10,
                  padx=40,
                  sticky=tk.W + tk.E)

        settings_frame.pack(fill="x")
コード例 #5
0
ファイル: dt_launcher.py プロジェクト: TeamAIRE/MultiTwin
        def __init__(self, master,title=None,args=None):

                self.master = master
                self.args = args
                self.name = title
                master.title("Startup interface for %s" % title)
                self.arguments = dict()

                style = Style()
                style.configure(".",background="lightgrey")
                
                labelStyle = Style()
                labelStyle.configure("TLabel", background="lightgrey")
                buttonStyle = Style()
                buttonStyle.configure("TButton", background = "lightgrey")
                chkbuttonStyle = Style()
                chkbuttonStyle.configure("TCheckbutton", background = "lightgrey")
                rbuttonStyle = Style()
                rbuttonStyle.configure("TRadiobutton", background = "lightgrey")

                row = 0
                column = 0
                
                # Input edge file
                self.inEdgeLabel = Label(master, text = "Input edge file")
                self.inEdgeLabel.grid(row=row,column=column, sticky=W, padx=3)
                self.inEdgeFile = StringVar()
                if self.args.input_edge_file:
                        self.inEdgeFile.set(self.args.input_edge_file)
                self.inEdgeEntry = Entry(master, width = WIDTH, textvariable = self.inEdgeFile)
                column += 1
                self.inEdgeEntry.grid(row=row,column=column, padx=3)
                self.inEdgeSelect = Button(master, text = "Select", command = lambda: self.setOutputFiles(IN=self.inEdgeFile,TWIN=self.outTwinFile,TWINCOMP=self.twinCompFile))
                column += 1
                self.inEdgeSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "required")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                # tip
                helpText1 = "Edge file for input graph (two columns, tab-delimited)."
                self.inEdgeTip = CreateToolTip(self.inEdgeEntry, helpText1)
                ##
                row += 1
                column = 0

                # Output twin file
                self.outTwinLabel = Label(master, text = "Output twin file")
                self.outTwinLabel.grid(row=row,column=column, sticky=W, padx=3)
                self.outTwinFile = StringVar()
                if self.args.o:
                        self.outTwinFile.set(self.args.o)
                self.outTwinEntry = Entry(master, width = WIDTH, textvariable = self.outTwinFile)
                column += 1
                self.outTwinEntry.grid(row=row,column=column, padx=3)
                self.outTwinSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.outTwinFile))
                column += 1
                self.outTwinSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "required")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                # tip
                helpText2 = "Links a nodeID to its twin class ID (two columns, tab-delimited)."
                self.outTwinTip = CreateToolTip(self.outTwinEntry, helpText2)
                ##
                row += 1
                column = 0

                # Twin component file
                self.twinCompLabel = Label(master, text = "Twin component file ")
                self.twinCompLabel.grid(row=row,column=column, sticky=W, padx=3)
                self.twinCompFile = StringVar()
                if self.args.c:
                        self.twinCompFile.set(self.args.c)
                self.twinCompEntry = Entry(master, width = WIDTH, textvariable = self.twinCompFile)
                column += 1
                self.twinCompEntry.grid(row=row,column=column, padx=3)
                self.twinCompSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.twinCompFile))
                column += 1
                self.twinCompSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "optional")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                # tip
                helpText3 = "Links a nodeID and its neighbours to the twin class ID.\nThis is usually an overlapping clustering."
                self.twinCompTip = CreateToolTip(self.twinCompEntry, helpText3)
                ##
                row += 1
                column = 0

                # Populate outFiles if edge file given
                if self.args.input_edge_file:
                        inFile = os.path.split(self.args.input_edge_file)[1]
                        inRad = inFile.split(".")[0]
                        twin = inRad+".twins"
                        twinComp = inRad+".twin_comp"
                        self.outTwinFile.set(twin)
                        self.twinCompFile.set(twinComp)

                # Partiteness options
                self.inNodeLabel = Label(master, text = "Partitneness")
                self.inNodeLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                MODES = [("Unipartite", "1"),("Bipartite", "2"),]
                self.inNodeType = StringVar()
                self.v = StringVar()
                if str(self.args.n) == '1' or str(self.args.n) == '2':
                        self.v.set(self.args.n) # initialize at bipartite
                elif self.args.n:
                        self.v.set("m")
                        self.inNodeType.set(self.args.n)
                rbFrame = Frame(master)  # create subframe for radiobuttons
                for text,mode in MODES:
                        b = Radiobutton(rbFrame, text=text, variable=self.v, value=mode, command = lambda: self.inNodeType.set(''))
                        # tip
                        CreateToolTip(b,"Select if graph is %s" % text.lower())
                        ##
                        b.pack(side="left", fill=None, expand=False, padx=3)
                b = Radiobutton(rbFrame, text="Multipartite", variable=self.v, value="m", command = lambda: self.openFile(var=self.inNodeType))
                CreateToolTip(b,"Select if graph is multipartite.\nThis will open a select box for the node type file.")
                b.pack(side="left", fill=None, expand=False, padx=3)                        
                rbFrame.grid(row=row,column=column, padx=3)
                row += 1
                column = 0
                self.inNodeEntry = Entry(master, width = WIDTH, textvariable = self.inNodeType, validate='focusin',validatecommand = lambda: self.v.set("m"))
                CreateToolTip(self.inNodeEntry,"""Select node type file for multipartite graphs.\nThis will reset the partiteness to "Multipartite".""")
                column += 1
                self.inNodeEntry.grid(row=row,column=column, padx=3)
                self.inNodeSelect = Button(master, text = "Select", command = lambda: self.openFile2(var=self.inNodeType,var2=self.v,value="m")) # reset value to "multipartite" when type file is chosen.
                column += 1
                self.inNodeSelect.grid(row=row,column=column, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "for multipartite")
                column += 1
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                CreateToolTip(self.inNodeSelect,"""Select node type file for multipartite graphs.\nThis will reset the partiteness to "Multipartite".""")
                row += 1
                column = 0

                # unilat
                self.twinSelectLabel = Label(master, text = "Restrict to node types")
                self.twinSelectLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                self.unilat = StringVar()
                if self.args.u:
                        self.unilat.set(self.args.u)
                self.twinSelectEntry = Entry(master, width = WIDTH, textvariable = self.unilat)
                self.twinSelectEntry.grid(row=row,column=column, padx=3)
                column += 2
                self.optionLabel2 = Label(master, text = "optional (comma-separated)")
                self.optionLabel2.grid(row=row,column=column, padx=3)
                CreateToolTip(self.twinSelectEntry,"Computes twins for nodes of specified types only.")
                row += 1
                column = 0

                # Min support 
                self.minsuppLabel = Label(master, text = "Minimum support")
                self.minsuppLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                self.minsupp = StringVar()
                if self.args.thr:
                        self.minsupp.set(self.args.thr)
                self.minsuppEntry = Entry(master, width = WIDTH, textvariable = self.minsupp)
                self.minsuppEntry.grid(row=row,column=column, padx=3)
                column += 2
                self.optionLabel2 = Label(master, text = "optional")
                self.optionLabel2.grid(row=row,column=column, padx=3,sticky=W)
                CreateToolTip(self.minsuppEntry,"Returns twins only if their neighbourhood has at least this number of elements.")
                row += 1
                column = 0

                # min size
                self.minsizeLabel = Label(master, text = "Minimum twin size")
                self.minsizeLabel.grid(row=row,column=column, sticky=W, padx=3)
                column += 1
                self.minsize = StringVar()
                if self.args.M:
                        self.minsize.set(self.args.M)
                self.minsizeEntry = Entry(master, width = WIDTH, textvariable = self.minsize)
                self.minsizeEntry.grid(row=row,column=column, padx=3)
                column += 2
                self.optionLabel2 = Label(master, text = "optional")
                self.optionLabel2.grid(row=row,column=column, padx=3,sticky=W)
                CreateToolTip(self.minsizeEntry,"Returns twins only if they have at least this number of elements.")
                row += 1
                column = 0

                # Log
                self.optionLabel = Label(master, text = "Log file")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.l = StringVar()
                try:
                        log = self.args.l.name.strip("(<,>")
                except:
                        log = log
                self.l.set(log)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.l)
                self.optionEntry.grid(row=row,column=1, padx=3)
                row += 2

                cbFrame = Frame(master)  # create subframe for command buttons

                self.run_button = Button(cbFrame, text="Run", command=self.run)
                self.run_button.grid(row=row,column=0,padx=12)
                
                self.close_button = Button(cbFrame, text="Close", command=self.Quit)
                self.close_button.grid(row=row,column=1,padx=12)

                cbFrame.grid(row=row,column=1,columnspan=2,sticky=E+W)

                helpText = detect_twins.processArgs().format_help()
                self.helpbutton = Button(master, text="Help", command = lambda: HelpWindow(text=helpText,name=self.name))
                self.helpbutton.grid(row=row,column=2,sticky=W,padx=3)
コード例 #6
0
        def __init__(self, master,title=None,args=None):

                self.master = master
                self.args = args
                self.name = title
                master.title("Startup interface for %s" % title)
                self.arguments = dict()

                style = Style()
                style.configure(".",background="lightgrey")
                
                labelStyle = Style()
                labelStyle.configure("TLabel", background="lightgrey")
                buttonStyle = Style()
                buttonStyle.configure("TButton", background = "lightgrey")
                chkbuttonStyle = Style()
                chkbuttonStyle.configure("TCheckbutton", background = "lightgrey")
                rbuttonStyle = Style()
                rbuttonStyle.configure("TRadiobutton", background = "lightgrey")
                
                row = 0
        
                self.blastLabel = Label(master, text = "Blast/Diamond output file")
                self.blastLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.blastFile = StringVar()
                if self.args.b:
                        self.blastFile.set(self.args.b)
                self.blastEntry = Entry(master, width = WIDTH, textvariable = self.blastFile)
                self.blastEntry.grid(row=row,column=1, padx=3)
                self.blastSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.blastFile))
                self.blastSelect.grid(row=row,column=2, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "required")
                self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                CreateToolTip(self.blastEntry,"Sequence similarity file produced by BLAST or DIAMOND.\nUses specific format (see README).")
                row += 1

                self.networkLabel = Label(master, text = "Genome to gene file")
                self.networkLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.networkFile = StringVar()
                if self.args.g:
                        self.networkFile.set(self.args.g)
                self.networkEntry = Entry(master, width = WIDTH, textvariable = self.networkFile)
                self.networkEntry.grid(row=row,column=1, padx=3)
                self.networkSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.networkFile))
                self.networkSelect.grid(row=row,column=2, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "required")
                self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                CreateToolTip(self.networkEntry,"Input bipartite graph edge file (Tab-separated).\nCheck for the ordering of the items on each line:\nGenome first, then sequence ID.")
                row += 1
                
                self.annotLabel = Label(master, text = "Annotation file")
                self.annotLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.a = StringVar()
                if self.args.a:
                        self.a.set(self.args.a)
                self.annotEntry = Entry(master, width = WIDTH, textvariable = self.a)
                self.annotEntry.grid(row=row,column=1, padx=3)
                self.annotSelect = Button(master, text = "Select", command = lambda: self.openAnnotFile(var=self.a))
                self.annotSelect.grid(row=row,column=2, sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "recommended")
                self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                CreateToolTip(self.annotEntry,"Common annotation file for genomes and genes.\nTab-delimited, compulsory header with attribute names.\nSpecify empty annotations with '-'.")
                row += 1

                self.k = StringVar()
                if self.a.get():
                        with open(self.a.get(),'r') as ANNOT:
                                keyList = ANNOT.readline().strip().split("\t")[1:]
                                #print(keyList)
                                keyList.sort()
                                keyString = ",".join(keyList)
                        self.optionLabel = Label(master, text = "Annotation keys")
                        self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                        self.k = StringVar()
                        self.k.set(keyString)
                        self.optionEntry = Entry(master, width = WIDTH, textvariable = self.k)
                        self.optionEntry.grid(row=row,column=1, padx=3)
                        self.optionLabel2 = Label(master, text = "comma-separated")
                        self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                        CreateToolTip(self.optionEntry,"List of available attributes in file %s.\nIf you wish to remove some, click on line and edit." % self.args.a)
                row += 1
                                
                self.optionLabel = Label(master, text = "Identity threshold(s)")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.n = StringVar()
                if self.args.n:
                        self.n.set(self.args.n)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.n)
                self.optionEntry.grid(row=row,column=1, padx=3)
                self.optionLabel2 = Label(master, text = "comma-separated")
                self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                CreateToolTip(self.optionEntry,"List of thresholds considered.\nOne subdirectory will be created for each value.")
                row += 1
                
                self.optionLabel = Label(master, text = "Mutual cover")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.c = StringVar()
                if self.args.c:
                        self.c.set(self.args.c)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.c)
                self.optionEntry.grid(row=row,column=1, sticky=W, padx=3)
                CreateToolTip(self.optionEntry,"Set new value for minimum mutual cover for sequence similarity.")
                row += 1
                
                self.optionLabel = Label(master, text = "Clustering method")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                option_list = ["cc","families"]
                self.C = StringVar()
                self.C.set(option_list[0])
                self.optionEntry = Combobox(master, width = 10, textvariable = self.C)
                self.optionEntry['values'] = option_list
                self.optionEntry.grid(row=row,column=1,sticky=W, padx=3)
                CreateToolTip(self.optionEntry,"""Select method for the definition of gene families.\ncc = connected components of sequence similarity network.\nfamilies = communities produced by the "Louvain" multilevel algorithm.""")
                row += 1
                
                self.optionLabel = Label(master, text = "Input network")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.I = StringVar()
                if self.args.I:
                        self.I.set(self.args.I)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.I)
                self.optionEntry.grid(row=row,column=1, padx=3)
                self.optionSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.I))
                self.optionSelect.grid(row=row,column=2, sticky=W, padx=3)                                   
                self.optionLabel2 = Label(master, text = "optional")
                self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                CreateToolTip(self.optionEntry,"Supply directly sequence similarity network.\nSkips use of cleanblast on the blast file output.")
                row += 1
                
                self.optionLabel = Label(master, text = "Fasta file")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.f = StringVar()
                if self.args.f:
                        self.f.set(self.args.f)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.f)
                self.optionEntry.grid(row=row,column=1, padx=3)
                self.optionSelect = Button(master, text = "Select", command = lambda: self.openFile(var=self.f))
                self.optionSelect.grid(row=row,column=2, sticky=W, padx=3)                                
                self.optionLabel2 = Label(master, text = "optional")
                self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                CreateToolTip(self.optionEntry,"Supply fasta file for the protein sequences.\nAdds sequence similarity detection step.\nWARNING: this could take a long time.")
                row += 1
                
                self.optionLabel = Label(master, text = "Similarity search software")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                option_list = ["Blast","Diamond"]
                self.A = StringVar()
                self.A.set(option_list[0])
                self.optionEntry = Combobox(master, width =10,  textvariable = self.A)
                self.optionEntry['values'] = option_list
                self.optionEntry.grid(row=row,column=1,sticky=W, padx=3)
                self.optionLabel2 = Label(master, text = "optional (requires fasta file)")
                self.optionLabel2.grid(row=row,column=3,sticky=W, padx=3)
                CreateToolTip(self.optionEntry,"Selects sequence similarity detection software.\nSilently ignored if no fasta file is given.")
                row += 1
                
                self.optionLabel = Label(master, text = "Unique node identifier")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.i = StringVar()
                if self.args.i:
                        self.i.set(self.args.i)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.i)
                self.optionEntry.grid(row=row,column=1, padx=3)
                CreateToolTip(self.optionEntry,"""Name of first column in %s file.\nCheck that the items in this column match the node IDs in the ROOT graph.""" % self.args.a)
                row += 1

                self.optionLabel = Label(master, text = "Graphic interface for Description")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.K = BooleanVar()
                self.K.set(self.args.K)
                self.chk = Checkbutton(master, text="Display?", var = self.K)
                self.chk.grid (row=row,column=1,padx=3,sticky=W)
                CreateToolTip(self.chk,"Displays graphic customization interface for the last description.py step.\nIf not selected, displays all attributes for all key types and all trail levels.")
                row += 1
                column = 0
                self.outDirLabel = Label(master, text = "Output directory")
                self.outDirLabel.grid(row=row,column=column, sticky=W, padx=3)
                self.outDir = StringVar()
                if self.args.D:
                        self.outDir.set(self.args.D)
                else:
                        self.outDir.set('')
                self.outDirEntry = Entry(master, width = WIDTH, textvariable = self.outDir)
                column += 1
                self.outDirEntry.grid(row=row,column=column, padx=3)
                self.optionLabel2 = Label(master, text = "optional")
                column += 2
                self.optionLabel2.grid(row=row,column=column,sticky=W, padx=3)
                # tip
                helpText8 = "Storage directory for output files."
                self.outDirTip = CreateToolTip(self.outDirEntry, helpText8)
                #
                row += 1
                
                self.optionLabel = Label(master, text = "Log file")
                self.optionLabel.grid(row=row,column=0, sticky=W, padx=3)
                self.l = StringVar()
                try:
                        log = self.args.l.name.strip("(<,>")
                except:
                        log = log
                self.l.set(log)
                self.optionEntry = Entry(master, width = WIDTH, textvariable = self.l)
                self.optionEntry.grid(row=row,column=1, padx=3)
                row += 2

                cbFrame = Frame(master)  # create subframe for command buttons

                self.run_button = Button(cbFrame, text="Run", command=self.run)
                self.run_button.grid(row=row,column=0,padx=12)
                
                self.close_button = Button(cbFrame, text="Close", command=self.Quit)
                self.close_button.grid(row=row,column=1,padx=12)

                cbFrame.grid(row=row,column=1,columnspan=2,sticky=E+W)

                helpText = bitwin.processArgs().format_help()
                self.helpbutton = Button(master, text="Help", command = lambda: HelpWindow(text=helpText,name=self.name))
                self.helpbutton.grid(row=row,column=2,sticky=W,padx=3)
コード例 #7
0
    def initUI(self):
        # set frame title
        self.parent.title("Configuration settings for %s" % self.XML)

        # pack frame
        self.pack(fill=BOTH, expand=1)

        # configure grid columns
        #NCols = max(3,self.K+1)
        NCols = 3
        for i in range(NCols):
            self.columnconfigure(i, pad=3)

        # configure grid rows
        NRows = self.M + self.T + self.A
        for i in range(NRows):
            self.rowconfigure(i, pad=3)
        row = 0

        label = Label(self, text="ROOT directory: %s" % self.RootDir)
        label.grid(row=row, columnspan=WIDTH, sticky=W, padx=3)
        row += 1

        # Module selection
        # File
        self.compLabel = Label(self, text="Component file")
        self.compLabel.grid(row=row, column=0, sticky=W, padx=3)
        self.compEntry = Entry(self,
                               width=WIDTH,
                               textvariable=self.mod.ModFile)
        self.compEntry.grid(row=row, column=1, padx=3)
        self.compSelect = Button(self,
                                 text="Select",
                                 command=self.selectModFile)
        self.compSelect.grid(row=row, column=2, sticky=W, padx=3)
        helpText1 = "Terminal clustering file whose component's contents one wishes to analyze.\nIf left empty, each node of the graph is a component."
        self.compTip = CreateToolTip(self.compEntry, helpText1)
        row += 1
        # Name
        self.lab1 = StringVar()
        #self.lab1.set("Name of components")
        modfile = os.path.split(self.mod.ModFile.get())[1]
        #comp_name = os.path.relpath(self.mod.ModFile.get(), start=self.RootDir)
        self.lab1.set("Name of components in file %s" % modfile)
        label1 = Label(self, textvariable=self.lab1)
        label1.grid(row=row, column=0, sticky=W, padx=3)
        entry1 = Entry(self, width=WIDTH, textvariable=self.mod.ModName)
        entry1.grid(row=row, column=1)
        CreateToolTip(entry1, "Name that will identify each component")
        row += 1

        # Module keys
        """
                if self.mod.Keys:
                        for nT in self.nodeTypes:
                                label = Label (self,text = "Name of type %d nodes" % nT)
                                label.grid (row=row,column=0,sticky=W,padx=3)

                                entry = Entry (self,width=WIDTH,textvariable = self.mod.Keys[nT].name)
                                entry.grid (row=row,column=1)
                                
                                chk = Checkbutton(self, text="Display?", var = self.mod.Keys[nT].display)
                                chk.grid (row=row,column=2)
                                row +=1
                """
        # Trails selection
        for trail_index in self.trails:
            trail = self.trails[trail_index]
            fname = os.path.relpath(trail.filename, start=self.RootDir)
            label = Label(self,
                          text="Trail file ROOT/%s of rank %d" %
                          (fname, trail_index))
            #label = Label (self,text = "Trail file %s of rank %d" % (trail.filename,trail_index))
            label.grid(row=row, columnspan=WIDTH, sticky=W, padx=3)
            row += 1

            # Trail keys
            for nT in self.nodeTypes:
                label = Label(self, text="Name of type %d nodes" % nT)
                label.grid(row=row, column=0, sticky=W, padx=3)

                entry = Entry(self,
                              width=WIDTH,
                              textvariable=trail.Keys[nT].name)
                entry.grid(row=row, column=1)
                CreateToolTip(
                    entry,
                    "Name for node of type %d in trail file of rank %d" %
                    (nT, trail_index))

                chk = Checkbutton(self,
                                  text="Display?",
                                  var=trail.Keys[nT].display)
                chk.grid(row=row, column=2, sticky=W)
                CreateToolTip(
                    chk,
                    "Select if node of type %d should appear in description" %
                    nT)
                row += 1

        Separator(self, orient=HORIZONTAL).grid(row=row,
                                                column=0,
                                                columnspan=WIDTH,
                                                sticky=E + W)
        row += 1
        label = Label(self, text="List of attributes")
        label.grid(row=row, column=0, sticky=W, padx=3)
        label = Label(self, text="Display attribute for key type?")
        label.grid(row=row, column=1)
        row += 1
        Separator(self, orient=HORIZONTAL).grid(row=row,
                                                column=0,
                                                columnspan=WIDTH,
                                                sticky=E + W)
        row += 1

        # Attributes selection
        for attr_index in self.attrs:
            attr = self.attrs[attr_index]

            label = Label(self, text=attr.name)
            label.grid(row=row, column=0, sticky=W, padx=3)

            # Attr Keys
            column = 0
            cbFrame = Frame(self)
            for nT in self.nodeTypes:
                chk = Checkbutton(cbFrame,
                                  text="Key " + str(nT),
                                  var=attr.Keys[nT].display)
                chk.pack(side="left", fill=None, expand=False, padx=3)
                CreateToolTip(
                    chk,
                    "Select if attribute %s is relevant for node of type %d" %
                    (attr.name, nT))
            cbFrame.grid(row=row, column=1)
            row += 1

        # create OK button
        button1 = Button(self, text="OK", command=self.onOK)
        button1.grid(row=row, column=0, sticky=E)
        self.parent.bind("<Return>", self.onOK)

        # create Cancel button
        button2 = Button(self, text="Cancel", command=self.onCancel)
        button2.grid(row=row, column=2, sticky=W)
        self.parent.bind("<Escape>", self.onCancel)
コード例 #8
0
ファイル: fg_launcher.py プロジェクト: TeamAIRE/MultiTwin
    def __init__(self, master, title=None, args=None):

        self.master = master
        self.args = args
        self.name = title
        master.title("Startup interface for %s" % title)
        self.arguments = dict()

        style = Style()
        style.configure(".", background="lightgrey")

        labelStyle = Style()
        labelStyle.configure("TLabel", background="lightgrey")
        buttonStyle = Style()
        buttonStyle.configure("TButton", background="lightgrey")
        chkbuttonStyle = Style()
        chkbuttonStyle.configure("TCheckbutton", background="lightgrey")
        rbuttonStyle = Style()
        rbuttonStyle.configure("TRadiobutton", background="lightgrey")

        row = 0
        column = 0

        self.inEdgeLabel = Label(master, text="Input edge file")
        self.inEdgeLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.inEdgeFile = StringVar()
        if self.args.input_edge_file:
            self.inEdgeFile.set(self.args.input_edge_file)
        self.inEdgeEntry = Entry(master,
                                 width=WIDTH,
                                 textvariable=self.inEdgeFile)
        column += 1
        self.inEdgeEntry.grid(row=row, column=column, padx=3)
        self.inEdgeSelect = Button(
            master,
            text="Select",
            command=lambda: self.setRequiredFiles(IN=self.inEdgeFile,
                                                  OUT=self.outEdgeFile,
                                                  TRAIL=self.outTrailFile))
        column += 1
        self.inEdgeSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="required")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText1 = "Edge file for input graph (two columns, tab-delimited)."
        self.inEdgeTip = CreateToolTip(self.inEdgeEntry, helpText1)
        ##
        column += 2

        self.outEdgeLabel = Label(master, text="Output edge file")
        self.outEdgeLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.outEdgeFile = StringVar()
        if self.args.output_edge_file:
            self.outEdgeFile.set(self.args.output_edge_file)
        self.outEdgeEntry = Entry(master,
                                  width=WIDTH,
                                  textvariable=self.outEdgeFile)
        column += 1
        self.outEdgeEntry.grid(row=row, column=column, padx=3)
        self.outEdgeSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile(var=self.outEdgeFile))
        column += 1
        self.outEdgeSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="required")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText2 = "Edge file for output graph"
        self.outEdgeTip = CreateToolTip(self.outEdgeEntry, helpText2)
        #
        row += 1
        column = 0

        self.inTrailLabel = Label(master, text="Input trail file")
        self.inTrailLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.inTrailFile = StringVar()
        if self.args.t:
            self.inTrailFile.set(self.args.t)
        self.inTrailEntry = Entry(master,
                                  width=WIDTH,
                                  textvariable=self.inTrailFile)
        column += 1
        self.inTrailEntry.grid(row=row, column=column, padx=3)
        self.inTrailSelect = Button(
            master,
            text="Select",
            command=lambda: self.setFile(var1=self.inTrailFile,
                                         var2=self.outTrailFile))
        column += 1
        self.inTrailSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="optional")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText3 = "Links IDs of current graph to IDs of ROOT graph (two columns, tab-delimited).\nIf skipped, current graph is considered ROOT."
        self.inTrailTip = CreateToolTip(self.inTrailEntry, helpText3)
        #
        column += 2

        self.outTrailLabel = Label(master, text="Output trail file")
        self.outTrailLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.outTrailFile = StringVar()
        if self.args.output_trail_file:
            self.outTrailFile.set(self.args.output_trail_file)
        column += 1
        self.outTrailEntry = Entry(master,
                                   width=WIDTH,
                                   textvariable=self.outTrailFile)
        self.outTrailEntry.grid(row=row, column=column, padx=3)
        column += 1
        self.outTrailSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile(var=self.outTrailFile))
        self.outTrailSelect.grid(row=row, column=column, sticky=W, padx=3)
        column += 1
        self.optionLabel2 = Label(master, text="required")
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText4 = "Links new IDs to ROOT graph"
        self.outTrailTip = CreateToolTip(self.outTrailEntry, helpText4)
        #
        row += 1
        column = 0

        self.inNodeLabel = Label(master, text="Input node type file")
        self.inNodeLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.inNodeType = StringVar()
        if self.args.n:
            self.inNodeType.set(self.args.n)
        self.inNodeEntry = Entry(master,
                                 width=WIDTH,
                                 textvariable=self.inNodeType)
        column += 1
        self.inNodeEntry.grid(row=row, column=column, padx=3)
        self.inNodeSelect = Button(
            master,
            text="Select",
            command=lambda: self.setFile(var1=self.inNodeType,
                                         var2=self.outNodeType))
        column += 1
        self.inNodeSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="for k-partite")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText5 = "Stores node types (two columns, tab-delimited).\nRequired for multipartite (more than bipartite)."
        self.inNodeTip = CreateToolTip(self.inNodeEntry, helpText5)
        #
        column += 2

        self.outNodeLabel = Label(master, text="Output node type file")
        self.outNodeLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.outNodeType = StringVar()
        if self.args.N:
            self.outNodeType.set(self.args.N)
        self.outNodeEntry = Entry(master,
                                  width=WIDTH,
                                  textvariable=self.outNodeType)
        column += 1
        self.outNodeEntry.grid(row=row, column=column, padx=3)
        self.outNodeSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile(var=self.outNodeType))
        column += 1
        self.outNodeSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="for k-partite")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText6 = "Updates node types with new nodeIDs.\nRequired when input node type file is given."
        self.outNodeTip = CreateToolTip(self.outNodeEntry, helpText6)
        #
        row += 1
        column = 0

        self.componentLabel = Label(master, text="Community file")
        self.componentLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.componentFile = StringVar()
        if self.args.c:
            self.componentFile.set(self.args.c)
        self.componentEntry = Entry(master,
                                    width=WIDTH,
                                    textvariable=self.componentFile)
        column += 1
        self.componentEntry.grid(row=row, column=column, padx=3)
        self.componentSelect = Button(
            master,
            text="Select",
            command=lambda: self.openFile(var=self.componentFile))
        column += 1
        self.componentSelect.grid(row=row, column=column, sticky=W, padx=3)
        self.optionLabel2 = Label(master, text="optional")
        column += 1
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText7 = "Specifies grouping of nodes into communities or super-nodes.\nIf not given, input graph is simply renumbered."
        self.componentTip = CreateToolTip(self.componentEntry, helpText7)
        #
        column += 2

        self.outDirLabel = Label(master, text="Output directory")
        self.outDirLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.outDir = StringVar()
        if self.args.d:
            self.outDir.set(self.args.d)
        else:
            self.outDir.set("OutputDir")
        self.outDirEntry = Entry(master, width=WIDTH, textvariable=self.outDir)
        column += 1
        self.outDirEntry.grid(row=row, column=column, padx=3)
        self.optionLabel2 = Label(master, text="optional")
        column += 2
        self.optionLabel2.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText8 = "Storage directory for output files.\nIf suppressed, check that in- and output filenames do not collide."
        self.outDirTip = CreateToolTip(self.outDirEntry, helpText8)
        #
        row += 1
        column = 0

        self.optionLabel = Label(master, text="Clustering file format")
        self.optionLabel.grid(row=row, column=column, sticky=W, padx=3)
        option_list = ["Component", "Fasta"]
        self.C = StringVar()
        self.C.set(option_list[0])
        if self.args.f:
            self.C.set(option_list[1])
        self.optionEntry = Combobox(master, width=10, textvariable=self.C)
        self.optionEntry['values'] = option_list
        column += 1
        self.optionEntry.grid(row=row, column=column, sticky=W, padx=3)
        # tip
        helpText9 = """Specifies format of community file \nComponent=two columns, tab-delimited\nFasta=one line per node, ">" for community ID"""
        self.optionTip = CreateToolTip(self.optionEntry, helpText9)
        #
        column += 2

        self.w = BooleanVar()
        self.w.set(self.args.w)
        self.chk = Checkbutton(master, text="Use weights", var=self.w)
        self.chk.grid(row=row, column=column, padx=3, sticky=W)
        # tip
        helpText10 = "Weighs super-nodes with log(size_of_community)"
        self.chkTip = CreateToolTip(self.chk, helpText10)
        #
        column += 2

        self.optionLabel = Label(master, text="Keep community IDs")
        self.optionLabel.grid(row=row, column=column, sticky=W, padx=3)
        self.K = BooleanVar()
        self.K.set(self.args.C)
        self.chk = Checkbutton(master, text="", var=self.K)
        column += 1
        self.chk.grid(row=row, column=column, padx=3, sticky=W)
        # tip
        helpText11 = "Gives to super-nodes the same ID as in the community file"
        self.keepTip = CreateToolTip(self.optionLabel, helpText11)
        #
        row += 1
        column = 1

        self.optionLabel = Label(master, text="Log file")
        self.optionLabel.grid(row=row, column=0, sticky=W, padx=3)
        self.l = StringVar()
        try:
            log = self.args.l.name.strip("(<,>")
        except:
            log = log
        self.l.set(log)
        self.optionEntry = Entry(master, width=WIDTH, textvariable=self.l)
        self.optionEntry.grid(row=row, column=1, padx=3)
        row += 2

        self.run_button = Button(master, text="Run", command=self.run)
        self.run_button.grid(row=row, column=2)

        self.close_button = Button(master, text="Close", command=self.Quit)
        self.close_button.grid(row=row, column=4)

        helpText = factorgraph.processArgs().format_help()
        self.helpbutton = Button(
            master,
            text="Help",
            command=lambda: HelpWindow(text=helpText, name=self.name))
        self.helpbutton.grid(row=row, column=6, sticky=W, padx=3)