本文整理汇总了Python中gtk.Label方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.Label方法的具体用法?Python gtk.Label怎么用?Python gtk.Label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.Label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _entry_to_label
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def _entry_to_label (self, widget, event):
# pylint: disable-msg=W0613
"""replace gtk.Entry by the gtk.Label"""
if self._entry and self._entry in self.get_children():
#disconnect signals to avoid segfault :s
for sig in self._entry_handler_id:
if self._entry.handler_is_connected(sig):
self._entry.disconnect(sig)
self._entry_handler_id = []
self.remove (self._entry)
self.add (self._label)
self._entry = None
self.show_all ()
self.emit('edit-done')
return(True)
return(False)
示例2: createTabLabel
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [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
示例3: addBgClick
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def addBgClick(self, widget=None, init=False):
"""Creates a new background and adds a new tab to the notebook."""
n = self.bgNotebook.get_n_pages()
if n > (self.defaults["bgCount"] + 2):
if confirmDialog(self, "You already have %d background styles. Are you sure you would like another?" % n) == gtk.RESPONSE_NO:
return
self.addBg()
newId = len(self.bgs)
self.bgNotebook.append_page(self.bgs[newId-1], gtk.Label("Background ID %d" % (newId)))
self.bgNotebook.show_all()
self.updateComboBoxes(n, "add")
self.bgNotebook.set_current_page(n)
if not init:
self.changeOccurred()
示例4: quit
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def quit(self, widget, event=None):
"""Asks if user would like to save file before quitting, then quits the program."""
if self.toSave:
if self.oneConfigFile:
response = gtk.RESPONSE_YES
else:
dialog = gtk.Dialog("Save config?", self, gtk.DIALOG_MODAL, (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
dialog.get_content_area().add(gtk.Label("Save config before quitting?"))
dialog.get_content_area().set_size_request(300, 100)
dialog.show_all()
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_CANCEL:
return True # Return True to stop it quitting when we hit "Cancel"
elif response == gtk.RESPONSE_NO:
gtk.main_quit()
elif response == gtk.RESPONSE_YES:
self.save()
gtk.main_quit()
else:
gtk.main_quit()
示例5: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def __init__(self, title=None):
""" Initializer
@param self: this object
@param title: title
"""
self.__title_text = None
gtk.widget_push_composite_child()
self.__title = gobject.new(gtk.Label, visible=True, xalign=0, yalign=0.5)
self.__indent = gobject.new(gtk.Label, visible=True, label=' ')
gtk.widget_pop_composite_child()
gtk.Bin.__init__(self)
self.__title.set_parent(self)
self.__indent.set_parent(self)
if title is not None:
self.props.title = title
示例6: add_box_hardware
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def add_box_hardware(self, title, text):
vboxframe = gtk.Frame()
vboxframe.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
vboxchild = gtk.Fixed()
vboxevent = gtk.EventBox()
vboxevent.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
vboxevent.add(vboxchild)
vboxframe.add(vboxevent)
vboxchildlabel1 = gtk.Label()
vboxchildlabel1.set_selectable(True)
vboxchildlabel1.set_markup("<b>" + title + "</b>")
vboxchild.put(vboxchildlabel1, 5, 5)
vboxchildlabel2 = gtk.Label()
vboxchildlabel2.set_selectable(True)
vboxchildlabel2.set_text('\n'.join(text) + "\n")
vboxchild.put(vboxchildlabel2, 5, 35)
self.wine.builder.get_object("hosttablehw").add(vboxframe)
self.wine.builder.get_object("hosttablehw").show_all()
示例7: _init_gui
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [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()
示例8: _create_placeholder_widget
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def _create_placeholder_widget(self):
hbox = gtk.HBox()
hbox.set_spacing(self._PLACEHOLDER_WIDGET_HORIZONTAL_SPACING_BETWEEN_ELEMENTS)
hbox.pack_start(
gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_BUTTON),
expand=False,
fill=False)
label = gtk.Label()
label.set_use_markup(True)
label.set_markup(
'<span font_size="small">{}</span>'.format(
gobject.markup_escape_text(_("Cannot modify this parameter"))))
hbox.pack_start(label, expand=False, fill=False)
return hbox
示例9: _create_field_tooltip
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def _create_field_tooltip(self):
self._field_tooltip_window = gtk.Window(type=gtk.WINDOW_POPUP)
self._field_tooltip_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP)
self._field_tooltip_window.set_resizable(False)
# This copies the style of GTK tooltips.
self._field_tooltip_window.set_name("gtk-tooltips")
self._field_tooltip_text = gtk.Label()
self._field_tooltip_hbox = gtk.HBox(homogeneous=False)
self._field_tooltip_hbox.pack_start(
self._field_tooltip_text, expand=False, fill=False)
self._field_tooltip_frame = gtk.Frame()
self._field_tooltip_frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self._field_tooltip_frame.add(self._field_tooltip_hbox)
self._field_tooltip_frame.show_all()
self._field_tooltip_window.add(self._field_tooltip_frame)
示例10: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [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
示例11: key_edit_window_title
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def key_edit_window_title(self):
window = self.get_toplevel()
dialog = gtk.Dialog(_('Rename Window'), window,
gtk.DIALOG_MODAL,
( gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT ))
dialog.set_default_response(gtk.RESPONSE_ACCEPT)
dialog.set_has_separator(False)
dialog.set_resizable(False)
dialog.set_border_width(8)
label = gtk.Label(_('Enter a new title for the Terminator window...'))
name = gtk.Entry()
name.set_activates_default(True)
if window.title.text != self.vte.get_window_title():
name.set_text(self.get_toplevel().title.text)
dialog.vbox.pack_start(label, False, False, 6)
dialog.vbox.pack_start(name, False, False, 6)
dialog.show_all()
res = dialog.run()
if res == gtk.RESPONSE_ACCEPT:
if name.get_text():
window.title.force_title(None)
window.title.force_title(name.get_text())
else:
window.title.force_title(None)
dialog.destroy()
return
# End key events
示例12: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def __init__(self, text = ""):
""" Class initialiser"""
gtk.EventBox.__init__(self)
self.__gobject_init__()
self._entry_handler_id = []
self._label = gtk.Label(text)
self._custom = False
self.set_visible_window (False)
self.add (self._label)
self.connect ("button-press-event", self._on_click_text)
示例13: _create_command_dialog
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
dialog = gtk.Dialog(
_("New Command"),
None,
gtk.DIALOG_MODAL,
(
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
)
)
table = gtk.Table(3, 2)
label = gtk.Label(_("Enabled:"))
table.attach(label, 0, 1, 0, 1)
enabled = gtk.CheckButton()
enabled.set_active(enabled_var)
table.attach(enabled, 1, 2, 0, 1)
label = gtk.Label(_("Name:"))
table.attach(label, 0, 1, 1, 2)
name = gtk.Entry()
name.set_text(name_var)
table.attach(name, 1, 2, 1, 2)
label = gtk.Label(_("Command:"))
table.attach(label, 0, 1, 2, 3)
command = gtk.Entry()
command.set_text(command_var)
table.attach(command, 1, 2, 2, 3)
dialog.vbox.pack_start(table)
dialog.show_all()
return (dialog,enabled,name,command)
示例14: addBgDefs
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def addBgDefs(self, bgDefs):
"""Add interface elements for a list of background style definitions. bgDefs
should be a list containing dictionaries with the following keys: rounded,
border_width, background_color, border_color"""
for d in bgDefs:
self.addBg()
for child in self.bgs[-1].get_children():
if child.get_name() == "rounded":
child.set_text(d["rounded"])
elif child.get_name() == "border":
child.set_text(d["border_width"])
elif child.get_name() == "bgColEntry":
child.set_text(d["background_color"].split(" ")[0].strip())
child.activate()
elif child.get_name() == "borderColEntry":
child.set_text(d["border_color"].split(" ")[0].strip())
child.activate()
elif child.get_name() == "bgCol":
list = d["background_color"].split(" ")
if len(list) > 1:
child.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
else:
child.set_alpha(65535)
elif child.get_name() == "borderCol":
list = d["border_color"].split(" ")
if len(list) > 1:
child.set_alpha(int(int(list[1].strip()) * 65535 / 100.0))
else:
child.set_alpha(65535)
newId = len(self.bgs)
self.bgNotebook.append_page(self.bgs[newId-1], gtk.Label("Background ID %d" % (newId)))
self.bgNotebook.show_all()
self.updateComboBoxes(newId-1, "add")
self.bgNotebook.set_current_page(newId)
示例15: createLabel
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import Label [as 别名]
def createLabel(parent, text="", gridX=0, gridY=0, sizeX=1, sizeY=1, xPadding=0):
"""Creates a label and adds it to a parent widget."""
temp = gtk.Label(text)
temp.set_alignment(0, 0.5)
parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xpadding=xPadding)
return temp