Ejemplo n.º 1
0
		def fetch_eppic_plugin():
			print "Getting PMGApp"
			app = plugins.get_pmgapp()
			print "Getting TK"
			root = plugins.get_tk_root()

			print "Getting panel"
			panel = EppicPanel(root)
Ejemplo n.º 2
0
def mainDialog():
    app = plugins.get_pmgapp()
    root = plugins.get_tk_root()
    self = Tkinter.Toplevel(root)
    self.title('CHemical Energy Wise Decomposition')
    self.minsize(250, 0)
    self.resizable(0, 0)
    CHEWD(self)
Ejemplo n.º 3
0
        def fetch_eppic_plugin():
            print "Getting PMGApp"
            app = plugins.get_pmgapp()
            print "Getting TK"
            root = plugins.get_tk_root()

            print "Getting panel"
            panel = EppicPanel(root)
Ejemplo n.º 4
0
    def __init__(self, selection=None, name=None, symbols='', state=-1):
        try:
            from pymol.plugins import get_pmgapp
            pmgapp = get_pmgapp()
        except ImportError:
            pmgapp = None

        if pmgapp is not None:
            rootframe = Tkinter.Toplevel(pmgapp.root)
            parent = rootframe
        else:
            rootframe = Tkinter.Tk()
            parent = rootframe

        rootframe.title(' Dynamic Angle Plotting ')
        rootframe.protocol("WM_DELETE_WINDOW", self.close_callback)

        canvas = SimplePlot(parent, width=320, height=320)
        canvas.bind("<Button-2>", canvas.pickWhich)
        canvas.bind("<Button-3>", canvas.pickWhich)
        canvas.pack(side=Tkinter.LEFT, fill="both", expand=1)
        canvas.axis(xint=150,
                    xlabels=[-180, -120, -60, 0, 60, 120, 180],
                    ylabels=[
                        -180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120,
                        150, 180
                    ])

        if symbols == 'ss':
            canvas.symbols = 1

        if name is None:
            try:
                name = cmd.get_unused_name('DynoRama')
            except AttributeError:
                name = 'DynoRamaObject'

        self.rootframe = rootframe
        self.canvas = canvas
        self.name = name
        self.lock = 0
        self.state = state

        if name != 'none':
            auto_zoom = cmd.get('auto_zoom')
            cmd.set('auto_zoom', 0)
            cmd.load_callback(self, name)
            cmd.set('auto_zoom', auto_zoom)
            canvas.bind("<ButtonPress-1>", canvas.down)
            canvas.bind("<ButtonRelease-1>", canvas.up)
            canvas.bind("<Motion>", canvas.drag)

        if selection is not None:
            self.start(selection)

        if with_mainloop and pmgapp is None:
            rootframe.mainloop()
Ejemplo n.º 5
0
    def __init__(self, selection=None, name=None, symbols='', state=-1):
        try:
            from pymol.plugins import get_pmgapp
            pmgapp = get_pmgapp()
        except ImportError:
            pmgapp = None

        if pmgapp is not None:
            rootframe = Tkinter.Toplevel(pmgapp.root)
            parent = rootframe
        else:
            rootframe = Tkinter.Tk()
            parent = rootframe

        rootframe.title(' Dynamic Angle Plotting ')
        rootframe.protocol("WM_DELETE_WINDOW", self.close_callback)

        canvas = SimplePlot(parent, width=320, height=320)
        canvas.bind("<Button-2>", canvas.pickWhich)
        canvas.bind("<Button-3>", canvas.pickWhich)
        canvas.pack(side=Tkinter.LEFT, fill="both", expand=1)
        canvas.axis(xint=150,
                    xlabels=[-180, -120, -60, 0, 60, 120, 180],
                    ylabels=[-180, -150, -120, -90, -60, -30, 0, 30, 60, 90, 120, 150, 180])

        if symbols == 'ss':
            canvas.symbols = 1

        if name is None:
            try:
                name = cmd.get_unused_name('DynoRama')
            except AttributeError:
                name = 'DynoRamaObject'

        self.rootframe = rootframe
        self.canvas = canvas
        self.name = name
        self.lock = 0
        self.state = state

        if name != 'none':
            auto_zoom = cmd.get('auto_zoom')
            cmd.set('auto_zoom', 0)
            cmd.load_callback(self, name)
            cmd.set('auto_zoom', auto_zoom)
            canvas.bind("<ButtonPress-1>", canvas.down)
            canvas.bind("<ButtonRelease-1>", canvas.up)
            canvas.bind("<Motion>", canvas.drag)

        if selection is not None:
            self.start(selection)

        if with_mainloop and pmgapp is None:
            rootframe.mainloop()
Ejemplo n.º 6
0
    def open_builder_panel(self):
        from pmg_qt.builder import BuilderPanelDocked
        from pymol import plugins

        app = plugins.get_pmgapp()
        if not self.builder:
            self.builder = BuilderPanelDocked(self, app)
            self.addDockWidget(Qt.TopDockWidgetArea, self.builder)

        self.builder.show()
        self.builder.raise_()
Ejemplo n.º 7
0
    def open_builder_panel(self):
        from pmg_qt.builder import BuilderPanelDocked
        from pymol import plugins

        app = plugins.get_pmgapp()
        if not self.builder:
            self.builder = BuilderPanelDocked(self, app)
            self.addDockWidget(Qt.TopDockWidgetArea, self.builder)

        self.builder.show()
        self.builder.raise_()
Ejemplo n.º 8
0
def calloutpanel():
    self = Tkinter.Toplevel(plugins.get_tk_root())
    self.title('Label Settings')
    master = self
    app = plugins.get_pmgapp()

    def makeframe(text):
        f = Tkinter.LabelFrame(self, text=text, padx=5, pady=5)
        f.pack(fill=Tkinter.X, expand=1)
        return f

    topframes = {}

    def updatetopframe(v):
        for top in topframes.values():
            top.pack_forget()
        if v not in topframes:
            if v == 'PICKED':
                if cmd.count_atoms('?pk1') != 1:
                    tkMessageBox.showwarning(
                        'Warning', 'Please pick an atom in edit mode')
                    return
                setting = Setting.AtomSetting(app, 'pk1')
            elif v == 'GLOBAL':
                setting = app.skin.setting
            else:
                raise ValueError(v)
            topframes[v] = maketopframe(self, setting)
        topframes[v].pack(fill=Tkinter.BOTH, expand=1)

    but_level = Pmw.OptionMenu(master,
                               labelpos='w',
                               label_text='Selection:',
                               items=['GLOBAL', 'PICKED'],
                               command=updatetopframe)
    but_level.pack(side=Tkinter.TOP)

    master = makeframe("Unset Object or Atom level Settings")
    Tkinter.Button(
        master, text="all atoms",
        command=lambda: unset_label_settings('(*)')).pack(side=Tkinter.LEFT)
    Tkinter.Button(
        master, text="all objects",
        command=lambda: unset_label_settings('*')).pack(side=Tkinter.LEFT)

    updatetopframe('GLOBAL')
Ejemplo n.º 9
0
    def initializePlugins(self):
        from pymol import plugins
        from . import mimic_tk

        self.menudict['Plugin'].clear()

        app = plugins.get_pmgapp()

        plugins.legacysupport.addPluginManagerMenuItem()

        # Redirect to Legacy submenu
        self.menudict['PluginQt'] = self.menudict['Plugin']
        self.menudict['Plugin'] = self.menudict['PluginQt'].addMenu('Legacy Plugins')
        self.menudict['Plugin'].setTearOffEnabled(True)
        self.menudict['PluginQt'].addSeparator()

        plugins.HAVE_QT = True
        plugins.initialize(app)
Ejemplo n.º 10
0
    def initializePlugins(self):
        from pymol import plugins
        from . import mimic_tk

        self.menudict['Plugin'].clear()

        app = plugins.get_pmgapp()

        plugins.legacysupport.addPluginManagerMenuItem()

        # Redirect to Legacy submenu
        self.menudict['PluginQt'] = self.menudict['Plugin']
        self.menudict['Plugin'] = self.menudict['PluginQt'].addMenu('Legacy Plugins')
        self.menudict['Plugin'].setTearOffEnabled(True)
        self.menudict['PluginQt'].addSeparator()

        plugins.HAVE_QT = True
        plugins.initialize(app)
Ejemplo n.º 11
0
def calloutpanel():
    self = Tkinter.Toplevel()
    self.title('Label Settings')
    master = self
    app = plugins.get_pmgapp()

    def makeframe(text):
        f = Tkinter.LabelFrame(self, text=text, padx=5, pady=5)
        f.pack(fill=Tkinter.X, expand=1)
        return f

    topframes = {}
    def updatetopframe(v):
        for top in topframes.values():
            top.pack_forget()
        if v not in topframes:
            if v == 'PICKED':
                if cmd.count_atoms('?pk1') != 1:
                    tkMessageBox.showwarning('Warning', 'Please pick an atom in edit mode')
                    return
                setting = Setting.AtomSetting(app, 'pk1')
            elif v == 'GLOBAL':
                setting = app.skin.setting
            else:
                raise ValueError(v)
            topframes[v] = maketopframe(self, setting)
        topframes[v].pack(fill=Tkinter.BOTH, expand=1)

    but_level = Pmw.OptionMenu(master, labelpos='w', label_text='Selection:',
            items=['GLOBAL', 'PICKED'], command=updatetopframe)
    but_level.pack(side=Tkinter.TOP)

    master = makeframe("Unset Object or Atom level Settings")
    Tkinter.Button(master, text="all atoms",
            command=lambda: unset_label_settings('(*)')
            ).pack(side=Tkinter.LEFT)
    Tkinter.Button(master, text="all objects",
            command=lambda: unset_label_settings('*')
            ).pack(side=Tkinter.LEFT)

    updatetopframe('GLOBAL')
Ejemplo n.º 12
0
def get_pmgapp():
    '''
    TODO move to this module
    '''
    from pymol import plugins
    return plugins.get_pmgapp()
Ejemplo n.º 13
0
def fetchdialog():
    from Tkinter import LEFT, RIGHT, TOP, BOTTOM

    app = plugins.get_pmgapp()
    root = plugins.get_tk_root()

    self = Tkinter.Toplevel(root)
    self.title('PDB Loader Service')
    self.minsize(250, 0)
    self.resizable(0,0)
    outer = self

    pad = 4

    type_options = [
        "pdb (Asymmetric Unit)",
        "pdb1 (Biological Unit)",
        "2fofc (Density)",
        "fofc (Difference Density)",
        "cid (PubChem Compound)",
        "sid (PubChem Substance)",
        "emd (EMDB Density)",
    ]

    var_code = Tkinter.StringVar(self)
    var_chain = Tkinter.StringVar(self)
    var_type = Tkinter.StringVar(self, type_options[0])
    var_keep = Tkinter.BooleanVar(self,
            not cmd.get_setting_boolean('autoclose_dialogs'))

    def callback(*args):
        code = var_code.get()
        type = get_trunc(var_type)
        if type == 'pdb':
            code += var_chain.get()
        try:
            result = cmd.fetch(code, type=type)
            if result == -1:
                raise CmdException('You entered an invalid pdb code: ' + code)
        except CmdException as e:
            import tkMessageBox
            tkMessageBox.showerror('Error', str(e), parent=self)
            return
        cmd.log('fetch %s, type=%s, async=0\n' % (code, type))
        if not var_keep.get():
            self.destroy()

    def callback_type(*args):
        v = get_trunc(var_type)
        if v.startswith('pdb') or v.endswith('fofc'):
            but_code.configure(width=4)
        else:
            but_code.configure(width=20)
        if v == 'pdb':
            frame_pdb.pack(side=LEFT)
        else:
            frame_pdb.pack_forget()

    def makerow(label=None, parent=None, **kwargs):
        master = Tkinter.Frame(parent or outer)
        master.pack(fill=Tkinter.X, **kwargs)
        if label:
            Tkinter.Label(master, text=label).pack(side=LEFT)
        return master

    padkw = {'padx': pad, 'pady': (pad, 0)}

    master = makerow("Type:", **padkw)
    but_type = Tkinter.OptionMenu(master, var_type, *type_options,
            command=callback_type).pack(side=LEFT)

    master = makerow("Code:", **padkw)
    but_code = Tkinter.Entry(master, textvariable=var_code, width=4)
    but_code.bind("<Return>", callback)
    but_code.pack(side=LEFT)

    frame_pdb = makerow("Chain:", master, side=LEFT, padx=8)
    but_chain = Tkinter.Entry(frame_pdb, textvariable=var_chain, width=4)
    but_chain.bind("<Return>", callback)
    but_chain.pack(side=LEFT)

    master = makerow(padx=pad, pady=(2*pad,0))
    but_ok = Tkinter.Button(master, width=10, text="OK",
            command=callback)
    but_cancel = Tkinter.Button(master, width=10, text="Cancel",
            command=self.destroy)

    but_cancel.pack(side=RIGHT, fill=Tkinter.X)
    but_ok.pack(side=RIGHT, fill=Tkinter.X)

    master = makerow(padx=pad, pady=(2,pad))
    but_keep = Tkinter.Checkbutton(master, text="Keep dialog open", variable=var_keep)
    but_keep.pack(side=RIGHT)

    but_code.focus_set()
Ejemplo n.º 14
0
def NMR_GUI():
    from pymol import plugins
    root = plugins.get_tk_root()
    app = plugins.get_pmgapp()
    pyNMR.startGUI(Tk.Toplevel(root))
Ejemplo n.º 15
0
def create_dialog():

    dialog = QtWidgets.QDialog()
    dialog.setWindowTitle('Lighting Settings')

    setting = plugins.get_pmgapp().skin.setting

    sliders = [
        "Diffuse Reflection",
        ('ambient', 0, 1, None),
        ('reflect', -1, 1, None),
        "Direct Light from Front",
        ('direct (+reflect)', -1, 1, None),  # diffuse, coupled with "reflect"
        ('spec_direct', 0, 1, None),
        ('spec_direct_power', 0, 100, 1),
        "Free placeable directed Lights",
        ('light_count', 1, 8, 1),
        ('edit_light', 1, 7, 1),
        "Specular Reflection",
        ('spec_count', -1, 8, 1),
        # ('spec_power', -1, 200, 1), # deprecated since v1.5
        ('shininess', 0, 100, None),  # same as spec_power
        ('spec_reflect', -0.01, 1, None),
        ('specular', 0, 1, None),
        ('specular_intensity (=specular)', 0, 1, None),  # same as specular
        "Ambient Occlusion (Surface only)",
        ('ambient_occlusion_mode', 0, 2, 1),
        ('ambient_occlusion_scale', 1.0, 50., None),
        ('ambient_occlusion_smooth', 1, 20, 1),
        "Ray trace only",
        ('power', 1, 10, None),
        ('reflect_power', 1, 10, None),
    ]

    layout = QtWidgets.QVBoxLayout(dialog)

    button_layout = QtWidgets.QHBoxLayout()
    layout.addLayout(button_layout)
    layout.setContentsMargins(5, 0, 5, 0)
    button_layout.addWidget(
        QtWidgets.QLabel("<font color=red>Presets:</font>"))

    presets = [
        ("Default", preset_default),
        ("Metal", preset_metal),
        ("Plastic", preset_plastic),
        ("Rubber", preset_rubber),
        ("X-Ray", preset_xray),
    ]

    for name, fun in presets:
        btn = QtWidgets.QPushButton(name, dialog)
        btn.pressed.connect(fun)
        btn.setAutoDefault(False)
        button_layout.addWidget(btn)

    form_layout = QtWidgets.QFormLayout()
    form_layout.setContentsMargins(0, 0, 0, 0)
    form_layout.setVerticalSpacing(0)
    form_layout.setLabelAlignment(Qt.AlignLeft)
    layout.addLayout(form_layout)

    for i, item in enumerate(sliders, 1):
        if isinstance(item, str):
            label = QtWidgets.QLabel("<font color=blue>" + item + "</font>")
            form_layout.addRow(label)
            continue

        name, min, max, res = item
        if res is None:
            res = 0.01 if (max - min < 100) else 0.1

        line_edit = QtWidgets.QLineEdit(dialog)
        slider = SettingSlider(dialog,
                               name.split()[0], min, max, res, line_edit)

        h_layout = QtWidgets.QHBoxLayout()
        h_layout.addWidget(slider, 3)
        h_layout.addWidget(line_edit, 1)

        form_layout.addRow(name, h_layout)

    return dialog
Ejemplo n.º 16
0
def fetchdialog(simulation=False):
    if simulation:
        root = Tkinter.Tk()
    else:
        app = plugins.get_pmgapp()
        root = plugins.get_tk_root()

    appData = {"cifDir": False}

    mainWindow = Tkinter.Toplevel(root)
    #    self = VerticalScrolledFrame(root)
    mainWindow.title('Supramolecular analyser')
    mainWindow.minsize(1335, 400)

    mainWindow.resizable(1, 1)

    #    self = VerticalScrolledFrame(self)
    canvas = Tkinter.Canvas(mainWindow, width=1320, height=900)
    canvas.grid(row=0, column=0, columnspan=50)

    mainScrollbar = Tkinter.Scrollbar(mainWindow,
                                      orient="vertical",
                                      command=canvas.yview)
    mainScrollbar.grid(row=0, column=50, rowspan=1)

    def moveDown(event):
        canvas.yview_scroll(1, "units")

    def moveUp(event):
        canvas.yview_scroll(-1, "units")
#

    canvas.configure(yscrollcommand=mainScrollbar.set)
    #    canvas.configure(scrollregion = canvas.bbox("all"))
    canvas.configure(scrollregion=(0, 0, 1320, 1800))
    canvas.bind_all("<Down>", moveDown)
    canvas.bind_all("<Up>", moveUp)

    self = Tkinter.Frame(canvas, width=1320, height=900)
    canvas.create_window((0, 0), window=self, anchor='nw')

    nb = ttk.Notebook(self, height=700, width=1320)

    pageAnionPi = ttk.Frame(nb)
    pagePiPi = ttk.Frame(nb)
    pageCationPi = ttk.Frame(nb)
    pageAnionCation = ttk.Frame(nb)
    pageHBonds = ttk.Frame(nb)
    pageMetalLigand = ttk.Frame(nb)
    pageLinearAnionPi = ttk.Frame(nb)
    pagePlanarAnionPi = ttk.Frame(nb)
    pageQM = ttk.Frame(nb)
    pageJobStatus = ttk.Frame(nb)

    nb.add(pageAnionPi, text="AnionPi")
    nb.add(pagePiPi, text="PiPi")
    nb.add(pageCationPi, text="CationPi")
    nb.add(pageAnionCation, text="AnionCation")
    nb.add(pageHBonds, text="HBonds")
    nb.add(pageMetalLigand, text="MetalLigand")
    nb.add(pageLinearAnionPi, text="LinearAnionPi")
    nb.add(pagePlanarAnionPi, text="PlanarAnionPi")
    nb.add(pageQM, text="QM assistant")
    nb.add(pageJobStatus, text="Job monitor")

    nb.grid(column=0, row=0, columnspan=20)

    supramolecularComposition = SupramolecularComposition(
        pageAnionPi, pagePiPi, pageCationPi, pageAnionCation, pageHBonds,
        pageMetalLigand, pageLinearAnionPi, pagePlanarAnionPi, pageQM,
        pageJobStatus)

    ######################
    # GENERAL
    ######################

    def readLogDir():
        appData["logDir"] = tkFileDialog.askdirectory()
        if not appData["logDir"]:
            print("nihuhu")
            return

        ent_logDir.configure(state="normal")
        ent_logDir.delete(0, "end")
        ent_logDir.insert(0, appData["logDir"])
        ent_logDir.configure(state="readonly")

        supramolecularComposition.readAllLogsFromDir(appData["logDir"])

    but_readLogDir = Tkinter.Button(self,
                                    width=20,
                                    text="Read log Dir",
                                    command=readLogDir)
    but_readLogDir.grid(row=2, column=0, columnspan=2)

    ent_logDir = Tkinter.Entry(self, width=45)
    ent_logDir.configure(state="readonly")
    ent_logDir.grid(row=2, column=2, columnspan=4)

    def selectCif():
        appData["cifDir"] = tkFileDialog.askdirectory()
        if not appData["cifDir"]:
            print("nihuhu")
            return

        ent_cifDir.configure(state="normal")
        ent_cifDir.delete(0, "end")
        ent_cifDir.insert(0, appData["cifDir"])
        ent_cifDir.configure(state="readonly")

        supramolecularComposition.selectCifDir(appData["cifDir"])

    but_cifDir = Tkinter.Button(self,
                                width=10,
                                command=selectCif,
                                text="Cif dir")
    but_cifDir.grid(row=2, column=6)

    ent_cifDir = Tkinter.Entry(self, width=45)
    ent_cifDir.configure(state="readonly")
    ent_cifDir.grid(row=2, column=7, columnspan=3)

    def setParellelSelection():
        state = var_parallelSelection.get()
        supramolecularComposition.setParallelSelection(state)

    lab_parallelSelection = Tkinter.Label(self, text="Parallel selection")
    lab_parallelSelection.grid(row=2, column=10)

    var_parallelSelection = Tkinter.IntVar()
    chk_parallelSelection = Tkinter.Checkbutton(self,
                                                variable=var_parallelSelection,
                                                command=setParellelSelection)
    chk_parallelSelection.grid(row=2, column=11)

    actionMenu = {}

    column = 1

    lab_usePage = Tkinter.Label(self, width=10, text="Use:")
    lab_usePage.grid(row=4, column=0)

    lab_doNotUsePage = Tkinter.Label(self, width=10, text="Exclude:")
    lab_doNotUsePage.grid(row=5, column=0)

    for label in supramolecularComposition.actionLabels:
        actionMenu[label] = {}

        actionMenu[label]["label"] = Tkinter.Label(self, text=label)
        actionMenu[label]["label"].grid(row=3, column=column)

        actual_row = 4

        actionMenu[label]["checkValue"] = Tkinter.IntVar()
        actionMenu[label]["checkbox"] = Tkinter.Checkbutton(
            self, variable=actionMenu[label]["checkValue"])
        actionMenu[label]["checkbox"].grid(row=actual_row, column=column)

        actual_row += 1

        actionMenu[label]["checkValueExclude"] = Tkinter.IntVar()
        actionMenu[label]["checkboxExclude"] = Tkinter.Checkbutton(
            self, variable=actionMenu[label]["checkValueExclude"])
        actionMenu[label]["checkboxExclude"].grid(row=actual_row,
                                                  column=column)

        column += 1

    lab_showInt = Tkinter.Label(self, width=10, text="Show:")
    lab_showInt.grid(row=6, column=0)

    showMenu = {}
    column = 1

    for label in supramolecularComposition.actionLabels:
        showMenu[label] = {}

        showMenu[label]["checkValue"] = Tkinter.IntVar()
        showMenu[label]["checkbox"] = Tkinter.Checkbutton(
            self, variable=showMenu[label]["checkValue"])
        showMenu[label]["checkbox"].grid(row=6, column=column)

        column += 1

    def mergeResults():
        supramolecularComposition.merge(actionMenu)

    ent_recordingState = Tkinter.Entry(self, width=20)
    ent_recordingState.grid(row=3, column=9, columnspan=2)
    ent_recordingState.insert(0, "Not recording")
    ent_recordingState.configure(state="readonly")

    def startRecording():
        ent_recordingState.configure(state="normal")
        ent_recordingState.delete(0, "end")
        ent_recordingState.insert(0, "Recording")
        ent_recordingState.configure(state="readonly")

        supramolecularComposition.startRecording()

    but_startRecording = Tkinter.Button(self,
                                        width=20,
                                        text="Start recording",
                                        command=startRecording)
    but_startRecording.grid(row=3, column=11, columnspan=2)

    def stopRecording():
        ent_recordingState.configure(state="normal")
        ent_recordingState.delete(0, "end")
        ent_recordingState.insert(0, "Not recording")
        ent_recordingState.configure(state="readonly")

        supramolecularComposition.stopRecording()

    but_stopRecording = Tkinter.Button(self,
                                       width=20,
                                       text="Stop recording",
                                       command=stopRecording)
    but_stopRecording.grid(row=4, column=11, columnspan=2)

    but_merge = Tkinter.Button(self,
                               width=20,
                               text="Merge!",
                               command=mergeResults)
    but_merge.grid(row=5, column=9, columnspan=2)

    def showAllInteractions():
        supramolecularComposition.showAll(showMenu)

    but_showMany = Tkinter.Button(self,
                                  width=20,
                                  text="Show",
                                  command=showAllInteractions)
    but_showMany.grid(row=6, column=9, columnspan=2)

    but_saveState = Tkinter.Button(self,
                                   width=20,
                                   text="Save GUI state",
                                   command=supramolecularComposition.saveState)
    but_saveState.grid(row=5, column=11, columnspan=2)

    but_loadState = Tkinter.Button(self,
                                   width=20,
                                   text="Load GUI state",
                                   command=supramolecularComposition.loadState)
    but_loadState.grid(row=6, column=11, columnspan=2)

    #INDYVIDUALS
    lab_anionGroupAsIndyviduals = Tkinter.Label(
        self, width=30, text="Anion's groups as indyviduals:")
    lab_anionGroupAsIndyviduals.grid(row=7, column=1, columnspan=3)

    chk_anionGroupsAsIndyviduals = Tkinter.Checkbutton(
        self, variable=supramolecularComposition.anionsAsIndyviduals)
    chk_anionGroupsAsIndyviduals.grid(row=7, column=4)

    lab_ringsAsIndyviduals = Tkinter.Label(
        self, width=30, text="Residues's rings as indyviduals:")
    lab_ringsAsIndyviduals.grid(row=7, column=5, columnspan=2)

    chk_ringsAsIndyviduals = Tkinter.Checkbutton(
        self, variable=supramolecularComposition.residuesRingsAsIndyviduals)
    chk_ringsAsIndyviduals.grid(row=7, column=7)
    ######################
    # ALL
    ######################

    supramolecularComposition.grid()
    #    canvas.configure(scrollregion = canvas.bbox("all"))

    if simulation:
        self.mainloop()
Ejemplo n.º 17
0
def fetchdialog():
    app = plugins.get_pmgapp()
    root = plugins.get_tk_root()

    self = Tkinter.Toplevel(root)
    self.title('PDB Loader Service')
    self.minsize(250, 0)
    self.resizable(0, 0)
    outer = self

    pad = 4

    type_options = [
        "cif (mmCIF)",
        "pdb (Asymmetric Unit)",
        "pdb1 (Biological Unit)",
        "2fofc (Density)",
        "fofc (Difference Density)",
        "cid (PubChem Compound)",
        "sid (PubChem Substance)",
        "emd (EMDB Density)",
        "cc (Chemical Component)",
    ]

    var_code = Tkinter.StringVar(self)
    var_chain = Tkinter.StringVar(self)
    var_assembly = Tkinter.StringVar(self, cmd.get('assembly'))
    var_name = Tkinter.StringVar(self)
    var_type = Tkinter.StringVar(self, type_options[0])
    var_keep = Tkinter.BooleanVar(
        self, not cmd.get_setting_boolean('autoclose_dialogs'))

    def callback(*args):
        code = var_code.get()
        type = get_trunc(var_type)
        if type in ('pdb', 'cif'):
            code += var_chain.get()
        if type == 'cif':
            cmd.set('assembly', var_assembly.get())
        try:
            result = cmd.fetch(code, var_name.get(), type=type)
            if result == -1:
                raise CmdException('You entered an invalid pdb code: ' + code)
        except CmdException as e:
            tkMessageBox.showerror('Error', str(e), parent=self)
            return
        cmd.log('fetch %s, type=%s, async=0\n' % (code, type))
        if not var_keep.get():
            self.destroy()

    def callback_type(*args):
        v = get_trunc(var_type)
        if v.startswith('pdb') or v.endswith('fofc') or v.startswith('cif'):
            but_code.configure(width=4)
        else:
            but_code.configure(width=20)
        if v in ('pdb', 'cif'):
            frame_pdb.pack(side=LEFT)
        else:
            frame_pdb.pack_forget()
        if v == 'cif':
            frame_assembly.pack(side=LEFT)
        else:
            frame_assembly.pack_forget()

    def makerow(label=None, parent=None, **kwargs):
        master = Tkinter.Frame(parent or outer)
        master.pack(fill=Tkinter.X, **kwargs)
        if label:
            Tkinter.Label(master, text=label).pack(side=LEFT)
        return master

    padkw = {'padx': pad, 'pady': (pad, 0)}

    master = makerow("Type:", **padkw)
    but_type = Tkinter.OptionMenu(master,
                                  var_type,
                                  *type_options,
                                  command=callback_type).pack(side=LEFT)

    master = makerow("Code:", **padkw)
    but_code = Tkinter.Entry(master, textvariable=var_code, width=4)
    but_code.bind("<Return>", callback)
    but_code.pack(side=LEFT)

    frame_pdb = makerow("Chain:", master, side=LEFT, padx=8)
    but_chain = Tkinter.Entry(frame_pdb, textvariable=var_chain, width=4)
    but_chain.bind("<Return>", callback)
    but_chain.pack(side=LEFT)

    frame_assembly = makerow("Assembly:", master, side=LEFT, padx=8)
    but_assembly = Tkinter.Entry(frame_assembly,
                                 textvariable=var_assembly,
                                 width=4)
    but_assembly.bind("<Return>", callback)
    but_assembly.pack(side=LEFT)

    frame_name = makerow("Name of new object:", **padkw)
    but_name = Tkinter.Entry(frame_name, textvariable=var_name, width=8)
    but_name.bind("<Return>", callback)
    but_name.pack(side=LEFT)

    master = makerow(padx=pad, pady=(2 * pad, 0))
    but_ok = Tkinter.Button(master, width=10, text="OK", command=callback)
    but_cancel = Tkinter.Button(master,
                                width=10,
                                text="Cancel",
                                command=self.destroy)

    but_cancel.pack(side=RIGHT, fill=Tkinter.X)
    but_ok.pack(side=RIGHT, fill=Tkinter.X)

    master = makerow(padx=pad, pady=(2, pad))
    but_keep = Tkinter.Checkbutton(master,
                                   text="Keep dialog open",
                                   variable=var_keep)
    but_keep.pack(side=RIGHT)

    but_code.focus_set()
Ejemplo n.º 18
0
 def edit_pymolrc(self):
     from . import TextEditor
     from pymol import plugins
     TextEditor.edit_pymolrc(plugins.get_pmgapp())
Ejemplo n.º 19
0
 def edit_pymolrc(self):
     from . import TextEditor
     from pymol import plugins
     TextEditor.edit_pymolrc(plugins.get_pmgapp())
Ejemplo n.º 20
0
Archivo: gui.py Proyecto: evonove/pymol
def get_pmgapp():
    '''
    TODO move to this module
    '''
    from pymol import plugins
    return plugins.get_pmgapp()