Example #1
0
    def __init__(self, handle, create_jobject=True):
        "The entry point to the Activity"
        activity.Activity.__init__(self, handle, False)
        self.selected_journal_entry = None
        self.selected_path = None

        canvas = gtk.Notebook()
        canvas.props.show_border = True
        canvas.props.show_tabs = True
        canvas.show()

        self.ls_journal = gtk.ListStore(gobject.TYPE_STRING,
                                        gobject.TYPE_STRING,
                                        gobject.TYPE_PYOBJECT)
        tv_journal = gtk.TreeView(self.ls_journal)
        tv_journal.set_rules_hint(True)
        tv_journal.set_search_column(COLUMN_TITLE)
        self.selection_journal = tv_journal.get_selection()
        self.selection_journal.set_mode(gtk.SELECTION_BROWSE)
        self.selection_journal.connect("changed", self.selection_journal_cb)
        renderer = gtk.CellRendererText()
        renderer.set_property('wrap-mode', gtk.WRAP_WORD)
        renderer.set_property('wrap-width', 500)
        renderer.set_property('width', 500)
        self.col_journal = gtk.TreeViewColumn(_('Title'),
                                              renderer,
                                              text=COLUMN_TITLE)
        self.col_journal.set_sort_column_id(COLUMN_TITLE)
        tv_journal.append_column(self.col_journal)

        self.col_mime = gtk.TreeViewColumn(_('MIME'),
                                           renderer,
                                           text=COLUMN_MIME)
        self.col_mime.set_sort_column_id(COLUMN_MIME)
        tv_journal.append_column(self.col_mime)

        self.list_scroller_journal = gtk.ScrolledWindow(hadjustment=None,
                                                        vadjustment=None)
        self.list_scroller_journal.set_policy(gtk.POLICY_AUTOMATIC,
                                              gtk.POLICY_AUTOMATIC)
        self.list_scroller_journal.add(tv_journal)

        label_attributes = pango.AttrList()
        label_attributes.insert(pango.AttrSize(14000, 0, -1))
        label_attributes.insert(
            pango.AttrForeground(65535, 65535, 65535, 0, -1))

        tab1_label = gtk.Label(_("Journal"))
        tab1_label.set_attributes(label_attributes)
        tab1_label.show()
        tv_journal.show()
        self.list_scroller_journal.show()

        column_table = gtk.Table(rows=1, columns=2, homogeneous=False)

        image_table = gtk.Table(rows=2, columns=2, homogeneous=False)
        self.image = gtk.Image()
        image_table.attach(self.image,
                           0,
                           2,
                           0,
                           1,
                           xoptions=gtk.FILL | gtk.SHRINK,
                           yoptions=gtk.FILL | gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)

        self.btn_save = gtk.Button(_("Save"))
        self.btn_save.connect('button_press_event',
                              self.save_button_press_event_cb)
        image_table.attach(self.btn_save,
                           0,
                           1,
                           1,
                           2,
                           xoptions=gtk.SHRINK,
                           yoptions=gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)
        self.btn_save.props.sensitive = False
        self.btn_save.show()

        self.btn_delete = gtk.Button(_("Delete"))
        self.btn_delete.connect('button_press_event',
                                self.delete_button_press_event_cb)
        image_table.attach(self.btn_delete,
                           1,
                           2,
                           1,
                           2,
                           xoptions=gtk.SHRINK,
                           yoptions=gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)
        self.btn_delete.props.sensitive = False
        self.btn_delete.show()

        column_table.attach(image_table,
                            0,
                            1,
                            0,
                            1,
                            xoptions=gtk.FILL | gtk.SHRINK,
                            yoptions=gtk.SHRINK,
                            xpadding=10,
                            ypadding=10)

        entry_table = gtk.Table(rows=3, columns=2, homogeneous=False)

        title_label = gtk.Label(_("Title"))
        entry_table.attach(title_label,
                           0,
                           1,
                           0,
                           1,
                           xoptions=gtk.SHRINK,
                           yoptions=gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)
        title_label.show()

        self.title_entry = gtk.Entry(max=0)
        entry_table.attach(self.title_entry,
                           1,
                           2,
                           0,
                           1,
                           xoptions=gtk.FILL | gtk.SHRINK,
                           yoptions=gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)
        self.title_entry.connect('key_press_event', self.key_press_event_cb)
        self.title_entry.show()

        description_label = gtk.Label(_("Description"))
        entry_table.attach(description_label,
                           0,
                           1,
                           1,
                           2,
                           xoptions=gtk.SHRINK,
                           yoptions=gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)
        description_label.show()

        self.description_textview = gtk.TextView()
        self.description_textview.set_wrap_mode(gtk.WRAP_WORD)
        entry_table.attach(self.description_textview,
                           1,
                           2,
                           1,
                           2,
                           xoptions=gtk.EXPAND | gtk.FILL | gtk.SHRINK,
                           yoptions=gtk.EXPAND | gtk.FILL | gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)
        self.description_textview.props.accepts_tab = False
        self.description_textview.connect('key_press_event',
                                          self.key_press_event_cb)
        self.description_textview.show()

        tags_label = gtk.Label(_("Tags"))
        entry_table.attach(tags_label,
                           0,
                           1,
                           2,
                           3,
                           xoptions=gtk.SHRINK,
                           yoptions=gtk.SHRINK,
                           xpadding=10,
                           ypadding=10)
        tags_label.show()

        self.tags_textview = gtk.TextView()
        self.tags_textview.set_wrap_mode(gtk.WRAP_WORD)
        entry_table.attach(self.tags_textview,
                           1,
                           2,
                           2,
                           3,
                           xoptions=gtk.FILL,
                           yoptions=gtk.EXPAND | gtk.FILL,
                           xpadding=10,
                           ypadding=10)
        self.tags_textview.props.accepts_tab = False
        self.tags_textview.connect('key_press_event', self.key_press_event_cb)
        self.tags_textview.show()

        entry_table.show()

        self.scroller_entry = gtk.ScrolledWindow(hadjustment=None,
                                                 vadjustment=None)
        self.scroller_entry.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scroller_entry.add_with_viewport(entry_table)
        self.scroller_entry.show()

        column_table.attach(self.scroller_entry,
                            1,
                            2,
                            0,
                            1,
                            xoptions=gtk.FILL | gtk.EXPAND | gtk.SHRINK,
                            yoptions=gtk.FILL | gtk.EXPAND | gtk.SHRINK,
                            xpadding=10,
                            ypadding=10)
        image_table.show()
        column_table.show()

        vbox = gtk.VBox(homogeneous=True, spacing=5)
        vbox.pack_start(column_table)
        vbox.pack_end(self.list_scroller_journal)

        canvas.append_page(vbox, tab1_label)

        self._filechooser = gtk.FileChooserWidget(
            action=gtk.FILE_CHOOSER_ACTION_OPEN, backend=None)
        self._filechooser.set_current_folder("/media")
        self.copy_button = gtk.Button(_("Copy File To The Journal"))
        self.copy_button.connect('clicked', self.create_journal_entry)
        self.copy_button.show()
        self._filechooser.set_extra_widget(self.copy_button)
        preview = gtk.Image()
        self._filechooser.set_preview_widget(preview)
        self._filechooser.connect("update-preview", self.update_preview_cb,
                                  preview)
        tab2_label = gtk.Label(_("Files"))
        tab2_label.set_attributes(label_attributes)
        tab2_label.show()
        canvas.append_page(self._filechooser, tab2_label)

        self.set_canvas(canvas)
        self.show_all()

        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False
        self.set_toolbox(toolbox)
        toolbox.show()

        self.load_journal_table()

        bus = dbus.SessionBus()
        remote_object = bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH)
        _datastore = dbus.Interface(remote_object, DS_DBUS_INTERFACE)
        _datastore.connect_to_signal('Created', self.datastore_created_cb)
        _datastore.connect_to_signal('Updated', self.datastore_updated_cb)
        _datastore.connect_to_signal('Deleted', self.datastore_deleted_cb)

        self.selected_journal_entry = None
Example #2
0
def save(widget, graph):
    parent = common.get_toplevel_window()
    dia = gtk.Dialog(
        _('Save As'), parent,
        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
    dia.set_icon(TRYTON_ICON)
    dia.set_has_separator(True)
    dia.set_default_response(gtk.RESPONSE_OK)

    dia.vbox.set_spacing(5)
    dia.vbox.set_homogeneous(False)

    title = gtk.Label('<b>' + _('Image Size') + '</b>')
    title.set_alignment(0.0, 0.5)
    title.set_use_markup(True)
    dia.vbox.pack_start(title)

    table = gtk.Table(2, 2)
    table.set_col_spacings(3)
    table.set_row_spacings(3)
    table.set_border_width(1)
    table.attach(gtk.Label(_('Width:')),
                 0,
                 1,
                 0,
                 1,
                 yoptions=False,
                 xoptions=gtk.FILL)
    spinwidth = gtk.SpinButton(
        gtk.Adjustment(400.0, 0.0, sys.maxint, 1.0, 10.0))
    spinwidth.set_numeric(True)
    spinwidth.set_activates_default(True)
    table.attach(spinwidth, 1, 2, 0, 1, yoptions=False, xoptions=gtk.FILL)
    table.attach(gtk.Label(_('Height:')),
                 0,
                 1,
                 1,
                 2,
                 yoptions=False,
                 xoptions=gtk.FILL)
    spinheight = gtk.SpinButton(
        gtk.Adjustment(200.0, 0.0, sys.maxint, 1.0, 10.0))
    spinheight.set_numeric(True)
    spinheight.set_activates_default(True)
    table.attach(spinheight, 1, 2, 1, 2, yoptions=False, xoptions=gtk.FILL)
    dia.vbox.pack_start(table)

    filechooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE, None)
    filechooser.set_current_folder(CONFIG['client.default_path'])
    filter = gtk.FileFilter()
    filter.set_name(_('PNG image (*.png)'))
    filter.add_mime_type('image/png')
    filter.add_pattern('*.png')
    filechooser.add_filter(filter)
    dia.vbox.pack_start(filechooser)

    dia.show_all()

    while True:
        response = dia.run()
        width = spinwidth.get_value_as_int()
        height = spinheight.get_value_as_int()
        filename = filechooser.get_filename()
        if filename:
            filename = filename.decode('utf-8')
            try:
                CONFIG['client.default_path'] = \
                    os.path.dirname(filename)
                CONFIG.save()
            except IOError:
                pass
        if response == gtk.RESPONSE_OK:
            if width and height and filename:
                if not filename.endswith('.png'):
                    filename = filename + '.png'
                try:
                    graph.export_png(filename, width, height)
                    break
                except MemoryError:
                    common.message(_('Image size too large!'), dia,
                                   gtk.MESSAGE_ERROR)
        else:
            break
    parent.present()
    dia.destroy()
    return
Example #3
0
    def __init__(self, image):
        self.image = image

        self.dialog = gimpui.Dialog(PLUGIN_TITLE, None, None, 0, None, None)
        self.dialog.set_transient()
        self.dialog.set_default_size(750, 600)
        self.dialog.set_border_width(8)
        dialog_position = retrieve_setting('dialog_position')
        if dialog_position is not None:
            self.dialog.move(*dialog_position)

        self.directory_chooser_label = gtk.Label()
        self.directory_chooser_label.set_markup(
            "<b>Choose output directory</b>")
        self.directory_chooser_label.set_alignment(0.0, 0.5)

        self.directory_chooser = gtk.FileChooserWidget(
            action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)

        self.hbox_file_format = gtk.HBox(homogeneous=False)
        self.hbox_file_format.set_spacing(5)
        self.file_format_label = gtk.Label()
        self.file_format_label.set_markup("<b>File format:</b>")
        self.file_format_label.set_alignment(0.0, 0.5)
        self.file_format_label.set_size_request(100, -1)
        self.file_format_entry = gtk.Entry()
        self.file_format_entry.set_size_request(100, -1)
        self.file_format_error_icon = gtk.Image()
        self.file_format_error_icon.set_from_stock(gtk.STOCK_STOP,
                                                   gtk.ICON_SIZE_BUTTON)
        self.file_format_error_message = gtk.Label()
        self.file_format_error_message.set_alignment(0.0, 0.5)
        self.hbox_file_format.pack_start(self.file_format_label, expand=False)
        self.hbox_file_format.pack_start(self.file_format_entry, expand=False)
        self.hbox_file_format.pack_start(self.file_format_error_icon,
                                         expand=False)
        self.hbox_file_format.pack_start(self.file_format_error_message,
                                         expand=False)

        self.hbox_export_options = gtk.HBox(homogeneous=False)
        self.hbox_export_options.set_spacing(5)
        self.url_label = gtk.Label()
        self.url_label.set_markup("<b>URL:</b>")
        self.url_label.set_alignment(0.0, 0.5)
        self.url_label.set_size_request(100, -1)
        self.url_entry = gtk.Entry()
        self.url_entry.set_size_request(100, -1)
        self.url_entry.set_tooltip_text(
            "Set the URL for the large image linkout")
        self.hbox_export_options.pack_start(self.url_label, expand=False)
        self.hbox_export_options.pack_start(self.url_entry, expand=True)

        self.hbox_action_area = gtk.HBox(homogeneous=False)
        self.export_layers_button = gtk.Button(label="Export Layers")
        self.export_layers_button.set_size_request(110, -1)
        self.cancel_button = gtk.Button(label="Cancel")
        self.cancel_button.set_size_request(110, -1)
        self.progress_bar = gimpui.ProgressBar()
        #     self.progress_bar = gtk.ProgressBar()

        self.hbox_action_area.set_spacing(8)
        self.hbox_action_area.set_border_width(8)
        self.hbox_action_area.pack_start(self.progress_bar,
                                         expand=True,
                                         fill=True)
        self.hbox_action_area.pack_end(self.export_layers_button,
                                       expand=False,
                                       fill=True)
        self.hbox_action_area.pack_end(self.cancel_button,
                                       expand=False,
                                       fill=True)

        self.dialog.vbox.set_spacing(3)
        self.dialog.vbox.pack_start(self.directory_chooser_label,
                                    expand=False,
                                    fill=False)
        self.dialog.vbox.pack_start(self.directory_chooser, padding=5)
        self.dialog.vbox.pack_start(self.hbox_file_format,
                                    expand=False,
                                    fill=False)
        self.dialog.vbox.pack_start(self.hbox_export_options,
                                    expand=False,
                                    fill=False)
        self.dialog.vbox.pack_start(self.hbox_action_area,
                                    expand=False,
                                    fill=False)

        self.dialog.connect("response", self.response)
        self.cancel_button.connect("clicked", self.cancel)
        self.export_layers_button.connect("clicked", self.export)

        # Assign last used values if last export was successful and
        # if there are any, otherwise use default values.
        selected_directory = retrieve_setting('output_directory')
        if selected_directory is not None:
            self.directory_chooser.set_current_folder(selected_directory)
        else:
            if self.image.uri is not None:
                self.directory_chooser.set_uri(self.image.uri)
            else:
                self.directory_chooser.set_current_folder(
                    ExportLayersPlugin.
                    PARAMS_DEFAULT_VALUES['output_directory'])
        self.file_format_entry.set_text(
            retrieve_setting(
                'file_format',
                ExportLayersPlugin.PARAMS_DEFAULT_VALUES['file_format']))

        self.dialog.show_all()
        # Action area is unused, the dialog bottom would otherwise be filled with empty space.
        self.dialog.action_area.hide()

        self.display_label_error_message()
        self.progress_bar.set_visible(False)
Example #4
0
    def __init__(self):
        gtk.Assistant.__init__(self)
        self.set_title(_('Import catalogue'))
        self.set_geometry_hints(min_width=800, min_height=600)

        self.connect('apply', self.apply_pressed)
        self.connect('cancel', self.cancel_pressed)
        self.connect('prepare', self.prepare)

        self.page0 = gtk.FileChooserWidget()

        fil = gtk.FileFilter()
        fil.set_name('All files (*)')
        fil.add_pattern('*')
        self.page0.add_filter(fil)

        fil = gtk.FileFilter()
        fil.set_name('FLOW catalogs (*.mctR)')
        fil.add_pattern('*.mctR')
        self.page0.add_filter(fil)

        self.page0.set_filter(self.page0.list_filters()[1])

        self.page0.set_current_folder('/home/observer/RTS2-F/CATALOGS/')

        self.append_page(self.page0)
        self.set_page_type(self.page0, gtk.ASSISTANT_PAGE_CONTENT)
        self.set_page_title(self.page0, _('Select catalog to import'))
        self.set_page_complete(self.page0, False)

        self.page0.connect('selection-changed', self.selection_activated)

        self.page_match = gtk.VBox()
        self.append_page(self.page_match)
        self.set_page_type(self.page_match, gtk.ASSISTANT_PAGE_CONTENT)
        self.set_page_title(self.page_match, _('Matching targets'))

        self.pm_l = gtk.Label()
        self.page_match.pack_start(self.pm_l, False, False)

        self.pm_t = gtk.ProgressBar()
        self.page_match.pack_start(self.pm_t, False, False)

        self.targetstore = jsontable.JsonTable(None,
                                               data={
                                                   'h': [{
                                                       "n": "Process",
                                                       "t": "b",
                                                       "c": 0
                                                   }, {
                                                       "n": "Create",
                                                       "t": "b",
                                                       "c": 1
                                                   }, {
                                                       "n": "Enable",
                                                       "t": "b",
                                                       "c": 2
                                                   }, {
                                                       "n": "Target Name",
                                                       "t": "s",
                                                       "c": 3
                                                   }, {
                                                       "n": "RA",
                                                       "t": "r",
                                                       "c": 4
                                                   }, {
                                                       "n": "DEC",
                                                       "t": "d",
                                                       "c": 5
                                                   }, {
                                                       "n": "ID",
                                                       "t": "n",
                                                       "prefix": "/targets/",
                                                       "href": 0,
                                                       "c": 6
                                                   }, {
                                                       "n": "Matched name",
                                                       "t": "s",
                                                       "c": 7
                                                   }, {
                                                       "n": "Matched RA",
                                                       "t": "r",
                                                       "c": 8
                                                   }, {
                                                       "n": "Matched DEC",
                                                       "t": "d",
                                                       "c": 9
                                                   }, {
                                                       "n": "Script",
                                                       "t": "s",
                                                       "c": 10
                                                   }, {
                                                       "n": "Object",
                                                       "t": "object",
                                                       "c": 11
                                                   }],
                                                   "d": []
                                               })

        self.targetstore.tv.get_column(0).get_cell_renderers()[0].set_property(
            'activatable', True)
        self.targetstore.tv.get_column(0).get_cell_renderers()[0].connect(
            'toggled', self.toggled_process)

        self.targetstore.tv.get_column(1).add_attribute(
            self.targetstore.tv.get_column(1).get_cell_renderers()[0],
            'activatable', 0)
        self.targetstore.tv.get_column(1).get_cell_renderers()[0].connect(
            'toggled', self.toggled_create)

        self.targetstore.tv.get_column(2).add_attribute(
            self.targetstore.tv.get_column(2).get_cell_renderers()[0],
            'activatable', 0)
        self.targetstore.tv.get_column(2).get_cell_renderers()[0].connect(
            'toggled', self.toggled_enabled)

        self.targetstore.tv.get_column(6).get_cell_renderers()[0].set_property(
            'editable', True)
        self.targetstore.tv.get_column(6).get_cell_renderers()[0].connect(
            'edited', self.match_edited)

        for i in range(1, self.targetstore.data.get_n_columns() - 1):
            self.targetstore.tv.get_column(i).add_attribute(
                self.targetstore.tv.get_column(i).get_cell_renderers()[0],
                'sensitive', 0)

        self.page_match.pack_end(self.targetstore, True, True)

        self.page_create_summary = gtk.ScrolledWindow()
        self.create_summary_text = gtk.TextView()

        self.page_create_summary.set_policy(gtk.POLICY_AUTOMATIC,
                                            gtk.POLICY_AUTOMATIC)
        self.page_create_summary.add(self.create_summary_text)

        self.append_page(self.page_create_summary)
        self.set_page_type(self.page_create_summary,
                           gtk.ASSISTANT_PAGE_CONFIRM)
        self.set_page_title(self.page_create_summary, _('Summary'))

        self.page_create = gtk.ScrolledWindow()
        self.create_text = gtk.TextView()

        self.page_create.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.page_create.add(self.create_text)

        self.append_page(self.page_create)
        self.set_page_type(self.page_create, gtk.ASSISTANT_PAGE_SUMMARY)
        self.set_page_title(self.page_create, _('Populating database'))

        self.pi = None
        self.program = None
        self.acqexp = 15

        # ID of created targets
        self.created_targets_id = []

        self.show_all()
Example #5
0
    def __init__(self, settings, config, sql=None, parent=None):
        self.settings = settings
        self.config = config
        self.parent = parent

        self.importer = SummaryImporter(config, sql, parent, self)

        self.vbox = gtk.VBox(False, 0)
        self.vbox.show()

        self.chooser = gtk.FileChooserWidget()
        self.chooser.set_filename(self.settings['bulkImport-defaultPath'])
        self.chooser.set_select_multiple(True)
        self.vbox.add(self.chooser)
        self.chooser.show()

        #    Table widget to hold the settings
        self.table = gtk.Table(rows=5, columns=5, homogeneous=False)
        self.vbox.add(self.table)
        self.table.show()

        #    label - tsc
        self.lab_filter = gtk.Label(_("Site filter:"))
        self.table.attach(self.lab_filter,
                          1,
                          2,
                          2,
                          3,
                          xpadding=0,
                          ypadding=0,
                          yoptions=gtk.SHRINK)
        self.lab_filter.show()
        self.lab_filter.set_justify(gtk.JUSTIFY_RIGHT)
        self.lab_filter.set_alignment(1.0, 0.5)

        #    ComboBox - filter
        self.cbfilter = gtk.combo_box_new_text()
        disabled_sites = []  # move disabled sites to bottom of list
        for w in self.config.hhcs:
            print "%s = '%s'" % (w, self.config.hhcs[w].summaryImporter)
            try:
                # Include sites with a tourney summary importer, and enabled
                if self.config.supported_sites[w].enabled and self.config.hhcs[
                        w].summaryImporter != '':
                    self.cbfilter.append_text(w)
                else:
                    disabled_sites.append(w)
            except:  # self.supported_sites[w] may not exist if hud_config is bad
                disabled_sites.append(w)
        for w in disabled_sites:
            if self.config.hhcs[w].summaryImporter != '':
                self.cbfilter.append_text(w)
        self.cbfilter.set_active(0)
        self.table.attach(self.cbfilter,
                          2,
                          3,
                          2,
                          3,
                          xpadding=10,
                          ypadding=1,
                          yoptions=gtk.SHRINK)
        self.cbfilter.show()

        #    button - Import
        self.load_button = gtk.Button(
            _('_Bulk Import'))  # todo: rename variables to import too
        self.load_button.connect('clicked', self.load_clicked,
                                 _('Import clicked'))
        self.table.attach(self.load_button,
                          2,
                          3,
                          4,
                          5,
                          xpadding=0,
                          ypadding=0,
                          yoptions=gtk.SHRINK)
        self.load_button.show()

        #    label - spacer (keeps rows 3 & 5 apart)
        self.lab_spacer = gtk.Label()
        self.table.attach(self.lab_spacer,
                          3,
                          5,
                          3,
                          4,
                          xpadding=0,
                          ypadding=0,
                          yoptions=gtk.SHRINK)
        self.lab_spacer.show()
Example #6
0
 def _create_gui_element(self, setting):
     return gtk.FileChooserWidget(
         action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
Example #7
0
  def _init_gui(self):
    self._dialog = gimpui.Dialog(title=pygimplib.config.PLUGIN_TITLE, role=pygimplib.config.PLUGIN_NAME)
    self._dialog.set_transient()
    self._dialog.set_default_size(*self._DIALOG_SIZE)
    self._dialog.set_border_width(self._DIALOG_BORDER_WIDTH)
    
    self._folder_chooser_label = gtk.Label()
    self._folder_chooser_label.set_markup("<b>" + _("Save in folder:") + "</b>")
    self._folder_chooser_label.set_alignment(0.0, 0.5)
    
    self._folder_chooser = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
    
    self._export_name_preview = gui_previews.ExportNamePreview(
      self._layer_exporter_for_previews,
      self._initial_layer_tree,
      self._settings['gui_session/export_name_preview_layers_collapsed_state'].value[self._image.ID],
      self._settings['main/selected_layers'].value[self._image.ID],
      self._settings['gui/displayed_tags'],
      on_selection_changed_func=self._on_name_preview_selection_changed,
      on_after_update_func=self._on_name_preview_after_update,
      on_after_edit_tags_func=self._on_name_preview_after_edit_tags)
    
    self._export_image_preview = gui_previews.ExportImagePreview(
      self._layer_exporter_for_previews,
      self._initial_layer_tree,
      self._settings['gui_session/export_image_preview_displayed_layers'].value[self._image.ID])
    
    self._vbox_folder_chooser = gtk.VBox(homogeneous=False)
    self._vbox_folder_chooser.set_spacing(self._DIALOG_VBOX_SPACING * 2)
    self._vbox_folder_chooser.pack_start(self._folder_chooser_label, expand=False, fill=False)
    self._vbox_folder_chooser.pack_start(self._folder_chooser)
    
    self._vpaned_previews = gtk.VPaned()
    self._vpaned_previews.pack1(self._export_name_preview.widget, resize=True, shrink=True)
    self._vpaned_previews.pack2(self._export_image_preview.widget, resize=True, shrink=True)
    
    self._frame_previews = gtk.Frame()
    self._frame_previews.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
    self._frame_previews.add(self._vpaned_previews)
    
    self._hpaned_chooser_and_previews = gtk.HPaned()
    self._hpaned_chooser_and_previews.pack1(self._vbox_folder_chooser, resize=True, shrink=False)
    self._hpaned_chooser_and_previews.pack2(self._frame_previews, resize=True, shrink=True)
    
    self._file_extension_label = gtk.Label()
    self._file_extension_label.set_markup(
      "<b>" + gobject.markup_escape_text(self._settings['main/file_extension'].display_name) + ":</b>")
    self._file_extension_label.set_alignment(0.0, 0.5)
    
    self._file_extension_entry = pggui_entries.FileExtensionEntry()
    self._file_extension_entry.set_width_chars(self._FILE_EXTENSION_ENTRY_WIDTH_CHARS)
    
    self._save_as_label = gtk.Label()
    self._save_as_label.set_markup("<b>" + _("Save as") + ":</b>")
    self._save_as_label.set_alignment(0.0, 0.5)
    
    self._dot_label = gtk.Label(".")
    self._dot_label.set_alignment(0.0, 1.0)
    
    self._filename_pattern_entry = pggui_entries.FilenamePatternEntry(
      exportlayers.LayerExporter.SUGGESTED_LAYER_FILENAME_PATTERNS,
      minimum_width_chars=self._FILENAME_PATTERN_ENTRY_MIN_WIDTH_CHARS,
      maximum_width_chars=self._FILENAME_PATTERN_ENTRY_MAX_WIDTH_CHARS,
      default_item=self._settings['main/layer_filename_pattern'].default_value)
    
    self._label_message = gtk.Label()
    self._label_message.set_alignment(0.0, 0.5)
    self._label_message.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
    
    self._menu_item_show_more_settings = gtk.CheckMenuItem(_("Show More Settings"))
    
    self._vpaned_settings = gtk.VPaned()
    
    self._settings.initialize_gui({
      'file_extension': [pgsetting.SettingGuiTypes.extended_entry, self._file_extension_entry],
      'dialog_position': [pgsetting.SettingGuiTypes.window_position, self._dialog],
      'dialog_size': [pgsetting.SettingGuiTypes.window_size, self._dialog],
      'show_more_settings': [pgsetting.SettingGuiTypes.check_menu_item, self._menu_item_show_more_settings],
      'chooser_and_previews_hpane_position': [
        pgsetting.SettingGuiTypes.paned_position, self._hpaned_chooser_and_previews],
      'previews_vpane_position': [
        pgsetting.SettingGuiTypes.paned_position, self._vpaned_previews],
      'settings_vpane_position': [
        pgsetting.SettingGuiTypes.paned_position, self._vpaned_settings],
      'layer_filename_pattern': [pgsetting.SettingGuiTypes.extended_entry, self._filename_pattern_entry]
    })
    
    self._current_directory_setting.set_gui(pgsetting.SettingGuiTypes.folder_chooser, self._folder_chooser)
    
    self._hbox_export_name_labels = gtk.HBox(homogeneous=False)
    self._hbox_export_name_labels.pack_start(self._file_extension_label, expand=False, fill=False)
    self._hbox_export_name_labels.pack_start(self._save_as_label, expand=False, fill=False)
    
    self._hbox_export_name_entries = gtk.HBox(homogeneous=False)
    self._hbox_export_name_entries.set_spacing(self._HBOX_EXPORT_NAME_ENTRIES_SPACING)
    self._hbox_export_name_entries.pack_start(self._filename_pattern_entry, expand=False, fill=False)
    self._hbox_export_name_entries.pack_start(self._dot_label, expand=False, fill=False)
    self._hbox_export_name_entries.pack_start(self._file_extension_entry, expand=False, fill=False)
    
    self._hbox_export_name = gtk.HBox(homogeneous=False)
    self._hbox_export_name.set_spacing(self._HBOX_EXPORT_LABELS_NAME_SPACING)
    self._hbox_export_name.pack_start(self._hbox_export_name_labels, expand=False, fill=False)
    self._hbox_export_name.pack_start(self._hbox_export_name_entries, expand=False, fill=False)
    
    self._hbox_export_name_and_message = gtk.HBox(homogeneous=False)
    self._hbox_export_name_and_message.set_spacing(self._HBOX_HORIZONTAL_SPACING)
    self._hbox_export_name_and_message.pack_start(self._hbox_export_name, expand=False, fill=False)
    self._hbox_export_name_and_message.pack_start(self._label_message, expand=True, fill=True)
    
    self._hbox_settings_checkbuttons = gtk.HBox(homogeneous=False)
    self._hbox_settings_checkbuttons.pack_start(self._settings['main/layer_groups_as_folders'].gui.element)
    self._hbox_settings_checkbuttons.pack_start(self._settings['main/use_image_size'].gui.element)
    self._hbox_settings_checkbuttons.pack_start(self._settings['main/only_visible_layers'].gui.element)
    
    self._vbox_more_settings_builtin = gtk.VBox(homogeneous=False)
    self._vbox_more_settings_builtin.set_spacing(self._MORE_SETTINGS_VERTICAL_SPACING)
    self._vbox_more_settings_builtin.pack_start(
      self._settings['main/process_tagged_layers'].gui.element, expand=False, fill=False)
    self._vbox_more_settings_builtin.pack_start(
      self._settings['main/export_only_selected_layers'].gui.element, expand=False, fill=False)
    
    self._scrolled_window_more_settings_builtin = gtk.ScrolledWindow()
    self._scrolled_window_more_settings_builtin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    self._scrolled_window_more_settings_builtin.add_with_viewport(self._vbox_more_settings_builtin)
    self._scrolled_window_more_settings_builtin.get_child().set_shadow_type(gtk.SHADOW_NONE)
    
    self._box_more_operations = gui_operations.OperationsBox(
      label_add_text=_("Add _Operations..."), spacing=self._MORE_SETTINGS_OPERATIONS_SPACING,
      settings=list(self._settings['main/more_operations'].iterate_all()),
      displayed_settings_names=self._settings['gui/displayed_builtin_operations'].value)
    
    self._box_more_filters = gui_operations.OperationsBox(
      label_add_text=_("Add _Filters..."), spacing=self._MORE_SETTINGS_OPERATIONS_SPACING,
      settings=list(self._settings['main/more_filters'].iterate_all()),
      displayed_settings_names=self._settings['gui/displayed_builtin_filters'].value)
    
    self._hbox_more_settings = gtk.HBox(homogeneous=True)
    self._hbox_more_settings.set_spacing(self._MORE_SETTINGS_HORIZONTAL_SPACING)
    self._hbox_more_settings.pack_start(self._scrolled_window_more_settings_builtin, expand=True, fill=True)
    self._hbox_more_settings.pack_start(self._box_more_operations.widget, expand=True, fill=True)
    self._hbox_more_settings.pack_start(self._box_more_filters.widget, expand=True, fill=True)
    
    self._vbox_basic_settings = gtk.VBox()
    self._vbox_basic_settings.set_spacing(self._DIALOG_VBOX_SPACING)
    self._vbox_basic_settings.pack_start(self._hpaned_chooser_and_previews)
    self._vbox_basic_settings.pack_start(self._hbox_export_name_and_message, expand=False, fill=False)
    self._vbox_basic_settings.pack_start(self._hbox_settings_checkbuttons, expand=False, fill=False)
    
    self._vpaned_settings.pack1(self._vbox_basic_settings, resize=True, shrink=False)
    self._vpaned_settings.pack2(self._hbox_more_settings, resize=False, shrink=True)
    
    self._button_export = self._dialog.add_button(_("_Export"), gtk.RESPONSE_OK)
    self._button_cancel = self._dialog.add_button(_("_Cancel"), gtk.RESPONSE_CANCEL)
    self._dialog.set_alternative_button_order([gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL])
    
    self._button_stop = gtk.Button()
    self._button_stop.set_label(_("_Stop"))
    
    self._label_button_settings = gtk.Label(_("_Settings"))
    self._label_button_settings.set_use_underline(True)
    
    self._hbox_button_settings = gtk.HBox()
    self._hbox_button_settings.pack_start(self._label_button_settings, expand=True, fill=True)
    self._hbox_button_settings.pack_start(
      gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_IN), expand=False, fill=False)
    
    self._button_settings = gtk.Button()
    self._button_settings.add(self._hbox_button_settings)
    
    self._menu_item_save_settings = gtk.MenuItem(_("Save Settings"))
    self._menu_item_reset_settings = gtk.MenuItem(_("Reset settings"))

    self._menu_settings = gtk.Menu()
    self._menu_settings.append(self._menu_item_show_more_settings)
    self._menu_settings.append(self._menu_item_save_settings)
    self._menu_settings.append(self._menu_item_reset_settings)
    self._menu_settings.show_all()

    self._dialog.action_area.pack_end(self._button_stop, expand=False, fill=False)
    self._dialog.action_area.pack_start(self._button_settings, expand=False, fill=False)
    self._dialog.action_area.set_child_secondary(self._button_settings, True)
    
    self._dialog.vbox.set_spacing(self._DIALOG_VBOX_SPACING)
    self._dialog.vbox.pack_start(self._vpaned_settings, expand=True, fill=True)
    self._dialog.vbox.pack_end(self._vbox_progress_bars, expand=False, fill=False)
    
    # Move the action area above the progress bar.
    self._dialog.vbox.reorder_child(self._dialog.action_area, -1)
    
    self._button_export.connect("clicked", self._on_button_export_clicked)
    self._button_cancel.connect("clicked", self._on_button_cancel_clicked)
    self._button_stop.connect("clicked", self._stop)
    self._dialog.connect("key-press-event", self._on_dialog_key_press)
    self._dialog.connect("delete-event", self._on_dialog_delete_event)
    
    self._button_settings.connect("clicked", self._on_button_settings_clicked)
    self._menu_item_show_more_settings.connect("toggled", self._on_menu_item_show_more_settings_toggled)
    self._menu_item_save_settings.connect("activate", self._on_save_settings_activate)
    self._menu_item_reset_settings.connect("activate", self._on_reset_settings_activate)
    
    self._file_extension_entry.connect(
      "changed", self._on_text_entry_changed,
      self._settings['main/file_extension'], "invalid_file_extension")
    self._filename_pattern_entry.connect(
      "changed", self._on_text_entry_changed,
      self._settings['main/layer_filename_pattern'], "invalid_layer_filename_pattern")
    
    self._dialog.connect("notify::is-active", self._on_dialog_is_active_changed)
    self._hpaned_chooser_and_previews.connect("notify::position", self._on_hpaned_position_changed)
    self._vpaned_previews.connect("notify::position", self._on_vpaned_position_changed)
    
    self._connect_setting_changes_to_previews()
    self._connect_setting_changes_to_operations_boxes()
    
    self._dialog.set_default_response(gtk.RESPONSE_CANCEL)
    
    self._dialog.vbox.show_all()
    self._vbox_progress_bars.hide()
    self._button_stop.hide()
    
    self._dialog.action_area.set_border_width(self._DIALOG_ACTION_AREA_BORDER_WIDTH)
    
    self._connect_visible_changed_for_previews()
    
    self._show_hide_more_settings()
    
    self._init_previews()
    
    self._dialog.set_focus(self._file_extension_entry)
    self._button_export.set_flags(gtk.CAN_DEFAULT)
    self._button_export.grab_default()
    self._filename_pattern_entry.set_activates_default(True)
    self._file_extension_entry.set_activates_default(True)
    # Place the cursor at the end of the text entry.
    self._file_extension_entry.set_position(-1)
    
    self._dialog.show()
Example #8
0
    def __init__(self,
                 mode,
                 title=None,
                 filename=None,
                 params=None,
                 pattern=False):
        debug.mainthreadTest()
        widgetscope.WidgetScope.__init__(self, None)
        self.dialog = gtklogger.Dialog()
        self.set_title(title)
        gtklogger.newTopLevelWidget(self.dialog, self.dialog.get_title())
        self.filechooser = gtk.FileChooserWidget(action=_modes[mode])
        self.dialog.set_default_size(500, 300)
        self.filechooser.show()
        self.dialog.vbox.pack_start(self.filechooser, expand=1, fill=1)
        gtklogger.setWidgetName(self.filechooser, "FileChooser")
        gtklogger.connect(self.filechooser, 'selection-changed',
                          self.selectionchangedCB)
        self.dialog.add_button(gtk.STOCK_OK, self.OK)
        self.dialog.add_button(gtk.STOCK_CANCEL, self.CANCEL)
        self.dialog.set_default_response(self.OK)

        self.pattern = (pattern and (mode == 'r'))
        if self.pattern:
            # TODO: Fix aesthetics of the widgets.
            self.filechooser.set_select_multiple(True)
            self.patternrow = gtk.HBox()
            self.patternrow.pack_start(gtk.Label("Pattern: "),
                                       expand=0,
                                       fill=0,
                                       padding=5)
            self.pattern_entry = gtk.Entry()
            self.pattern_entry.set_editable(1)
            self.pattern_entry.set_text("*")
            gtklogger.connect(self.pattern_entry, 'changed',
                              self.patternchangedCB)
            self.patternrow.pack_start(self.pattern_entry,
                                       expand=1,
                                       fill=1,
                                       padding=5)
            self.patternrow.show_all()

        if params is None:
            self.table = None
            if self.pattern:
                self.filechooser.set_extra_widget(self.patternrow)
        else:
            self.table = parameterwidgets.ParameterTable(params,
                                                         scope=self,
                                                         name="Parameters")
            self.sbcallback = switchboard.requestCallbackMain(
                ('validity', self.table), self.validityCB)
            if not self.pattern:
                self.filechooser.set_extra_widget(self.table.gtk)
            else:
                vbox = gtk.VBox()
                vbox.pack_start(self.patternrow)
                vbox.pack_start(self.table.gtk)
                vbox.show()
                self.filechooser.set_extra_widget(vbox)

        if filename is not None:
            self.filechooser.set_current_name(filename)
Example #9
0
    def __init__(self, handle):
        super(Sindiente, self).__init__(handle)
        #ventana
        self.nivel = None
        self.set_title(_('Sin Dientes'))
        self.carpeta_imagen = 'resources/personaje_'
        self.sugar_data = self.get_activity_root() + '/data/'
        self.connect('key-press-event', self._key_press_cb)

        #Barra de herramientas sugar

        toolbox = widgets.ActivityToolbox(self)
        self.set_toolbar_box(toolbox)
        toolbox.show()

        #general
        self.comprobar_interfaz = False
        self.modificar_text = pango.FontDescription("Bold 10")
        self._archivo_sugar()

        #contenedores
        self.contenedor = gtk.VBox()
        self.contenedor_superior = gtk.HBox()
        self.contenedor_inferior = gtk.HBox()
        self.contenedor.pack_start(self.contenedor_superior)
        self.contenedor.pack_start(self.contenedor_inferior, expand=False)
        self.subcontenedor = gtk.VBox()
        self.contenedor_nivel = gtk.VBox()
        self.contenedor_nivel_1 = gtk.VBox()
        self.contenedor_nivel_2 = gtk.VBox()
        self.contenedor_instruc = gtk.VBox()
        self.contenedor_instruc_1 = gtk.HBox()
        self.contenedor_instruc_2 = gtk.HBox()
        self.contenedor_instruc_3 = gtk.HBox()
        self.contenedor_instruc_4 = gtk.HBox()
        self.contenedor_np_v = gtk.VBox()
        self.contenedor_np_1 = gtk.HBox()
        self.contenedor_np_2 = gtk.HBox()

        #Elegir personaje
        self.elegir_personaje_v = gtk.VBox()
        self.elegir_personaje_1 = gtk.HBox()
        self.elegir_personaje_2 = gtk.HBox()
        self.boton_personaje_1 = gtk.HBox()
        self.boton_personaje_2 = gtk.HBox()

        self.text_boton_nino = _('Elegir')
        self.btn_nino_1 = gtk.Button(self.text_boton_nino)
        self.btn_nino_2 = gtk.Button(self.text_boton_nino)
        self.btn_nino_3 = gtk.Button(self.text_boton_nino)
        self.btn_nina_1 = gtk.Button(self.text_boton_nino)
        self.btn_nina_2 = gtk.Button(self.text_boton_nino)
        self.btn_nina_3 = gtk.Button(self.text_boton_nino)
        self.btn_nino_1.connect('clicked', self._btn_nino_1_cb)
        self.btn_nino_2.connect('clicked', self._btn_nino_2_cb)
        self.btn_nino_3.connect('clicked', self._btn_nino_3_cb)
        self.btn_nina_1.connect('clicked', self._btn_nina_1_cb)
        self.btn_nina_2.connect('clicked', self._btn_nina_2_cb)
        self.btn_nina_3.connect('clicked', self._btn_nina_3_cb)

        #niños
        self.personaje_label = gtk.Label(_("Elige un personaje"))
        self.personaje_label.modify_font(self.modificar_text)
        self.nino_1 = gtk.Image()
        self.nino_1.set_from_file('resources/personaje_1/00.png')
        self.nino_2 = gtk.Image()
        self.nino_2.set_from_file('resources/personaje_2/00.png')
        self.nino_3 = gtk.Image()
        self.nino_3.set_from_file('resources/personaje_3/00.png')

        self.nina_1 = gtk.Image()
        self.nina_1.set_from_file('resources/personaje_4/00.png')
        self.nina_2 = gtk.Image()
        self.nina_2.set_from_file('resources/personaje_5/00.png')
        self.nina_3 = gtk.Image()
        self.nina_3.set_from_file('resources/personaje_6/00.png')

        self.boton_personaje_1.pack_start(self.btn_nino_1, True, False)
        self.boton_personaje_1.pack_start(self.btn_nino_2, True, False)
        self.boton_personaje_1.pack_start(self.btn_nino_3, True, False)
        self.boton_personaje_2.pack_start(self.btn_nina_1, True, False)
        self.boton_personaje_2.pack_start(self.btn_nina_2, True, False)
        self.boton_personaje_2.pack_start(self.btn_nina_3, True, False)

        self.elegir_personaje_1.pack_start(self.nino_1)
        self.elegir_personaje_1.pack_start(self.nino_2)
        self.elegir_personaje_1.pack_start(self.nino_3)
        self.elegir_personaje_2.pack_start(self.nina_1)
        self.elegir_personaje_2.pack_start(self.nina_2)
        self.elegir_personaje_2.pack_start(self.nina_3)

        self.elegir_personaje_v.pack_start(self.personaje_label)
        self.elegir_personaje_v.pack_start(self.elegir_personaje_1)
        self.elegir_personaje_v.pack_start(self.boton_personaje_1, False)
        self.elegir_personaje_v.pack_start(self.elegir_personaje_2)
        self.elegir_personaje_v.pack_start(self.boton_personaje_2, False)
        self.elegir_personaje_v.show_all()
        self.set_canvas(self.elegir_personaje_v)

        #interface menu
        self.imagen_menu = gtk.Image()
        self.nivel_1 = gtk.Button(_('Animales'))
        self.nivel_1.connect('clicked', self._nivel_uno_cb, None)
        self.nivel_2 = gtk.Button(_('Plantas'))
        self.nivel_2.connect('clicked', self._nivel_dos_cb, None)
        self.nivel_3 = gtk.Button(_('Países'))
        self.nivel_3.connect('clicked', self._nivel_tres_cb, None)
        self.nivel_4 = gtk.Button(_('Sustantivos'))
        self.nivel_4.connect('clicked', self._nivel_cuatro_cb, None)
        self.nivel_5 = gtk.Button(_('Verbos'))
        self.nivel_5.connect('clicked', self._nivel_cinco_cb, None)
        self.nivel_6 = gtk.Button(_('Cosas'))
        self.nivel_6.connect('clicked', self._nivel_seis_cb, None)
        self.nivel_7 = gtk.Button(_('Valores Morales'))
        self.nivel_7.connect('clicked', self._nivel_siete_cb, None)
        self.importar_btn = gtk.Button(_('Agregar lista de palabra'))
        self.importar_btn.connect('clicked', self._importar_cb, None)
        self.instrucciones = gtk.Button(_('Instrucciones de juego'))
        self.instrucciones.connect('clicked', self._instrucciones_cb, None)
        self.nuevapalabra_btn = gtk.Button(_('Modo Versus'))
        self.nuevapalabra_btn.connect('clicked', self._nuevapalabra_cb, None)
        self.cambiar_personaje_btn = gtk.Button(_('Cambiar personaje'))
        self.cambiar_personaje_btn.connect('clicked',
                                           self._cambiar_personaje_cb)
        self.categoria_libre = gtk.Button(_('Categoría Personalizada'))
        self.categoria_libre.connect('clicked',
                                     self._categoria_personalizada_cb)
        self.bienvenida = gtk.Label(_('Bienvenido a \"Sin Diente\"'))
        self.bienvenida.modify_font(self.modificar_text)

        #agregando elementos de menú
        self.contenedor_nivel_h = gtk.HBox()
        self.contenedor_nivel.pack_start(self.bienvenida, False, padding=15)
        self.contenedor_nivel.pack_start(self.imagen_menu, False, padding=15)
        self.contenedor_nivel.pack_start(self.contenedor_nivel_h)
        self.contenedor_nivel_h.pack_start(self.contenedor_nivel_1, padding=20)
        self.contenedor_nivel_h.pack_start(self.contenedor_nivel_2, padding=20)
        self.contenedor_nivel_1.pack_start(self.nivel_1, False, padding=10)
        self.contenedor_nivel_1.pack_start(self.nivel_2, False, padding=10)
        self.contenedor_nivel_1.pack_start(self.nivel_3, False, padding=10)
        self.contenedor_nivel_1.pack_start(self.nivel_4, False, padding=10)
        self.contenedor_nivel_1.pack_start(self.cambiar_personaje_btn,
                                           False,
                                           padding=10)
        self.contenedor_nivel_1.pack_start(self.instrucciones,
                                           False,
                                           padding=10)
        self.contenedor_nivel_2.pack_start(self.nivel_5, False, padding=10)
        self.contenedor_nivel_2.pack_start(self.nivel_6, False, padding=10)
        self.contenedor_nivel_2.pack_start(self.nivel_7, False, padding=10)
        self.contenedor_nivel_2.pack_start(self.nuevapalabra_btn,
                                           False,
                                           padding=10)
        self.contenedor_nivel_2.pack_start(self.importar_btn,
                                           False,
                                           padding=10)
        self.contenedor_nivel_2.pack_start(self.categoria_libre,
                                           False,
                                           padding=10)
        self.contenedor_nivel.show_all()

        #interface juego
        self.imagen = gtk.Image()
        self.instrucciones_label = gtk.Label()
        #self.instrucciones_label.set_justify(gtk.JUSTIFY_FILL)
        self.instrucciones_label.modify_font(self.modificar_text)
        #self.aciertos_label = gtk.Label(_('Puntaje: 0'))
        self.errores_label = gtk.Label()
        self.errores_label_2 = gtk.Label()
        self.errores_label_2.modify_font(self.modificar_text)
        self.palabra_label = gtk.Label()
        self.definicion_label = gtk.Label()
        self.definicion_label.modify_font(self.modificar_text)
        self.definicion = gtk.Label()
        self.definicion.set_line_wrap(True)
        self.pista_label = gtk.Label()
        self.pista_label.modify_font(self.modificar_text)
        self.pista = gtk.Label()
        self.pista.set_line_wrap(True)
        #self.pista.set_max_width_chars(0)
        self.letrasusadas_label = gtk.Label()
        self.letrasusadas_label_2 = gtk.Label()
        self.letrasusadas_label_2.modify_font(self.modificar_text)
        self.palabra_entry = gtk.Entry()
        self.ok_btn = gtk.Button(_('Ingresar'))
        self.ok_btn.connect('clicked', self._ok_btn_clicked_cb, None)
        self.nuevojuego_btn = gtk.Button(_('Nuevo Juego'))
        self.nuevojuego_btn.connect('clicked', self._nuevojuego_btn_clicked_cb,
                                    None)
        self.atras_btn = gtk.Button(_('Atrás'))
        self.atras_btn.connect('clicked', self._atras_cb)
        self.aciertos = 0  #Cuenta los aciertos de letras en la palabra secreta

        #agregando elementos juego
        self.marco = gtk.Frame(_("Instrucciones"))
        self.marco.set_size_request(350, -1)
        self.contenedor_superior.pack_start(self.imagen)
        self.contenedor_superior.pack_start(self.marco)

        self.subcontenedor.pack_start(self.instrucciones_label)
        self.subcontenedor.pack_start(self.definicion_label, False, padding=5)
        self.subcontenedor.pack_start(self.definicion, False, padding=5)
        self.subcontenedor.pack_start(self.pista_label, False, padding=5)
        self.subcontenedor.pack_start(self.pista, False, padding=5)
        #self.subcontenedor.pack_start(self.aciertos_label)
        self.subcontenedor.pack_start(self.errores_label_2, False, padding=5)
        self.subcontenedor.pack_start(self.errores_label, False, padding=5)
        self.subcontenedor.pack_start(self.letrasusadas_label_2, False)
        self.subcontenedor.pack_start(self.letrasusadas_label, False)
        self.subcontenedor.pack_start(self.palabra_label)
        self.marco.add(self.subcontenedor)

        self.contenedor_inferior.pack_start(self.atras_btn, False, padding=6)
        self.contenedor_inferior.pack_start(self.palabra_entry, padding=1)
        self.contenedor_inferior.pack_start(self.ok_btn, False, padding=1)
        self.contenedor_inferior.pack_start(self.nuevojuego_btn,
                                            False,
                                            padding=1)

        #interface instrucciones
        self.area_instruc = gtk.ScrolledWindow()
        self.area_instruc.set_shadow_type(gtk.SHADOW_OUT)
        self.area_instruc.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.imagen_1 = gtk.Image()
        self.imagen_1.set_from_file('resources/sindiente1.png')
        self.imagen_2 = gtk.Image()
        self.imagen_2.set_from_file('resources/sindiente2.png')
        self.imagen_3 = gtk.Image()
        self.imagen_3.set_from_file('resources/sindiente3.png')
        self.imagen_4 = gtk.Image()
        self.imagen_4.set_from_file('resources/sindiente4.png')

        self.instruc = gtk.Label(_('Instrucciones'))
        self.instruc.modify_font(self.modificar_text)
        self.instruc_1 = gtk.Label(
            _('Oprime el botón “Nuevo Juego” para empezar a \njugar.'))
        self.instruc_2 = gtk.Label(
            _('La lineas representan las letras de las palabras \nque están ocultas. Cuenta las letras se compone \nla palabra.'
              ))
        self.instruc_3 = gtk.Label(
            _('Ingresa una letra en el espacio en blanco y oprime \nel botón “Ingresar”. Si descubres una letra esta \naparecerá sobre la linea y ganarás un punto.\nPero si fallas, tu amigo perderá un diente.'
              ))
        self.instruc_4 = gtk.Label(
            _('Las letras que ya han sido ingresadas no podrán ser \nusada de nuevo y aparecerán en el área de "Letras Usadas"'
              ))
        self.atras_btn_1 = gtk.Button(_('Atrás'))
        self.atras_btn_1.connect('clicked', self._atras_cb)

        #agregando elementos de instrucciones
        self.contenedor_instruc_1.pack_start(self.instruc_1)
        self.contenedor_instruc_1.pack_start(self.imagen_1)
        self.contenedor_instruc_2.pack_start(self.imagen_2)
        self.contenedor_instruc_2.pack_start(self.instruc_2)
        self.contenedor_instruc_3.pack_start(self.instruc_3)
        self.contenedor_instruc_3.pack_start(self.imagen_3)
        self.contenedor_instruc_4.pack_start(self.imagen_4)
        self.contenedor_instruc_4.pack_start(self.instruc_4)
        self.contenedor_instruc.pack_start(self.instruc, padding=25)
        self.contenedor_instruc.pack_start(self.contenedor_instruc_1,
                                           padding=50)
        self.contenedor_instruc.pack_start(self.contenedor_instruc_2,
                                           padding=50)
        self.contenedor_instruc.pack_start(self.contenedor_instruc_3,
                                           padding=50)
        self.contenedor_instruc.pack_start(self.contenedor_instruc_4,
                                           padding=15)
        self.contenedor_instruc.pack_start(self.atras_btn_1)
        self.area_instruc.add_with_viewport(self.contenedor_instruc)

        #interface nueva palabra
        self.nueva_palabra_label = gtk.Label(
            _('Ingresa una palabra para jugar'))
        self.nueva_palabra_label.modify_font(self.modificar_text)
        self.n_palabra_label = gtk.Label(_('Palabra'))
        self.nuevo_significado_label = gtk.Label(_('Significado'))
        self.nueva_pista_label = gtk.Label(_('Pista'))
        self.nueva_palabra = gtk.Entry()
        self.nuevo_significado = gtk.Entry()
        self.nueva_pista = gtk.Entry()
        self.boton_np = gtk.Button(_('Ingresar palabra'))
        self.boton_np.connect('clicked', self._nueva_p_cb)
        self.atras_imp = gtk.Button(_('Atrás'))
        self.atras_imp.connect('clicked', self._atras_cb)

        #agregando elementos de nueva palabra
        self.contenedor_np_v.pack_start(self.nueva_palabra_label,
                                        False,
                                        padding=80)
        self.contenedor_np_v.pack_start(self.n_palabra_label, False)
        self.contenedor_np_v.pack_start(self.nueva_palabra, False, padding=15)
        self.contenedor_np_v.pack_start(self.nueva_pista_label, False)
        self.contenedor_np_v.pack_start(self.nueva_pista, False, padding=15)
        self.contenedor_np_v.pack_start(self.nuevo_significado_label, False)
        self.contenedor_np_v.pack_start(self.nuevo_significado,
                                        False,
                                        padding=15)
        self.contenedor_np_v.pack_start(self.contenedor_np_1, False, False,
                                        100)
        self.contenedor_np_1.pack_start(self.atras_imp, True, False)
        self.contenedor_np_1.pack_start(self.boton_np, True, False)
        self.contenedor_np_2.pack_start(self.contenedor_np_v, padding=100)

        #interface importar
        self.combo = self.combo = gtk.combo_box_new_text()
        self.combo.set_size_request(180, -1)
        self.combo.append_text(_('Animales'))
        self.combo.append_text(_('Plantas'))
        self.combo.append_text(_('Países'))
        self.combo.append_text(_('Sustantivos'))
        self.combo.append_text(_('Verbos'))
        self.combo.append_text(_('Cosas'))
        self.combo.append_text(_('Valores morales'))
        self.combo.append_text(_('Categoría Personalizada'))
        self.combo.set_active(0)
        self.atras_btn_imp = gtk.Button(_('Atrás'))
        self.atras_btn_imp.connect('clicked', self._atras_cb)
        self.boton_importar = gtk.Button(_('Importar'))
        self.boton_importar.connect('clicked', self._importar_archivo_cb)
        self.archivo = gtk.FileChooserWidget()
        self.archivo.set_current_folder('/media')
        self.niveles = gtk.Label(_('Categorías'))
        self.importar = gtk.HBox()
        self.importar.pack_start(self.atras_btn_imp, False, padding=5)
        self.importar.pack_start(self.niveles, False, padding=10)
        self.importar.pack_start(self.combo, False)
        self.importar.pack_start(self.boton_importar)
        self.archivo.set_extra_widget(self.importar)

        #interface categoria personalizada NONE
        self.sin_importar = gtk.Label(
            _('No se ha importado ninguna lista de palabras para crear una categoría personalizada'
              ))

        self.show()