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

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

项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self):
        assert Visualizer.INSTANCE is None
        Visualizer.INSTANCE = self
        super(Visualizer, self).__init__()
        self.nodes =  {} # node index -> Node
        self.channels = {} # id(ns3.Channel) -> Channel
        self.window = None # toplevel window
        self.canvas = None # goocanvas.Canvas
        self.time_label = None # gtk.Label
        self.play_button = None # gtk.ToggleButton
        self.zoom = None # gtk.Adjustment
        self._scrolled_window = None # gtk.ScrolledWindow

        self.links_group = goocanvas.Group()
        self.channels_group = goocanvas.Group()
        self.nodes_group = goocanvas.Group()

        self._update_timeout_id = None
        self.simulation = SimulationThread(self)
        self.selected_node = None # node currently selected
        self.speed = 1.0
        self.information_windows = []
        self._transmission_arrows = []
        self._last_transmissions = []
        self._drop_arrows = []
        self._last_drops = []
        self._show_transmissions_mode = None
        self.set_show_transmissions_mode(ShowTransmissionsMode.ALL)
        self._panning_state = None
        self.node_size_adjustment = None
        self.transmissions_smoothing_adjustment = None
        self.sample_period = SAMPLE_PERIOD
        self.node_drag_state = None
        self.follow_node = None
        self.shell_window = None

        self.create_gui()

        for plugin in plugins:
            plugin(self)
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, window, index, uistate):

        Dialog.__init__(self, window, _('Tags Manager (IconTags plugin)'), # T: dialog title
                        buttons=gtk.BUTTONS_OK_CANCEL,
                        defaultwindowsize=(450, 400) )

        # Don't confuse with local variable 'self.uistate',
        # which is already determined for this class.
        self._window = window
        self.plugin_uistate = uistate
        self.show_pages_button = gtk.ToggleButton('Show Pages')
    self.show_pages_button.connect('toggled', self.toggle_show_pages)
        self.add_extra_button(self.show_pages_button)

        self.treeview_tags = TagsManagerTagsView(index, self.plugin_uistate['Icons for Tags'])
        self.treeview_pages = TagsManagerPagesView(index, window.ui)
        self.scrolled_widget = ScrolledWindow(self.treeview_tags)
        self.vbox.pack_start(self.scrolled_widget, True)

        self.treeview_tags.connect('row-activated', self.get_tag)

        # Enable left/right arrows to navigate between views.
        self.treeview_tags.connect('key-release-event', self.toggle_view)
        self.treeview_pages.connect('key-release-event', self.toggle_view)

        # Update if tags change.
        self.connectto_all(index, (
            ('tag-inserted', lambda *a: self.update()),
            ('tag-removed', lambda *a: self.update())
        ))

        self.show_all()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, window, index, uistate):

        Dialog.__init__(self, window, _('Tags Manager (IconTags plugin)'), # T: dialog title
                        buttons=gtk.BUTTONS_OK_CANCEL,
                        defaultwindowsize=(450, 400) )

        # Don't confuse with local variable 'self.uistate',
        # which is already determined for this class.
        self._window = window
        self.plugin_uistate = uistate
        self.show_pages_button = gtk.ToggleButton('Show Pages')
        self.show_pages_button.connect('toggled', self.toggle_show_pages)
        self.add_extra_button(self.show_pages_button)

        self.treeview_tags = TagsManagerTagsView(index, self.plugin_uistate['Icons for Tags'])
        self.treeview_pages = TagsManagerPagesView(index, window.ui)
        self.scrolled_widget = ScrolledWindow(self.treeview_tags)
        self.vbox.pack_start(self.scrolled_widget, True)

        self.treeview_tags.connect('row-activated', self.get_tag)

        # Enable left/right arrows to navigate between views.
        self.treeview_tags.connect('key-release-event', self.toggle_view)
        self.treeview_pages.connect('key-release-event', self.toggle_view)

        # Update if tags change.
        self.connectto_all(index.update_iter.tags, (
            ('tag-row-inserted', lambda *a: self.update()),
            ('tag-row-deleted', lambda *a: self.update())
        ))

        self.show_all()
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def toggle_button_stock(stock,size):
        """
        Return a button with a image from stock items 
        """
        b = gtk.ToggleButton()
        img = gtk.Image()
        img.set_from_stock(stock,size)
        b.set_image(img)
        return b
项目: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)