# ------------------------------------------------------------------ class ModuleInfoDialog(Form): def __init__(self, docs): Form.__init__(self) self.ClientSize = Size(400, 400) self.Text = "Module Details" self.Icon = Icon(UIGlobal.ApplicationIcon) infoPane = ModuleInfoPane() infoPane.SetFromDocs(docs) self.Controls.Add(infoPane) # ------------------------------------------------------------------ if __name__ == "__main__": import FTModules mm = FTModules.ModuleManager() mm.LoadAll() mb = ModuleBrowser(mm) form = Form() form.ClientSize = Size(500, 300) form.Text = "Test of Module Browser" form.Controls.Add(mb) Application.Run(form)
# ------------------------------------------------------------------ class ModuleInfoDialog(Form): def __init__(self, docs): Form.__init__(self) self.ClientSize = Size(400, 400) self.Text = "Module Details" self.Icon = Icon(UIGlobal.ApplicationIcon) infoPane = ModuleInfoPane() infoPane.SetFromDocs(docs) self.Controls.Add(infoPane) # ------------------------------------------------------------------ if __name__ == "__main__": import FTModules mm = FTModules.ModuleManager() mm.LoadAll() mb = ModuleBrowser(mm) form = Form() form.ClientSize = Size(500, 300) form.Text = "Test of Module Browser" form.Controls.Add(mb) Application.Run(form)
def draw(self, show=True, filename=None, update=False, usecoords=False): """Create a 2D depiction of the molecule. Optional parameters: show -- display on screen (default is True) filename -- write to file (default is None) update -- update the coordinates of the atoms to those determined by the structure diagram generator (default is False) usecoords -- don't calculate 2D coordinates, just use the current coordinates (default is False) Tkinter and Python Imaging Library are required for image display. """ if update: mol = self.Mol else: mol = self.Mol.clone() if not usecoords: mol.layout() if show or filename: renderer = IndigoRenderer(indigo) indigo.setOption("render-output-format", "png") indigo.setOption("render-margins", 10, 10) indigo.setOption("render-coloring", "True") indigo.setOption("render-image-size", 300, 300) indigo.setOption("render-background-color", "1.0, 1.0, 1.0") if self.title: indigo.setOption("render-comment", self.title) if filename: filedes = None else: filedes, filename = tempfile.mkstemp() renderer.renderToFile(mol, filename) if show: if sys.platform[:4] == "java": image = javax.imageio.ImageIO.read(java.io.File(filename)) frame = javax.swing.JFrame(visible=1) frame.getContentPane().add( javax.swing.JLabel(javax.swing.ImageIcon(image))) frame.setSize(300, 300) frame.setDefaultCloseOperation( javax.swing.WindowConstants.DISPOSE_ON_CLOSE) frame.show() elif sys.platform[:3] == "cli": if filedes: errormessage = ( "It is only possible to show the molecule if you " "provide a filename. The reason for this is that I kept " "having problems when using temporary files.") raise RuntimeError(errormessage) form = Form() form.ClientSize = Size(300, 300) form.Text = self.title image = Image.FromFile(filename) box = PictureBox() box.SizeMode = PictureBoxSizeMode.StretchImage box.Image = image box.Dock = DockStyle.Fill form.Controls.Add(box) form.Show() Application.Run(form) else: if not PILtk: errormessage = ( "Tkinter or Python Imaging " "Library not found, but is required for image " "display. See installation instructions for " "more information.") raise ImportError(errormessage) root = tk.Tk() root.title((hasattr(self, "title") and self.title) or self.__str__().rstrip()) frame = tk.Frame(root, colormap="new", visual='truecolor').pack() image = PIL.open(filename) imagedata = PILtk.PhotoImage(image) label = tk.Label(frame, image=imagedata).pack() quitbutton = tk.Button( root, text="Close", command=root.destroy).pack(fill=tk.X) root.mainloop() if filedes: os.close(filedes) os.remove(filename)
self.FormClosing += self.__OnFormClosing def __OnLoad(self, sender, event): self.cmPanel.SetFocusOnCurrentCollection() def __OnCollectionActivated(self, collectionName): # make selection available to caller self.activatedCollection = collectionName self.Close() def __OnFormClosing(self, sender, event): self.activatedCollection = self.cmPanel.currentCollection self.cmPanel.SaveAll() # ------------------------------------------------------------------ if __name__ == "__main__": collections = FTCollections.CollectionsManager() mm = FTModules.ModuleManager() mm.LoadAll() cmPanel = CollectionsManagerUI(collections, mm, None) form = Form() form.ClientSize = Size(600, 550) form.Text = "Test of Collections Manager" form.Controls.Add(cmPanel) Application.Run(form)
def draw(self, show=True, filename=None, update=False, usecoords=False): """Create a 2D depiction of the molecule. Optional parameters: show -- display on screen (default is True) filename -- write to file (default is None) update -- update the coordinates of the atoms to those determined by the structure diagram generator (default is False) usecoords -- don't calculate 2D coordinates, just use the current coordinates (default is False) Tkinter and Python Imaging Library are required for image display. """ if update: mol = self.Mol else: mol = self.Mol.clone() if not usecoords: mol.layout() if show or filename: renderer = IndigoRenderer(indigo) indigo.setOption("render-output-format", "png") indigo.setOption("render-margins", 10, 10) indigo.setOption("render-coloring", "True") indigo.setOption("render-image-size", 300, 300) indigo.setOption("render-background-color", "1.0, 1.0, 1.0") if self.title: indigo.setOption("render-comment", self.title) if filename: filedes = None else: filedes, filename = tempfile.mkstemp() renderer.renderToFile(mol, filename) if show: if sys.platform[:4] == "java": image = javax.imageio.ImageIO.read(java.io.File(filename)) frame = javax.swing.JFrame(visible=1) frame.getContentPane().add(javax.swing.JLabel(javax.swing.ImageIcon(image))) frame.setSize(300,300) frame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE) frame.show() elif sys.platform[:3] == "cli": if filedes: errormessage = ("It is only possible to show the molecule if you " "provide a filename. The reason for this is that I kept " "having problems when using temporary files.") raise RuntimeError(errormessage) form = Form() form.ClientSize = Size(300, 300) form.Text = self.title image = Image.FromFile(filename) box = PictureBox() box.SizeMode = PictureBoxSizeMode.StretchImage box.Image = image box.Dock = DockStyle.Fill form.Controls.Add(box) form.Show() Application.Run(form) else: if not PILtk: errormessage = ("Tkinter or Python Imaging " "Library not found, but is required for image " "display. See installation instructions for " "more information.") raise ImportError, errormessage root = tk.Tk() root.title((hasattr(self, "title") and self.title) or self.__str__().rstrip()) frame = tk.Frame(root, colormap="new", visual='truecolor').pack() image = PIL.open(filename) imagedata = PILtk.PhotoImage(image) label = tk.Label(frame, image=imagedata).pack() quitbutton = tk.Button(root, text="Close", command=root.destroy).pack(fill=tk.X) root.mainloop() if filedes: os.close(filedes) os.remove(filename)
self.Controls.Add(self.cmPanel) self.FormClosing += self.__OnFormClosing def __OnLoad(self, sender, event): self.cmPanel.SetFocusOnCurrentCollection() def __OnCollectionActivated(self, collectionName): # make selection available to caller self.activatedCollection = collectionName self.Close() def __OnFormClosing(self, sender, event): self.activatedCollection = self.cmPanel.currentCollection self.cmPanel.SaveAll() # ------------------------------------------------------------------ if __name__ == "__main__": collections = FTCollections.CollectionsManager() mm = FTModules.ModuleManager() mm.LoadAll() cmPanel = CollectionsManagerUI(collections, mm, None) form = Form() form.ClientSize = Size(600, 550) form.Text = "Test of Collections Manager" form.Controls.Add(cmPanel) Application.Run(form)