本文整理汇总了Python中gi.repository.Gtk.Dialog方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.Dialog方法的具体用法?Python Gtk.Dialog怎么用?Python Gtk.Dialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.Dialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore_create_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def restore_create_dialog():
# ask if the user wants to create a new wallet, or recover from a seed.
# if he wants to recover, and nothing is found, do not create wallet
dialog = Gtk.Dialog("electrum", parent=None,
flags=Gtk.DialogFlags.MODAL,
buttons= ("create", 0, "restore",1, "cancel",2) )
label = Gtk.Label("Wallet file not found.\nDo you want to create a new wallet,\n or to restore an existing one?" )
label.show()
dialog.vbox.pack_start(label, True, True, 0)
dialog.show()
r = dialog.run()
dialog.destroy()
if r==2: return False
return 'restore' if r==1 else 'create'
示例2: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def __init__(self, uistate, data, parent):
super().__init__(uistate, [], self)
self.window = Gtk.Dialog()
self.set_window(self.window, None, _("Database Information"))
self.window.set_modal(True)
self.ok = self.window.add_button(_('_OK'), Gtk.ResponseType.OK)
self.ok.connect('clicked', self.on_ok_clicked)
self.window.set_position(Gtk.WindowPosition.CENTER)
self.window.set_default_size(600, 400)
s = Gtk.ScrolledWindow()
titles = [
(_('Setting'), 0, 150),
(_('Value'), 1, 400)
]
treeview = Gtk.TreeView()
model = Gtk.ListModel(treeview, titles)
for key, value in sorted(data.items()):
model.add((key, str(value),), key)
s.add(treeview)
self.window.vbox.pack_start(s, True, True, 0)
if parent:
self.window.set_transient_for(parent)
self.show()
示例3: _config_chooser_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def _config_chooser_dialog(self, title_text, description):
"""Dialog to select which config shall be exported
:param title_text: Title text
:param description: Description
"""
dialog = Gtk.Dialog(title_text, self.view["preferences_window"],
flags=0, buttons=
(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
label = Gtk.Label(label=description)
label.set_padding(xpad=10, ypad=10)
dialog.vbox.pack_start(label, True, True, 0)
label.show()
self._gui_checkbox = Gtk.CheckButton(label="GUI Config")
dialog.vbox.pack_start(self._gui_checkbox, True, True, 0)
self._gui_checkbox.show()
self._core_checkbox = Gtk.CheckButton(label="Core Config")
self._core_checkbox.show()
dialog.vbox.pack_start(self._core_checkbox, True, True, 0)
response = dialog.run()
dialog.destroy()
return response
示例4: _preferences_button_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def _preferences_button_clicked(self, *args):
row = self._listbox.get_selected_row()
widget = self._get_preference_widget(row)
if not widget:
return
if self._has_headerbar:
dlg = Gtk.Dialog(use_header_bar=True, flags=Gtk.DialogFlags.MODAL)
dlg.get_header_bar().set_show_close_button(True)
else:
dlg = Gtk.Dialog(flags=Gtk.DialogFlags.MODAL)
dlg.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
dlg.props.title = row.plugin.get_name()
area = dlg.get_content_area()
area.add(widget)
dlg.set_resizable(False)
dlg.run()
dlg.destroy()
示例5: addNewBank
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def addNewBank(self, model):
dialog = Gtk.Dialog(None, None,
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK))
label = Gtk.Label(label='Bank Name:')
entry = Gtk.Entry()
dialog.vbox.pack_start(label, False, False, 0)
dialog.vbox.pack_start(entry, False, False, 0)
dialog.show_all()
result = dialog.run()
bank_name = entry.get_text()
if result == Gtk.ResponseType.OK and len(bank_name) != 0:
iter = model.append()
model.set(iter, 0, bank_name)
self.add_bank(bank_name)
dialog.destroy()
示例6: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def __init__(self, parent, exists, appid, name):
Gtk.Dialog.__init__(self, "Install appmanifest", parent, 0)
self.set_default_size(300, 100)
label0 = Gtk.Label("Install \""+ name +"\"?")
label1 = Gtk.Label("appmanifest_"+ str(appid) +".acf")
if exists:
self.set_title("appmanifest already exists")
self.add_buttons( "Cancel", Gtk.ResponseType.CANCEL,
"Delete anyway", Gtk.ResponseType.OK )
label0.set_text("This will just remove the appmanifest file")
label1.set_text("Use Steam to remove all of \""+ name +"\".")
else:
self.add_buttons("Cancel", Gtk.ResponseType.CANCEL,
"Install", Gtk.ResponseType.OK,)
self.get_content_area().add(label0)
self.get_content_area().add(label1)
self.show_all()
示例7: showOutput
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def showOutput(self, widget): # Request for daemon output
widget.set_sensitive(False) # Disable menu item
def displayOutput(outText, widget):
# # # NOTE: it is called not from main thread, so it have to add action in main loop queue
def do_display(outText, widget):
# global APPLOGO
statusWindow = Gtk.Dialog(_('Yandex.Disk daemon output message'))
statusWindow.set_icon(APPLOGO)
statusWindow.set_border_width(6)
statusWindow.add_button(_('Close'), Gtk.ResponseType.CLOSE)
textBox = Gtk.TextView() # Create text-box to display daemon output
# Set output buffer with daemon output in user language
textBox.get_buffer().set_text(outText)
textBox.set_editable(False)
# Put it inside the dialogue content area
statusWindow.get_content_area().pack_start(textBox, True, True, 6)
statusWindow.show_all(); statusWindow.run(); statusWindow.destroy()
widget.set_sensitive(True) # Enable menu item
idle_add(do_display, outText, widget)
self.daemon.output(lambda t: displayOutput(t, widget))
示例8: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def __init__(self, application):
"""
:param application: The parent application for this object.
:type application: :py:class:`Gtk.Application`
"""
utilities.assert_arg_type(application, Gtk.Application, arg_pos=1)
self.config = application.config
"""A reference to the King Phisher client configuration."""
self.application = application
"""The parent :py:class:`Gtk.Application` instance."""
self.logger = logging.getLogger('KingPhisher.Client.' + self.__class__.__name__)
builder = Gtk.Builder()
self.gtk_builder = builder
"""A :py:class:`Gtk.Builder` instance used to load Glade data with."""
top_level_dependencies = [gobject.name for gobject in self.dependencies.children if isinstance(gobject, GladeProxy)]
top_level_dependencies.append(self.dependencies.name)
if self.dependencies.top_level is not None:
top_level_dependencies.extend(self.dependencies.top_level)
builder.add_objects_from_file(which_glade(), top_level_dependencies)
builder.connect_signals(self)
gobject = builder.get_object(self.dependencies.name)
setattr(self, self.top_gobject, gobject)
if isinstance(gobject, Gtk.Window):
gobject.set_transient_for(self.application.get_active_window())
self.application.add_reference(self)
if isinstance(gobject, Gtk.ApplicationWindow):
application.add_window(gobject)
if isinstance(gobject, Gtk.Dialog):
gobject.set_modal(True)
self.gobjects = utilities.FreezableDict()
"""A :py:class:`~king_phisher.utilities.FreezableDict` which maps gobjects to their unique GTK Builder id."""
self._load_child_dependencies(self.dependencies)
self.gobjects.freeze()
self._load_child_proxies()
if self.objects_persist:
self.objects_load_from_config()
示例9: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def __init__(self, parent, title):
Gtk.Dialog.__init__(self, transient_for=parent)
self.set_title(title)
self.set_modal(True)
self.set_resizable(False)
self.set_size_request(300, -1)
self.set_border_width(10)
self.values = list()
self.dialog_box = self.get_content_area()
self.dialog_box.set_spacing(6)
示例10: params_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def params_dialog(parent, title, limits):
def on_apply_clicked(button, h_scale, dialog):
dialog.values.append(int(h_scale.get_value()))
dialog.destroy()
dialog = Dialog(parent, title)
default = (limits[0] + limits[1]) / 2
h_scale = Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL, limits[0],
limits[1], 20)
h_scale.set_value(default)
h_scale.set_hexpand(True)
h_scale.set_valign(Gtk.Align.START)
cancel_button = Gtk.Button.new_with_label(_("Cancel"))
cancel_button.connect('clicked', dialog.close)
ok_button = Gtk.Button.new_with_label(_("Apply"))
ok_button.connect('clicked', on_apply_clicked, h_scale, dialog)
ok_button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION)
button_box = Gtk.Box(spacing=6)
button_box.pack_start(cancel_button, True, True, 0)
button_box.pack_start(ok_button, True, True, 0)
dialog.dialog_box.add(h_scale)
dialog.dialog_box.add(button_box)
dialog.launch()
return dialog
示例11: details_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def details_dialog(parent, infos):
dialog = Dialog(parent, _("Image details"))
grid = Gtk.Grid(row_spacing=12, column_spacing=12, column_homogeneous=True)
grid.attach(Gtk.Label('<b>' + _("Name") + '</b>',
use_markup=True, xalign=0.0), 0, 0, 1, 1)
grid.attach(Gtk.Label(infos['name'], xalign=0.0), 1, 0, 1, 1)
grid.attach(Gtk.Label('<b>' + _("Mode") + '</b>',
use_markup=True, xalign=0.0), 0, 1, 1, 1)
grid.attach(Gtk.Label(infos['mode'], xalign=0.0), 1,1, 1, 1)
grid.attach(Gtk.Label('<b>' + _("Size") + '</b>',
use_markup=True, xalign=0.0), 0, 2, 1, 1)
grid.attach(Gtk.Label(infos['size'], xalign=0.0), 1, 2, 1, 1)
if len(infos) > 3:
grid.attach(Gtk.Label('<b>' + _("Weight") + '</b>',
use_markup=True, xalign=0.0), 0, 3, 1, 1)
grid.attach(Gtk.Label(infos['weight'], xalign=0.0), 1, 3, 1, 1)
grid.attach(Gtk.Label('<b>' + _("Last change") + '</b>',
use_markup=True, xalign=0.0), 0, 4, 1, 1)
grid.attach(Gtk.Label(infos['last_change'], xalign=0.0), 1, 4, 1, 1)
close_button = Gtk.Button.new_with_label(_("Close"))
close_button.connect('clicked', dialog.close)
close_button.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION)
grid.attach(close_button, 0, 5, 2, 1)
dialog.dialog_box.add(grid)
dialog.launch()
示例12: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def __init__(self, title, window=None, ok_button=True, cancel_button=True):
Gtk.Dialog.__init__(self, title, window)
self.set_modal(True)
self.set_destroy_with_parent(True)
if ok_button:
self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
if cancel_button:
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
self.set_default_response(Gtk.ResponseType.ACCEPT)
self.set_resizable(False)
self.set_icon_from_file(comun.ICON)
self.connect('realize', self.on_realize)
self.init_ui()
self.show_all()
示例13: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def __init__(self, parent):
"""It creates the widget of the dialogs"""
Gtk.Dialog.__init__(self)
self.ind_parent = parent
self.custom_entry = None
self.interval_entry = None
self.sensor_mgr = SensorManager()
self._create_content()
self.set_data()
self.show_all()
# not implemented yet - just hide
self.display_icon_checkbutton.set_visible(False)
self.iconpath_button.set_visible(False)
self.iconpath_entry.set_visible(False)
示例14: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def __init__(self, parent):
Gtk.Dialog.__init__(self, "Filetransfer", parent, 0)
self.set_default_size(150, 50)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_transient_for(parent)
label = Gtk.Label("Transfering Files ...")
self.progressbar = Gtk.ProgressBar()
box = self.get_content_area()
box.add(label)
box.add(self.progressbar)
self.show_all()
示例15: _create_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Dialog [as 别名]
def _create_dialog(self):
"""
Create a dialog box to select a form.
"""
# pylint: disable-msg=E1101
title = _("%(title)s - Gramps") % {'title': _("Select Form")}
top = Gtk.Dialog(title)
top.set_default_size(400, 350)
top.set_modal(True)
top.set_transient_for(self.uistate.window)
top.vbox.set_spacing(5)
label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>'
% _("Select Form"))
label.set_use_markup(True)
top.vbox.pack_start(label, 0, 0, 5)
box = Gtk.Box()
top.vbox.pack_start(box, 1, 1, 5)
self.model = Gtk.TreeStore(str, str)
self.tree = Gtk.TreeView(model=self.model)
self.tree.connect('button-press-event', self.__button_press)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn("Source", renderer, text=1)
column.set_sort_column_id(1)
self.tree.append_column(column)
slist = Gtk.ScrolledWindow()
slist.add(self.tree)
slist.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
box.pack_start(slist, 1, 1, 5)
top.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL)
top.add_button(_('_OK'), Gtk.ResponseType.OK)
top.show_all()
return top