Example #1
0
ventana = gtk.Window(gtk.WINDOW_TOPLEVEL)
ventana.set_position(gtk.WIN_POS_CENTER)
ventana.set_title('Unlock Me!')
ventana.connect('delete_event', Salir)
ventana.set_border_width(sizeBorde)
ventana.modify_bg(gtk.STATE_NORMAL,
                  ventana.get_colormap().alloc_color('#0061a8'))
ventana.set_resizable(False)
ventana.set_icon_from_file("Images/icon.png")

tbox_level = gtk.Entry()  # Textbox para escoger nivel

pantalla = gtk.Fixed()

borde = gtk.Fixed()
imagen_borde = gtk.Image()
imagen_borde.show()
imagen_borde.set_from_file('Images/borde.png')
borde.put(imagen_borde, 0, 0)
borde.set_size_request(sizeRecuadro * sizeTablero + 2 * sizeBorde,
                       sizeRecuadro * sizeTablero + 2 * sizeBorde)
pantalla.put(borde, sizeRecuadro + sizeBorde, 0)

tablero = gtk.Fixed()
tablero.set_size_request(sizeRecuadro * sizeTablero,
                         sizeRecuadro * sizeTablero)
pantalla.put(tablero, sizeRecuadro + sizeBorde * 2, sizeBorde)

mensajeNivel = gtk.Label("¡Bienvenido!")
mensajeNivel.set_style(mensajeNivel.get_style().copy())
pantalla.put(mensajeNivel, int(sizeRecuadro * 3.3),
    def __init__(self,
                 model_name,
                 parent,
                 model=None,
                 attrs=None,
                 model_ctx=None,
                 window=None,
                 context=None,
                 readonly=False):

        if attrs is None:
            attrs = {}
        if model_ctx is None:
            model_ctx = {}
        if context is None:
            context = {}

        if not window:
            window = service.LocalService('gui.main').window

        self.dia = gtk.Dialog(
            _('OpenERP'), window,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.window = window
        if ('string' in attrs) and attrs['string']:
            self.dia.set_title(self.dia.get_title() + ' - ' + attrs['string'])
        self.dia.set_property('default-width', 760)
        self.dia.set_property('default-height', 500)
        self.dia.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dia.set_icon(common.OPENERP_ICON)

        self.accel_group = gtk.AccelGroup()
        self.dia.add_accel_group(self.accel_group)
        self.but_cancel = self.dia.add_button(_('Cancel'), gtk.RESPONSE_CANCEL)
        icon = gtk.Image()
        icon.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
        self.but_cancel.set_image(icon)
        self.but_cancel.add_accelerator('clicked', self.accel_group,
                                        gtk.keysyms.Escape,
                                        gtk.gdk.CONTROL_MASK,
                                        gtk.ACCEL_VISIBLE)

        self.but_save_close = self.dia.add_button(_('Save & Close'),
                                                  gtk.RESPONSE_APPLY)
        icon = gtk.Image()
        icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
        self.but_save_close.set_image(icon)

        self.but_save_new = self.dia.add_button(_('Save & New'),
                                                gtk.RESPONSE_OK)
        icon = gtk.Image()
        icon.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
        self.but_save_new.set_image(icon)
        self.but_save_new.add_accelerator('clicked', self.accel_group,
                                          gtk.keysyms.Return,
                                          gtk.gdk.CONTROL_MASK,
                                          gtk.ACCEL_VISIBLE)

        self.context = context

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_placement(gtk.CORNER_TOP_LEFT)
        scroll.set_shadow_type(gtk.SHADOW_NONE)
        self.dia.vbox.pack_start(scroll, expand=True, fill=True)

        vp = gtk.Viewport()
        vp.set_shadow_type(gtk.SHADOW_NONE)
        scroll.add(vp)
        self.screen = Screen(model_name,
                             view_type=[],
                             parent=parent,
                             window=self.dia,
                             readonly=readonly,
                             context=context)
        self.screen.models._context.update(model_ctx)
        if not model:
            model = self.screen.new(context=context)
        else:
            self.screen.models.model_add(model)
        self.screen.current_model = model
        if ('views' in attrs) and ('form' in attrs['views']):
            arch = attrs['views']['form']['arch']
            fields = attrs['views']['form']['fields']
            self.screen.add_view(arch, fields, display=True, context=context)
        else:
            self.screen.add_view_id(False,
                                    'form',
                                    display=True,
                                    context=context)
        if not model or model.id is None:
            self.screen.make_buttons_readonly()
        vp.add(self.screen.widget)
        x, y = self.screen.screen_container.size_get()
        vp.set_size_request(x, y + 30)
        self.dia.show_all()
        self.screen.readonly = readonly
        self.screen.display()
Example #3
0
 def set_widget_icon(self, widget, imgfile):
     image = gtk.Image()
     image.set_from_file(imgfile)
     self.back_button.set_image(image)
     widget.show()
Example #4
0
    def __init__(self,
                 screen,
                 callback,
                 view_type='form',
                 new=False,
                 many=0,
                 domain=None,
                 context=None,
                 save_current=False,
                 title='',
                 rec_name=None):
        NoModal.__init__(self)
        self.screen = screen
        self.callback = callback
        self.many = many
        self.domain = domain
        self.context = context
        self.save_current = save_current
        self.title = title
        self.prev_view = self.screen.current_view
        self.screen.screen_container.alternate_view = True
        if view_type not in (x.view_type for x in self.screen.views) and \
                view_type not in self.screen.view_to_load:
            self.screen.add_view_id(None, view_type)
        self.screen.switch_view(view_type=view_type)
        if new:
            self.screen.new(rec_name=rec_name)
        self.win = gtk.Dialog(_('Link'), self.parent,
                              gtk.DIALOG_DESTROY_WITH_PARENT)
        self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_deletable(False)
        self.win.connect('delete-event', lambda *a: True)
        self.win.connect('close', self.close)
        self.win.connect('response', self.response)

        self.accel_group = gtk.AccelGroup()
        self.win.add_accel_group(self.accel_group)

        readonly = self.screen.readonly or self.screen.group.readonly

        self.but_ok = None
        self.but_new = None

        if view_type == 'form':
            if not new and self.screen.current_record.id < 0:
                stock_id = gtk.STOCK_DELETE
            else:
                stock_id = gtk.STOCK_CANCEL
            self.but_cancel = self.win.add_button(stock_id,
                                                  gtk.RESPONSE_CANCEL)

        if new and self.many:
            self.but_new = self.win.add_button(gtk.STOCK_NEW,
                                               gtk.RESPONSE_ACCEPT)
            self.but_new.set_accel_path('<tryton>/Form/New', self.accel_group)

        if self.save_current:
            self.but_ok = gtk.Button(_('_Save'), use_underline=True)
            img_save = gtk.Image()
            img_save.set_from_stock('tryton-save', gtk.ICON_SIZE_BUTTON)
            self.but_ok.set_image(img_save)
            self.but_ok.set_accel_path('<tryton>/Form/Save', self.accel_group)
            self.but_ok.set_can_default(True)
            self.but_ok.show()
            self.win.add_action_widget(self.but_ok, gtk.RESPONSE_OK)
            if not new:
                self.but_ok.props.sensitive = False
        else:
            self.but_ok = self.win.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        self.but_ok.add_accelerator('clicked', self.accel_group,
                                    gtk.keysyms.Return, gtk.gdk.CONTROL_MASK,
                                    gtk.ACCEL_VISIBLE)
        self.win.set_default_response(gtk.RESPONSE_OK)

        self.win.set_title(self.title)

        title = gtk.Label()
        title.modify_font(pango.FontDescription("bold 12"))
        title.set_label(self.title)
        title.set_padding(20, 3)
        title.set_alignment(0.0, 0.5)
        title.set_size_request(0, -1)  # Allow overflow
        title.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000"))
        title.show()

        hbox = gtk.HBox()
        hbox.pack_start(title, expand=True, fill=True)
        hbox.show()

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        frame.add(hbox)
        frame.show()

        eb = gtk.EventBox()
        eb.add(frame)
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff"))
        eb.show()

        self.win.vbox.pack_start(eb, expand=False, fill=True, padding=3)

        if view_type == 'tree':
            hbox = gtk.HBox(homogeneous=False, spacing=0)
            tooltips = common.Tooltips()
            access = common.MODELACCESS[screen.model_name]

            if domain is not None:
                self.wid_text = gtk.Entry()
                self.wid_text.set_property('width_chars', 13)
                self.wid_text.connect('activate', self._sig_activate)
                self.wid_text.connect('focus-out-event', self._focus_out)
                hbox.pack_start(self.wid_text, expand=True, fill=True)

                self.but_add = gtk.Button()
                tooltips.set_tip(self.but_add, _('Add'))
                self.but_add.connect('clicked', self._sig_add)
                img_add = gtk.Image()
                img_add.set_from_stock('tryton-list-add',
                                       gtk.ICON_SIZE_SMALL_TOOLBAR)
                img_add.set_alignment(0.5, 0.5)
                self.but_add.add(img_add)
                self.but_add.set_relief(gtk.RELIEF_NONE)
                hbox.pack_start(self.but_add, expand=False, fill=False)
                if not access['read'] or readonly:
                    self.but_add.set_sensitive(False)

                self.but_remove = gtk.Button()
                tooltips.set_tip(self.but_remove, _('Remove <Del>'))
                self.but_remove.connect('clicked', self._sig_remove, True)
                img_remove = gtk.Image()
                img_remove.set_from_stock('tryton-list-remove',
                                          gtk.ICON_SIZE_SMALL_TOOLBAR)
                img_remove.set_alignment(0.5, 0.5)
                self.but_remove.add(img_remove)
                self.but_remove.set_relief(gtk.RELIEF_NONE)
                hbox.pack_start(self.but_remove, expand=False, fill=False)
                if not access['read'] or readonly:
                    self.but_remove.set_sensitive(False)

                hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

            self.but_new = gtk.Button()
            tooltips.set_tip(self.but_new, _('Create a new record <F3>'))
            self.but_new.connect('clicked', self._sig_new)
            img_new = gtk.Image()
            img_new.set_from_stock('tryton-new', gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_new.set_alignment(0.5, 0.5)
            self.but_new.add(img_new)
            self.but_new.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_new, expand=False, fill=False)
            if not access['create'] or readonly:
                self.but_new.set_sensitive(False)

            self.but_del = gtk.Button()
            tooltips.set_tip(self.but_del, _('Delete selected record <Del>'))
            self.but_del.connect('clicked', self._sig_remove, False)
            img_del = gtk.Image()
            img_del.set_from_stock('tryton-delete',
                                   gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_del.set_alignment(0.5, 0.5)
            self.but_del.add(img_del)
            self.but_del.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_del, expand=False, fill=False)
            if not access['delete'] or readonly:
                self.but_del.set_sensitive(False)

            self.but_undel = gtk.Button()
            tooltips.set_tip(self.but_undel,
                             _('Undelete selected record <Ins>'))
            self.but_undel.connect('clicked', self._sig_undelete)
            img_undel = gtk.Image()
            img_undel.set_from_stock('tryton-undo',
                                     gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_undel.set_alignment(0.5, 0.5)
            self.but_undel.add(img_undel)
            self.but_undel.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_undel, expand=False, fill=False)
            if not access['delete'] or readonly:
                self.but_undel.set_sensitive(False)

            hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

            self.but_pre = gtk.Button()
            tooltips.set_tip(self.but_pre, _('Previous'))
            self.but_pre.connect('clicked', self._sig_previous)
            img_pre = gtk.Image()
            img_pre.set_from_stock('tryton-go-previous',
                                   gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_pre.set_alignment(0.5, 0.5)
            self.but_pre.add(img_pre)
            self.but_pre.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_pre, expand=False, fill=False)

            self.label = gtk.Label('(0,0)')
            hbox.pack_start(self.label, expand=False, fill=False)

            self.but_next = gtk.Button()
            tooltips.set_tip(self.but_next, _('Next'))
            self.but_next.connect('clicked', self._sig_next)
            img_next = gtk.Image()
            img_next.set_from_stock('tryton-go-next',
                                    gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_next.set_alignment(0.5, 0.5)
            self.but_next.add(img_next)
            self.but_next.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_next, expand=False, fill=False)

            hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

            but_switch = gtk.Button()
            tooltips.set_tip(but_switch, _('Switch'))
            but_switch.connect('clicked', self.switch_view)
            img_switch = gtk.Image()
            img_switch.set_from_stock('tryton-fullscreen',
                                      gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_switch.set_alignment(0.5, 0.5)
            but_switch.add(img_switch)
            but_switch.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(but_switch, expand=False, fill=False)

            but_switch.props.sensitive = screen.number_of_views > 1

            tooltips.enable()

            alignment = gtk.Alignment(1.0)
            alignment.add(hbox)
            alignment.show_all()

            self.win.vbox.pack_start(alignment, expand=False, fill=True)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_placement(gtk.CORNER_TOP_LEFT)
        scroll.set_shadow_type(gtk.SHADOW_NONE)
        scroll.show()
        self.win.vbox.pack_start(scroll, expand=True, fill=True)

        scroll.add(self.screen.screen_container.alternate_viewport)

        self.create_info_bar()
        self.win.vbox.pack_start(self.info_bar, False, True)

        sensible_allocation = self.sensible_widget.get_allocation()
        self.win.set_default_size(sensible_allocation.width,
                                  sensible_allocation.height)

        if view_type == 'tree':
            self.screen.signal_connect(self, 'record-message', self._sig_label)
            self.screen.screen_container.alternate_viewport.connect(
                'key-press-event', self.on_keypress)

        if self.save_current and not new:
            self.screen.signal_connect(self, 'record-message',
                                       self.activate_save)
            self.screen.signal_connect(self, 'record-modified',
                                       self.activate_save)

        self.register()
        self.win.show()

        common.center_window(self.win, self.parent, self.sensible_widget)

        self.screen.display()
        self.screen.current_view.set_cursor()
    def __init__(self, daddy=None):
        HIGWindow.__init__(self)

        self.daddy = daddy
        self.wtitle = _("Scan Scheduler Editor")

        # header
        self.title_markup = "<span size='16500' weight='heavy'>%s</span>"
        self.ttitle = HIGEntryLabel("")
        self.ttitle.set_line_wrap(False)
        self.ttitle.set_markup(self.title_markup % self.wtitle)
        self.umit_logo = gtk.Image()
        self.umit_logo.set_from_file(logo)
        # schemas name
        self.schema_name_lbl = HIGEntryLabel(_("Schema Name"))
        self.schema_name = gtk.combo_box_entry_new_text()
        self.schema_name.connect('changed', self._check_schema)
        # target and scan profiles
        #self.target_lbl = HIGEntryLabel(_("Target"))
        #self.target = gtk.Entry()
        self.scan_name_lbl = HIGEntryLabel(_("Scan Profile"))
        self.scan_name = ProfileCombo()
        self.scan_name.update()
        self.scan_name.set_active(0)
        self.scan_name.connect('changed', self._set_scan_command)
        # scan command
        self.scan_command_lbl = HIGEntryLabel(_("Command"))
        self.scan_command = gtk.Entry()
        # scheduling profile
        self.sched_name_lbl = HIGEntryLabel(_("Scheduling Profile"))
        self.sched_name = gtk.combo_box_new_text()
        self.sched_name_edit = gtk.Button(stock=gtk.STOCK_EDIT)
        blbl = self.sched_name_edit.get_children()[0].get_children(
        )[0].get_children()[1]
        blbl.set_text(_("Edit Profiles"))
        self.sched_name_edit.connect('clicked', self._edit_schedprofiles)
        # schema settings
        self.schema_sett_frame = HIGFrame()
        self.setting_saveto = gtk.CheckButton(_("Save outputs to"))
        self.setting_saveto_entry = gtk.Entry()
        self.setting_saveto_browse = gtk.Button(_("..."))
        self.setting_saveto_browse.connect('clicked', self._select_saveto)
        self.setting_mailto = gtk.CheckButton(_("Send output to email"))
        self.setting_mailto_entry = gtk.Entry()
        self.setting_smtp_lbl = HIGEntryLabel(_("SMTP Schema"))
        self.setting_smtp = gtk.combo_box_new_text()
        self.setting_addtoinv = gtk.CheckButton(_("Add to the Inventory"))
        self.setting_enabled = gtk.CheckButton(_("Enabled"))
        # bottom buttons
        self.help = HIGButton(stock=gtk.STOCK_HELP)
        self.help.connect('clicked', self._show_help)
        self.apply = HIGButton(stock=gtk.STOCK_APPLY)
        self.apply.connect('clicked', self._save_schema)
        self.cancel = HIGButton(stock=gtk.STOCK_CANCEL)
        self.cancel.connect('clicked', self._exit)
        self.ok = HIGButton(stock=gtk.STOCK_OK)
        self.ok.connect('clicked', self._save_schema_and_leave)

        self.load_smtp_schemas()
        self._set_scan_command(None)
        self.profile_running = None  # no SchedProfileEditor instance is running.
        self._load_pscheds()
        self.load_schemas()

        self.__set_props()
        self.__do_layout()

        self.connect('destroy', self._exit)
Example #6
0
    def __init__(self):
        super(IconFileSelection, self).__init__()

        # set some default values'
        self.icon_size = 48
        self.start_dir = os.path.expanduser('/')
        self.cur_dir = self.start_dir
        self.user_dir = os.path.expanduser('~')
        self.jump_to_dir = os.path.expanduser('/tmp')
        self.filetypes = ("ngc,py")
        self.sortorder = _FOLDERFIRST
        # This will hold the path we will return
        self.path = ""
        self.button_state = {}
        self.old_button_state = {}        

        # Make the GUI and connect signals
        vbox = gtk.VBox(False, 0)

        self.buttonbox = gtk.HButtonBox()
        self.buttonbox.set_layout(gtk.BUTTONBOX_EDGE)
        self.buttonbox.set_property("homogeneous", True)
        vbox.pack_end(self.buttonbox, False, False, 0)

        self.btn_home = gtk.Button()
        self.btn_home.set_size_request(56, 56)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_HOME, 48)
        self.btn_home.set_image(image)
        self.btn_home.set_tooltip_text(_("Move to your home directory"))
        self.buttonbox.add(self.btn_home)

        self.btn_dir_up = gtk.Button();
        self.btn_dir_up.set_size_request(56, 56)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_GOTO_TOP, 48)
        self.btn_dir_up.set_image(image)
        self.btn_dir_up.set_tooltip_text(_("Move to parent directory"))
        self.buttonbox.add(self.btn_dir_up)

        self.btn_sel_prev = gtk.Button()
        self.btn_sel_prev.set_size_request(56, 56)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_GO_BACK, 48)
        self.btn_sel_prev.set_image(image)
        self.btn_sel_prev.set_tooltip_text(_("Select the previous file"))
        self.buttonbox.add(self.btn_sel_prev)

        self.btn_sel_next = gtk.Button()
        self.btn_sel_next.set_size_request(56, 56)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_GO_FORWARD, 48)
        self.btn_sel_next.set_image(image)
        self.btn_sel_next.set_tooltip_text(_("Select the next file"))
        self.buttonbox.add(self.btn_sel_next)

# ToDo : Find out how to move one line down or up
#        self.btn_go_down = gtk.Button()
#        self.btn_go_down.set_size_request(56,56)
#        image = gtk.Image()
#        image.set_from_stock(gtk.STOCK_GO_DOWN,48)
#        self.btn_go_down.set_image(image)
#        self.buttonbox.add(self.btn_go_down)
#
#        self.btn_go_up = gtk.Button()
#        self.btn_go_up.set_size_request(56,56)
#        image = gtk.Image()
#        image.set_from_stock(gtk.STOCK_GO_UP,48)
#        self.btn_go_up.set_image(image)
#        self.buttonbox.add(self.btn_go_up)
# ToDo : End

        self.btn_jump_to = gtk.Button()
        self.btn_jump_to.set_size_request(56, 56)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_JUMP_TO, 48)
        self.btn_jump_to.set_image(image)
        self.btn_jump_to.set_tooltip_text(_("Jump to user defined directory"))
        self.buttonbox.add(self.btn_jump_to)

        self.btn_select = gtk.Button()
        self.btn_select.set_size_request(56, 56)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_OK, 48)
        self.btn_select.set_image(image)
        self.btn_select.set_tooltip_text(_("select the highlighted file and return the path"))
        self.buttonbox.add(self.btn_select)

        self.btn_exit = gtk.Button()
        self.btn_exit.set_size_request(56, 56)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_STOP, 48)
        self.btn_exit.set_image(image)
        self.btn_exit.set_tooltip_text(_("Close without returning a file path"))
        self.buttonbox.add(self.btn_exit)

        self.dirIcon = self._get_icon("folder")

        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        vbox.pack_start(sw, True, True, 0)

        self.file_label = gtk.Label("File Label")
        vbox.pack_start(self.file_label, False, True, 0)

        self.store = self._create_store()
        
        self.iconView = gtk.IconView(self.store)
        self.iconView.set_selection_mode(gtk.SELECTION_SINGLE)

        self.iconView.set_text_column(COL_PATH)
        self.iconView.set_pixbuf_column(COL_PIXBUF)

        sw.add(self.iconView)
        self.iconView.grab_focus()
        self.model = self.iconView.get_model()

        self.btn_dir_up.connect("clicked", self.on_btn_dir_up_clicked)
        self.btn_home.connect("clicked", self.on_btn_home_clicked)
        self.btn_sel_next.connect("clicked", self.on_btn_sel_next_clicked)
        self.btn_sel_prev.connect("clicked", self.on_btn_sel_prev_clicked)
#        self.btn_go_down.connect("clicked", self.on_btn_go_down_clicked)
#        self.btn_go_up.connect("clicked", self.on_btn_go_up_clicked)
        self.btn_jump_to.connect("clicked", self.on_btn_jump_to_clicked)
        self.btn_select.connect("clicked", self.on_btn_select_clicked)
        self.btn_exit.connect("clicked", self.on_btn_exit_clicked)
        # will be emitted, when a icon has been activated, so we keep track of the path
        self.iconView.connect("item-activated", self._on_item_activated)
        # will be emitted, when a icon is activated and the ENTER key has been pressed
        self.iconView.connect("activate-cursor-item", self._on_activate_cursor_item)
        # will be emmited if the selection has changed, this happens also if the user clicks ones on an icon
        self.iconView.connect("selection-changed",  self._on_selection_changed)
        # will be emitted, when the widget is destroyed
        self.connect("destroy", gtk.main_quit)      
        
        self.add(vbox)
        self.show_all()

        # To use the the events, we have to unmask them
        self.iconView.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.iconView.connect("button_press_event", self._button_press)
        
        self._fill_store()
        self._init_button_state()
def secondarybuttonsOMGWTF():
    toppannelbox.pack_start(gtk.VSeparator(), False)

    # Analytics

    startsider = gtk.Button()
    startsider.props.relief = gtk.RELIEF_NONE
    startsibox = gtk.HBox(False)
    startsiico = gtk.Image()
    startsiico.set_from_file("py_data/icons/stats.png")
    startsibox.pack_start(startsiico, False)
    startsibox.pack_start(gtk.Label("  Analytics"))
    startsider.add(startsibox)
    startsider.set_tooltip_text(
        "Schedules, Analitycs.\nAre you doing by deadline? Ah...?")
    startsider.connect("clicked", chgCUR, "stats")
    toppannelbox.pack_start(startsider, False)

    # checklist

    checklistider = gtk.Button()
    checklistider.props.relief = gtk.RELIEF_NONE
    checklistibox = gtk.HBox(False)
    checklistiico = gtk.Image()
    checklistiico.set_from_file("py_data/icons/checklist.png")
    checklistibox.pack_start(checklistiico, False)
    checklistibox.pack_start(gtk.Label("  Main Checklist"))
    checklistider.add(checklistibox)
    checklistider.set_tooltip_text("Open Main Checklist")
    checklistider.connect("clicked", checklist.checkwindow, os.getcwd(),
                          "Main Checklist", "project.progress")
    toppannelbox.pack_start(checklistider, False)

    toppannelbox.pack_start(gtk.VSeparator(), False)

    # SCROLLED AREA

    # THIS SQUIZE THE LAST BUTTONS TO THE ORGANIZER WILL FIT INTO SMALLER SCREENS.
    # SOME PEOPLE STILL USING 720p SCREENS. LIKE FAKE HD TVs AND SUCH.
    # SO EFFORT SHOULD BE PUT INTO MAKING ORGANIZER COMPATIBLE WITH THOSE TINY SCREEN SIZES.

    Squiz = gtk.ScrolledWindow()
    Squiz.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
    Squiz.set_size_request(50, 20)

    Squizbox = gtk.HBox(False)
    Squiz.add_with_viewport(Squizbox)

    toppannelbox.pack_end(Squiz)

    # Settings AKA blender version ( I'm not going to change names of the buttons and shit)

    blendverb = gtk.Button()
    blendverb.props.relief = gtk.RELIEF_NONE
    blendbox = gtk.HBox(False)
    blendico = gtk.Image()
    blendico.set_from_file("py_data/icons/settings.png")
    blendbox.pack_start(blendico, False)
    blendbox.pack_start(gtk.Label("  Settings"))
    blendverb.add(blendbox)
    blendverb.set_tooltip_text("Blender Versions, And other settings")
    blendverb.connect("clicked", chgCUR, "bldv")
    #blendver.set_sensitive(False)
    Squizbox.pack_end(blendverb, False)

    Squizbox.pack_end(gtk.VSeparator(), False)

    # TELEGRAM

    def telegram(w):
        oscalls.Open("https://t.me/blenderorganizer")

    syncider = gtk.Button()
    syncider.props.relief = gtk.RELIEF_NONE
    syncibox = gtk.HBox(False)
    synciico = gtk.Image()
    synciico.set_from_file("py_data/icons/telegram.png")
    syncibox.pack_start(synciico, False)
    syncibox.pack_start(gtk.Label("  Chat"))
    syncider.add(syncibox)
    syncider.set_tooltip_text(
        "Get Help, Request Features, Chat With Developers")
    syncider.connect("clicked", telegram)
    #syncider.set_sensitive(False)
    Squizbox.pack_end(syncider, False)

    ctut = "Analytics"
    if CUR in ["chr", "veh", "loc", "obj"]:
        ctut = "Items"
    elif CUR == "rnd":
        ctut = "Story Editor"

    def tutorials(w):

        if CUR in ["chr", "veh", "loc", "obj"]:
            oscalls.Open(
                "https://open.lbry.com/@blender-organizer:5/BlenderOrganizerAssetsTutorialv4.87:e?r=5adqY5G5DyH8YxFL9UpT4ubYnWnaK2hN"
            )
        elif CUR == "rnd":
            oscalls.Open(
                "https://open.lbry.com/@blender-organizer:5/BlenderOrganizerStoryEditorTutorialv4.87:0?r=5adqY5G5DyH8YxFL9UpT4ubYnWnaK2hN"
            )
        else:
            oscalls.Open(
                "https://open.lbry.com/@blender-organizer:5/BlenderOrganizerAnalyticsTutorial4.87:6?r=5adqY5G5DyH8YxFL9UpT4ubYnWnaK2hN"
            )  # PUT

    syncider = gtk.Button()
    syncider.props.relief = gtk.RELIEF_NONE
    syncibox = gtk.HBox(False)
    synciico = gtk.Image()
    synciico.set_from_file("py_data/icons/info.png")
    syncibox.pack_start(synciico, False)
    syncibox.pack_start(gtk.Label(ctut + " Help!"))
    syncider.add(syncibox)
    syncider.set_tooltip_text(
        "Watch a tutorial on YouTube\nabout Blender-Organizer's " + ctut)
    syncider.connect("clicked", tutorials)
    #syncider.set_sensitive(False)
    Squizbox.pack_end(syncider, False)

    Squizbox.pack_end(gtk.VSeparator(), False)

    # SYNC

    #syncider = gtk.Button()
    #syncider.props.relief = gtk.RELIEF_NONE
    #syncibox = gtk.HBox(False)
    #synciico = gtk.Image()
    #synciico.set_from_file("py_data/icons/sync.png")
    #syncibox.pack_start(synciico, False)
    #syncibox.pack_start(gtk.Label("  Synchronize"))
    #syncider.add(syncibox)
    #syncider.set_tooltip_text("Synchronize between multiple machines")
    #syncider.connect("clicked",chgCUR, "sync")
    #syncider.set_sensitive(False)
    #toppannelbox.pack_end(syncider, False)

    # REPORT BUG
    def Reportbug(w=False):

        oscalls.Open("https://github.com/JYamihud/blender-organizer/issues")

    Reportbugider = gtk.Button()
    Reportbugider.props.relief = gtk.RELIEF_NONE
    Reportbugibox = gtk.HBox(False)
    Reportbugiico = gtk.Image()
    Reportbugiico.set_from_file("py_data/icons/report_bug.png")
    Reportbugibox.pack_start(Reportbugiico, False)
    Reportbugibox.pack_start(gtk.Label("  Report BUG!"))
    Reportbugider.add(Reportbugibox)
    Reportbugider.set_tooltip_text("Go to report bug page.")
    #Reportbugider.set_sensitive(False)
    Reportbugider.connect("clicked", Reportbug)

    Squizbox.pack_end(Reportbugider, False)

    # Update

    Updateider = gtk.Button()
    Updateider.props.relief = gtk.RELIEF_NONE
    Updateibox = gtk.HBox(False)
    Updateiico = gtk.Image()
    Updateiico.set_from_file("py_data/icons/update.png")
    Updateibox.pack_start(Updateiico, False)
    Updateibox.pack_start(gtk.Label("  Update"))
    Updateider.add(Updateibox)
    Updateider.set_tooltip_text("Check for updates")
    #Updateider.set_sensitive(False)
    Updateider.connect("clicked", update_window.main, os.getcwd())

    Squizbox.pack_end(Updateider, False)

    Squizbox.pack_end(gtk.VSeparator(), False)
Example #8
0
def file_selection(title,
                   filename='',
                   action=gtk.FILE_CHOOSER_ACTION_OPEN,
                   preview=True,
                   multi=False,
                   filters=None):
    parent = get_toplevel_window()
    if action == gtk.FILE_CHOOSER_ACTION_OPEN:
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
                   gtk.RESPONSE_OK)
    else:
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE,
                   gtk.RESPONSE_OK)
    win = gtk.FileChooserDialog(title, None, action, buttons)
    win.set_transient_for(parent)
    win.set_icon(TRYTON_ICON)
    if filename:
        if action in (gtk.FILE_CHOOSER_ACTION_SAVE,
                      gtk.FILE_CHOOSER_ACTION_CREATE_FOLDER):
            win.set_current_name(filename)
        else:
            win.set_filename(filename)
    if hasattr(win, 'set_do_overwrite_confirmation'):
        win.set_do_overwrite_confirmation(True)
    win.set_select_multiple(multi)
    win.set_default_response(gtk.RESPONSE_OK)
    if filters is not None:
        for filt in filters:
            win.add_filter(filt)

    def update_preview_cb(win, img):
        have_preview = False
        filename = win.get_preview_filename()
        if filename:
            try:
                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                    filename, 128, 128)
                img.set_from_pixbuf(pixbuf)
                have_preview = True
            except (IOError, glib.GError):
                pass
        win.set_preview_widget_active(have_preview)
        return

    if preview:
        img_preview = gtk.Image()
        win.set_preview_widget(img_preview)
        win.connect('update-preview', update_preview_cb, img_preview)

    if os.name == 'nt':
        encoding = 'utf-8'
    else:
        encoding = sys.getfilesystemencoding()
    button = win.run()
    if button != gtk.RESPONSE_OK:
        result = None
    elif not multi:
        result = win.get_filename()
        if result:
            result = unicode(result, encoding)
    else:
        result = [unicode(path, encoding) for path in win.get_filenames()]
    parent.present()
    win.destroy()
    return result
Example #9
0
    def build_dialog(self, parent, title, details):
        dialog = gtk.Dialog(_('Error'), parent,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)

        but_send = gtk.Button(_('Report Bug'))
        dialog.add_action_widget(but_send, gtk.RESPONSE_OK)
        dialog.add_button("gtk-close", gtk.RESPONSE_CANCEL)
        dialog.set_default_response(gtk.RESPONSE_CANCEL)

        vbox = gtk.VBox()
        label_title = gtk.Label()
        label_title.set_markup('<b>' + _('Application Error.') + '</b>')
        label_title.set_padding(-1, 5)
        vbox.pack_start(label_title, False, False)
        vbox.pack_start(gtk.HSeparator(), False, False)

        hbox = gtk.HBox()
        image = gtk.Image()
        image.set_from_stock('tryton-dialog-error', gtk.ICON_SIZE_DIALOG)
        hbox.pack_start(image, False, False)

        scrolledwindow = gtk.ScrolledWindow()
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolledwindow.set_shadow_type(gtk.SHADOW_NONE)

        viewport = gtk.Viewport()
        viewport.set_shadow_type(gtk.SHADOW_NONE)

        box = gtk.VBox()
        label_error = gtk.Label()
        label_error.set_markup('')
        label_error.set_alignment(0, 0.5)
        label_error.set_padding(-1, 14)
        label_error.modify_font(pango.FontDescription("monospace"))
        label_error.set_markup('<b>' + _('Error: ') + '</b>' + to_xml(title))
        box.pack_start(label_error, False, False)
        textview = gtk.TextView()
        buf = gtk.TextBuffer()
        buf.set_text(details)
        textview.set_buffer(buf)
        textview.set_editable(False)
        textview.set_sensitive(True)
        textview.modify_font(pango.FontDescription("monospace"))
        box.pack_start(textview, False, False)

        viewport.add(box)
        scrolledwindow.add(viewport)
        hbox.pack_start(scrolledwindow)

        vbox.pack_start(hbox)

        button_roundup = gtk.Button()
        button_roundup.set_relief(gtk.RELIEF_NONE)
        label_roundup = gtk.Label()
        label_roundup.set_markup(
            _('To report bugs you must have an account'
              ' on <u>%s</u>') % CONFIG['roundup.url'])
        label_roundup.set_alignment(1, 0.5)
        label_roundup.set_padding(20, 5)

        button_roundup.connect(
            'clicked',
            lambda widget: webbrowser.open(CONFIG['roundup.url'], new=2))
        button_roundup.add(label_roundup)
        vbox.pack_start(button_roundup, False, False)

        dialog.vbox.pack_start(vbox)
        dialog.set_default_size(600, 400)
        return dialog
def on_redisplay(widget):
    global Section, SectionTauPi, SectionFilt, Fold, ns, nt
    global dt, dt_s

    main.tableDis.destroy()
    main.tableDis = gtk.Table(2, 3, False)
    main.tableDis.show()
    main.hbox.pack_start(main.tableDis)

    try:
        SectionTauPi.shape
    except NameError:
        SectionTauPi = Section
#print "Entre a la excepcion"

    try:
        SectionFilt.shape
    except NameError:
        SectionFilt = Section

    # 3 PNG Files to display
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.imshow(Section,
              extent=[Offset[0], Offset[Fold - 1],
                      int((ns - 1) * dt), 0],
              cmap='gray')
    ax.set_xlim(Offset[0], Offset[Fold - 1])
    ax.set_aspect(0.5)
    #plt.colorbar()
    plt.title('Input CDP')
    plt.xlabel('Offset [m]')
    plt.ylabel('Time [ms]')
    fig.savefig('Input.png', bbox_inches='tight')
    fig.clf()

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.imshow(SectionTauPi,
              extent=[Offset[0], Offset[Fold - 1],
                      int((ns - 1) * dt), 0])
    ax.set_xlim(Offset[0], Offset[Fold - 1])
    ax.set_aspect(0.5)
    #plt.colorbar()
    plt.title('Picking Filter Panel')
    plt.xlabel('Offset [m]')
    plt.ylabel('Time [ms]')
    fig.savefig('Filter.png', bbox_inches='tight')
    fig.clf()

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.imshow(SectionFilt,
              extent=[Offset[0], Offset[Fold - 1],
                      int((ns - 1) * dt), 0],
              cmap='gray')
    ax.set_xlim(Offset[0], Offset[Fold - 1])
    ax.set_aspect(0.5)
    #plt.colorbar()
    plt.title('Filtered CDP')
    plt.xlabel('Offset [m]')
    plt.ylabel('Time [ms]')
    fig.savefig('Output.png', bbox_inches='tight')
    fig.clf()

    # Loading a PNG file as PIXBUF
    pixfsis = gtk.gdk.pixbuf_new_from_file("Input.png")
    pixfsis = pixfsis.scale_simple(300, 500, gtk.gdk.INTERP_BILINEAR)
    imageIn = gtk.Image()
    imageIn.set_from_pixbuf(pixfsis)
    imageIn.show()
    main.tableDis.attach(imageIn, 0, 1, 1, 2)

    main.drawing_area.connect("expose_event", expose_event)
    main.drawing_area.connect("configure_event", configure_event)
    #main.drawing_area.connect("motion_notify_event", motion_notify_event)
    main.drawing_area.connect("button_press_event", button_press_event)

    main.drawing_area.set_events(gtk.gdk.EXPOSURE_MASK
                                 | gtk.gdk.LEAVE_NOTIFY_MASK
                                 | gtk.gdk.BUTTON_PRESS_MASK
                                 | gtk.gdk.POINTER_MOTION_MASK
                                 | gtk.gdk.POINTER_MOTION_HINT_MASK)

    main.tableDis.attach(main.drawing_area, 1, 2, 1, 2)

    pixfsis = gtk.gdk.pixbuf_new_from_file("Output.png")
    pixfsis = pixfsis.scale_simple(300, 500, gtk.gdk.INTERP_BILINEAR)
    imageIn = gtk.Image()
    imageIn.set_from_pixbuf(pixfsis)
    #imageIn.show()
    main.tableDis.attach(imageIn, 2, 3, 1, 2)

    main.drawing_area.show()
Example #11
0
def populate(menu, model, record, title='', field=None, context=None):
    '''
    Fill menu with the actions of model for the record.
    If title is filled, the actions will be put in a submenu.
    '''
    if record is None:
        return
    elif isinstance(record, (int, long)):
        if record < 0:
            return
    elif record.id < 0:
        return

    def load(record):
        if isinstance(record, (int, long)):
            screen = Screen(model, context=context)
            screen.load([record])
            record = screen.current_record
        return record

    def id_(record):
        if not isinstance(record, (int, long)):
            return record.id
        return record

    def activate(menuitem, action, atype):
        rec = load(record)
        action = Action.evaluate(action, atype, rec)
        data = {
            'model': model,
            'id': rec.id,
            'ids': [rec.id],
        }
        event = gtk.get_current_event()
        allow_similar = False
        if (event.state & gtk.gdk.CONTROL_MASK
                or event.state & gtk.gdk.MOD1_MASK):
            allow_similar = True
        with Window(hide_current=True, allow_similar=allow_similar):
            Action._exec_action(action, data, rec.get_context())

    def attachment(menuitem):
        Attachment(load(record), None)

    def note(menuitem):
        Note(load(record), None)

    def edit(menuitem):
        with Window(hide_current=True, allow_similar=True):
            Window.create(model,
                          view_ids=field.attrs.get('view_ids', '').split(','),
                          res_id=id_(record),
                          mode=['form'],
                          name=field.attrs.get('string'))

    if title:
        if len(menu):
            menu.append(gtk.SeparatorMenuItem())
        title_item = gtk.MenuItem(title)
        menu.append(title_item)
        submenu = gtk.Menu()
        title_item.set_submenu(submenu)
        action_menu = submenu
    else:
        action_menu = menu

    if len(action_menu):
        action_menu.append(gtk.SeparatorMenuItem())
    if field:
        edit_item = gtk.MenuItem(_('Edit...'))
        edit_item.connect('activate', edit)
        action_menu.append(edit_item)
        action_menu.append(gtk.SeparatorMenuItem())
    attachment_item = gtk.ImageMenuItem()
    attachment_item.set_label(_('Attachments...'))
    attachment_icon = gtk.Image()
    attachment_icon.set_from_stock('tryton-attachment', gtk.ICON_SIZE_MENU)
    attachment_item.set_image(attachment_icon)
    action_menu.append(attachment_item)
    attachment_item.connect('activate', attachment)
    note_item = gtk.ImageMenuItem()
    note_item.set_label(_('Notes...'))
    note_icon = gtk.Image()
    note_icon.set_from_stock('tryton-note', gtk.ICON_SIZE_MENU)
    note_item.set_image(note_icon)
    action_menu.append(note_item)
    note_item.connect('activate', note)

    def set_toolbar(toolbar):
        try:
            toolbar = toolbar()
        except RPCException:
            return
        for atype, icon, label, flavor in (
            ('action', 'tryton-executable', _('Actions...'), None),
            ('relate', 'tryton-go-jump', _('Relate...'), None),
            ('print', 'tryton-print-open', _('Report...'), 'open'),
            ('print', 'tryton-print-email', _('E-Mail...'), 'email'),
            ('print', 'tryton-print', _('Print...'), 'print'),
        ):
            if len(action_menu):
                action_menu.append(gtk.SeparatorMenuItem())
            title_item = gtk.ImageMenuItem()
            title_item.set_label(label)
            title_icon = gtk.Image()
            title_icon.set_from_stock(icon, gtk.ICON_SIZE_MENU)
            title_item.set_image(title_icon)
            action_menu.append(title_item)
            if not toolbar[atype]:
                title_item.set_sensitive(False)
                continue
            submenu = gtk.Menu()
            title_item.set_submenu(submenu)
            for action in toolbar[atype]:
                action = action.copy()
                item = gtk.MenuItem(action['name'])
                submenu.append(item)
                if flavor == 'print':
                    action['direct_print'] = True
                elif flavor == 'email':
                    action['email_print'] = True
                item.connect('activate', activate, action, atype)
            menu.show_all()

    RPCExecute('model', model, 'view_toolbar_get', callback=set_toolbar)
    menu.show_all()
Example #12
0
import utils
import os

__DOMAIN = "icon_host"

__itens = []

STOCK_SERVER = "server"
__itens.append((STOCK_SERVER, _("Server"), 0, 0, __DOMAIN))

STOCK_DATABASE = "database"
__itens.append((STOCK_DATABASE, _("Database"), 0, 0, __DOMAIN))

STOCK_TABLE = "table"
__itens.append((STOCK_DATABASE, _("Table"), 0, 0, __DOMAIN))

STOCK_NAMESPACE = "namespace"
__itens.append((STOCK_NAMESPACE, _("Namespace"), 0, 0, __DOMAIN))

gtk.stock_add(__itens)

__factory = gtk.IconFactory()

for png in os.listdir(utils.get_res_icons("")):
    image = gtk.Image()
    image.set_from_file(utils.get_res_icons(png))
    pixbuf = image.get_pixbuf()
    __factory.add(os.path.basename(png)[:-4], gtk.IconSet(pixbuf))

__factory.add_default()
Example #13
0
    def build_folder_menu(self, folder):
	"""
	Build a submenu for the specified folder,
	including items to show the size, open the folder in
	the file manager, show each connected peer, and to 
	copy the secrets to the clipboard.

	Stores references to the size and peer items so they
	can easily be updated.
	"""
	menu = gtk.Menu()

	folderitem = self.folderitems[folder['name']]
	folderitem['sizeitem'] = gtk.MenuItem(folder['size'])
	folderitem['sizeitem'].set_sensitive(False)
	folderitem['sizeitem'].show()
	openfolder = gtk.MenuItem('Open in File Browser')
	openfolder.connect("activate", self.open_fm, folder['name'])
	openfolder.show()

	menu.append(folderitem['sizeitem'])
	menu.append(openfolder)

	if len(folder['peers']) > 0:
	    sep = gtk.SeparatorMenuItem()
	    sep.show()
	    menu.append(sep)
            folderitem['topsepitem'] = sep
	    for peer in folder['peers']:
		buf = self.format_status(peer)
		img = gtk.Image()
		if peer['direct']:
			img.set_from_file(args.iconpath+'/btsync-direct.png')
		else:
			img.set_from_file(args.iconpath+'/btsync-relay.png')
		peeritem = gtk.ImageMenuItem(gtk.STOCK_NEW, buf)
		peeritem.set_image(img)
                peeritem.set_always_show_image(True)
		peeritem.set_sensitive(False)
		peeritem.show()
		folderitem['peeritems'][peer['name']] = peeritem
		menu.append(peeritem)
        else:
            folderitem['topsepitem'] = None

        sep = gtk.SeparatorMenuItem()
	sep.show()
	menu.append(sep)
        folderitem['bottomsepitem'] = sep

	readonly = gtk.MenuItem('Get Read Only Secret')
	readonly.connect("activate", self.copy_secret, folder['readonlysecret'])
	readwrite = gtk.MenuItem('Get Full Access Secret')
	readwrite.connect("activate", self.copy_secret, folder['secret'])

	readonly.show()
	readwrite.show()

	menu.append(readonly)
	menu.append(readwrite)

	return menu
Example #14
0
    def EventoSoltar(self, car, event, data=None):
        global maximoNivel, deshacer, intentos, tablero, cars, coches, tbox_level
        car.arrastrando = False

        if car.orientacion == 'H':
            movimientox = int(event.x_root) - car.xInicial
            nuevax = int((car.coordenadax + movimientox) / sizeRecuadro)
            nuevay = int(car.coordenaday / sizeRecuadro)

            if nuevax < car.limiteIz:  #si el puntero se sale del tablero el coche permanece en la maxima posicion que puede alcanzar por ese lado
                nuevax = car.limiteIz
            elif nuevax > car.limiteDe:
                nuevax = car.limiteDe
            else:
                nuevax = nuevax

        else:

            movimientoy = int(event.y_root) - car.yInicial
            nuevay = int((car.coordenaday + movimientoy) / sizeRecuadro)
            nuevax = int((car.coordenadax) / sizeRecuadro)

            if nuevay < car.limiteAr:
                nuevay = car.limiteAr
            elif nuevay > car.limiteAb:
                nuevay = car.limiteAb
            else:
                nuevay = nuevay

        car.coordenadax = nuevax * sizeRecuadro
        car.coordenaday = nuevay * sizeRecuadro

        tablero.move(car, car.coordenadax, car.coordenaday)

        actualizarPosiciones()

        imagen_reset = gtk.Image(
        )  #Como ya ha empezado a jugar permite que se pueda pulsar el boton de reset de nivel
        imagen_reset.set_from_file("Images/reset.png")
        reset.set_image(imagen_reset)
        reset.set_sensitive(True)
        reset.connect_object("clicked", self.Reiniciar, car)

        if car.letra == 'A' and int(
                car.coordenadax / sizeRecuadro) == 5:  #Condicion de victoria

            victoria = gtk.EventBox(
            )  #Muestra una imagen felicitando al jugador
            victoria.modify_bg(gtk.STATE_NORMAL,
                               victoria.get_colormap().alloc_color('white'))
            cars.append(victoria)
            win = gtk.Image()
            win.show()
            win.set_from_file('Images/win.gif')
            victoria.add(win)
            victoria.set_visible_window(False)
            tablero.put(victoria, 0, 0)
            victoria.show()
            mensajeIntentos.set_label('Lo has conseguido en ' + str(intentos) +
                                      ' movimientos')

            Records(
                intentos
            )  #Se actualizan los records y dependiendo de los niveles jugados habilita los botones correspondientes y uno mas
            records = open('records.txt', 'r')
            lista = records.readlines()
            maximoNivel = len(lista)
            records.close()

            for n in range(maximoNivel):
                botones[n].set_sensitive(True)
                botones[n].set_relief(gtk.RELIEF_NORMAL)
                if n == 19:
                    break

            tbox_level.set_text("1-" + str(maximoNivel))

        return gtk.TRUE
Example #15
0
    def dialog_tablecolhandle(self, title, rename_text):
        """Opens the Table Column Handle Dialog"""
        dialog = gtk.Dialog(title=title,
                            parent=self.dad.window,
                            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                     gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        dialog.set_default_size(300, -1)
        dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        hbox_column_rename = gtk.HBox()
        image_column_rename = gtk.Image()
        image_column_rename.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON)
        table_column_rename_radiobutton = gtk.RadioButton(label=_("Rename Column"))
        table_column_rename_entry = gtk.Entry()
        table_column_rename_entry.set_text(rename_text)
        table_column_rename_entry.set_sensitive(self.dad.table_column_mode == 'rename')
        hbox_column_rename.pack_start(image_column_rename, expand=False)
        hbox_column_rename.pack_start(table_column_rename_radiobutton)
        hbox_column_rename.pack_start(table_column_rename_entry)

        hbox_column_delete = gtk.HBox()
        image_column_delete = gtk.Image()
        image_column_delete.set_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON)
        table_column_delete_radiobutton = gtk.RadioButton(label=_("Delete Column"))
        table_column_delete_radiobutton.set_group(table_column_rename_radiobutton)
        hbox_column_delete.pack_start(image_column_delete, expand=False)
        hbox_column_delete.pack_start(table_column_delete_radiobutton)

        hbox_column_add = gtk.HBox()
        image_column_add = gtk.Image()
        image_column_add.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
        table_column_add_radiobutton = gtk.RadioButton(label=_("Add Column"))
        table_column_add_radiobutton.set_group(table_column_rename_radiobutton)
        table_column_new_entry = gtk.Entry()
        hbox_column_add.pack_start(image_column_add, expand=False)
        hbox_column_add.pack_start(table_column_add_radiobutton)
        hbox_column_add.pack_start(table_column_new_entry)
        table_column_new_entry.set_sensitive(self.dad.table_column_mode == 'add')

        hbox_column_left = gtk.HBox()
        image_column_left = gtk.Image()
        image_column_left.set_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_BUTTON)
        table_column_left_radiobutton = gtk.RadioButton(label=_("Move Column Left"))
        table_column_left_radiobutton.set_group(table_column_rename_radiobutton)
        hbox_column_left.pack_start(image_column_left, expand=False)
        hbox_column_left.pack_start(table_column_left_radiobutton)

        hbox_column_right = gtk.HBox()
        image_column_right = gtk.Image()
        image_column_right.set_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
        table_column_right_radiobutton = gtk.RadioButton(label=_("Move Column Right"))
        table_column_right_radiobutton.set_group(table_column_rename_radiobutton)
        hbox_column_right.pack_start(image_column_right, expand=False)
        hbox_column_right.pack_start(table_column_right_radiobutton)

        table_column_rename_radiobutton.set_active(self.dad.table_column_mode == "rename")
        table_column_delete_radiobutton.set_active(self.dad.table_column_mode == "delete")
        table_column_add_radiobutton.set_active(self.dad.table_column_mode == "add")
        table_column_left_radiobutton.set_active(self.dad.table_column_mode == cons.TAG_PROP_LEFT)
        table_column_right_radiobutton.set_active(self.dad.table_column_mode == cons.TAG_PROP_RIGHT)
        if self.dad.table_column_mode == "rename":
            table_column_rename_entry.grab_focus()
        elif self.dad.table_column_mode == "add":
            table_column_new_entry.grab_focus()

        tablehandle_vbox_col = gtk.VBox()
        tablehandle_vbox_col.pack_start(hbox_column_rename)
        tablehandle_vbox_col.pack_start(hbox_column_delete)
        tablehandle_vbox_col.pack_start(hbox_column_add)
        tablehandle_vbox_col.pack_start(hbox_column_left)
        tablehandle_vbox_col.pack_start(hbox_column_right)

        content_area = dialog.get_content_area()
        content_area.set_spacing(5)
        content_area.pack_start(tablehandle_vbox_col)
        content_area.show_all()

        def on_key_press_tablecolhandle(widget, event):
            keyname = gtk.gdk.keyval_name(event.keyval)
            if keyname == cons.STR_KEY_RETURN:
                try:
                    dialog.get_widget_for_response(gtk.RESPONSE_ACCEPT).clicked()
                except:
                    print cons.STR_PYGTK_222_REQUIRED
                return True
            elif keyname == cons.STR_KEY_TAB:
                if self.dad.table_column_mode == "rename":
                    table_column_delete_radiobutton.set_active(True)
                elif self.dad.table_column_mode == "delete":
                    table_column_add_radiobutton.set_active(True)
                elif self.dad.table_column_mode == "add":
                    table_column_left_radiobutton.set_active(True)
                elif self.dad.table_column_mode == cons.TAG_PROP_LEFT:
                    table_column_right_radiobutton.set_active(True)
                else:
                    table_column_rename_radiobutton.set_active(True)
                return True
            return False

        def on_table_column_rename_radiobutton_toggled(radiobutton):
            if radiobutton.get_active():
                table_column_rename_entry.set_sensitive(True)
                self.dad.table_column_mode = "rename"
                table_column_rename_entry.grab_focus()
            else:
                table_column_rename_entry.set_sensitive(False)

        def on_table_column_delete_radiobutton_toggled(radiobutton):
            if radiobutton.get_active(): self.dad.table_column_mode = "delete"

        def on_table_column_add_radiobutton_toggled(radiobutton):
            if radiobutton.get_active():
                table_column_new_entry.set_sensitive(True)
                self.dad.table_column_mode = "add"
                table_column_new_entry.grab_focus()
            else:
                table_column_new_entry.set_sensitive(False)

        def on_table_column_left_radiobutton_toggled(radiobutton):
            if radiobutton.get_active(): self.dad.table_column_mode = cons.TAG_PROP_LEFT

        def on_table_column_right_radiobutton_toggled(radiobutton):
            if radiobutton.get_active(): self.dad.table_column_mode = cons.TAG_PROP_RIGHT

        dialog.connect('key_press_event', on_key_press_tablecolhandle)
        table_column_rename_radiobutton.connect('toggled', on_table_column_rename_radiobutton_toggled)
        table_column_delete_radiobutton.connect('toggled', on_table_column_delete_radiobutton_toggled)
        table_column_add_radiobutton.connect('toggled', on_table_column_add_radiobutton_toggled)
        table_column_left_radiobutton.connect('toggled', on_table_column_left_radiobutton_toggled)
        table_column_right_radiobutton.connect('toggled', on_table_column_right_radiobutton_toggled)
        response = dialog.run()
        dialog.hide()
        if response == gtk.RESPONSE_ACCEPT:
            ret_rename = unicode(table_column_rename_entry.get_text(), cons.STR_UTF8, cons.STR_IGNORE)
            ret_add = unicode(table_column_new_entry.get_text(), cons.STR_UTF8, cons.STR_IGNORE)
            return [True, ret_rename, ret_add]
        return [False, None, None]
Example #16
0
def send_bugtracker(title, msg):
    from tryton import rpc
    parent = get_toplevel_window()
    win = gtk.Dialog(
        _('Bug Tracker'), parent,
        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
    win.set_icon(TRYTON_ICON)
    win.set_default_response(gtk.RESPONSE_OK)

    hbox = gtk.HBox()
    image = gtk.Image()
    image.set_from_stock('tryton-dialog-information', gtk.ICON_SIZE_DIALOG)
    hbox.pack_start(image, False, False)

    table = gtk.Table(2, 2)
    table.set_col_spacings(3)
    table.set_row_spacings(3)
    table.set_border_width(1)
    label_user = gtk.Label(_('User:'******'Password:'******'ascii', 'replace')
            protocol = 'http'
            if ssl or hasattr(socket, 'ssl'):
                protocol = 'https'
            quote = partial(urllib.quote, safe="!$&'()*+,;=:")
            server = xmlrpclib.Server(
                ('%s://%s:%s@' + CONFIG['roundup.xmlrpc']) %
                (protocol, quote(user), quote(password)),
                allow_none=True)
            if hashlib:
                msg_md5 = hashlib.md5(msg + '\n' + title).hexdigest()
            else:
                msg_md5 = md5.new(msg + '\n' + title).hexdigest()
            if not title:
                title = '[no title]'
            issue_id = None
            msg_ids = server.filter('msg', None, {'summary': str(msg_md5)})
            for msg_id in msg_ids:
                summary = server.display('msg%s' % msg_id,
                                         'summary')['summary']
                if summary == msg_md5:
                    issue_ids = server.filter('issue', None,
                                              {'messages': msg_id})
                    if issue_ids:
                        issue_id = issue_ids[0]
                        break
            if issue_id:
                # issue to same message already exists, add user to nosy-list
                server.set('issue' + str(issue_id), *['nosy=+' + user])
                message(
                    _('The same bug was already reported by another user.\n'
                      'To keep you informed your username is added '
                      'to the nosy-list of this issue') + '%s' % issue_id)
            else:
                # create a new issue for this error-message
                # first create message
                msg_id = server.create(
                    'msg', *[
                        'content=' + msg, 'author=' + user,
                        'summary=' + msg_md5
                    ])
                # second create issue with this message
                issue_id = server.create(
                    'issue', *[
                        'messages=' + str(msg_id), 'nosy=' + user,
                        'title=' + title, 'priority=bug'
                    ])
                message(_('Created new bug with ID ') + 'issue%s' % issue_id)
            webbrowser.open(CONFIG['roundup.url'] + 'issue%s' % issue_id,
                            new=2)
        except (socket.error, xmlrpclib.Fault), exception:
            if (isinstance(exception, xmlrpclib.Fault)
                    and 'roundup.cgi.exceptions.Unauthorised'
                    in exception.faultString):
                message(_('Connection error.\nBad username or password.'))
                return send_bugtracker(title, msg)
            tb_s = reduce(
                lambda x, y: x + y,
                traceback.format_exception(sys.exc_type, sys.exc_value,
                                           sys.exc_traceback))
            message(_('Exception:') + '\n' + tb_s, msg_type=gtk.MESSAGE_ERROR)
 def _set_vm_status_icon(self, vm, menu_item):
     image = gtk.Image()
     image.set_from_icon_name(vm.run_status_icon_name(), gtk.ICON_SIZE_MENU)
     image.set_sensitive(vm.is_active())
     menu_item.set_image(image)
    def __init__(self, handle):
        """Set up the Elephant activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

        share_button = ShareButton(self)
        toolbar_box.toolbar.insert(share_button, -1)
        share_button.show()

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        # Instances to Elephants classes
        words = elephant.word_list()

        # Get a word form word list and path
        self.get_random_word(words)

        # Vertical box conteinter definition
        vbox_main = gtk.VBox()

        # Horizontal boxes conteiners definition
        hbox_01 = gtk.HBox()
        hbox_02 = gtk.HBox()
        hbox_03 = gtk.HBox()

        # Buttons definitions
        self.button_repeat = gtk.Button()
        self.button_repeat.set_label('Repetir')

        self.button_option1 = gtk.Button()
        self.button_option2 = gtk.Button()
        self.button_option3 = gtk.Button()

        # Image and label word
        self.label_word = gtk.Label()
        self.image_word = gtk.Image()
        #self.image_word = self.show_image(path)
        #self.label_word = self.show_label(word)

        # Create layout
        self.set_canvas(vbox_main)
        vbox_main.add(hbox_01)
        vbox_main.add(hbox_02)
        vbox_main.add(hbox_03)

        # Put label and label on layout
        hbox_02.add(self.image_word)
        hbox_02.add(self.label_word)

        # conectors
        self.connect('realize', self.__window_realize)
        self.button_repeat.connect('clicked', self.__button_clicked_rep)
        self.button_option1.connect('clicked', self.__button_clicked_op)
        self.button_option2.connect('clicked', self.__button_clicked_op)
        self.button_option3.connect('clicked', self.__button_clicked_op)

        # Put buttons on layout
        hbox_01.add(self.button_repeat)
        hbox_03.add(self.button_option1)
        hbox_03.add(self.button_option2)
        hbox_03.add(self.button_option3)

        # ShowMeTheMoney!!!
        vbox_main.show_all()
        #label_word.show()
        self.elephant_is_saying()
def drawmainbuttons():

    try:
        global mainbuttonsbox
        mainbuttonsbox.destroy()

    except:
        pass

    mainbuttonsbox = gtk.HBox()

    # scenes

    scender = gtk.Button()
    scender.props.relief = gtk.RELIEF_NONE
    scenbox = gtk.HBox(False)
    scenico = gtk.Image()
    scenico.set_from_file("py_data/icons/scn_asset_undone.png")
    if CUR == "rnd":
        scenico.set_from_file("py_data/icons/scn_asset_done.png")
    scenbox.pack_start(scenico, False)
    scenbox.pack_start(gtk.Label("  Story Editor"))
    scender.add(scenbox)
    scender.set_tooltip_text("The Famous Blender-Organizer Story Editor")
    scender.connect("clicked", chgCUR, "rnd")
    mainbuttonsbox.pack_start(scender, False)

    # characters

    charder = gtk.Button()
    charder.props.relief = gtk.RELIEF_NONE
    charbox = gtk.HBox(False)
    charico = gtk.Image()
    charico.set_from_file("py_data/icons/chr_asset_undone.png")
    if CUR == "chr":
        charico.set_from_file("py_data/icons/chr_asset_done.png")
    charbox.pack_start(charico, False)
    charbox.pack_start(gtk.Label("  Characters"))
    charder.add(charbox)
    charder.set_tooltip_text(
        "Do The People. The Characters. \nThe Humans. The Aliens.\n The Monsters"
    )
    charder.connect("clicked", chgCUR, "chr")
    mainbuttonsbox.pack_start(charder, False)

    # vehicles

    vehider = gtk.Button()
    vehider.props.relief = gtk.RELIEF_NONE
    vehibox = gtk.HBox(False)
    vehiico = gtk.Image()
    vehiico.set_from_file("py_data/icons/veh_asset_undone.png")
    if CUR == "veh":
        vehiico.set_from_file("py_data/icons/veh_asset_done.png")
    vehibox.pack_start(vehiico, False)
    vehibox.pack_start(gtk.Label("  Vehicles"))
    vehider.add(vehibox)
    vehider.set_tooltip_text(
        "People Should Have Cars. \nIK It's a little bit Hibdy Bi.\nBut I love cars so much, they have to have their own tab"
    )
    vehider.connect("clicked", chgCUR, "veh")
    mainbuttonsbox.pack_start(vehider, False)

    # locations

    locider = gtk.Button()
    locider.props.relief = gtk.RELIEF_NONE
    locibox = gtk.HBox(False)
    lociico = gtk.Image()
    lociico.set_from_file("py_data/icons/loc_asset_undone.png")
    if CUR == "loc":
        lociico.set_from_file("py_data/icons/loc_asset_done.png")
    locibox.pack_start(lociico, False)
    locibox.pack_start(gtk.Label("  Locations"))
    locider.add(locibox)
    locider.set_tooltip_text(
        "The Places. The Settings.\nThe Backgrounds. The Cities.\nThe Houses. YOU KNOW."
    )
    locider.connect("clicked", chgCUR, "loc")
    mainbuttonsbox.pack_start(locider, False)

    # Objects

    objider = gtk.Button()
    objider.props.relief = gtk.RELIEF_NONE
    objibox = gtk.HBox(False)
    objiico = gtk.Image()
    objiico.set_from_file("py_data/icons/obj_asset_undone.png")
    if CUR == "obj":
        objiico.set_from_file("py_data/icons/obj_asset_done.png")
    objibox.pack_start(objiico, False)
    objibox.pack_start(gtk.Label("  Other"))
    objider.add(objibox)
    objider.set_tooltip_text("All The Other Junk")
    objider.connect("clicked", chgCUR, "obj")
    mainbuttonsbox.pack_start(objider, False)

    toppannelbox.pack_start(mainbuttonsbox, False)

    mainbuttonsbox.show_all()
Example #20
0
    def __init__(self, tviews, uicore):
        super(RightCombo, self).__init__(1, 7, False)

        self.tviews = tviews
        self.uicore = uicore

        # Theme Label
        self.theme_label = gtk.Label('Color theme:')
        self.attach(self.theme_label, 0, 1, 0, 1)

        # Theme ComboBox
        self.theme_combo = gtk.combo_box_new_text()
        options = ['Classic', 'Cobalt', 'kate', 'Oblivion', 'Tango']
        for option in options:
            self.theme_combo.append_text(option)
        # Set first by default
        self.theme_combo.set_active(0)

        self.theme_combo.connect("changed", self.theme_combo_change)
        self.attach(self.theme_combo, 1, 2, 0, 1)

        # Right Combo Label
        self.rc_label = gtk.Label('Data format:')
        self.attach(self.rc_label, 2, 3, 0, 1)

        # Right ComboBox
        self.right_combo = gtk.combo_box_new_text()
        #        options = ['Disassembly', "Hexdump", "String Repr", "Strings", "Plain Text", 'URL']
        #        for option in options:
        #            self.right_combo.append_text(option)
        #        # Set Disassembly by default
        #        self.right_combo.set_active(0)
        #        self.create_options()

        self.connect = self.right_combo.connect("changed",
                                                self.right_combo_change)
        self.attach(self.right_combo, 3, 4, 0, 1)

        #
        # Open File Stuff

        # Open file label
        self.open_label = gtk.Label('File to open:')
        self.attach(self.open_label, 4, 5, 0, 1)

        # Open file text entry
        self.open_entry = gtk.Entry(100)
        self.attach(self.open_entry, 5, 6, 0, 1)

        # Open file button
        self.open_button = gtk.Button()

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_MENU)

        #        self.open_button.connect("clicked", self.open_new_file)
        self.open_button.set_image(image)
        self.open_button.set_relief(gtk.RELIEF_NONE)
        self.open_button.set_sensitive(False)

        self.attach(self.open_button, 6, 7, 0, 1)
Example #21
0
    def _create_toolitems_2_4(self):
        # use the GTK+ 2.4 GtkToolbar API
        iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR
        if not _new_tooltip_api:
            self.tooltips = gtk.Tooltips()

        for text, tooltip_text, image_num, callback, callback_arg, scroll \
                in self.toolitems:
            if text is None:
                self.insert( gtk.SeparatorToolItem(), -1 )
                continue
            image = gtk.Image()
            image.set_from_stock(image_num, iconSize)
            tbutton = gtk.ToolButton(image, text)
            self.insert(tbutton, -1)
            if callback_arg:
                tbutton.connect('clicked', getattr(self, callback),
                                callback_arg)
            else:
                tbutton.connect('clicked', getattr(self, callback))
            if scroll:
                tbutton.connect('scroll_event', getattr(self, callback))
            if _new_tooltip_api:
                tbutton.set_tooltip_text(tooltip_text)
            else:
                tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')

        # Axes toolitem, is empty at start, update() adds a menu if >=2 axes
        self.axes_toolitem = gtk.ToolItem()
        self.insert(self.axes_toolitem, 0)
        if _new_tooltip_api:
            self.axes_toolitem.set_tooltip_text(
                                'Select axes that controls affect')
        else:
            self.axes_toolitem.set_tooltip (
                self.tooltips,
                tip_text='Select axes that controls affect',
                tip_private = 'Private')

        align = gtk.Alignment (xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
        self.axes_toolitem.add(align)

        self.menubutton = gtk.Button ("Axes")
        align.add (self.menubutton)

        def position_menu (menu):
            """Function for positioning a popup menu.
            Place menu below the menu button, but ensure it does not go off
            the bottom of the screen.
            The default is to popup menu at current mouse position
            """
            x0, y0    = self.window.get_origin()
            x1, y1, m = self.window.get_pointer()
            x2, y2    = self.menubutton.get_pointer()
            sc_h      = self.get_screen().get_height()  # requires GTK+ 2.2 +
            w, h      = menu.size_request()

            x = x0 + x1 - x2
            y = y0 + y1 - y2 + self.menubutton.allocation.height
            y = min(y, sc_h - h)
            return x, y, True

        def button_clicked (button, data=None):
            self.axismenu.popup (None, None, position_menu, 0,
                                 gtk.get_current_event_time())

        self.menubutton.connect ("clicked", button_clicked)
Example #22
0
    def __init__(self, filename=None):
        """
        Database restore widget
        """
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_("Restore Database"),
                                 parent=self.parent,
                                 flags=gtk.DIALOG_MODAL
                                 | gtk.WIN_POS_CENTER_ON_PARENT)
        vbox = gtk.VBox()
        self.dialog.vbox.pack_start(vbox)
        self.tooltips = common.Tooltips()
        table = gtk.Table(6, 3, False)
        table.set_border_width(9)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        vbox.pack_start(table)
        self.label_server_url = gtk.Label(_("Server Connection:"))
        self.label_server_url.set_size_request(117, -1)
        self.label_server_url.set_alignment(1, 0.5)
        self.label_server_url.set_padding(3, 3)
        table.attach(self.label_server_url, 0, 1, 0, 1, yoptions=gtk.FILL)
        self.entry_server_url = gtk.Entry()
        self.entry_server_url.set_sensitive(False)
        self.entry_server_url.unset_flags(gtk.CAN_FOCUS)
        self.entry_server_url.set_editable(False)
        self.entry_server_url.set_activates_default(True)
        self.entry_server_url.set_width_chars(16)
        self.tooltips.set_tip(
            self.entry_server_url,
            _("This is the URL of "
              "the server. Use server 'localhost' and port '8000' if "
              "the server is installed on this computer. Click on "
              "'Change' to change the address."))
        table.attach(self.entry_server_url, 1, 2, 0, 1, yoptions=gtk.FILL)
        self.button_server_change = gtk.Button(_("C_hange"),
                                               stock=None,
                                               use_underline=True)
        img_button_server_change = gtk.Image()
        img_button_server_change.set_from_stock('tryton-preferences-system',
                                                gtk.ICON_SIZE_BUTTON)
        self.button_server_change.set_image(img_button_server_change)
        self.tooltips.set_tip(self.button_server_change,
                              _("Setup the "
                                "server connection..."))
        table.attach(self.button_server_change, 2, 3, 0, 1, yoptions=gtk.FILL)
        self.label_server_password = gtk.Label(_("Tryton Server Password:"******"This is the "
              "password of the Tryton server. It doesn't belong to a "
              "real user. This password is usually defined in the trytond "
              "configuration."))
        table.attach(self.entry_server_password, 1, 3, 1, 2, yoptions=gtk.FILL)
        self.hseparator = gtk.HSeparator()
        table.attach(self.hseparator, 0, 3, 2, 3, yoptions=gtk.FILL)
        label_filename = gtk.Label()
        label_filename.set_markup(_("File to Restore:"))
        label_filename.set_alignment(1, 0.5)
        table.attach(label_filename, 0, 1, 3, 4, yoptions=gtk.FILL)
        entry_filename = gtk.Label()
        entry_filename.set_markup("<tt>" + filename + "</tt>")
        table.attach(entry_filename, 1, 3, 3, 4, yoptions=gtk.FILL)
        self.entry_db_name = gtk.Entry()
        self.entry_db_name.set_visibility(True)
        self.entry_db_name.set_activates_default(True)
        self.entry_db_name.set_width_chars(16)
        self.entry_db_name.set_max_length(63)
        handlerid = self.entry_db_name.connect("insert-text",
                                               self.entry_insert_text)
        self.entry_db_name.set_data('handlerid', handlerid)
        self.tooltips.set_tip(
            self.entry_db_name,
            _("Choose the name of "
              "the database to be restored.\n"
              "Allowed characters are alphanumerical or _ (underscore)\n"
              "You need to avoid all accents, space or special "
              "characters! \nExample: tryton"))
        table.attach(self.entry_db_name, 1, 3, 4, 5, yoptions=gtk.FILL)
        label_db_name = gtk.Label(_("New Database Name:"))
        label_db_name.set_alignment(1, 0.5)
        table.attach(label_db_name, 0, 1, 4, 5, yoptions=gtk.FILL)
        label_db_update = gtk.Label(_('Update Database:'))
        label_db_update.set_alignment(1, 0.5)
        table.attach(label_db_update, 0, 1, 5, 6, yoptions=gtk.FILL)
        self.check_update = gtk.CheckButton()
        self.tooltips.set_tip(
            self.check_update,
            _('Check for an automatic '
              'database update after restoring a database from a previous '
              'Tryton version.'))
        self.check_update.set_active(True)
        table.attach(self.check_update, 1, 3, 5, 6, yoptions=gtk.FILL)
        # Buttons and events
        self.dialog.connect("key-press-event", self.event_show_button_restore)
        self.dialog.add_button("gtk-cancel", gtk.RESPONSE_CANCEL)
        self.button_restore = gtk.Button(_('Restore'))
        self.button_restore.set_flags(gtk.CAN_DEFAULT)
        self.button_restore.set_flags(gtk.HAS_DEFAULT)
        self.button_restore.set_sensitive(False)
        img_restore = gtk.Image()
        img_restore.set_from_stock('tryton-folder-saved-search',
                                   gtk.ICON_SIZE_BUTTON)
        self.button_restore.set_image(img_restore)
        self.tooltips.set_tip(self.button_restore,
                              _('Restore the database from file.'))
        self.dialog.add_action_widget(self.button_restore, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)

        self.entry_server_password.grab_focus()
    def __init__(self, parent):
        super(JigsawPuzzleUI, self).__init__(border_color=COLOR_FRAME_OUTER)

        self._shuffling = False

        self._parent = parent
        # We want the translatables to be detected but not yet translated
        global _
        _ = lambda x: x
        self.labels_to_translate = []

        self._state = GAME_IDLE
        self._readonly = False
        self._join_time = 0

        inner_table = gtk.Table(2, 2, False)
        self.add(inner_table)

        self.game = JigsawPuzzleWidget()
        self.game.connect('picked', self.piece_pick_cb, False)
        self.game.connect('dropped', self.piece_drop_cb)
        self.game.connect('solved', self.do_solve)
        self.game.connect('cutter-changed', self.cutter_change_cb)
        self.game.show()

        # panel is a holder for everything on the left side down to (not inclusive) the language dropdown
        panel = gtk.VBox()

        # Logo image
        img_logo = gtk.Image()
        img_logo.set_from_file("icons/logo.png")
        img_logo.show()
        panel.pack_start(img_logo, expand=False, fill=False)

        # Control panel has the image controls
        control_panel = BorderFrame(border=BORDER_ALL_BUT_BOTTOM,
                                    border_color=COLOR_FRAME_CONTROLS,
                                    bg_color=COLOR_BG_CONTROLS)
        control_panel_box = gtk.VBox()

        scrolled = gtk.ScrolledWindow()
        scrolled.props.hscrollbar_policy = gtk.POLICY_NEVER
        scrolled.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
        scrolled.show()
        scrolled.add_with_viewport(control_panel_box)
        scrolled.child.modify_bg(gtk.STATE_NORMAL,
                                 gtk.gdk.color_parse(COLOR_BG_CONTROLS))
        control_panel.add(scrolled)

        spacer = gtk.Label()
        spacer.set_size_request(-1, 5)
        control_panel_box.pack_start(spacer, expand=False, fill=False)

        btn_box = gtk.Table(2, 5, False)
        btn_box.set_col_spacings(5)
        btn_box.set_row_spacings(5)
        btn_box.attach(gtk.Label(), 0, 1, 0, 2)
        # Cut type buttons
        self.btn_basic_cut = gtk.ToggleButton()
        i = gtk.Image()
        i.set_from_pixbuf(
            utils.load_image(os.path.join('icons', 'cut_basic.svg')))
        self.btn_basic_cut.set_image(i)
        btn_box.attach(prepare_btn(self.btn_basic_cut), 1, 2, 0, 1, 0, 0)
        self.btn_simple_cut = gtk.ToggleButton()
        i = gtk.Image()
        i.set_from_pixbuf(
            utils.load_image(os.path.join('icons', 'cut_simple.svg')))
        self.btn_simple_cut.set_image(i)
        btn_box.attach(prepare_btn(self.btn_simple_cut), 2, 3, 0, 1, 0, 0)
        self.btn_classic_cut = gtk.ToggleButton()
        i = gtk.Image()
        i.set_from_pixbuf(
            utils.load_image(os.path.join('icons', 'cut_classic.svg')))
        self.btn_classic_cut.set_image(i)
        # Link cutter buttons with cutter styles
        self.btn_cut_mapping = {
            'basic': self.btn_basic_cut,
            'simple': self.btn_simple_cut,
            'classic': self.btn_classic_cut,
        }
        for k, v in self.btn_cut_mapping.items():
            v.connect("released", self.set_piece_cut, k)

        btn_box.attach(prepare_btn(self.btn_classic_cut), 3, 4, 0, 1, 0, 0)
        # Difficulty level buttons
        self.btn_easy_level = gtk.ToggleButton()
        i = gtk.Image()
        i.set_from_pixbuf(
            utils.load_image(os.path.join('icons', 'level_easy.svg')))
        self.btn_easy_level.set_active(True)
        self.btn_easy_level.set_image(i)
        btn_box.attach(prepare_btn(self.btn_easy_level), 1, 2, 1, 2, 0, 0)
        self.btn_normal_level = gtk.ToggleButton()
        i = gtk.Image()
        i.set_from_pixbuf(
            utils.load_image(os.path.join('icons', 'level_normal.svg')))
        self.btn_normal_level.set_image(i)
        btn_box.attach(prepare_btn(self.btn_normal_level), 2, 3, 1, 2, 0, 0)
        self.btn_hard_level = gtk.ToggleButton()
        i = gtk.Image()
        i.set_from_pixbuf(
            utils.load_image(os.path.join('icons', 'level_hard.svg')))
        self.btn_hard_level.set_image(i)
        # Link level buttons with levels
        self.btn_level_mapping = {
            3: self.btn_easy_level,
            5: self.btn_normal_level,
            8: self.btn_hard_level,
        }
        for k, v in self.btn_level_mapping.items():
            v.connect("released", self.set_level, k)

        btn_box.attach(prepare_btn(self.btn_hard_level), 3, 4, 1, 2, 0, 0)

        btn_box.attach(gtk.Label(), 4, 5, 0, 2)
        control_panel_box.pack_start(btn_box, expand=False)

        self.thumb = ImageSelectorWidget(frame_color=COLOR_FRAME_THUMB,
                                         prepare_btn_cb=prepare_btn,
                                         method=utils.RESIZE_PAD,
                                         image_dir="images",
                                         parent=self._parent)
        self.thumb.connect("category_press", self.do_select_category)
        self.thumb.connect("image_press", self.do_shuffle)
        control_panel_box.pack_start(self.thumb, expand=False)

        spacer = gtk.Label()
        spacer.set_size_request(-1, 5)
        control_panel_box.pack_start(spacer, expand=False, fill=False)

        # The game control buttons
        btn_box = gtk.Table(3, 4, False)
        btn_box.set_row_spacings(2)
        btn_box.attach(gtk.Label(), 0, 1, 0, 4)
        btn_box.attach(gtk.Label(), 2, 3, 0, 4)
        self.btn_solve = prepare_btn(gtk.Button(" "), 200)
        self.labels_to_translate.append([self.btn_solve, _("Solve")])
        self.btn_solve.connect("clicked", self.do_solve)
        btn_box.attach(self.btn_solve, 1, 2, 0, 1, 0, 0)
        self.btn_shuffle = prepare_btn(gtk.Button(" "), 200)
        self.labels_to_translate.append([self.btn_shuffle, _("Shuffle")])
        self.btn_shuffle.connect("clicked", self.do_shuffle)
        btn_box.attach(self.btn_shuffle, 1, 2, 1, 2, 0, 0)
        self.btn_add = prepare_btn(gtk.Button(" "), 200)
        self.labels_to_translate.append([self.btn_add, _("My Picture")])
        self.btn_add.connect("clicked", self.do_add_image)
        btn_box.attach(self.btn_add, 1, 2, 2, 3, 0, 0)
        self.btn_hint = prepare_btn(gtk.ToggleButton(" "), 200)
        self.labels_to_translate.append([self.btn_hint, _("Board Hint")])
        self.btn_hint.connect("clicked", self.do_show_hint)
        btn_box.attach(self.btn_hint, 1, 2, 3, 4, 0, 0)
        control_panel_box.pack_start(btn_box, False)
        self.control_panel_box = control_panel_box

        # Control panel end
        panel.pack_start(control_panel, expand=True, fill=True)

        inner_table.attach(panel, 0, 1, 0, 1, 0)

        self.game_box = BorderFrame(border_color=COLOR_FRAME_GAME)
        self.game_box.add(self.game)

        self.notebook = gtk.Notebook()
        self.notebook.show()
        self.notebook.props.show_border = False
        self.notebook.props.show_tabs = False
        self.notebook.append_page(self.game_box)
        inner_table.attach(self.notebook, 1, 2, 0, 1)

        lang_combo = prepare_btn(
            LanguageComboBox('org.worldwideworkshop.olpc.JigsawPuzzle'))
        lang_combo.connect('changed', self.do_select_language)
        # Push the gettext translator into the global namespace
        del _
        lang_combo.install()
        lang_box = BorderFrame(bg_color=COLOR_BG_CONTROLS,
                               border_color=COLOR_FRAME_CONTROLS)
        hbox = gtk.HBox(False)
        vbox = gtk.VBox(False)
        vbox.pack_start(lang_combo, padding=8)
        hbox.pack_start(vbox, padding=8)
        lang_box.add(hbox)
        inner_table.attach(lang_box, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        timer_box = BorderFrame(border=BORDER_ALL_BUT_LEFT,
                                bg_color=COLOR_BG_CONTROLS,
                                border_color=COLOR_FRAME_CONTROLS)
        timer_hbox = gtk.HBox(False)
        self.timer = TimerWidget(bg_color=COLOR_BG_BUTTONS[0][1],
                                 fg_color=COLOR_FG_BUTTONS[0][1],
                                 lbl_color=COLOR_BG_BUTTONS[1][1])
        self.timer.set_sensitive(False)
        self.timer.set_border_width(3)
        self.labels_to_translate.append((self.timer, _("Time: ")))
        timer_hbox.pack_start(self.timer, False, padding=8)
        self.timer.connect('timer_toggle', self.timer_toggle_cb)

        self.msg_label = gtk.Label()
        self.msg_label.show()
        timer_hbox.pack_start(self.msg_label, True)

        self.btn_lesson = prepare_btn(gtk.Button(" "))
        self.labels_to_translate.append([self.btn_lesson, _("Lesson Plans")])
        self.btn_lesson.connect("clicked", self.do_lesson_plan)
        timer_hbox.pack_start(self.btn_lesson, False, padding=8)
        vbox = gtk.VBox(False)
        vbox.pack_start(timer_hbox, padding=8)
        timer_box.add(vbox)
        inner_table.attach(timer_box, 1, 2, 1, 2, gtk.FILL, gtk.FILL)
        #panel.pack_start(lang_box, expand=False, fill=False)

        self.do_select_language(lang_combo)

        self.buddy_panel = BuddyPanel(BUDDYMODE_COLLABORATION)
        self.buddy_panel.show()

        if not parent._shared_activity:
            self.do_select_category(self)

        self.set_contest_mode(False)

        # Assert consistent state
        self.cutter_change_cb(None, self.game.get_cutter(),
                              self.game.get_target_pieces_per_line())
Example #24
0
    def __init__(self, stack, title, message, callback, image):
        log(None, stack, title, message, callback, image)
        self.stack = stack
        gtk.Window.__init__(self)

        self.set_size_request(stack.size_x, -1)
        self.set_decorated(False)
        self.set_deletable(False)
        self.set_property("skip-pager-hint", True)
        self.set_property("skip-taskbar-hint", True)
        self.connect("enter-notify-event", self.on_hover, True)
        self.connect("leave-notify-event", self.on_hover, False)
        self.set_opacity(0.2)
        self.set_keep_above(True)
        self.destroy_cb = stack.destroy_popup_cb

        main_box = gtk.VBox()
        header_box = gtk.HBox()
        self.header = gtk.Label()
        self.header.set_markup("<b>%s</b>" % title)
        self.header.set_padding(3, 3)
        self.header.set_alignment(0, 0)
        header_box.pack_start(self.header, True, True, 5)
        if True:
            close_button = gtk.Image()
            close_button.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON)
            close_button.set_padding(3, 3)
            close_window = gtk.EventBox()
            close_window.set_visible_window(False)
            close_window.connect("button-press-event", self.hide_notification)
            close_window.add(close_button)
            header_box.pack_end(close_window, False, False)
        main_box.pack_start(header_box)

        body_box = gtk.HBox()
        if image is not None:
            self.image = gtk.Image()
            self.image.set_size_request(70, 70)
            self.image.set_alignment(0, 0)
            self.image.set_from_pixbuf(image)
            body_box.pack_start(self.image, False, False, 5)
        self.message = gtk.Label()
        self.message.set_property("wrap", True)
        self.message.set_size_request(stack.size_x - 90, -1)
        self.message.set_alignment(0, 0)
        self.message.set_padding(5, 10)
        self.message.set_text(message)
        self.counter = gtk.Label()
        self.counter.set_alignment(1, 1)
        self.counter.set_padding(3, 3)
        self.timeout = stack.timeout

        body_box.pack_start(self.message, True, False, 5)
        body_box.pack_end(self.counter, False, False, 5)
        main_box.pack_start(body_box)

        if callback:
            cb_text, cb = callback
            button = gtk.Button(cb_text)
            button.set_relief(gtk.RELIEF_NORMAL)

            def popup_cb_clicked(*args):
                self.hide_notification()
                log(None, *args)
                cb()

            button.connect("clicked", popup_cb_clicked)
            alignment = gtk.Alignment(xalign=1.0,
                                      yalign=0.5,
                                      xscale=0.0,
                                      yscale=0.0)
            alignment.add(button)
            main_box.pack_start(alignment)
        self.add(main_box)
        if stack.bg_color is not None:
            self.modify_bg(gtk.STATE_NORMAL, stack.bg_color)
        if stack.fg_color is not None:
            self.message.modify_fg(gtk.STATE_NORMAL, stack.fg_color)
            self.header.modify_fg(gtk.STATE_NORMAL, stack.fg_color)
            self.counter.modify_fg(gtk.STATE_NORMAL, stack.fg_color)
        self.show_timeout = stack.show_timeout
        self.hover = False
        self.show_all()
        self.w, self.h = self.size_request()
        self.move(self.get_x(self.w), self.get_y(self.h))
        self.fade_in_timer = gobject.timeout_add(100, self.fade_in)
        #ensure we dont show it in the taskbar:
        self.window.set_skip_taskbar_hint(True)
        self.window.set_skip_pager_hint(True)
        self.realize()
        add_close_accel(self, self.hide_notification)
Example #25
0
    def make_widget(self):
        def refresh_snapshot(item):
            self.image.refresh_snapshot()
            return True

        def image_button_clicked(button):
            event = gtk.get_current_event()
            if event.state & gtk.gdk.CONTROL_MASK:
                self.use_current_position(button)
                return True
            else:
                self.play_from_here(button)
                return True

        def image_button_press(button, event):
            if event.button == 3 and event.type == gtk.gdk.BUTTON_PRESS:
                # Display the popup menu
                menu = gtk.Menu()
                item = gtk.MenuItem(_("Refresh snapshot"))
                item.connect('activate', refresh_snapshot)
                menu.append(item)
                menu.show_all()
                menu.popup(None, None, None, 0, gtk.get_current_event_time())
                return True
            return False

        def make_button(incr_value, pixmap):
            """Helper function to build the buttons."""
            b = gtk.Button()
            i = gtk.Image()
            i.set_from_file(config.data.advenefile(('pixmaps', pixmap)))
            # FIXME: to re-enable
            # The proper way is to do
            #b.set_image(i)
            # but it works only on linux, gtk 2.10
            # and is broken on windows and mac
            al = gtk.Alignment()
            al.set_padding(0, 0, 0, 0)
            al.add(i)
            b.add(al)

            def increment_value_cb(widget, increment):
                self.set_value(self.value + increment)
                return True

            b.connect('clicked', increment_value_cb, incr_value)
            if incr_value < 0:
                tip = _("Decrement value by %.2f s") % (incr_value / 1000.0)
            else:
                tip = _("Increment value by %.2f s") % (incr_value / 1000.0)
            b.set_tooltip_text(tip)
            return b

        vbox = gtk.VBox()

        hbox = gtk.HBox()
        hbox.set_homogeneous(False)

        if self.editable:
            vb = gtk.VBox()
            b = make_button(-self.large_increment, "2leftarrow.png")
            vb.pack_start(b, expand=False)
            b = make_button(-self.small_increment, "1leftarrow.png")
            vb.pack_start(b, expand=False)
            hbox.pack_start(vb, expand=False)

        if self.compact:
            width = 50
        else:
            width = 100
        self.image = TimestampRepresentation(
            self.value,
            self.controller,
            width,
            epsilon=1000 / config.data.preferences['default-fps'],
            visible_label=False,
            callback=self.set_value)
        self.image.connect('button-press-event', image_button_press)
        self.image.connect('clicked', image_button_clicked)
        self.image.set_tooltip_text(
            _("Click to play\nControl+click to set to current time\nScroll to modify value (with control/shift)\nRight-click to invalidate screenshot"
              ))
        hbox.pack_start(self.image, expand=False)

        if self.editable:
            vb = gtk.VBox()
            b = make_button(self.large_increment, "2rightarrow.png")
            vb.pack_start(b, expand=False)
            b = make_button(self.small_increment, "1rightarrow.png")
            vb.pack_start(b, expand=False)
            hbox.pack_start(vb, expand=False)

        hb = gtk.HBox()

        if self.editable:
            self.entry = gtk.Entry()
            self.entry.set_tooltip_text(
                _("Enter a timecode.\nAn integer value will be considered as milliseconds.\nA float value (12.2) will be considered as seconds.\nHH:MM:SS.sss values are possible."
                  ))
            # Default width of the entry field
            self.entry.set_width_chars(len(helper.format_time(0.0)))
            self.entry.connect('activate', self.convert_entered_value)
            self.entry.connect('focus-out-event', self.convert_entered_value)
            self.entry.set_editable(self.editable)
            hb.pack_start(self.entry, expand=False)
        else:
            self.entry = None

        if self.editable:
            current_pos = gtk.Button()
            i = gtk.Image()
            i.set_from_file(
                config.data.advenefile(('pixmaps', 'set-to-now.png')))
            current_pos.set_tooltip_text(_("Set to current player position"))
            current_pos.add(i)
            current_pos.connect('clicked', self.use_current_position)
            hb.pack_start(current_pos, expand=False)

        vbox.pack_start(hbox, expand=False)
        vbox.pack_start(hb, expand=False)
        hb.set_style(self.image.box.get_style())
        #self.entry.set_style(self.image.box.get_style())
        vbox.set_style(self.image.box.get_style())
        vbox.show_all()

        hb.set_no_show_all(True)
        hbox.set_no_show_all(True)
        self.image.label.hide()
        hb.show()

        def handle_scroll_event(button, event):
            if event.state & gtk.gdk.CONTROL_MASK:
                i = config.data.preferences['scroll-increment']
            elif event.state & gtk.gdk.SHIFT_MASK:
                i = config.data.preferences['second-scroll-increment']
            else:
                # 1 frame
                i = 1000 / config.data.preferences['default-fps']

            if event.direction == gtk.gdk.SCROLL_DOWN or event.direction == gtk.gdk.SCROLL_LEFT:
                incr = -i
            elif event.direction == gtk.gdk.SCROLL_UP or event.direction == gtk.gdk.SCROLL_RIGHT:
                incr = i

            if not self.set_value(self.value + incr):
                return True
            return True

        if self.editable:
            # The widget can receive drops from annotations
            vbox.connect('drag-data-received', self.drag_received)
            vbox.drag_dest_set(
                gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT
                | gtk.DEST_DEFAULT_ALL, config.data.drag_type['annotation'] +
                config.data.drag_type['timestamp'], gtk.gdk.ACTION_LINK)

            vbox.connect('scroll-event', handle_scroll_event)

        vbox.show_all()
        return vbox
Example #26
0
 def set_icon(self, icon):
     self.img = gtk.Image()
     self.img.set_from_icon_name(icon, gtk.ICON_SIZE_BUTTON)
     self.set_image(self.img)
Example #27
0
	def __init__(self):
		smallLightTheme = Theme("Droid Sans Bold 10", "Monospace 10", "HandyLinuxClear", "HandyLinuxClear", "Adwaita", "22", "/usr/share/xfce4/backdrops/handy_flat_clear_by_Starsheep.png")
		normalLightTheme = Theme("Droid Sans Bold 12", "Monospace 12", "HandyLinuxClear", "HandyLinuxClear", "Adwaita", "22", "/usr/share/xfce4/backdrops/handy_flat_clear_by_Starsheep.png")
		largeLightTheme = Theme("Droid Sans Bold 18", "Monospace 18", "HandyLinuxClear", "HandyLinuxClearBigButton", "Adwaita", "48", "/usr/share/xfce4/backdrops/handy_flat_clear_by_Starsheep.png")
		smallDarkTheme = Theme("Droid Sans Bold 10", "Monospace 10", "HandyLinuxDark", "HandyLinuxDark", "DMZ-White", "22", "/usr/share/xfce4/backdrops/handy_flat_darkblack_by_Starsheep.png")
		normalDarkTheme = Theme("Droid Sans Bold 12", "Monospace 12", "HandyLinuxDark", "HandyLinuxDark", "DMZ-White", "22", "/usr/share/xfce4/backdrops/handy_flat_darkblack_by_Starsheep.png")
		largeDarkTheme = Theme("Droid Sans Bold 18", "Monospace 18", "HandyLinuxDark", "HandyLinuxDarkBigButton", "DMZ-White", "48", "/usr/share/xfce4/backdrops/handy_flat_darkblack_by_Starsheep.png")

		currentTheme = Theme()
		currentTheme.getCurrent()

		window = gtk.Window()
		window.set_title("HandyTheme")
		window.connect("destroy", self.Quitter)
		window.set_default_size(450, 250)

		table = gtk.Table(3,3,False)

		boutonSmallLight =  gtk.Button()
		imgSmallLight = gtk.Image()
		imgSmallLight.set_from_file("icons/smallLight.png")
		boutonSmallLight.set_image(imgSmallLight)
		boutonSmallLight.connect("clicked", smallLightTheme.apply)

		boutonNormalLight =  gtk.Button()
		imgNormalLight = gtk.Image()
		imgNormalLight.set_from_file("icons/normalLight.png")
		boutonNormalLight.set_image(imgNormalLight)
		boutonNormalLight.connect("clicked", normalLightTheme.apply)

		boutonLargeLight =  gtk.Button()
		imgLargeLight = gtk.Image()
		imgLargeLight.set_from_file("icons/largeLight.png")
		boutonLargeLight.set_image(imgLargeLight)
		boutonLargeLight.connect("clicked", largeLightTheme.apply)

		boutonSmallDark =  gtk.Button()
		imgSmallDark = gtk.Image()
		imgSmallDark.set_from_file("icons/smallDark.png")
		boutonSmallDark.set_image(imgSmallDark)
		boutonSmallDark.connect("clicked", smallDarkTheme.apply)

		boutonNormalDark =  gtk.Button()
		imgNormalDark = gtk.Image()
		imgNormalDark.set_from_file("icons/normalDark.png")
		boutonNormalDark.set_image(imgNormalDark)
		boutonNormalDark.connect("clicked", normalDarkTheme.apply)

		boutonLargeDark =  gtk.Button()
		imgLargeDark = gtk.Image()
		imgLargeDark.set_from_file("icons/largeDark.png")
		boutonLargeDark.set_image(imgLargeDark)
		boutonLargeDark.connect("clicked", largeDarkTheme.apply)

		boutonReset = gtk.Button(stock=gtk.STOCK_UNDO)
		boutonReset.connect("clicked", currentTheme.apply)

		table.attach(boutonSmallLight,0,1,0,1)
		table.attach(boutonNormalLight,1,2,0,1)
		table.attach(boutonLargeLight,2,3,0,1)

		table.attach(boutonSmallDark,0,1,1,2)
		table.attach(boutonNormalDark,1,2,1,2)
		table.attach(boutonLargeDark,2,3,1,2)

		table.attach(boutonReset,0,3,2,3)

		table.set_row_spacings(5)
		table.set_col_spacings(5)
		table.set_row_spacing(1,10)

		window.add(table)
		window.show_all()
Example #28
0
    def __init__(self):
        self.tips = [
            _('''<b>Welcome to Tryton</b>


'''),
            _(u'''<b>Do you know Triton, one of the namesakes for our project?</b>

Triton (pronounced /ˈtraɪtən/ TRYE-tən, or as in Greek Τρίτων) is the
largest moon of the planet Neptune, discovered on October 10, 1846
by William Lassell. It is the only large moon in the Solar System
with a retrograde orbit, which is an orbit in the opposite direction
to its planet's rotation. At 2,700 km in diameter, it is the seventh-largest
moon in the Solar System. Triton comprises more than 99.5 percent of all
the mass known to orbit Neptune, including the planet's rings and twelve
other known moons. It is also more massive than all the Solar System's
159 known smaller moons combined.
'''),
            _('''<b>Export list records</b>

You can copy records from any list with Ctrl + C
and paste in any application with Ctrl + V
'''),
            _('''<b>Export graphs</b>

You can save any graphs in PNG file with right-click on it.
'''),
        ]

        parent = get_toplevel_window()
        self.win = gtk.Dialog(
            _('Tips'), parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_has_separator(True)
        self.win.set_size_request(500, 400)

        self.win.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
        self.win.set_default_response(gtk.RESPONSE_CLOSE)
        vbox = gtk.VBox()
        img = gtk.Image()
        img.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        vbox.pack_start(img, False, False)
        self.label = gtk.Label()
        self.label.set_alignment(0, 0)
        vbox.pack_start(self.label, True, True)
        separator = gtk.HSeparator()
        vbox.pack_start(separator, False, False)

        hbox = gtk.HBox()
        self.check = gtk.CheckButton(_('_Display a new tip next time'), True)
        self.check.set_active(True)
        hbox.pack_start(self.check)
        but_previous = gtk.Button()
        hbox_previous = gtk.HBox()
        img_previous = gtk.Image()
        img_previous.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_BUTTON)
        hbox_previous.pack_start(img_previous)
        label_previous = gtk.Label(_('Previous'))
        hbox_previous.pack_start(label_previous)
        but_previous.add(hbox_previous)
        but_previous.set_relief(gtk.RELIEF_NONE)
        but_previous.connect('clicked', self.tip_previous)
        hbox.pack_start(but_previous)
        hbox_next = gtk.HBox()
        label_next = gtk.Label(_('Next'))
        hbox_next.pack_start(label_next)
        but_next = gtk.Button()
        img_next = gtk.Image()
        img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_BUTTON)
        hbox_next.pack_start(img_next)
        but_next.add(hbox_next)
        but_next.set_relief(gtk.RELIEF_NONE)
        but_next.connect('clicked', self.tip_next)
        hbox.pack_start(but_next)
        vbox.pack_start(hbox, False, False)
        self.win.vbox.pack_start(vbox)
        self.win.show_all()

        try:
            self.number = int(CONFIG['tip.position'])
        except ValueError:
            self.number = 0

        self.tip_set()

        self.win.run()
        CONFIG['tip.autostart'] = self.check.get_active()
        CONFIG['tip.position'] = self.number + 1
        CONFIG.save()
        parent.present()
        self.win.destroy()
Example #29
0
 def do_star(self, fWizard, tmpDir):
     self.tmpDir = tmpDir
     self.fWizard = fWizard
     self.W = gtk.Dialog('Star',
                         None,
                         gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                         buttons=None)
     self.W.set_keep_above(True)
     self.W.set_position(gtk.WIN_POS_CENTER_ALWAYS)
     self.W.set_default_size(250, 200)
     t = gtk.Table(1, 1, True)
     t.set_row_spacings(6)
     self.W.vbox.add(t)
     cLabel = gtk.Label('Cut Type')
     cLabel.set_alignment(0.95, 0.5)
     cLabel.set_width_chars(10)
     t.attach(cLabel, 0, 1, 0, 1)
     self.outside = gtk.RadioButton(None, 'Outside')
     t.attach(self.outside, 1, 2, 0, 1)
     inside = gtk.RadioButton(self.outside, 'Inside')
     t.attach(inside, 2, 3, 0, 1)
     oLabel = gtk.Label('Offset')
     oLabel.set_alignment(0.95, 0.5)
     oLabel.set_width_chars(10)
     t.attach(oLabel, 3, 4, 0, 1)
     self.offset = gtk.CheckButton('Kerf Width')
     t.attach(self.offset, 4, 5, 0, 1)
     lLabel = gtk.Label('Lead In')
     lLabel.set_alignment(0.95, 0.5)
     lLabel.set_width_chars(10)
     t.attach(lLabel, 0, 1, 1, 2)
     self.liEntry = gtk.Entry()
     self.liEntry.set_width_chars(10)
     t.attach(self.liEntry, 1, 2, 1, 2)
     loLabel = gtk.Label('Lead Out')
     loLabel.set_alignment(0.95, 0.5)
     loLabel.set_width_chars(10)
     t.attach(loLabel, 0, 1, 2, 3)
     self.loEntry = gtk.Entry()
     self.loEntry.set_width_chars(10)
     t.attach(self.loEntry, 1, 2, 2, 3)
     xSLabel = gtk.Label('X start')
     xSLabel.set_alignment(0.95, 0.5)
     xSLabel.set_width_chars(10)
     t.attach(xSLabel, 0, 1, 3, 4)
     self.xSEntry = gtk.Entry()
     self.xSEntry.set_width_chars(10)
     t.attach(self.xSEntry, 1, 2, 3, 4)
     ySLabel = gtk.Label('Y start')
     ySLabel.set_alignment(0.95, 0.5)
     ySLabel.set_width_chars(10)
     t.attach(ySLabel, 0, 1, 4, 5)
     self.ySEntry = gtk.Entry()
     self.ySEntry.set_width_chars(10)
     t.attach(self.ySEntry, 1, 2, 4, 5)
     self.centre = gtk.RadioButton(None, 'Centre')
     t.attach(self.centre, 1, 2, 5, 6)
     bLeft = gtk.RadioButton(self.centre, 'Bottom Left')
     t.attach(bLeft, 0, 1, 5, 6)
     pLabel = gtk.Label('# of Points')
     pLabel.set_alignment(0.95, 0.5)
     pLabel.set_width_chars(10)
     t.attach(pLabel, 0, 1, 6, 7)
     self.pEntry = gtk.Entry()
     self.pEntry.set_width_chars(10)
     t.attach(self.pEntry, 1, 2, 6, 7)
     self.odLabel = gtk.Label('Outside Dia')
     self.odLabel.set_alignment(0.95, 0.5)
     self.odLabel.set_width_chars(10)
     t.attach(self.odLabel, 0, 1, 7, 8)
     self.odEntry = gtk.Entry()
     self.odEntry.set_width_chars(10)
     t.attach(self.odEntry, 1, 2, 7, 8)
     self.idLabel = gtk.Label('Inside Dia')
     self.idLabel.set_alignment(0.95, 0.5)
     self.idLabel.set_width_chars(10)
     t.attach(self.idLabel, 0, 1, 8, 9)
     self.idEntry = gtk.Entry()
     self.idEntry.set_width_chars(10)
     t.attach(self.idEntry, 1, 2, 8, 9)
     aLabel = gtk.Label('Angle')
     aLabel.set_alignment(0.95, 0.5)
     aLabel.set_width_chars(10)
     t.attach(aLabel, 0, 1, 9, 10)
     self.aEntry = gtk.Entry()
     self.aEntry.set_width_chars(10)
     self.aEntry.set_text('0')
     t.attach(self.aEntry, 1, 2, 9, 10)
     preview = gtk.Button('Preview')
     preview.connect('pressed', self.send_preview)
     t.attach(preview, 0, 1, 11, 12)
     self.add = gtk.Button('Add')
     self.add.set_sensitive(False)
     self.add.connect('pressed', self.add_shape_to_file)
     t.attach(self.add, 2, 3, 11, 12)
     end = gtk.Button('Return')
     end.connect('pressed', self.end_this_shape)
     t.attach(end, 4, 5, 11, 12)
     pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
         filename='./wizards/images/star.png', width=240, height=240)
     image = gtk.Image()
     image.set_from_pixbuf(pixbuf)
     t.attach(image, 2, 5, 1, 9)
     self.xSEntry.grab_focus()
     self.W.show_all()
     if os.path.exists(self.configFile):
         f_in = open(self.configFile, 'r')
         for line in f_in:
             if line.startswith('preamble'):
                 self.preamble = line.strip().split('=')[1]
             elif line.startswith('postamble'):
                 self.postamble = line.strip().split('=')[1]
             elif line.startswith('lead-in'):
                 self.liEntry.set_text(line.strip().split('=')[1])
             elif line.startswith('lead-out'):
                 self.loEntry.set_text(line.strip().split('=')[1])
     response = self.W.run()
Example #30
0
    def __init__(self, ancho, alto, titulo, banner):
        self.pasos = {}
        self.actual = ''

        # Creo la ventana
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        gtk.Window.set_position(self, gtk.WIN_POS_CENTER_ALWAYS)
        self.set_icon_from_file(BAR_ICON)
        self.titulo = titulo
        self.set_title(titulo)
        self.set_size_request(ancho, alto)
        self.set_resizable(0)
        self.set_border_width(0)

        # Creo el contenedor principal
        self.c_principal = gtk.Fixed()
        self.add(self.c_principal)

        # Calculo tamaño del banner
        self.banner_img = Image.open(banner)
        self.banner_w = self.banner_img.size[0]
        self.banner_h = self.banner_img.size[1]

        # Creo el banner
        self.banner = gtk.Image()
        self.banner.set_from_file(banner)
        self.banner.set_size_request(ancho, self.banner_h)

        # Creo el contenedor del banner y el texto del banner
        banner_container = gtk.Fixed()
        banner_container.set_size_request(self.banner_w, self.banner_h)

        attr = pango.AttrList()
        attr.insert(pango.AttrSize(25000, 0, -1))
        attr.insert(pango.AttrStyle(pango.STYLE_ITALIC, 0, -1))
        attr.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1))

        lbl1 = gtk.Label(_("Canaima Installation"))
        lbl1.set_attributes(attr)

        banner_container.put(self.banner, 0, 0)
        banner_container.put(lbl1, 100, 10)

        self.c_principal.put(banner_container, 0, 0)

        # Creo el contenedor de los pasos
        self.c_pasos = gtk.VBox()
        self.c_pasos.set_size_request((ancho - 10),
                                      (alto - 50 - self.banner_h))
        self.c_principal.put(self.c_pasos, 5, (self.banner_h + 5))

        # Creo la botonera
        self.botonera = gtk.Fixed()
        self.botonera.set_size_request(ancho, 40)
        self.c_principal.put(self.botonera, 0, (alto - 40))

        # Creo la linea divisoria
        self.linea = gtk.HSeparator()
        self.linea.set_size_request(ancho, 5)
        self.botonera.put(self.linea, 0, 0)

        # Anterior
        self.anterior = gtk.Button(stock=gtk.STOCK_GO_BACK)
        self.anterior.set_size_request(100, 30)
        self.botonera.put(self.anterior, (ancho - 210), 10)

        # Siguiente
        self.siguiente = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
        self.siguiente.set_size_request(100, 30)
        self.botonera.put(self.siguiente, (ancho - 110), 10)

        # Cancelar
        self.cancelar = gtk.Button(stock=gtk.STOCK_QUIT)
        self.cancelar.set_size_request(100, 30)
        self.cancelar.connect('clicked', self.close)
        self.botonera.put(self.cancelar, 10, 10)

        # Acerca
        self.acerca = gtk.Button(stock=gtk.STOCK_ABOUT)
        self.acerca.set_size_request(100, 30)
        self.acerca.connect('clicked', AboutWindow)
        self.botonera.put(self.acerca, 110, 10)

        self.connect("destroy", self.close)
        self.connect("delete-event", self.close)

        self.show_all()