def generate_components(self):
self.get_style_context().add_class("top")
self.infobar = Gtk.InfoBar()
self.infobar.set_show_close_button(True)
self.infobar.connect("response", self.response)
self.infobar.set_default_response(Gtk.ResponseType.CLOSE)
self.infobar.set_message_type(Gtk.MessageType.INFO)
content_area = self.infobar.get_content_area()
action_area = self.infobar.get_action_area()
self.undo_button = None
if self.undo_action:
self.undo_button = self.infobar.add_button(
_("Undo"), Gtk.ResponseType.CANCEL)
self.message_label = Gtk.Label()
self.message_label.set_text(self.message)
content_area.add(self.message_label)
self.add(self.infobar)
python类Label()的实例源码
inapp_notification.py 文件源码
项目:Gnome-Authenticator
作者: bil-elmoussaoui
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def __init__(self, parent, window, account):
# Read default values
self.window = window
self.parent = parent
self.account = account
# Create needed widgets
self.code_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
self.revealer = Gtk.Revealer()
self.checkbox = Gtk.CheckButton()
self.application_name = Gtk.Label(xalign=0)
self.code_label = Gtk.Label(xalign=0)
self.timer_label = Gtk.Label(xalign=0)
self.accel = Gtk.AccelGroup()
self.window.add_accel_group(self.accel)
self.accel.connect(Gdk.keyval_from_name('C'), Gdk.ModifierType.CONTROL_MASK, 0, self.copy_code)
self.accel.connect(Gdk.keyval_from_name("Enter"), Gdk.ModifierType.META_MASK, 0, self.toggle_code)
def bottom_bar_handler(self, tim: time, text: str, action: str):
"""Add actions to the eventlist in the bottom bar.
:param tim: Time of action.
:param text: Recognized text.
:param action: Action performed.
"""
row = Gtk.ListBoxRow()
box = Gtk.HBox()
box.set_homogeneous(True)
text_label = Gtk.Label(text)
text_label.set_line_wrap(True)
box.pack_start(Gtk.Label(tim), False, False, 0)
box.pack_start(text_label, True, True, 0)
box.pack_start(Gtk.Label(action), False, False, 0)
row.add(box)
# Remove old entries
if self.bottom_widget.get_object("event_list").get_row_at_index(40):
self.bottom_widget.get_object("event_list").get_row_at_index(40).destroy()
row.show_all()
self.bottom_widget.get_object("event_list").prepend(row)
def __init__(self, app, name, use_icon, widget):
self.pressed = Gtk.Label()
ControllerWidget.__init__(self, app, name, use_icon, widget)
grid = Gtk.Grid()
self.label.set_property("vexpand", True)
self.label.set_property("hexpand", True)
self.label.set_xalign(0.0); self.label.set_yalign(0.5)
self.pressed.set_property("hexpand", True)
self.pressed.set_xalign(0.0); self.pressed.set_yalign(1.0)
if self.icon:
self.icon.set_margin_right(5)
grid.attach(self.icon, 1, 1, 1, 2)
grid.attach(self.label, 2, 1, 1, 1)
grid.attach(self.pressed, 2, 2, 1, 1)
self.over_icon = False
self.widget.add(grid)
self.widget.show_all()
def __init__(self, parent):
self.parent = parent
self.language = 'Plain'
self.curLinter = None
self.lintersObj = {
'c': LinterClang(self.parent, self)
}
self.linterPopover = Gtk.Popover()
self.errorsLbl = Gtk.Label('Errors: 0')
self.statusLbl = Gtk.Label('Status: OK')
self.linterPopoverBox = Gtk.VBox()
self.linterPopoverBox.set_border_width(10)
self.linterPopoverBox.pack_start(self.errorsLbl, False, False, 0)
self.linterPopoverBox.pack_start(self.statusLbl, False, False, 0)
self.linterPopover.add(self.linterPopoverBox)
##
def buildTree(self, *args):
for item in self.files:
a = Gtk.Label(item)
if os.path.isdir(self.projectPath + '/' + item):
i = Gtk.Image.new_from_icon_name('folder', Gtk.IconSize.MENU) # change this for recursive function
else:
i = Gtk.Image.new_from_icon_name('text-x-script', Gtk.IconSize.MENU)
hb = Gtk.HBox(spacing=6)
hb.pack_start(i, False, False, 0)
hb.pack_start(a, False, False, 0)
row = Gtk.ListBoxRow()
row.add(hb)
self.sideView.add(row)
self.sideView.show_all()
def update(self, tablist: list, tabcurr: int):
"""Updates the widget's tabs.
:tablist: list of tab names.
:tabcurr: the active buffer's number.
"""
self.props.updating = True
for _ in range(self.get_n_pages()):
self.remove_page(-1)
for name in tablist:
page = Gtk.Box()
self.append_page(page, Gtk.Label(name))
self.child_set_property(page, 'tab-expand', True)
self.show_all()
self.set_current_page(tabcurr - 1)
self.set_show_tabs(self.get_n_pages() > 1)
self.props.updating = False
def __init__(self, sbrick_configuration, sbrick_communications_store):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=10, margin=5)
self.set_homogeneous(False)
self.sbrick_configuration = sbrick_configuration
self.sbrick_communications_store = sbrick_communications_store
self.sbrick_communications_store.add_observer(self)
label = Gtk.Label(sbrick_configuration["name"])
label.set_width_chars(20)
label.set_justify(Gtk.Justification.LEFT)
self.pack_start(label, False, True, 0)
self.handler_ids = []
self.sequence_player_handler_id = None
self.button_play = Gtk.Button.new()
self.button_play.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON))
self.button_play.connect("clicked", self.on_play_clicked)
self.pack_start(self.button_play, False, True, 0)
self.checkPause = Gtk.CheckButton("Pause in Play All")
self.checkPause.connect("toggled", self.on_pause_changed)
self.pack_start(self.checkPause, False, True, 0)
self.sbrick_communications = None
self.sequence_player = None
def _create_ticker_labels(self):
self._tickers_vbox.forall(lambda w: w.destroy())
self._ticker_labels = {}
for i, market_config in enumerate(config['markets']):
if market_config['ticker']:
market_id = get_market_id(market_config)
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
exchange, market = market_config['exchange'], market_config['market']
provider = btcwidget.exchanges.factory.get(exchange)
market_name = '{} - {}:'.format(provider.get_name(), market)
name_label = Gtk.Label(market_name)
color = self._get_color(i)
name_label.set_markup('<span color="{}">{}</span>'.format(color, market_name))
name_label.set_size_request(150, 10)
name_label.set_alignment(0, 0.5)
hbox.pack_start(name_label, False, False, 10)
price_label = Gtk.Label()
hbox.pack_start(price_label, False, False, 10)
self._ticker_labels[market_id] = price_label
price_label.get_parent()
self._tickers_vbox.pack_start(hbox, True, True, 2)
self._tickers_vbox.show_all()
def create_version_view(self, label, version):
custom = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
spacing=12,
expand=True,
visible=True)
title = Gtk.Label(halign='start', expand=True, visible=True, label=label)
subtitle = Gtk.Label(halign='start', expand=True, visible=True)
subtitle.get_style_context().add_class('dim-label')
subtitle.set_markup(version)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, expand=True, visible=True)
vbox.pack_start(title, True, True, 0)
vbox.pack_start(subtitle, True, True, 0)
custom.pack_start(vbox, True, True, 0)
pack = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
spacing=6,
expand=True,
visible=True)
pack.pack_start(custom, True, True, 0)
return pack
def __init__(self, data, chapter):
"""
Holds data that is chapter name and chapter_link that is link to chapter file. For use as ListBox element.
:param data:
:param chapter:
"""
super(Gtk.ListBoxRow, self).__init__()
# Remember chapter name and file link
self.data = data
self.chapter_link = chapter
# Just a bunch of label styling
label = Gtk.Label(xalign=0)
label.set_text(data)
label.set_justify(Gtk.Justification.LEFT)
try:
label.set_margin_start(10)
except AttributeError:
label.set_margin_left(10)
label.set_width_chars(20)
label.set_ellipsize(Pango.EllipsizeMode.END)
self.add(label)
def __init__(self):
#self._widget = Gtk.Notebook()
self._widget = Gtk.Label("Configuration panel for JSHint Plugin")
#grid = Gtk.Grid()
#for i in range(30):
# button = Gtk.CheckButton("Button {}".format(i))
# button.set_tooltip_text("This is the button {}".format(i))
# grid.attach(button, i // 10, i % 10, 1, 1)
#self._widget.append_page(grid, Gtk.Label("Enforcing"))
#page = Gtk.Box()
#page.add(Gtk.Label("Relaxing options"))
#self._widget.append_page(page, Gtk.Label("Relaxing"))
#page = Gtk.Box()
#page.add(Gtk.Label("Environments options"))
#self._widget.append_page(page, Gtk.Label("Environments"))
def add_module_is_deprecated_label(self):
"""
The deprecated module must set a message in self.g_deprecated_label
in on_start_practise, preferable telling the file name of the
lesson file.
"""
img = Gtk.Image()
img.set_from_stock(Gtk.STOCK_DIALOG_WARNING,
Gtk.IconSize.BUTTON)
hbox = Gtk.HBox()
hbox.set_border_width(12)
self.practise_box.set_child_packing(self.g_lesson_heading, False, False, 0, 0)
hbox.set_spacing(6)
hbox.pack_start(img, True, True, 0)
self.g_deprecated_label = Gtk.Label()
hbox.pack_start(self.g_deprecated_label, True, True, 0)
self.practise_box.pack_start(hbox, False, False, 0)
self.practise_box.reorder_child(hbox, 0)
def _add_auto_new_question_gui(self, box):
hbox = gu.bHBox(box, False)
hbox.set_spacing(gu.PAD_SMALL)
adj = Gtk.Adjustment(0, 0, 10, 0.1, 1)
spin = gu.nSpinButton(self.m_exname, 'seconds_before_new_question',
adj)
spin.set_digits(1)
label = Gtk.Label(label=_("Delay (seconds):"))
label.show()
def f(button, spin=spin, label=label):
spin.set_sensitive(button.get_active())
label.set_sensitive(button.get_active())
b = gu.nCheckButton(self.m_exname, 'new_question_automatically',
_("_New question automatically."), callback=f)
hbox.pack_start(b, False, False, 0)
label.set_sensitive(b.get_active())
hbox.pack_start(label, False, False, 0)
spin.set_sensitive(b.get_active())
hbox.pack_start(spin, False, False, 0)
def add_select_num_beats_gui(self):
###
hbox = Gtk.HBox()
hbox.set_spacing(gu.hig.SPACE_SMALL)
label = Gtk.Label(label=_("Number of beats in question:"))
hbox.pack_start(label, False, False, 0)
self.config_box_sizegroup.add_widget(label)
label.set_alignment(1.0, 0.5)
hbox.pack_start(gu.nSpinButton(self.m_exname, "num_beats",
Gtk.Adjustment(4, 1, 100, 1, 10)), False, False, 0)
self.config_box.pack_start(hbox, False, False, 0)
hbox.show_all()
#
hbox = Gtk.HBox()
hbox.set_spacing(gu.hig.SPACE_SMALL)
label = Gtk.Label(label=_("Count in before question:"))
hbox.pack_start(label, False, False, 0)
self.config_box_sizegroup.add_widget(label)
label.set_alignment(1.0, 0.5)
hbox.pack_start(gu.nSpinButton(self.m_exname, "count_in",
Gtk.Adjustment(2, 0, 10, 1, 10)), False, False, 0)
hbox.show_all()
self.config_box.pack_start(hbox, False, False, 0)
def create(self):
table = Gtk.Table()
label = Gtk.Label()
label.set_alignment(0.0, 0.5)
label.set_markup(u"<b>%s</b>" % self.m_heading)
self.pack_start(label, True, True, 0)
for idx, (cell1, cell2) in enumerate(self.m_data):
table.attach(label_from_key(self.m_statistics, cell1), 1, 2, idx*2+1, idx*2+2,
xoptions=Gtk.AttachOptions.SHRINK, xpadding=2)
table.attach(Gtk.Label(label=cell2), 3, 4, idx*2+1, idx*2+2,
xoptions=Gtk.AttachOptions.SHRINK, xpadding=2)
for idx in range(len(self.m_data) + 1):
table.attach(Gtk.HSeparator(), 0, 5, idx*2, idx*2+1, xoptions=Gtk.AttachOptions.FILL)
table.attach(Gtk.VSeparator(), 0, 1, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK)
table.attach(Gtk.VSeparator(), 2, 3, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK)
table.attach(Gtk.VSeparator(), 4, 5, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK)
self.pack_start(table, False, False, 0)
self.show_all()
def __init__(self, statistics, heading):
Gtk.ScrolledWindow.__init__(self)
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.vbox = Gtk.VBox(False, 0)
self.vbox.set_spacing(gu.PAD)
self.vbox.set_border_width(gu.PAD)
self.add_with_viewport(self.vbox)
hbox = Gtk.HBox(False, 0)
hbox.set_spacing(gu.hig.SPACE_SMALL)
im = Gtk.Image.new_from_file("graphics/applications-system.svg")
self.g_settings_button = b = Gtk.Button()
b.connect('clicked', self.on_delete_statistics)
b.add(im)
hbox.pack_start(b, False, False, 0)
self.g_heading = Gtk.Label(label=heading)
self.g_heading.set_alignment(0.0, 0.5)
self.g_heading.set_name("StatisticsH1")
hbox.pack_start(self.g_heading, False, False, 0)
self.vbox.pack_start(hbox, False, False, 0)
self.m_statistics = statistics
self.g_tables = Gtk.VBox(False, 0)
self.g_tables.show()
self.vbox.pack_start(self.g_tables, True, True, 0)
self.show_all()
def hig_category_vbox(title, spacing=6):
"""
spacing the space to put between children. HIG say is should be 6, but
while packing Gtk.LinkButtons there is too much space between the links
when packing with 6 pixels. So I added the spacing parameter.
Return a tuple of two boxes:
box1 -- a box containing everything including the title. Useful
if you have to hide a category.
box2 The box you should pack your stuff in.
"""
vbox = Gtk.VBox(False, 0)
vbox.set_spacing(hig.SPACE_SMALL)
label = Gtk.Label(label='<span weight="bold">%s</span>' % title)
label.set_use_markup(True)
label.set_alignment(0.0, 0.0)
vbox.pack_start(label, False, False, 0)
hbox = Gtk.Box(False, 0)
vbox.pack_start(hbox, False, False, 0)
fill = Gtk.Label(label=" ")
hbox.pack_start(fill, False, False, 0)
category_content_vbox = Gtk.VBox(False, 0)
hbox.pack_start(category_content_vbox, True, True, 0)
category_content_vbox.set_spacing(spacing)
vbox.show_all()
return vbox, category_content_vbox
def hig_label_widget(txt, widget, sizegroup, expand=False, fill=False):
"""
Return a box containing a label and a widget, aligned nice
as the HIG say we should. widget can also be a list or tuple of
widgets.
"""
hbox = Gtk.Box()
hbox.set_spacing(hig.SPACE_SMALL)
label = Gtk.Label(label=txt)
label.set_alignment(0.0, 0.5)
if sizegroup:
sizegroup.add_widget(label)
hbox.pack_start(label, False, False, 0)
if not isinstance(widget, (list, tuple)):
widget = [widget]
for w in widget:
hbox.pack_start(w, fill, expand, padding=0)
label.set_use_underline(True)
label.set_mnemonic_widget(widget[0])
return hbox
def create_statistics_config(self):
it, page_vbox = self.new_page_box(None, _("Statistics"))
box, category_vbox = gu.hig_category_vbox(_("Statistics from 3.15 and older"))
page_vbox.pack_start(box, False, False, 0)
self.g_old_stat_info = Gtk.Label()
self.g_old_stat_info.set_line_wrap(True)
self.g_old_stat_info.set_alignment(0.0, 0.5)
category_vbox.pack_start(self.g_old_stat_info, False, False, 0)
###
self.g_delete_old_statistics = Gtk.Button(stock=Gtk.STOCK_DELETE)
self.g_delete_old_statistics.connect('clicked', self.delete_obsolete_statistics)
category_vbox.pack_start(self.g_delete_old_statistics, False, False, 0)
box, category_vbox = gu.hig_category_vbox(_("Statistics"))
page_vbox.pack_start(box, False, False, 0)
self.g_stat_info = Gtk.Label()
self.g_stat_info.set_line_wrap(True)
self.g_stat_info.set_alignment(0.0, 0.5)
category_vbox.pack_start(self.g_stat_info, False, False, 0)
b = Gtk.Button(stock=Gtk.STOCK_DELETE)
b.connect('clicked', self.delete_statistics)
category_vbox.pack_start(b, False, False, 0)
self.update_statistics_info()
self.update_old_statistics_info()
def _worker_Xrandom(self, rfunc):
styles = ["8beat", "ballad", "rock"]
s = """
styles = %s
question {
style = %s("8beat", "ballad")
}
question {
style = %s(styles)
}
""" % (", ".join(['"%s"' % x for x in styles]), rfunc, rfunc)
self.p = QuestionsLessonfile()
p = self.do_file(s)
for idx in range(2):
st = p.m_questions[idx]['style']
for x in range(20):
self.assert_(str(st) in styles)
self.assert_(unicode(st) in styles)
st.randomize()
# This test only works with nrandom, because prandom will
# return a possible different value every time.
if rfunc == 'nrandom':
l = Gtk.Label(label=st)
self.assert_(l.get_text() == unicode(st), "%s and gtk does not cooperate." % rfunc)
def __init__(self, oldname):
Gtk.Dialog.__init__(self, _(u"_Rename profile\u2026").replace("_", "").replace(u"\u2026", ""))
self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
vbox = gu.hig_dlg_vbox()
self.vbox.pack_start(vbox, True, True, 0)
label = Gtk.Label(label=_(u"Rename the profile «%s» to:") % oldname)
label.set_alignment(0.0, 0.5)
vbox.pack_start(label, False, False, 0)
self.g_entry = Gtk.Entry()
self.g_entry.set_text(oldname)
self.g_entry.set_activates_default(True)
self.g_entry.connect('changed', self.on_entry_changed)
vbox.pack_start(self.g_entry, False, False, 0)
self.g_info = Gtk.Label()
self.g_info.set_no_show_all(True)
vbox.pack_start(self.g_info, False, False, 0)
self.set_default_response(Gtk.ResponseType.ACCEPT)
def __init__(self, lf, v):
"""
lf is the lesson file (aka m_P of the teacher object)
v is a list of element names defind in the lesson file lf,
for example:
['I', 'IV', 'V', 'I']
Return a HBox that presents a label with the label names
separated by "-".
"""
gu.AlignedHBox.__init__(self)
self.setup_pre()
for i, k in enumerate(v):
if k in lf.m_elements:
l = new_labelobject(lf.m_elements[k]['label'])
else:
l = Gtk.Label(label=k)
self.pack_start(l, False, False)
if i != len(v) - 1:
l = Gtk.Label(label="-")
self.pack_start(l, False, False)
self.setup_post()
self.show_all()
def __init__(self):
Gtk.Window.__init__(self, Gtk.WindowType.POPUP)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_resizable(True)
frame = Gtk.Frame()
frame.set_shadow_type(Gtk.ShadowType.OUT)
self.add(frame)
vbox = Gtk.VBox()
vbox.set_border_width(20)
frame.add(vbox)
l = Gtk.Label(label=_("Starting GNU Solfege %s") % buildinfo.VERSION_STRING)
l.set_name("Heading1")
vbox.pack_start(l, True, True, 0)
l = Gtk.Label(label="http://www.solfege.org")
vbox.pack_start(l, True, True, 0)
self.g_infolabel = Gtk.Label(label='')
vbox.pack_start(self.g_infolabel, True, True, 0)
self.show_all()
def __init__(self, parent, title, text):
Gtk.Dialog.__init__(self, title, parent, 0,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK))
self.set_default_size(350, 0)
self.set_default_response(Gtk.ResponseType.OK)
self.label = Gtk.Label(text)
self.label.set_margin_start(5)
self.label.set_margin_top(5)
self.label.set_margin_bottom(5)
self.label.set_margin_end(5)
self.entry = Gtk.Entry()
self.entry.set_margin_start(5)
self.entry.set_margin_top(5)
self.entry.set_margin_bottom(5)
self.entry.set_margin_end(5)
self.entry.connect('activate', lambda widget: self.response(Gtk.ResponseType.OK))
self.get_content_area().add(self.label)
self.get_content_area().add(self.entry)
def __create_album_flowboxitem(self, album, image, margin):
label_album = Gtk.Label(f'{album.Name} ({album.Year})', max_width_chars=0,
justify=Gtk.Justification.LEFT, wrap=True,
wrap_mode=Pango.WrapMode.WORD_CHAR, xalign=0, margin_top=5)
label_artist = Gtk.Label(album.Artist, max_width_chars=0, justify=Gtk.Justification.LEFT,
ellipsize=Pango.EllipsizeMode.END, xalign=0, margin_top=5)
label_album.get_style_context().add_class('text110')
label_artist.get_style_context().add_class('dim-label')
flowboxchild = Gtk.FlowBoxChild(halign=Gtk.Align.CENTER)
grid = Gtk.Grid(margin=margin, halign=Gtk.Align.CENTER)
grid.attach(image, 0, 0, 1, 1)
grid.attach(label_album, 0, 1, 1, 1)
grid.attach(label_artist, 0, 2, 1, 1)
flowboxchild.add(grid)
flowboxchild.data = album
return flowboxchild
def create_tab(self, title, tab_child, icon=''):
tab_box = Gtk.HBox(False, 3)
close_button = Gtk.Button()
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
label = Gtk.Label(label=title)
if icon:
i = Gtk.Image()
i.set_from_stock(eval('Gtk.STOCK_' + icon), Gtk.IconSize.MENU)
tab_box.pack_start(i, False, False, 0)
close_button.connect("clicked", self.close_tab, tab_child)
close_button.set_image(image)
close_button.set_relief(Gtk.ReliefStyle.NONE)
tab_box.pack_start(label, True, True, 0)
tab_box.pack_end(close_button, False, False, 0)
tab_box.show_all()
if title in ['Loading dasm...', 'Code', 'Callgraph', 'Flowgraph', 'Interactive', 'Strings', "Sections", 'Hexdump', 'Bindiff', 'File info']:
close_button.hide()
return tab_box
def __init__(self, tviews, uicore):
super(RightCombo,self).__init__(1, 7, False)
self.tviews = tviews
self.uicore = uicore
# Theme Label
self.theme_label = Gtk.Label(label='Color theme:')
self.attach(self.theme_label, 0, 1, 0, 1)
# Theme ComboBox
self.theme_combo = Gtk.ComboBoxText()
options = ['Classic', 'Cobalt', 'kate', 'Oblivion', 'Tango']
for option in options:
self.theme_combo.append_text(option)
# Set first by default
self.theme_combo.set_active(0)
self.theme_combo.connect("changed", self.theme_combo_change)
self.attach(self.theme_combo, 1, 2, 0, 1)
def __init__(self, lastWindow, message, value=""):
Gtk.Dialog.__init__(self, title="Prompt")
self.set_modal(True)
self.set_transient_for(lastWindow)
self.label = Gtk.Label(message)
self.entry = Gtk.Entry()
self.entry.set_text(value)
self.get_content_area().pack_start(self.label, True, True, 0)
self.get_content_area().pack_start(self.entry, True, True, 0)
self.add_button("OK", Gtk.ResponseType.OK)
self.add_button("Cancel", Gtk.ResponseType.CANCEL)
self.connect("key-press-event", self.keyPressed)
def on_delete_learned_data_clicked(self, dummy_widget):
'''
The button requesting to delete all data learned from
user input or text files has been clicked.
'''
SETUP_UI.delete_learned_data_button.set_sensitive(False)
confirm_question = Gtk.Dialog(
title=_('Are you sure?'),
parent=SETUP_UI.builder.get_object('main_dialog'),
buttons=(
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK))
box = confirm_question.get_content_area()
box.add(Gtk.Label(
_('Do you really want to delete all language \n'
+ 'data learned from typing or reading files?')))
confirm_question.show_all()
response = confirm_question.run()
confirm_question.destroy()
while Gtk.events_pending():
Gtk.main_iteration()
if response == Gtk.ResponseType.OK:
SETUP_UI.tabsqlitedb.remove_all_phrases()
SETUP_UI.delete_learned_data_button.set_sensitive(True)