本文整理汇总了Python中gtk.Button类的典型用法代码示例。如果您正苦于以下问题:Python Button类的具体用法?Python Button怎么用?Python Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: command_dialog
class command_dialog(Window):
def __init__(self, icon):
Window.__init__(self, WINDOW_TOPLEVEL)
self.set_property("skip-taskbar-hint", True)
self.set_property("destroy-with-parent", True)
self.set_modal(True)
self.set_position(WIN_POS_CENTER)
self.vbox = VBox(False, 0)
self.terminal = terminal()
self.terminal.connect("child-exited",
lambda _: self.close_button.show())
self.terminal.show()
self.close_button = Button(stock=STOCK_CLOSE)
self.close_button.connect("clicked", lambda _: self.destroy())
self.vbox.pack_start(self.terminal, False, False, 0)
self.vbox.pack_start(self.close_button, False, False, 0)
self.vbox.show()
self.add(self.vbox)
self.set_icon(pixbuf_new_from_file(icon))
def run(self, command):
self.show()
self.terminal.fork_command()
self.terminal.feed_child("pacman --noconfirm -%s;exit\n" %command)
示例2: __init__
def __init__(self, name='UDBar'):
HBox.__init__(self)
self.set_name(name)
self.ubutton = Button('update')
self.dbutton = Button('diff')
self.pack_start(self.ubutton, 0, 0, 0)
self.pack_end(self.dbutton, 0, 0, 0)
self.ubutton.show()
self.dbutton.show()
self.show()
示例3: TraitBar
class TraitBar(HBox):
def __init__(self, name='TraitBar'):
HBox.__init__(self)
self.set_name(name)
self.lcombo = MyCombo()
self.rcombo = MyCombo()
self.lcombo.set('')
self.rcombo.set('')
self.cbutton = Button('clear')
self.cbutton.show()
self.pack_start(self.lcombo, 0, 0, 0)
self.pack_end(self.rcombo, 0, 0, 0)
self.add(self.cbutton)
self.show()
示例4: __init__
def __init__(self, name='GenDialog'):
gtkDialog.__init__(self)
self.set_name(name)
self.ok_button = Button('ok', 'gtk-ok')
self.ok_button.set_name(name)
self.cancel_button = Button('cancel', 'gtk-cancel')
self.cancel_button.set_name(name)
self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0)
self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0)
self.ok_button.show()
self.cancel_button.show()
self.cancel_button.connect('clicked', lambda *x : self.destroy())
self._buttons_ = {}
self.show()
示例5: ItemButton
class ItemButton(HBox):
def __init__(self, item, name='ItemButton'):
HBox.__init__(self)
self.set_name(name)
self._key_, self._val_ = item
self.label = Label(self._key_)
self.button = Button(label=self._val_)
self.pack_start(self.label,0,0,0)
self.pack_end(self.button,1,1,5)
map(lambda x: x.show(), [self.label, self.button])
self.show()
def set(self, text):
self._val_ = text
self.button.set_label(self._val_)
示例6: _setup_layout
def _setup_layout(self):
self.hpaned = HPaned()
self.hpaned.add1(self.inst_tree)
self.hpaned.add2(self.rem_tree)
self.hpaned.show_all()
self.close_button = Button(stock=STOCK_CLOSE)
self.close_button.connect("clicked", lambda _: self.destroy())
self.terminal = terminal()
self.terminal.connect("child-exited", lambda _: self.close_button.show())
self.expander = Expander(_("Terminal"))
self.expander.connect("notify::expanded", self._set_size)
self.expander.show()
self.vbox = VBox(False, 0)
self.vbox.show()
self.vbox.pack_start(self.hpaned, False, False, 0)
self.vbox.pack_start(self.expander, False, False, 0)
self.vbox.pack_start(self.close_button, False, False, 0)
self.add(self.vbox)
示例7: __init__
def __init__(self):
from gtk import Window,WINDOW_TOPLEVEL,Button,Label,HBox,Entry,VBox,VSeparator
self.window = Window(WINDOW_TOPLEVEL)
self.window.set_title("Slideshow")
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(10)
self.vbox = VBox(False, 0)
self.window.add(self.vbox)
self.hbox1 = HBox(False, 0)
self.vbox.pack_start(self.hbox1, True, True, 1)
self.hbox = HBox(False, 0)
self.vbox.pack_start(self.hbox, False, False, 1)
self.hbox2 = HBox(False, 0)
self.vbox.pack_start(self.hbox2, True, True, 1)
self.label = Label('Identifikační číslo:')
self.hbox.pack_start(self.label, False, False, 1)
self.label.show()
self.editable = Entry()
self.editable.connect('key_press_event', self.key_press_event)
self.hbox.pack_start(self.editable, True, True, 1)
self.editable.show()
self.button = Button("Začít")
self.button.connect("clicked", self.callback)
self.button.set_receives_default(True)
self.button.set_can_focus(True)
self.hbox.pack_start(self.button, False, False, 1)
self.button.show()
self.hbox1.show()
self.hbox.show()
self.hbox2.show()
self.vbox.show()
self.window.show()
示例8: __init__
def __init__(self):
HBox.__init__(self)
MDSplusWidget.__init__(self)
HBox.set_homogeneous(self,False)
self.node_state=CheckButton('')
self.button=Button()
HBox.pack_start(self,self.node_state,False,False,0)
HBox.pack_start(self,self.button,False,False,0)
HBox.pack_start(self,Label(''),True,False,0)
if not guibuilder:
self.button.connect("clicked",self.popupXd)
self.button.connect("realize",self.setButtonLabel)
示例9: __init__
def __init__(self, title=TITLE, level=WINDOW_TOPLEVEL, on_exit=None):
self.title = title
self.grabbing = False
self.events = []
self.rgb = WHITE_RGB
self.on_exit = on_exit
self.window = Window(level)
self.window.set_title(title)
self.window.set_resizable(True)
self.window.add_events(POINTER_MOTION_MASK)
self.window.set_default_size(350, 150)
self.colors = []
grab_btn = Button('Grab')
grab_btn.connect_object('clicked', self.toggle_grab, self.window)
self.grab_btn = grab_btn
exit_btn = Button('Exit')
exit_btn.connect_object('clicked', self.destroy, self.window)
drawing = DrawingArea()
drawing.connect_object('expose_event', self.do_expose, self.window)
self.drawing = drawing
label = Label(rgb_to_string(WHITE_RGB))
self.label = label
table = Table(2, 2, True)
table.attach(self.drawing, 0, 1, 0, 1)
table.attach(label, 0, 1, 1, 2)
table.attach(grab_btn, 1, 2, 0, 1)
table.attach(exit_btn, 1, 2, 1, 2)
self.window.add(table)
示例10: initXdbox
def initXdbox(self):
self.xdbox=Window()
try:
self.xdbox.set_title(str(self.node))
except:
pass
vbox=VBox()
self.xdbox.expr=MDSplusExprWidget()
vbox.pack_start(self.xdbox.expr,True,True,20)
close=Button(stock=STOCK_CLOSE)
close.connect("clicked",self.xdbox_close)
redo=Button(stock=STOCK_REDO)
redo.connect("clicked",self.xdbox_redo)
cancel=Button(stock=STOCK_CANCEL)
cancel.connect("clicked",self.xdbox_cancel)
hbox=HBox()
hbox.pack_start(close,False,False,20)
hbox.pack_start(redo,False,False,20)
hbox.pack_start(cancel,False,False,20)
vbox.pack_start(hbox,False,False,20)
self.xdbox.add(vbox)
self.xdbox.expr.set_text(self.node_value())
示例11: __init__
def __init__(self):
Table.__init__(self, 1, 5)
self.entry1 = Entry()
self.entry2 = Entry()
self.button = Button("Search")
self.attach(self.entry1, 0, 1, 0, 1)
self.attach(self.entry2, 1, 2, 0, 1)
self.attach(self.button, 2, 3, 0, 1)
self.entry1.set_width_chars(12)
self.entry2.set_width_chars(12)
self.entry1.set_text("59.666042")
self.entry2.set_text("16.481794")
self.button.connect('clicked', self.clicked)
示例12: _setup_layout
def _setup_layout(self):
self.set_default_size(600,200)
self.hpaned = HPaned()
inst_scroll = ScrolledWindow()
inst_scroll.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
rem_scroll = ScrolledWindow()
rem_scroll.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
inst_scroll.add(self.inst_tree)
rem_scroll.add(self.rem_tree)
self.hpaned.pack1(inst_scroll, False, False)
self.hpaned.pack2(rem_scroll, False, False)
self.hpaned.show_all()
self.close_button = Button(stock=STOCK_CLOSE)
self.close_button.connect("clicked", lambda _: self.destroy())
self.terminal = terminal()
self.terminal.connect("child-exited", lambda _: self.close_button.show())
self.expander = Expander(_("Terminal"))
self.expander.connect("notify::expanded", self._set_size)
self.expander.show()
self.vbox = VBox(False, 0)
self.vbox.show()
self.vbox.pack_start(self.hpaned, True, True, 0)
self.vbox.pack_start(self.expander, False, False, 0)
self.vbox.pack_start(self.close_button, False, False, 0)
self.add(self.vbox)
示例13: __on_plugin_directories_button_click
def __on_plugin_directories_button_click(self, button):
"""Present a dialog to the user for selecting extra plugin directories
and process the request."""
dia = Dialog('Plugin Directories',
None, DIALOG_MODAL,
(STOCK_OK, RESPONSE_OK,
STOCK_CANCEL, RESPONSE_CANCEL ) )
dia.resize(500, 300)
dia.vbox.set_spacing(8)
# Setup the tree view of plugin directories.
model = ListStore(str) # each row contains a single string
tv = TreeView(model)
cell = CellRendererText()
column = TreeViewColumn('Directory', cell, text = 0)
tv.append_column(column)
dia.vbox.pack_start(tv)
# Populate the tree view.
plugin_directories = \
get_plugins_directories_from_config(self.config, self.config_path)
for plugin_directory in plugin_directories:
row = (plugin_directory,)
model.append(row)
modify_box = HBox(spacing = 8)
# Setup the remove directory button.
remove_button = Button('Remove')
remove_button.set_sensitive(False) # no directory selected initially
remove_button.connect('clicked', self.__on_remove, tv)
modify_box.pack_end(remove_button, expand = False)
tv.connect('cursor-changed', self.__on_select, remove_button)
# Setup the add directory button.
add_button = Button('Add')
add_button.connect('clicked', self.__on_add, tv)
modify_box.pack_end(add_button, expand = False)
dia.vbox.pack_start(modify_box, expand = False)
# Setup the "already included directories" label.
included_label = Label('Plugins in the PYTHONPATH are already ' +
'available to BoKeep.')
# Use a horizontal box to left-justify the label. For some reason,
# the label's set_justification property doesn't work for me.
label_box = HBox()
label_box.pack_start(included_label, expand = False)
dia.vbox.pack_start(label_box, expand = False)
dia.show_all()
dia_result = dia.run()
if dia_result == RESPONSE_OK:
# Remove the old plugin directories from the program's path.
plugin_directories = \
get_plugins_directories_from_config(self.config,
self.config_path)
for plugin_directory in plugin_directories:
path.remove(plugin_directory)
# Get the new plugin directories from the dialog.
plugin_directories = []
for row in model:
plugin_directory = row[0]
plugin_directories.append(plugin_directory)
# Update the BoKeep PYTHONPATH so that new plugins can be loaded and
# populate the list of possible new plugins.
for plugin_directory in plugin_directories:
path.append(plugin_directory)
self.__populate_possible_plugins()
# Save the new plugin directories in the configuration file.
set_plugin_directories_in_config(self.config,
self.config_path, plugin_directories)
dia.destroy()
示例14: _GenDialog
class _GenDialog(gtkDialog):
def __init__(self, name='GenDialog'):
gtkDialog.__init__(self)
self.set_name(name)
self.ok_button = Button('ok', 'gtk-ok')
self.ok_button.set_name(name)
self.cancel_button = Button('cancel', 'gtk-cancel')
self.cancel_button.set_name(name)
self.action_area.pack_start(self.ok_button, TRUE, TRUE, 0)
self.action_area.pack_end(self.cancel_button, TRUE, TRUE, 0)
self.ok_button.show()
self.cancel_button.show()
self.cancel_button.connect('clicked', lambda *x : self.destroy())
self._buttons_ = {}
self.show()
def set_ok(self, ok_fun):
self.ok_button.connect('clicked', ok_fun)
def set_cancel(self, cancel_fun):
self.cancel_button.connect('clicked', cancel_fun)
self.connect('destroy', cancel_fun)
def add_button(self, name, func, label='foo'):
if name not in self._buttons_.keys():
self._buttons_[name] = Button(label)
self._buttons_[name].show()
self._buttons_[name].connect('clicked', func)
self.action_area.add(self._buttons_[name])
示例15: start_stock_button
def start_stock_button(stock_code):
but = Button()
but.set_property('use-stock', True)
but.set_label(stock_code)
return but