Exemplo n.º 1
0
    def run(*_):
        for fmt in filters:
            w = getattr(form, 'format_' + fmt)
            if w.isChecked():
                break
        fname = getSaveFileNameWithExt(parent,
                'Save As...', parent.initialdir,
                filter=filters[fmt])
        if not fname:
            return

        parent.initialdir = os.path.dirname(fname)

        if fmt == 'png':
            parent.cmd.mpng(fname,
                    width=form.input_width.value(),
                    height=form.input_height.value(),
                    mode=2 if form.input_ray.isChecked() else 1,
                    quiet=0, modal=-1)
        else:
            mode = 'ray' if form.input_ray.isChecked() else 'draw'
            encoder = form.input_encoder.currentText()

            parent.cmd.movie.produce(fname,
                    width=form.input_width.value(),
                    height=form.input_height.value(),
                    quality=form.input_quality.value(),
                    mode=mode, encoder=encoder,
                    quiet=0)
Exemplo n.º 2
0
 def log_open(self, fname='', mode='w'):
     if not fname:
         fname = getSaveFileNameWithExt(self, 'Open Logfile...', self.initialdir,
                                 filter=';;'.join(self.LOG_FORMATS))
     if fname:
         self.initialdir = os.path.dirname(fname)
         self.cmd.log_open(fname, mode)
Exemplo n.º 3
0
 def run_save():
     fname = getSaveFileNameWithExt(self, 'Save As...', self.initialdir,
             filter='PNG File (*.png)')
     if not fname:
         return
     self.initialdir = os.path.dirname(fname)
     self.cmd.png(fname, prior=1, dpi=form.input_dpi.currentText())
Exemplo n.º 4
0
 def _file_save(self, filter, format):
     fname = getSaveFileNameWithExt(
         self,
         'Save As...',
         self.initialdir,
         filter=filter)
     if fname:
         self.cmd.save(fname, format=format, quiet=0)
Exemplo n.º 5
0
    def run():
        name = form.input_name.currentText()

        fname = getSaveFileNameWithExt(self,
            'Save As...',
            self.initialdir,
            filter=';;'.join(formats))

        if not fname:
            return

        self.cmd.save(fname, name, -1, quiet=0)
        form._dialog.close()
Exemplo n.º 6
0
 def session_save_as(self, fname=''):
     formats = [
         'PyMOL Session File (*.pse *.pze *.pse.gz)',
         'PyMOL Show File (*.psw *.pzw *.psw.gz)',
     ]
     if not fname:
         fname = getSaveFileNameWithExt(
             self,
             'Save Session As...',
             self.initialdir,
             filter=';;'.join(formats))
     if fname:
         self.initialdir = os.path.dirname(fname)
         self.cmd.save(fname, format='pse', quiet=0)
         self.recent_filenames_add(fname)
Exemplo n.º 7
0
    def run(*_):
        selection = form.input_selection.currentText() or default_selection
        state = int(form.input_state.currentText().split()[0])

        parent.cmd.set('pdb_conect_nodup',    not form.input_no_pdb_conect_nodup.isChecked())
        parent.cmd.set('pdb_conect_all',          form.input_pdb_conect_all.isChecked())
        parent.cmd.set('ignore_pdb_segi',     not form.input_no_ignore_pdb_segi.isChecked())
        parent.cmd.set('pdb_retain_ids',          form.input_pdb_retain_ids.isChecked())
        parent.cmd.set('retain_order',            form.input_retain_order.isChecked())

        if form.input_multi_state.isChecked():
            fmt = form.input_multi_state_fmt.text()
        elif form.input_multi_object.isChecked():
            fmt = form.input_multi_object_fmt.text()
        else:
            fmt = ''

        if fmt and form.input_multi_prompt.isChecked():
            fss = parent.cmd.multifilenamegen(fmt, selection, state)
        else:
            fss = [(fmt, selection, state)]

        for fname, selection, state in fss:
            fname = getSaveFileNameWithExt(parent,
                'Save Molecule As...',
                os.path.join(parent.initialdir, fname),
                filter=';;'.join(formats))

            if not fname:
                return

            parent.initialdir = os.path.dirname(fname)

            if form.input_multisave.isChecked():
                parent.cmd.multisave(fname, selection, state, quiet=0)
            elif '{' in os.path.basename(fname):
                parent.cmd.multifilesave(fname, selection, state, quiet=0)
            else:
                parent.cmd.save(fname, selection, state, quiet=0)
                parent.recent_filenames_add(fname)

        form._dialog.close()
Exemplo n.º 8
0
    def run():
        from pymol import exporting
        fname = getSaveFileNameWithExt(parent,
                                       'Save As...',
                                       parent.initialdir,
                                       filter='PNG File (*.png)')
        if not fname:
            return

        parent.initialdir = os.path.dirname(fname)

        rendering = form.input_rendering.currentIndex()
        ray = 0
        width, height, dpi = 0, 0, -1
        '''
        dpi = float(form.input_dpi.currentText())

        width = exporting._unit2px(
            form.input_width.value(), dpi,
            form.input_width_unit.currentText())
        height = exporting._unit2px(
            form.input_height.value(), dpi,
            form.input_height_unit.currentText())
        '''

        form._dialog.hide()

        if rendering == 1:
            parent.cmd.do('draw %d, %d' % (width, height))
            width = 0
            height = 0
        elif rendering == 2:
            parent.cmd.do('set opaque_background, 1')
            ray = 1
        elif rendering == 3:
            parent.cmd.do('set opaque_background, 0')
            ray = 1

        parent.cmd.sync()
        parent.cmd.do('png %s, %d, %d, %d, ray=%d' %
                      (fname, width, height, dpi, ray))
Exemplo n.º 9
0
    def run():
        from pymol import exporting
        fname = getSaveFileNameWithExt(parent, 'Save As...', parent.initialdir,
                                filter='PNG File (*.png)')
        if not fname:
            return

        parent.initialdir = os.path.dirname(fname)

        rendering = form.input_rendering.currentIndex()
        ray = 0
        width, height, dpi = 0, 0, -1

        '''
        dpi = float(form.input_dpi.currentText())

        width = exporting._unit2px(
            form.input_width.value(), dpi,
            form.input_width_unit.currentText())
        height = exporting._unit2px(
            form.input_height.value(), dpi,
            form.input_height_unit.currentText())
        '''

        form._dialog.hide()

        if rendering == 1:
            parent.cmd.do('draw %d, %d' % (width, height))
            width = 0
            height = 0
        elif rendering == 2:
            parent.cmd.do('set opaque_background, 1')
            ray = 1
        elif rendering == 3:
            parent.cmd.do('set opaque_background, 0')
            ray = 1

        parent.cmd.sync()
        parent.cmd.do(
            'png %s, %d, %d, %d, ray=%d' %
            (fname, width, height, dpi, ray))
Exemplo n.º 10
0
 def browse_filename():
     filename = getSaveFileNameWithExt(dialog,
                                       'Save As...',
                                       filter='PNG File (*.png)')
     if filename:
         form.input_filename.setText(filename)
Exemplo n.º 11
0
 def log_resume(self):
     fname = getSaveFileNameWithExt(self, 'Open Logfile...', self.initialdir,
                             filter=';;'.join(self.LOG_FORMATS))
     if fname:
         self.initialdir = os.path.dirname(fname)
         self.cmd.resume(fname)
Exemplo n.º 12
0
 def log_resume(self):
     fname = getSaveFileNameWithExt(self, 'Open Logfile...', self.initialdir,
                             filter=';;'.join(self.LOG_FORMATS))
     if fname:
         self.initialdir = os.path.dirname(fname)
         self.cmd.resume(fname)