Python gtk 模块,EventBox() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用gtk.EventBox()

项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def _create_list_labels(self):
        """create labels as rows"""
        #remove any existing rows
        [self.fixd.remove(row[0]) for row in self._rows]
        #create labels
        self._rows = []
        for i in range(self.num_rows):
            eb = gtk.EventBox()
            lbl = gtk.Label()
            lbl.modify_font(self._pango_font_desc)
            lbl.modify_fg(gtk.STATE_NORMAL, self._fg_col)
            lbl.modify_bg(gtk.STATE_NORMAL, self._hl_bg_col)
            lbl.set_property('xalign', self.properties['xalign'])
            lbl.set_angle(self.angle)
            lbl.show()
            eb.add(lbl)
            eb.add_events(gtk.gdk.BUTTON_PRESS_MASK)
            eb.connect('button-press-event', self._on_mouse_button, i)
            eb.show()
            eb.set_visible_window(False)
            self.fixd.add(eb)
            self._rows.append((eb, lbl))
        #colours
        self.modify_fg(gtk.STATE_NORMAL, self._fg_col)
        self.modify_highlight_bg(gtk.STATE_NORMAL, self._hl_bg_col)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def _makeWidgetObject(self):
        """Make the GTK widget object that is me.

        Called by __init__ to construct the GtkObject I wrap-- the ._o
        member of a pygtk GtkObject.  Isn't subclassing GtkObjects in
        Python fun?
        """
        ebox = gtk.EventBox()
        label = gtk.Label(self.getTextForLabel())
        label.set_alignment(0,0)
        ebox.add(label)
        return ebox._o
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def _makeWidgetObject(self):
        """Make the GTK widget object that is me.

        Called by __init__ to construct the GtkObject I wrap-- the ._o
        member of a pygtk GtkObject.  Isn't subclassing GtkObjects in
        Python fun?
        """
        ebox = gtk.EventBox()
        label = gtk.Label(self.getTextForLabel())
        label.set_alignment(0,0)
        ebox.add(label)
        return ebox._o
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def __init__(self, title, owner_, widget_, popup_):
        gtk.HBox.__init__(self, False, 0)

        self.title = title
        self.owner = owner_
        self.eb = gtk.EventBox()
        label = self.label = gtk.Label()
        self.eb.connect('button-press-event', self.popupmenu, label)
        label.set_alignment(0.0, 0.5)
        label.set_text(title)
        self.eb.add(label)        
        self.pack_start(self.eb)        
        label.show()        
        self.eb.show()                
        close_image = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
        image_w, image_h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        self.widget=widget_
        self.popup = popup_        
        close_btn = gtk.Button()
        close_btn.set_relief(gtk.RELIEF_NONE)
        close_btn.connect('clicked', self.on_close_tab, owner_)
        close_btn.set_size_request(image_w+7, image_h+6)
        close_btn.add(close_image)
        style = close_btn.get_style();
        self.eb2 = gtk.EventBox()
        self.eb2.add(close_btn)        
        self.pack_start(self.eb2, False, False)
        self.eb2.show()
        close_btn.show_all()  
        self.is_active = True
        self.show()
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def _make_label(self, widget_name):
        """create a label (inside an event box)"""
        evb = gtk.EventBox()
        evb.set_name(widget_name)
        lbl = gtk.Label(widget_name)
        lbl.show()
        #lbl.set_line_wrap(True)
        lbl.set_text('')
        evb.set_size_request(100, 25)
        evb.set_visible_window(True)
        evb.show()
        evb.add(lbl)
        evb.set_property('visible', False)
        return evb
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def make_evb_widget(self, widget):
        """create an event box and add the given widget to it"""
        evb = gtk.EventBox()
        #evb.show()
        evb.add(widget)
        return evb
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def __init__(self,layer,width=100,height=120):
        gtk.EventBox.__init__(self)
        self.set_size_request(width,height)
        #variables
        self.thumbnail = None
        self.label = None
        self.layer = layer
        self.fixed = False

        self._fix_button_images = []
        self._fix_button = None
        self._setup()
项目:pub1ic_POC    作者:i1ikey0u    | 项目源码 | 文件源码
def __init__(self, width, height):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(0)
        self.window.set_size_request(width, height + 30)
        self.window.set_app_paintable(True)

        self.screen = self.window.get_screen()
        self.rgba = self.screen.get_rgba_colormap()
        self.window.set_colormap(self.rgba)
        self.window.connect('expose-event', self.expose)

        self.vbox = gtk.VBox(False, 5)
        self.hbox = gtk.HBox(False, 3)
        self.bbox = gtk.HBox(True, 3)

        self.entry = gtk.Entry()
        self.entry.set_max_length(0)
        self.entry.set_size_request(int(width / 2), 25)
        self.entry.connect("activate", self.enter_callback, self.entry)
        self.spr = gtk.ToggleButton(label='spr')
        self.spr.connect("toggled", self.on_button_toggled, 'spr')
        self.ctrl = gtk.ToggleButton(label='ctrl')
        self.ctrl.connect("toggled", self.on_button_toggled, 'ctrl')
        self.alt = gtk.ToggleButton(label='alt')
        self.alt.connect("toggled", self.on_button_toggled, 'alt')
        self.enter = gtk.Button(label='Enter')
        self.enter.connect("clicked", self.on_enter_clicked)
        self.backspace = gtk.Button(label='Backspace')
        self.backspace.connect("clicked", self.on_backspace_clicked)
        self.shell = gtk.Button(label='R-Shell')
        self.shell.connect("clicked", self.on_shell_clicked, self.entry)

        self.hbox.add(self.entry)
        self.bbox.add(self.spr)
        self.bbox.add(self.ctrl)
        self.bbox.add(self.alt)
        self.bbox.add(self.enter)
        self.bbox.add(self.backspace)
        self.bbox.add(self.shell)
        self.hbox.add(self.bbox)

        self.halign = gtk.Alignment(1, 0, 1, 0)
        self.halign.add(self.hbox)

        self.allalign = gtk.Alignment(0, 0, 1, 1)
        self.clickbox = gtk.EventBox()
        self.clickbox.connect('button-press-event', self.on_click)
        self.clickbox.set_visible_window(False)

        self.allalign.add(self.clickbox)
        self.vbox.pack_start(self.allalign, True, True, 0)

        self.vbox.pack_end(self.halign, False, False, 0)

        self.window.add(self.vbox)

        self.window.show_all()

        self.window.move(100, 100)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def __init__(self, explorer, rootGroup, canvas):
        """Place a new Visage of an explorer in a canvas group.

        I also need a 'canvas' reference is for certain coordinate
        conversions, and pygnome doesn't give access to my GtkObject's
        .canvas attribute.  :(
        """
        # Ugh.  PyGtk/GtkObject/GnomeCanvas interfacing grits.
        gnome.CanvasGroup.__init__(self,
                                   _obj = rootGroup.add('group')._o)

        self.propertyLabels = PairList()
        reflect.accumulateClassList(self.__class__, 'propertyLabels',
                                    self.propertyLabels)
        self.groupLabels = PairList()
        reflect.accumulateClassList(self.__class__, 'groupLabels',
                                    self.groupLabels)

        self.explorer = explorer
        self.identifier = explorer.identifier
        self.objectId = explorer.id

        self.canvas = canvas
        self.rootGroup = rootGroup

        self.ebox = gtk.EventBox()
        self.ebox.set_name("Visage")
        self.frame = gtk.Frame(self.identifier)
        self.container = gtk.VBox()
        self.ebox.add(self.frame)
        self.frame.add(self.container)

        self.canvasWidget = self.add('widget', widget=self.ebox,
                                     x=0, y=0, anchor=gtk.ANCHOR_NW,
                                     size_pixels=0)

        self.border = self.add('rect', x1=0, y1=0,
                               x2=1, y2=1,
                               fill_color=None,
                               outline_color=self.color['border'],
                               width_pixels=self.border_width)

        self.subtable = {}

        self._setup_table()

        # TODO:
        #  Collapse me
        #  Movable/resizeable me
        #  Destroy me
        #  Set my detail level

        self.frame.connect("size_allocate", self.signal_size_allocate,
                           None)
        self.connect("destroy", self.signal_destroy, None)
        self.connect("event", self.signal_event)

        self.ebox.show_all()

        # Our creator will call our fill_ methods when she has the goods.
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        self.window = gtk.Window()
        self.window.set_title("Create An Image")
        self.window.set_icon_from_file(os.path.join(WORKINGDIR, "data", "icon.png"))
        colour = gtk.gdk.color_parse(DARKCOL)
        self.window.modify_bg(gtk.STATE_NORMAL, colour)

        self.vvbox = gtk.VBox()
        self.table = gtk.Table(5, 5)
        self.table.set_border_width(2)
        self.table.set_row_spacings(2)
        self.table.set_col_spacings(2)
        self.buttons = {}

        for y in range(5):
            for x in range(5):
                eb = gtk.EventBox()
                i = gtk.Image()
                i.set_from_file(os.path.join(WORKINGDIR, "data", "selected.png"))
                i.show()
                eb.add(i)
                eb.hide()
                eb.modify_bg(gtk.STATE_NORMAL, colour)
                eb.connect_object("button-press-event", self.togglePart, (x, y))

                eb2 = gtk.EventBox()
                i2 = gtk.Image()
                i2.set_from_file(os.path.join(WORKINGDIR, "data", "unselected.png"))
                i2.show()
                eb2.add(i2)
                eb2.show()
                eb2.modify_bg(gtk.STATE_NORMAL, colour)
                eb2.connect_object("button-press-event", self.togglePart, (x, y))

                self.buttons[(x, y)] = (eb, eb2)

                self.table.attach(eb, x, x + 1, y, y + 1)
                self.table.attach(eb2, x, x + 1, y, y + 1)

        self.table.show()
        self.vvbox.pack_start(self.table)
        hbox = gtk.HBox()
        self.confirmButton = gtk.Button("Okay")
        self.confirmButton.show()
        self.confirmButton.connect("clicked", self.okay)
        hbox.pack_start(self.confirmButton, True, False)
        cancelButton = gtk.Button("Cancel")
        cancelButton.connect("clicked", self.destroy)
        cancelButton.show()
        hbox.pack_end(cancelButton, True, False)
        hbox.show()
        self.vvbox.pack_start(hbox)
        self.vvbox.show()
        self.window.add(self.vvbox)
        self.onOkay = None

        self.running = True
        self.destoryed = False
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def __init__(self, explorer, rootGroup, canvas):
        """Place a new Visage of an explorer in a canvas group.

        I also need a 'canvas' reference is for certain coordinate
        conversions, and pygnome doesn't give access to my GtkObject's
        .canvas attribute.  :(
        """
        # Ugh.  PyGtk/GtkObject/GnomeCanvas interfacing grits.
        gnome.CanvasGroup.__init__(self,
                                   _obj = rootGroup.add('group')._o)

        self.propertyLabels = PairList()
        reflect.accumulateClassList(self.__class__, 'propertyLabels',
                                    self.propertyLabels)
        self.groupLabels = PairList()
        reflect.accumulateClassList(self.__class__, 'groupLabels',
                                    self.groupLabels)

        self.explorer = explorer
        self.identifier = explorer.identifier
        self.objectId = explorer.id

        self.canvas = canvas
        self.rootGroup = rootGroup

        self.ebox = gtk.EventBox()
        self.ebox.set_name("Visage")
        self.frame = gtk.Frame(self.identifier)
        self.container = gtk.VBox()
        self.ebox.add(self.frame)
        self.frame.add(self.container)

        self.canvasWidget = self.add('widget', widget=self.ebox,
                                     x=0, y=0, anchor=gtk.ANCHOR_NW,
                                     size_pixels=0)

        self.border = self.add('rect', x1=0, y1=0,
                               x2=1, y2=1,
                               fill_color=None,
                               outline_color=self.color['border'],
                               width_pixels=self.border_width)

        self.subtable = {}

        self._setup_table()

        # TODO:
        #  Collapse me
        #  Movable/resizeable me
        #  Destroy me
        #  Set my detail level

        self.frame.connect("size_allocate", self.signal_size_allocate,
                           None)
        self.connect("destroy", self.signal_destroy, None)
        self.connect("event", self.signal_event)

        self.ebox.show_all()

        # Our creator will call our fill_ methods when she has the goods.
项目:hazzy    作者:KurtJacobson    | 项目源码 | 文件源码
def __init__(self, inifile, width, height):
        gobject.GObject.__init__(self)

        super(HazzyGremlin, self).__init__(inifile)

        self.width = width
        self.height = height

        self.percent = 0
        self.mouse_mode = None
        self.zoom_in_pressed = False
        self.zoom_out_pressed = False

        self.set_display_units('in')

        # Gremlin width = width - 40 to allow room for the controls
        self.set_size_request(self.width - 40, self.height)

        # Add gremlin back-plot
        self.gremlin_view = gtk.HBox()
        fixed = gtk.Fixed()
        fixed.put(self, 0, 0)
        self.gremlin_view.add(fixed)
        self.connect('button_press_event', self.on_gremlin_clicked)

        # Add touchscreen controls
        gladefile = os.path.join(UIDIR, 'controls.glade')
        self.builder = gtk.Builder()
        self.builder.add_from_file(gladefile)
        self.builder.connect_signals(self)
        controls = self.builder.get_object('controls')
        controls.set_size_request(40, self.height)
        self.gremlin_view.add(controls)

        # Add progress label
        self.label = gtk.Label()
        self.label.modify_font(pango.FontDescription('FreeSans 11'))
        self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color('White'))
        labelbox = gtk.EventBox()
        labelbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('Black'))
        labelbox.set_size_request(-1, 20)
        labelbox.add(self.label)
        fixed.put(labelbox, 0 , self.height - 20)


#    def fileloading(self, current_line):
#        self.progressbar.show()
#        percent = current_line * 100 / self.line_count
#        if self.percent != percent:
#            self.percent = percent
#            msg = "Generating preview {}%".format(self.percent)
#            self.progressbar.set_text(msg)
#            self.progressbar.set_fraction(self.percent / 100)
#            log.debug(msg)
#            self.emit('loading_progress', percent)