我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用gi.repository.Gtk.Dialog()。
def __init__(self, parent): Gtk.Dialog.__init__(self, "Enter API Key", parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_default_size(150, 100) api_key_field = Gtk.Entry() api_key_field.set_placeholder_text("API Key") self.api_key_field = api_key_field box = self.get_content_area() box.set_margin_top(10) box.set_margin_bottom(10) box.set_margin_left(10) box.set_margin_right(10) box.set_spacing(10) box.add(api_key_field) self.show_all()
def __init__(self,title,parent,max_value): # Gtk.Dialog.__init__(self,title,parent) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_size_request(330, 40) self.set_resizable(False) self.connect('destroy', self.close) # vbox1 = Gtk.VBox(spacing = 5) vbox1.set_border_width(5) self.get_content_area().add(vbox1) # self.progressbar = Gtk.ProgressBar() vbox1.pack_start(self.progressbar,True,True,0) # self.show_all() # self.max_value=max_value self.value=0.0 self.map() while Gtk.events_pending(): Gtk.main_iteration()
def show_pieces_dialog(self, gtkaction): dialog = Gtk.Dialog( _("Select Pieces"), gv.gui.get_window(), 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) rb1 = Gtk.RadioButton.new_with_label(None, "Pieceset 1") dialog.vbox.pack_start(rb1, False, True, 5) rb2 = Gtk.RadioButton.new_with_label_from_widget(rb1, "Pieceset 2") dialog.vbox.pack_start(rb2, False, True, 5) dialog.show_all() dialog.set_default_response(Gtk.ResponseType.OK) if self.pieceset == 0: rb1.set_active(True) elif self.pieceset == 1: rb2.set_active(True) else: rb1.set_active() response = dialog.run() if response == Gtk.ResponseType.OK: if rb1.get_active(): self.pieceset = 0 elif rb2.get_active(): self.pieceset = 1 dialog.destroy() return
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, 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 __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)
def confirm(parent=None, title="", text=""): dialog = Gtk.Dialog(title, parent, 0) dialog.set_default_size(150, 100) dialog.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white")) label = Gtk.Label() label.set_markup('<span foreground="#494941" face="sans">' + text + '</span>') box = dialog.get_content_area() box.add(label) box.show_all() btn1 = dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) btn1.set_relief(2) btn2 = dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) btn2.set_relief(2) result = False response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.OK: result = True elif response == Gtk.ResponseType.CANCEL: result = False return result
def on_button(self, button): win_position = self._window.get_position() x_win = win_position[0] + self.entry.get_allocation().x + 3 y_win = win_position[1] + self.entry.get_allocation().y + 2*self.entry.get_allocation().height + 3 self.dialog = Gtk.Dialog()#None, None, Gtk.DialogFlags.MODAL) self.dialog.set_modal(True) self.dialog.set_decorated(False) self.dialog.move(x_win, y_win) self.calendar = Gtk.Calendar() # self.calendar.select_month(self.date.month-1,self.date.year) self.calendar.select_day(self.date.day) # self.calendar.show() self.dialog.vbox.pack_start(self.calendar, 0, 0, 0) self.dialog.connect('focus-out-event',self.on_focus_out) self.calendar.connect('day-selected', self.on_select) self.calendar.connect('month-changed', self.on_month_select) # self.dialog.run() value = self.calendar.get_date() value = datetime.date(value[0],value[1]+1,value[2]) self.set_date(value) self.dialog.destroy()
def create_window(self): self.dialog = Gtk.Dialog(None, None, Gtk.DialogFlags.MODAL) self.dialog.set_decorated(False) # scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_can_focus(False) scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT) self.dialog.vbox.pack_start(scrolledwindow, Gtk.AttachOptions.SHRINK, Gtk.AttachOptions.SHRINK,0) # self.store = Gtk.ListStore(str) for value in self.values: self.store.append([value]) self.tree = Gtk.TreeView(self.store) self.tree.set_headers_visible(False) self.tree.set_can_focus(False) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(title=None,cell_renderer=renderer, text=0) self.tree.append_column(column) # scrolledwindow.add(self.tree) self.tree.connect('focus-out-event',self.on_focus_out) self.dialog.connect('focus-out-event',self.on_focus_out) self.tree.connect('cursor-changed',self.on_cursor_changed) self.dialog.show_all()
def __init__(self, parent): Gtk.Dialog.__init__(self, "Something", parent, Gtk.DialogFlags.MODAL, buttons=( Gtk.STOCK_NEW, Gtk.ResponseType.OK, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) self.set_default_size(400, 600) box = self.get_content_area() label = Gtk.Label("Insert text you want to search for:") box.add(label) # self.entry = Gtk.Entry() # box.add(self.entry) self.main_area = Gtk.Stack() self.main_area.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.main_area.set_transition_duration(1000) self.entry = Gtk.Entry() self.main_area.add_titled(self.entry, "entry_name", "Entry Url") self.labelS = Gtk.Label() self.label_txt = """<big><i>you have choice to runn the scan directly or after setup the scanning process you want to follow on your target</i></big>""" self.labelS.set_markup(self.label_txt) self.labelS.set_line_wrap(True) self.main_area.add_titled(self.labelS, "label_name", "How Scan will Start") self.our_stackSwitcher = Gtk.StackSwitcher() self.our_stackSwitcher.set_stack(self.main_area) box.add(self.our_stackSwitcher) box.add(self.main_area) self.show_all() #~~~~~~~~~~~~ History Dialog ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
def do_activate(self): if not self.window: self.window = self.builder.get_object("main_window") self.window.set_application(self) self.window.present() #The preferences dialog self.preferences_dialog = Gtk.Dialog(self.window, self.window, True, ) self.preferences_dialog.add_buttons(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE, Gtk.STOCK_APPLY, Gtk.ResponseType.APPLY) self.preferences_dialog.set_title("Preferences") box = self.preferences_dialog.get_content_area() box.add(self.settings_box)
def __init__(self, parent): Gtk.Dialog.__init__(self, "Enter Credentials", parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_default_size(150, 100) username_field = Gtk.Entry() username_field.set_placeholder_text("Username") password_field = Gtk.Entry() password_field.set_placeholder_text("Password") password_field.set_visibility(False) password_field.set_invisible_char('*') self.username_field = username_field self.password_field = password_field box = self.get_content_area() box.set_margin_top(10) box.set_margin_bottom(10) box.set_margin_left(10) box.set_margin_right(10) box.set_spacing(10) box.add(username_field) box.add(password_field) self.show_all()
def __init__(self, parent, message=""): Gtk.Dialog.__init__(self, "Confirmation", parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_resizable(False) self.get_content_area().add(Gtk.Label(message)) self.show_all()
def __init__(self): Gtk.Dialog.__init__(self, 'File Downloader',None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_size_request(400, 100) self.set_title('? ubi site file downloader') self.connect('destroy', self.close_application) # vbox0 = Gtk.VBox(spacing = 10) vbox0.set_border_width(5) self.get_content_area().add(vbox0) # table1 = Gtk.Table(3,2,False) vbox0.add(table1) label10 = Gtk.Label('Extension:') label10.set_alignment(0, 0.5) table1.attach(label10,0,1,0,1) # self.entry10 = Gtk.Entry() table1.attach(self.entry10,1,2,0,1) # label11 = Gtk.Label('Url:') label11.set_alignment(0, 0.5) table1.attach(label11,0,1,1,2) # self.entry11 = Gtk.Entry() table1.attach(self.entry11,1,2,1,2) # #self.button = Gtk.Button('Select folder') #self.button.connect('clicked',self.on_button_clicked) #table1.attach(self.button,0,2,2,3) # self.show_all()
def show_dialog(self, gtkaction): dialog = Gtk.Dialog( _("Select Colour Scheme"), gv.gui.get_window(), 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) rb1 = Gtk.RadioButton.new_with_label(None, "Brown") dialog.vbox.pack_start(rb1, False, True, 5) rb2 = Gtk.RadioButton.new_with_label_from_widget(rb1, "Blue") dialog.vbox.pack_start(rb2, False, True, 5) rb3 = Gtk.RadioButton.new_with_label_from_widget(rb1, "Green") dialog.vbox.pack_start(rb3, False, True, 5) dialog.show_all() dialog.set_default_response(Gtk.ResponseType.OK) if self.colour_scheme == 0: rb1.set_active(True) elif self.colour_scheme == 1: rb2.set_active(True) elif self.colour_scheme == 2: rb3.set_active(True) else: rb1.set_active() response = dialog.run() if response == Gtk.ResponseType.OK: if rb1.get_active(): self.colour_scheme = 0 elif rb2.get_active(): self.colour_scheme = 1 elif rb3.get_active(): self.colour_scheme = 2 dialog.destroy() return
def __init__(self, parent): Gtk.Dialog.__init__(self, "Enter Password", parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_default_size(150, 100) self.input = Gtk.Entry() self.input.set_max_length(8) box = self.get_content_area() box.add(self.input) self.show_all()
def __init__(self, parent): Gtk.Dialog.__init__(self, "File Dialog", parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_default_size(500, 550) box = self.get_content_area() self.verticalbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3) box.add(self.verticalbox) self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) from_file = Gtk.Button("From File") from_file.connect("clicked", self.on_file) from_clipboard = Gtk.Button("Clipboard") from_clipboard.connect("clicked", self.on_clipboard) hbox1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, homogeneous=True) hbox1.pack_start(from_file, True, True, 0) hbox1.pack_start(from_clipboard, True, True, 0) self.verticalbox.pack_start(hbox1, False, False, 0) # Just holding the Place for real treeview widget self.scrollable_treelist = Gtk.Label() self.verticalbox.pack_start(self.scrollable_treelist, True, True, 0) self.show_all()
def __init__(self, parent, error_text): Gtk.Dialog.__init__(self, _("Make bug report"), parent, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)) self.m_error_text = error_text self.add_button(_("_Send"), RESPONSE_SEND) self.set_default_size(400, 400) sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) l = Gtk.Label(_("Information about the version of GNU Solfege, your operating system and Python version, and the Python traceback (error message) will be sent to the crash database. Your email will not be published or shared, but we might contact you by email if we have further questions about your crash report.")) l.set_line_wrap(True) l.show() self.vbox.pack_start(l, False, False, 0) self.g_email = Gtk.Entry() self.vbox.pack_start( gu.hig_label_widget(_("_Email:"), self.g_email, sizegroup), False, False, 0) self.g_email.set_text(cfg.get_string('user/email')) # 140 is max in the solfege.org database self.g_description = Gtk.Entry() self.g_description.set_max_length(140) self.vbox.pack_start( gu.hig_label_widget(_("S_hort description:"), self.g_description, sizegroup), False, False, 0) label = Gtk.Label(label=_("_Describe how to produce the error message:")) label.set_use_underline(True) label.set_alignment(0.0, 0.5) self.vbox.pack_start(label, False, False, 0) self.g_tw = Gtk.TextView() self.g_tw.set_wrap_mode(Gtk.WrapMode.WORD) self.g_tw.set_border_width(10) label.set_mnemonic_widget(self.g_tw) self.vbox.pack_start(self.g_tw, True, True, 0) self.show_all()
def __init__(self): Gtk.Dialog.__init__(self, _(u"_Create profile\u2026").replace(u"\u2026", "").replace("_", "")) 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=_("Enter the name of the new folder:")) label.set_alignment(0.0, 0.5) vbox.pack_start(label, False, False, 0) # self.g_entry = Gtk.Entry() self.g_entry.connect('changed', self.on_entry_changed) self.g_entry.set_activates_default(True) vbox.pack_start(self.g_entry, False, False, 0) # label = Gtk.Label(label=_("Your profile data will be stored in:")) label.set_alignment(0.0, 0.5) vbox.pack_start(label, False, False, 0) # self.g_profile_location = Gtk.Label() vbox.pack_start(self.g_profile_location, False, False, 0) # self.g_statusbox = Gtk.HBox() self.g_statusbox.set_no_show_all(True) vbox.pack_start(self.g_statusbox, False, False, 0) im = Gtk.Image() im.set_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.MENU) self.g_statusbox.pack_start(im, False, False, 0) im.show() self.g_status = Gtk.Label() self.g_status.show() self.g_statusbox.pack_start(self.g_status, False, False, 0) self.g_entry.set_text(_("New Profile")) self.set_default_response(Gtk.ResponseType.ACCEPT)
def __init__(self): Gtk.Dialog.__init__(self) self.set_default_size(500, 300) self.g_music_displayer = mpd.MusicDisplayer() self.vbox.pack_start(self.g_music_displayer, True, True, 0) b = gu.bButton(self.action_area, _("Close"), solfege.win.close_musicviewer) b.grab_focus() self.connect('destroy', solfege.win.close_musicviewer) self.show_all()
def show_bug_reports(self, *v): m = Gtk.Dialog(_("Question"), self, 0) m.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) m.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) vbox = Gtk.VBox() m.vbox.pack_start(vbox, False, False, 0) vbox.set_spacing(18) vbox.set_border_width(12) l = Gtk.Label(label=_("Please enter the email used when you submitted the bugs:")) vbox.pack_start(l, False, False, 0) self.g_email = Gtk.Entry() m.action_area.get_children()[0].grab_default() self.g_email.set_activates_default(True) vbox.pack_start(self.g_email, False, False, 0) m.show_all() ret = m.run() m.destroy() if ret == Gtk.ResponseType.OK: params = urllib.urlencode({ 'pagename': 'SITS-Incoming/SearchBugs', 'q': 'SITS-Incoming/"Submitter: %s"' % utils.mangle_email(self.g_email.get_text().decode("utf-8")()), }) try: webbrowser.open_new("http://www.solfege.org?%s" % params) except Exception, e: self.display_error_message2(_("Error opening web browser"), str(e))
def show_path_info(self, w): if not self.g_path_info_dlg: self.g_path_info_dlg = Gtk.Dialog(_("_File locations").replace("_", ""), self, buttons=(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) sc = Gtk.ScrolledWindow() sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) self.g_path_info_dlg.vbox.pack_start(sc, True, True, 0) # vbox = gu.hig_dlg_vbox() sc.add_with_viewport(vbox) box1, box2 = gu.hig_category_vbox(_("_File locations").replace("_", "")) vbox.pack_start(box1, True, True, 0) sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) # statistics.sqlite # win32 solfegerc # win32 langenviron.txt box2.pack_start(gu.hig_label_widget(_("Solfege application data:"), Gtk.Label(label=filesystem.app_data()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("Solfege user data:"), Gtk.Label(label=filesystem.user_data()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("Solfege config file:"), Gtk.Label(label=filesystem.rcfile()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("Solfege installation directory:"), Gtk.Label(label=os.getcwdu()), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget(_("User manual in HTML format:"), Gtk.Label(label=os.path.join(os.getcwdu(), "help")), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget("gtk:", Gtk.Label(label=str(Gtk)), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget("pyalsa:", Gtk.Label(label=str(alsaseq)), sizegroup), False, False, 0) box2.pack_start(gu.hig_label_widget("PYTHONHOME", Gtk.Label(os.environ.get('PYTHONHOME', 'Not defined')), sizegroup), False, False, 0) self.g_path_info_dlg.show_all() def f(*w): self.g_path_info_dlg.hide() return True self.g_path_info_dlg.connect('response', f) self.g_path_info_dlg.connect('delete-event', f) sc.set_size_request(min(vbox.size_request().width + gu.hig.SPACE_LARGE * 2, Gdk.Screen.width() * 0.9), vbox.size_request().height)
def __init__(self, value): # Gtk.Dialog.__init__(self, 'Backlight Indicator | ' + _('Set backlight'), None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.connect('close', self.close_ok) self.set_icon_from_file(comun.ICON) # vbox0 = Gtk.VBox(spacing=5) vbox0.set_border_width(5) self.get_content_area().add(vbox0) frame0 = Gtk.Frame() vbox0.pack_start(frame0, False, True, 1) table0 = Gtk.Table(2, 2, False) frame0.add(table0) label23 = Gtk.Label(_('Backlight') + ':') label23.set_alignment(0, 0.5) table0.attach(label23, 0, 1, 0, 1, xpadding=5, ypadding=5) configuration = Configuration() minimum_backlight = configuration.get('minimum-backlight') maximum_backlight = configuration.get('maximum-backlight') ba = BacklightManager() backlight = ba.get_backlight() adjustment3 = Gtk.Adjustment(backlight, minimum_backlight, maximum_backlight, 5, 10, 1) self.backlight = Gtk.Scale() self.backlight.set_digits(0) self.backlight.set_size_request(200, 10) self.backlight.set_adjustment(adjustment3) table0.attach(self.backlight, 1, 2, 0, 1, xpadding=5, ypadding=5) self.backlight.set_value(value) self.show_all()
def popup_stack(self, widget): dialog = Gtk.Dialog('The stack', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE)) ui.gtk3.common.set_bokken_icon(dialog) stack_img = Gtk.Image() stack_img.set_from_file(datafile_path('stack.png')) dialog.vbox.pack_start(self.create_h1_label("The stack"), False, False, 2) dialog.vbox.pack_start(stack_img, True, True, 2) dialog.show_all() dialog.run() dialog.destroy()
def popup_registers(self, widget): dialog = Gtk.Dialog('16-bit and 8-bit registers', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE)) ui.gtk3.common.set_bokken_icon(dialog) reg_img = Gtk.Image() reg_img.set_from_file(datafile_path('registers.png')) reg_label = Gtk.Label("The four primary general purpose registers (EAX, EBX, ECX and EDX)\nhave 16 and 8 bit overlapping aliases.") reg_label.set_alignment(0.1, 0.1) reg_label.set_padding (0, 3) dialog.vbox.pack_start(reg_label, False, False, 2) dialog.vbox.pack_start(reg_img, True, True, 2) dialog.show_all() dialog.run() dialog.destroy()
def __init__(self): parent = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) self.win = Gtk.Dialog("My dialog", parent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) ) self.button1 = self.win.add_button('Add to playlist', Gtk.ResponseType.OK) self.button2 = self.win.add_button('Play now', Gtk.ResponseType.OK) self.button1.connect("clicked", self._button_clicked) self.button2.connect("clicked", self._button_clicked) self.ret = None
def alert(parent = None, title="", text=""): dialog = Gtk.Dialog(title, parent, 0) dialog.set_default_size(150, 100) dialog.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#FAFAFA")) label = Gtk.Label() label.set_markup('<span foreground="#494941" face="sans">' + text + '</span>') box = dialog.get_content_area() box.add(label) btn = dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) btn.set_relief(2) box.show_all() dialog.run() dialog.destroy()
def __init__(self, parent): Gtk.Dialog.__init__(self, "Search", parent, Gtk.DialogFlags.MODAL, buttons=( Gtk.STOCK_FIND, Gtk.ResponseType.OK, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) box = self.get_content_area() label = Gtk.Label("Insert text you want to search for:") box.add(label) self.entry = Gtk.Entry() box.add(self.entry) self.show_all()
def create_import_from_server_dialog(self, chart_list): import_chart = None import_dialog = Gtk.Dialog("Import from server", self, 0) box = import_dialog.get_content_area() content_box = Gtk.Box() box.add(content_box) chart_selector = Gtk.ComboBoxText() for chart in sorted(chart_list): chart_selector.append_text(chart) content_box.pack_start(Gtk.Label("Choose a chart:"), True, True, 0) content_box.pack_start(chart_selector, True, True, 0) import_dialog.add_button('Import', Gtk.ResponseType.OK) content_box.show_all() response = import_dialog.run() if response == Gtk.ResponseType.OK: import_chart = chart_selector.get_active_text() import_dialog.destroy() if import_chart: return import_chart
def _on_button_clicked(self, button): dialog = Gtk.Dialog() dialog.set_transient_for(self) gpaste_settings = GPaste.SettingsUiWidget() for child in gpaste_settings.get_children(): if isinstance(child, Gtk.StackSwitcher): toplevel = dialog.get_toplevel() if not toplevel: continue gpaste_settings.remove(child) header_bar = Gtk.HeaderBar() header_bar.set_show_close_button(True) header_bar.set_title(None) header_bar.set_subtitle(None) header_bar.set_custom_title(child) toplevel.set_titlebar(header_bar) if isinstance(child, Gtk.Stack): child.set_transition_type( Gtk.StackTransitionType.SLIDE_LEFT_RIGHT ) child.set_transition_duration(self._transition_duration) content_area = dialog.get_content_area() content_area.add(gpaste_settings) dialog.show_all() dialog.run() dialog.destroy()
def __init__(self,url): self.code = None Gtk.Dialog.__init__(self) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_title(comun.APP) self.set_icon_from_file(comun.ICON) # vbox = Gtk.VBox(spacing = 5) self.get_content_area().add(vbox) hbox1 = Gtk.HBox() vbox.pack_start(hbox1,True,True,0) # self.scrolledwindow1 = Gtk.ScrolledWindow() self.scrolledwindow1.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN) hbox1.pack_start(self.scrolledwindow1,True,True,0) # self.viewer = WebKit.WebView() self.scrolledwindow1.add(self.viewer) self.scrolledwindow1.set_size_request(600,420) self.viewer.connect('navigation-policy-decision-requested', self.on_navigation_requested) self.viewer.open(url) # self.show_all() #################################################################### #########################BROWSER#################################### ####################################################################
def __init__(self, tasklist = None): Gtk.Dialog.__init__(self) if tasklist == None: self.set_title(comun.APPNAME + ' | '+_('Add new tasklist')) else: self.set_title(comun.APPNAME + ' | '+_('Edit tasklist')) self.set_modal(True) self.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT,Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL) self.set_size_request(200, 80) self.set_resizable(False) self.set_icon_from_file(comun.ICON) # vbox0 = Gtk.VBox(spacing = 5) vbox0.set_border_width(5) self.get_content_area().add(vbox0) # table1 = Gtk.Table(n_rows = 1, n_columns = 2, homogeneous = False) table1.set_border_width(5) table1.set_col_spacings(5) table1.set_row_spacings(5) vbox0.add(table1) # label11 = Gtk.Label.new(_('Title')+':') label11.set_alignment(0,.5) table1.attach(label11,0,1,0,1, xoptions = Gtk.AttachOptions.FILL, yoptions = Gtk.AttachOptions.FILL) # self.entry1 = Gtk.Entry() self.entry1.set_width_chars(60) table1.attach(self.entry1,1,2,0,1, xoptions = Gtk.AttachOptions.EXPAND, yoptions = Gtk.AttachOptions.SHRINK) # if tasklist is not None: if 'title' in tasklist.keys(): self.entry1.set_text(tasklist['title']) self.show_all()
def __init__(self, transient_for): kwargs = {} if self.use_header_bar: kwargs['use_header_bar'] = True Gtk.Dialog.__init__(self, transient_for=transient_for, title=_("Preferences"), **kwargs) self.set_default_size(500, -1) if not self.use_header_bar: self.add_button(_("Close"), Gtk.ResponseType.CLOSE) self.set_default_response(Gtk.ResponseType.CLOSE) else: # can't do it now, it doesn't have window decorations yet! GLib.idle_add(self.make_enter_close_the_dialog) builder = Gtk.Builder.new_from_file(PREFERENCES_UI_FILE) vbox = builder.get_object('dialog-vbox') self.get_content_area().add(vbox) virtual_midnight_entry = builder.get_object('virtual_midnight_entry') self.virtual_midnight_entry = virtual_midnight_entry hours_entry = builder.get_object('hours_entry') office_hours_entry = builder.get_object('office_hours_entry') name_entry = builder.get_object('name_entry') sender_entry = builder.get_object('sender_entry') recipient_entry = builder.get_object('recipient_entry') self.gsettings = Gio.Settings.new("org.gtimelog") self.gsettings.bind('hours', hours_entry, 'value', Gio.SettingsBindFlags.DEFAULT) self.gsettings.bind('office-hours', office_hours_entry, 'value', Gio.SettingsBindFlags.DEFAULT) self.gsettings.bind('name', name_entry, 'text', Gio.SettingsBindFlags.DEFAULT) self.gsettings.bind('sender', sender_entry, 'text', Gio.SettingsBindFlags.DEFAULT) self.gsettings.bind('list-email', recipient_entry, 'text', Gio.SettingsBindFlags.DEFAULT) self.gsettings.connect('changed::virtual-midnight', self.virtual_midnight_changed) self.virtual_midnight_changed() self.virtual_midnight_entry.connect('focus-out-event', self.virtual_midnight_set)
def __about_response(self, dialog, response_id): """ Destroy about dialog when closed @param dialog as Gtk.Dialog @param response id as int """ dialog.destroy()
def get_moses_dir(self): """@brief Gets Moses directory.""" directory = self.moses_dir response = Gtk.ResponseType.ACCEPT while response == Gtk.ResponseType.ACCEPT and not self.is_moses_dir_valid(directory): label = Gtk.Label("Enter MOSES installation directory") entry = Gtk.Entry() button = Gtk.Button("Choose File") button.connect("clicked", self._on_dir_clicked, entry) dialog = Gtk.Dialog("Moses configuration", None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) box = dialog.get_content_area() box.add(label) box.add(entry) box.add(button) label.show() entry.show() button.show() response = dialog.run() directory = entry.get_text() dialog.destroy() # If it is not valid, keep asking until valid or user leaves. if response != Gtk.ResponseType.ACCEPT: exit(1) self.moses_dir = directory return directory
def __init__(self, message, window): d = Gtk.Dialog( title="Alert", parent=window, flags=1, buttons=("Ok", Gtk.ResponseType.CANCEL) ) label = Gtk.Label(message) label.set_padding(40, 30) d.vbox.add(label) d.show_all() d.run() d.destroy()
def __init__(self, parent): Gtk.Dialog.__init__(self) self.set_default_size(420, 400) self.set_transient_for(parent) self.set_title(_("Terms of Use")) # buttons self.add_button(_("Decline"), Gtk.ResponseType.NO) self.add_button(_("Accept"), Gtk.ResponseType.YES) # label self.label = Gtk.Label(_(u"One moment, please\u2026")) self.label.show() # add the label box = self.get_action_area() box.pack_start(self.label, False, False, 0) box.set_child_secondary(self.label, True) # hrm, hrm, there really should be a better way for itm in box.get_children(): if itm.get_label() == _("Accept"): self.button_accept = itm break self.button_accept.set_sensitive(False) # webkit wb = ScrolledWebkitWindow() wb.show_all() self.webkit = wb.webkit self.webkit.connect( "notify::load-status", self._on_load_status_changed) # content content = self.get_content_area() self.spinner = SpinnerNotebook(wb) self.spinner.show_all() content.pack_start(self.spinner, True, True, 0)
def run(self): self.spinner.show_spinner() self.webkit.load_uri(SOFTWARE_CENTER_TOS_LINK_NO_HEADER) return Gtk.Dialog.run(self)
def __init__(self, title, pixbuf, parent=None): Gtk.Dialog.__init__(self) # find parent window for the dialog if not parent: parent = self.get_parent() while parent: parent = parent.get_parent() # screenshot img = Gtk.Image.new_from_pixbuf(pixbuf) # scolled window for screenshot scroll = Gtk.ScrolledWindow() scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scroll.add_with_viewport(img) content_area = self.get_content_area() content_area.pack_start(scroll, True, True, 0) # dialog self.set_title(title) self.set_transient_for(parent) self.set_destroy_with_parent(True) self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) self.set_default_size(SimpleShowImageDialog.DEFAULT_WIDTH, SimpleShowImageDialog.DEFAULT_HEIGHT)
def run(self): # show all and run the real thing self.show_all() Gtk.Dialog.run(self)
def run(self): if self.show_dialog == False: return Gtk.ResponseType.OK self.show_all() # and run the real thing return Gtk.Dialog.run(self)