当前位置: 首页>>代码示例>>Python>>正文


Python gtk.Button方法代码示例

本文整理汇总了Python中gtk.Button方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.Button方法的具体用法?Python gtk.Button怎么用?Python gtk.Button使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gtk的用法示例。


在下文中一共展示了gtk.Button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: hello_world_window

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def hello_world_window():
    """
    Create a GTK window with one 'Hello world' button.
    """
    # Create a new window.
    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.set_border_width(50)

    # Create a new button with the label "Hello World".
    button = gtk.Button("Hello World")
    window.add(button)

    # Clicking the button prints some text.
    def clicked(data):
        print("Button clicked!")

    button.connect("clicked", clicked)

    # Display the window.
    button.show()
    window.show() 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:23,代码来源:inputhook.py

示例2: createTabLabel

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def createTabLabel(page, notebook):
    label = gtk.Label(page.vwGetDisplayName())

    if not page.vwIsClosable():
        return label

    box = gtk.HBox()
    image = gtk.Image()
    image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)

    cbutton = gtk.Button()
    cbutton.connect("clicked", closeTabButton, page, notebook)
    cbutton.set_image(image)
    cbutton.set_relief(gtk.RELIEF_NONE)

    box.pack_start(label, True, True)
    box.pack_end(cbutton, False, False)
    box.show_all()
    return box 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:21,代码来源:notebook.py

示例3: run

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def run(self, graphic):
        window = gtk.Window()
        self.__window = window
        window.set_default_size(200, 200)
        vbox = gtk.VBox()
        window.add(vbox)
        render = GtkGraphicRenderer(graphic)
        self.__render = render
        vbox.pack_end(render, True, True, 0)
        hbox = gtk.HBox()
        vbox.pack_start(hbox, False, False, 0)
        smaller_zoom = gtk.Button("Zoom Out")
        smaller_zoom.connect("clicked", self.__set_smaller_cb)
        hbox.pack_start(smaller_zoom)
        bigger_zoom = gtk.Button("Zoom In")
        bigger_zoom.connect("clicked", self.__set_bigger_cb)
        hbox.pack_start(bigger_zoom)
        output_png = gtk.Button("Output Png")
        output_png.connect("clicked", self.__output_png_cb)
        hbox.pack_start(output_png)
        window.connect('destroy', gtk.main_quit)
        window.show_all()
        #gtk.bindings_activate(gtk.main_quit, 'q', 0)
        gtk.main() 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:26,代码来源:grid.py

示例4: _init_gui

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def _init_gui(self):
    self._dialog = gimpui.Dialog(title=pg.config.PLUGIN_TITLE, role=None)
    self._dialog.set_transient()
    self._dialog.set_border_width(self._BORDER_WIDTH)
    self._dialog.set_default_size(self._DIALOG_WIDTH, -1)
    
    self._button_stop = gtk.Button()
    self._button_stop.set_label(_("_Stop"))
    
    self._buttonbox = gtk.HButtonBox()
    self._buttonbox.pack_start(self._button_stop, expand=False, fill=False)
    
    self._progress_bar = gtk.ProgressBar()
    self._progress_bar.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
    
    self._hbox_action_area = gtk.HBox(homogeneous=False)
    self._hbox_action_area.set_spacing(self._HBOX_HORIZONTAL_SPACING)
    self._hbox_action_area.pack_start(self._progress_bar, expand=True, fill=True)
    self._hbox_action_area.pack_end(self._buttonbox, expand=False, fill=False)
    
    self._dialog.vbox.pack_end(self._hbox_action_area, expand=False, fill=False)
    
    self._button_stop.connect("clicked", self._on_button_stop_clicked)
    self._dialog.connect("delete-event", self._on_dialog_delete_event) 
开发者ID:khalim19,项目名称:gimp-plugin-export-layers,代码行数:26,代码来源:main.py

示例5: _init_gui

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def _init_gui(self):
    if self._add_operation_text is not None:
      self._button_add = gtk.Button()
      button_hbox = gtk.HBox()
      button_hbox.set_spacing(self._ADD_BUTTON_HBOX_SPACING)
      button_hbox.pack_start(
        gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU),
        expand=False,
        fill=False)
      
      label_add = gtk.Label(self._add_operation_text.encode(pg.GTK_CHARACTER_ENCODING))
      label_add.set_use_underline(True)
      button_hbox.pack_start(label_add, expand=False, fill=False)
      
      self._button_add.add(button_hbox)
    else:
      self._button_add = gtk.Button(stock=gtk.STOCK_ADD)
    
    self._button_add.set_relief(gtk.RELIEF_NONE)
    self._button_add.connect("clicked", self._on_button_add_clicked)
    
    self._vbox.pack_start(self._button_add, expand=False, fill=False)
    
    self._operations_menu = gtk.Menu()
    self._init_operations_menu_popup() 
开发者ID:khalim19,项目名称:gimp-plugin-export-layers,代码行数:27,代码来源:operations.py

示例6: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def __init__(self):
        super(CodePanel, self).__init__()
        label = gtk.Label("Enter R code to evaluate")
        label.show()
        self.pack_start(label, False, True, 0)
        s_window = gtk.ScrolledWindow()
        s_window.set_policy(gtk.POLICY_AUTOMATIC, 
                            gtk.POLICY_AUTOMATIC)
        s_window.show()
        self._rpad = gtk.TextView(buffer=None)
        self._rpad.set_editable(True)
        self._rpad.show()
        s_window.add(self._rpad)
        self.add(s_window)
        evalButton = gtk.Button("Evaluate highlighted code")
        evalButton.connect("clicked", self.evaluateAction, "evaluate")
        evalButton.show()
        self.pack_start(evalButton, False, False, 0)
        self._evalButton = evalButton 
开发者ID:rpy2,项目名称:rpy2,代码行数:21,代码来源:radmin.py

示例7: update_button

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def update_button(self):
        """Update the state of our close button"""
        if not self.config['close_button_on_tab']:
            if self.button:
                self.button.remove(self.icon)
                self.remove(self.button)
                del(self.button)
                del(self.icon)
                self.button = None
                self.icon = None
            return

        if not self.button:
            self.button = gtk.Button()
        if not self.icon:
            self.icon = gtk.Image()
            self.icon.set_from_stock(gtk.STOCK_CLOSE,
                                     gtk.ICON_SIZE_MENU)

        self.button.set_focus_on_click(False)
        self.button.set_relief(gtk.RELIEF_NONE)
        style = gtk.RcStyle()
        style.xthickness = 0
        style.ythickness = 0
        self.button.modify_style(style)
        self.button.add(self.icon)
        self.button.connect('clicked', self.on_close)
        self.button.set_name('terminator-tab-close-button')
        if hasattr(self.button, 'set_tooltip_text'):
            self.button.set_tooltip_text(_('Close Tab'))
        self.pack_start(self.button, False, False)
        self.show_all() 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:34,代码来源:notebook.py

示例8: createButton

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def createButton(parent, text="", stock=None, name="", gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None):
	"""Creates a button widget and adds it to a parent widget."""
	if stock:
		temp = gtk.Button(text, stock)
	else:
		temp = gtk.Button(text)
	
	temp.set_name(name)
	temp.connect("clicked", handler)
	
	parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0)
	
	return temp 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:15,代码来源:tintwizard.py

示例9: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def __init__(self, items=()):
        gtk.Dialog.__init__(self)
        self.ret = None
        self._started = 0
        self.connect("destroy", self.quit)
        self.connect("delete_event", self.quit)
        self.set_geometry_hints(min_width=250, min_height=300)
        scrolled_win = gtk.ScrolledWindow()
        scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolled_win.show()
        self.vbox.pack_start(scrolled_win)
        #self.vbox.show()

        button = gtk.Button("Cancel")
        button.connect("clicked", self.cancel)
        button.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(button)
        button.show()

        ls = gtk.ListStore(gobject.TYPE_STRING)
        for item in items:
            iter = ls.append()
            ls.set(iter, 0, item)

        lister = gtk.TreeView(ls)
        selection = lister.get_selection()
        selection.set_mode(gtk.SELECTION_BROWSE)
        selection.unselect_all()
        lister.set_search_column(0)
        scrolled_win.add_with_viewport(lister)

        column = gtk.TreeViewColumn('Keyword', gtk.CellRendererText(), text=0)
        lister.append_column(column)
        lister.set_headers_visible(False)
        lister.connect("row-activated", self.row_activated)
        lister.show() 
开发者ID:kdart,项目名称:pycopia,代码行数:38,代码来源:gtktools.py

示例10: button_press

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def button_press(self, widget, event):
        """! Button Press
        @param self this object
        @param widget widget
        @param event event
        @return true if button has been pressed otherwise false
        """
        (x, y, width, height) = self.__data.get_selection_rectangle()
        (d_x, d_y, d_width, d_height) = self.__data.get_data_rectangle()
        if event.y > y and event.y < y + height:
            if abs(event.x - x) < 5:
                self.__moving_left = True
                return True
            if abs(event.x - (x + width)) < 5:
                self.__moving_right = True
                return True
            if event.x > x and event.x < x + width:
                self.__moving_both = True
                self.__moving_both_start = event.x
                self.__moving_both_cur = event.x
                return True
        if event.y > d_y and event.y < (d_y + d_height):
            if event.x > d_x and event.x < (d_x + d_width):
                self.__moving_top = True
                self.__moving_top_start = event.x
                self.__moving_top_cur = event.x
                return True
        return False 
开发者ID:KTH,项目名称:royal-chaos,代码行数:30,代码来源:grid.py

示例11: button_release

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def button_release(self, widget, event):
        """! Button Release
        @param self this object
        @param widget widget
        @param event event
        @return true if button was released otherwise false
        """
        if self.__moving_left:
            self.__moving_left = False
            left = self.__data.scale_selection(self.__moving_left_cur)
            right = self.__data.get_range()[1]
            self.__data.set_range(left, right)
            self.__force_full_redraw = True
            self.queue_draw()
            return True
        if self.__moving_right:
            self.__moving_right = False
            right = self.__data.scale_selection(self.__moving_right_cur)
            left = self.__data.get_range()[0]
            self.__data.set_range(left, right)
            self.__force_full_redraw = True
            self.queue_draw()
            return True
        if self.__moving_both:
            self.__moving_both = False
            delta = self.__data.scale_selection(self.__moving_both_cur - self.__moving_both_start)
            (left, right) = self.__data.get_range()
            self.__data.set_range(left + delta, right + delta)
            self.__force_full_redraw = True
            self.queue_draw()
            return True
        if self.__moving_top:
            self.__moving_top = False
        return False 
开发者ID:KTH,项目名称:royal-chaos,代码行数:36,代码来源:grid.py

示例12: run

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def run(self, graphic):
        """! Run function
        @param self this object
        @param graphic graphic
        @return none
        """
        window = gtk.Window()
        self.__window = window
        window.set_default_size(200, 200)
        vbox = gtk.VBox()
        window.add(vbox)
        render = GtkGraphicRenderer(graphic)
        self.__render = render
        vbox.pack_end(render, True, True, 0)
        hbox = gtk.HBox()
        vbox.pack_start(hbox, False, False, 0)
        smaller_zoom = gtk.Button("Zoom Out")
        smaller_zoom.connect("clicked", self.__set_smaller_cb)
        hbox.pack_start(smaller_zoom)
        bigger_zoom = gtk.Button("Zoom In")
        bigger_zoom.connect("clicked", self.__set_bigger_cb)
        hbox.pack_start(bigger_zoom)
        output_png = gtk.Button("Output Png")
        output_png.connect("clicked", self.__output_png_cb)
        hbox.pack_start(output_png)
        window.connect('destroy', gtk.main_quit)
        window.show_all()
        #gtk.bindings_activate(gtk.main_quit, 'q', 0)
        gtk.main() 
开发者ID:KTH,项目名称:royal-chaos,代码行数:31,代码来源:grid.py

示例13: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def __init__(self, operation, item_widget):
    super().__init__(item_widget)
    
    self.operation_edit_dialog = None
    
    self._operation = operation
    
    self._button_edit = gtk.Button()
    self._setup_item_button(self._button_edit, gtk.STOCK_EDIT, position=0) 
开发者ID:khalim19,项目名称:gimp-plugin-export-layers,代码行数:11,代码来源:operations.py

示例14: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def __init__(self, item_widget):
    self._item_widget = item_widget
    
    self._hbox = gtk.HBox(homogeneous=False)
    self._hbox.set_spacing(self._HBOX_SPACING)
    
    self._hbox_buttons = gtk.HBox(homogeneous=False)
    self._hbox_buttons.set_spacing(self._HBOX_BUTTONS_SPACING)
    
    self._event_box_buttons = gtk.EventBox()
    self._event_box_buttons.add(self._hbox_buttons)
    
    self._hbox.pack_start(self._item_widget, expand=True, fill=True)
    self._hbox.pack_start(self._event_box_buttons, expand=False, fill=False)
    
    self._event_box = gtk.EventBox()
    self._event_box.add(self._hbox)
    
    self._has_hbox_buttons_focus = False
    
    self._button_remove = gtk.Button()
    self._setup_item_button(self._button_remove, gtk.STOCK_CLOSE)
    
    self._event_box.connect("enter-notify-event", self._on_event_box_enter_notify_event)
    self._event_box.connect("leave-notify-event", self._on_event_box_leave_notify_event)
    
    self._is_event_box_allocated_size = False
    self._buttons_allocation = None
    self._event_box.connect("size-allocate", self._on_event_box_size_allocate)
    self._event_box_buttons.connect(
      "size-allocate", self._on_event_box_buttons_size_allocate)
    
    self._event_box.show_all()
    
    self._hbox_buttons.set_no_show_all(True) 
开发者ID:khalim19,项目名称:gimp-plugin-export-layers,代码行数:37,代码来源:itembox.py

示例15: __init__

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Button [as 别名]
def __init__(self, text=None, **kwargs):
    super().__init__(self, **kwargs)
    
    self._label = gtk.Label(text)
    self._label.set_alignment(0.0, 0.5)
    self._label.show_all()
    self._label.set_no_show_all(True)
    
    self._button_edit = gtk.Button()
    self._button_edit.set_relief(gtk.RELIEF_NONE)
    self._button_edit_icon = gtk.image_new_from_pixbuf(
      self._button_edit.render_icon(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU))
    self._button_edit.add(self._button_edit_icon)
    
    self._hbox = gtk.HBox(homogeneous=False)
    self._hbox.set_spacing(self._LABEL_EDIT_BUTTON_SPACING)
    self._hbox.pack_start(self._label, expand=True, fill=True)
    self._hbox.pack_start(self._button_edit, expand=False, fill=False)
    
    self._entry = gtk.Entry()
    self._entry.show_all()
    self._entry.set_no_show_all(True)
    
    self._entry.hide()
    
    self.pack_start(self._hbox, expand=False, fill=False)
    self.pack_start(self._entry, expand=False, fill=False)
    
    self._button_edit.connect("clicked", self._on_button_edit_clicked)
    self._entry.connect("activate", self._on_entry_finished_editing)
    self._entry.connect("focus-out-event", self._on_entry_finished_editing) 
开发者ID:khalim19,项目名称:gimp-plugin-export-layers,代码行数:33,代码来源:editablelabel.py


注:本文中的gtk.Button方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。