Python gi.repository.Gtk 模块,MessageDialog() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.MessageDialog()

项目:mama    作者:maateen    | 项目源码 | 文件源码
def show_stable_release_message(self):
        dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.WARNING,
                                   Gtk.ButtonsType.OK_CANCEL,
                                   "Mama! New stable version available!")
        dialog.format_secondary_text(self.text)
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            print("Stable release dialog closed by clicking OK button")
            dialog.destroy()
            self.__download_latest_version()
        elif response == Gtk.ResponseType.CANCEL:
            print("Stable release dialog closed by clicking CANCEL button")
            dialog.destroy()


# Getting data from github API
项目:openanalysis    作者:OpenWeavers    | 项目源码 | 文件源码
def action_clicked_cb(self, button):
        try:
            ele = int(self.builder.get_object("item").get_text())
            choice = int(self.builder.get_object("operation").get_active())
            state = self.builder.get_object("state")
            val = self.map[choice](ele)
            if val is False:  # Search or Delete Case
                dialog = gtk.MessageDialog(None, 0, gtk.MessageType.ERROR,
                                           gtk.ButtonsType.CANCEL, "Value not found ERROR")
                dialog.format_secondary_text(
                    "Element not found in the %s" % self.ds.name)
                dialog.run()
                dialog.destroy()
            else:
                val = ele if val is True else None
                self.ds.draw(val)
                state.set_from_file(self.ds.file_path)
        except:
            raise
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def on_device_open_failed(self, *a):
        """
        Called when all (or user-selected) driver fails
        to communicate with controller.

        Shoudln't be really possible, but something
        _has_ to happen in such case.
        """
        d = Gtk.MessageDialog(parent=self.window,
            flags = Gtk.DialogFlags.MODAL,
            type = Gtk.MessageType.ERROR,
            buttons = Gtk.ButtonsType.OK,
            message_format = _("Failed to open device")
        )
        d.run()
        d.destroy()
        self.window.destroy()
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def on_btRemoveController_clicked(self, *a):
        tvControllers = self.builder.get_object("tvControllers")
        d = Gtk.MessageDialog(parent=self.window,
            flags = Gtk.DialogFlags.MODAL,
            type = Gtk.MessageType.WARNING,
            buttons = Gtk.ButtonsType.YES_NO,
            message_format = _("Unregister controller?"),
        )
        d.format_secondary_text(_("You'll lose all settings for it"))
        if d.run() == -8:
            # Yes
            model, iter = tvControllers.get_selection().get_selected()
            path = model[iter][0]
            try:
                os.unlink(path)
            except Exception, e:
                log.exception(e)
            self._needs_restart()
            self.load_controllers()
        d.destroy()
项目:PyIDE    作者:raggesilver    | 项目源码 | 文件源码
def entryDialog(self, message, title='', defaultText=''):
        # Returns user input as a string or None
        # If user does not input text it returns None, NOT AN EMPTY STRING.
        dialogWindow = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.OK_CANCEL, message)

        dialogWindow.set_title(title)

        dialogBox = dialogWindow.get_content_area()
        userEntry = Gtk.Entry()
        userEntry.set_text(defaultText)
        dialogBox.pack_end(userEntry, False, False, 0)

        dialogWindow.show_all()
        response = dialogWindow.run()
        text = userEntry.get_text()
        dialogWindow.destroy()
        if (response == Gtk.ResponseType.OK) and (text != ''):
            return text
        else:
            return None
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def info_box(self, msg):
        dialog = Gtk.MessageDialog(
            self.window,
            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.INFO,
            Gtk.ButtonsType.OK,
            None)

        # markup = "<b>" + msg + "</b>"
        markup = msg
        dialog.set_markup(markup)
        dialog.set_title(_("Info"))

        # some secondary text
        markup = msg

        # dialog.format_secondary_markup(markup)

        dialog.show_all()
        dialog.run()
        dialog.destroy()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def ok_cancel_box(self, msg):
        dialog = Gtk.MessageDialog(
            None,
            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.INFO,
            Gtk.ButtonsType.OK_CANCEL,
            None)

        # markup = "<b>" + msg + "</b>"
        markup = msg
        dialog.set_markup(markup)
        dialog.set_title(_("Ok/Cancel"))

        # some secondary text
        markup = msg

        # dialog.format_secondary_markup(markup)

        dialog.show_all()
        resp = dialog.run()
        dialog.destroy()

        return resp
项目:ImunesExperimentExporter    作者:patriziotufarolo    | 项目源码 | 文件源码
def onExportEverythingBtnClicked(self, event):
        if not self.currentSelectedExperiment:
            return
        go = self.glade.get_object
        folderChooser = go("export_everything_select_folder")
        folderChooser.set_title("Select the directory to which you want to save your experiment in")
        folderChooser.set_transient_for(self.window)
        response = folderChooser.run()
        if response == 0:
            dest_path = folderChooser.get_filename()
            if not dest_path:
                msgdialog = Gtk.MessageDialog(self.window, 1, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Please select the target folder and try again")
                msgdialog.run()
                msgdialog.destroy()
            else:
                self.exportAllContainers(dest_path)
                msgdialog = Gtk.MessageDialog(self.window, 1, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Experiment exported")
                msgdialog.run()
                msgdialog.destroy()
项目:ImunesExperimentExporter    作者:patriziotufarolo    | 项目源码 | 文件源码
def onExportSingleBtnClicked(self, event):
        if not self.currentSelectedExperiment or not self.currentSelectedContainer:
            return
        go = self.glade.get_object
        folderChooser = go("export_everything_select_folder")
        folderChooser.set_title("Select the directory to which you want to save your container in")
        folderChooser.set_transient_for(self.window)
        response = folderChooser.run()
        if response == 0:
            dest_path = folderChooser.get_filename()
            if not dest_path:
                msgdialog = Gtk.MessageDialog(self.window, 1, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Please select the target folder and try again")
                msgdialog.run()
                msgdialog.destroy()
            else:
                self.exportSingleContainer(dest_path)
                msgdialog = Gtk.MessageDialog(self.window, 1, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Experiment exported")
                msgdialog.run()
                msgdialog.destroy()
项目:ImunesExperimentExporter    作者:patriziotufarolo    | 项目源码 | 文件源码
def onImportSingleBtnClicked(self, event):
        if not self.currentSelectedExperiment or not self.currentSelectedContainer:
            return
        go = self.glade.get_object
        folderChooser = go("export_everything_select_folder")
        folderChooser.set_title("Select the directory where your tree starts from")
        folderChooser.set_transient_for(self.window)
        response = folderChooser.run()
        if response == 0:
            source_path = folderChooser.get_filename()
            if not source_path:
                msgdialog = Gtk.MessageDialog(self.window, 1, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Please select the source folder and try again")
                msgdialog.run()
                msgdialog.destroy()
            else:
                self.importSingleContainer(source_path)
                msgdialog = Gtk.MessageDialog(self.window, 1, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Experiment imported")
                msgdialog.run()
                msgdialog.destroy()
项目:efibootmgr-gui    作者:Elinvention    | 项目源码 | 文件源码
def entry_dialog(parent, message, title=''):
    dialog = Gtk.MessageDialog(parent,
            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, message)

    dialog.set_title(title)

    dialogBox = dialog.get_content_area()
    userEntry = Gtk.Entry()
    userEntry.set_size_request(250,0)
    dialogBox.pack_end(userEntry, False, False, 0)

    dialog.show_all()
    response = dialog.run()
    text = userEntry.get_text() 
    dialog.destroy()
    if (response == Gtk.ResponseType.OK) and (text != ''):
        return text
项目:Ebook-Viewer    作者:michaldaniel    | 项目源码 | 文件源码
def __on_import_menu_item_clicked(self, wiget):
        """
        Handles Import context menu item clicked event, imports only if Calibre present
        :param wiget:
        """
        if not os.path.exists("/usr/bin/ebook-convert"):
            error_dialog = Gtk.MessageDialog(self.__window, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK,
                                             _("Importing is unavailable"))
            error_dialog.format_secondary_text(_("Importing requires Calibre eBook reader to be installed."))
            error_dialog.run()
            error_dialog.destroy()
        else:
            # Loads file chooser component
            file_chooser_component = file_chooser.FileChooserWindow()
            (response, filename) = file_chooser_component.show_dialog(importing=True)

            # Check if Gtk.Response is OK, means user selected file
            if response == Gtk.ResponseType.OK:
                print("File selected: " + filename)  # Print selected file path to console
                # Save current book data
                self.__window.save_current_book_data()
                # Load new book
                self.__window.load_book_data(filename)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def on_delete_statistics(self, widget):

        class Dlg(Gtk.MessageDialog):
            def __init__(self, first, last, count):
                Gtk.MessageDialog.__init__(self, None, Gtk.DialogFlags.MODAL,
                                    Gtk.MessageType.QUESTION,
                                    Gtk.ButtonsType.YES_NO,
                                    _("Delete statistics and test results?"))
                self.format_secondary_text(_("This exercise have statistics from %(count)s practise sessions, from %(first)s to %(last)s") % {
                    'count': count,
                    'first': first.strftime("%x %X"),
                    'last': last.strftime("%x %X")})
                self.show_all()
        fileid = solfege.db.get_fileid(self.m_statistics.m_t.m_P.m_filename)
        first = datetime.datetime.fromtimestamp(solfege.db.get_first_timestamp(fileid))
        last = datetime.datetime.fromtimestamp(solfege.db.get_last_timestamp(fileid))
        count = solfege.db.get_session_count(fileid)
        dlg = Dlg(first, last, count)
        ret = dlg.run()
        if ret == Gtk.ResponseType.YES:
            solfege.db.delete_statistics(self.m_statistics.m_t.m_P.m_filename)
            self.update()
        dlg.destroy()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def load_file(self, filename):
        self.m_P = lessonfile.ChordLessonfile(filename)
        self.m_P.m_changed = False
        if self.m_P.m_questions:
            self.m_P._idx = 0
            self.set_navinfo()

        else:
            # Do a little trick to make an empty question
            self.m_P.m_questions = [dataparser.Question()]
            self.m_P.m_questions[-1].music = lessonfile.Music("", "chord")
            self.m_P.m_questions[-1].name = ""
            self.m_P._idx = 0

        if self.m_P.header.module not in ('idbyname', 'chord', 'chordvoicing'):
                dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL,
                    Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
                    _("The exercise module '%s' is not supported yet. Cannot edit this file.") % c)
                dialog.run()
                dialog.destroy()
                self.m_P = EditorLessonfile()
        self.update_appwin()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def file_open_cb(self, *v):
        dialog = Gtk.FileChooserDialog(_("Open..."), self,
                                   Gtk.FileChooserAction.OPEN,
                                   (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                    Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
        dialog.set_default_response(Gtk.ResponseType.OK)
        if dialog.run() == Gtk.ResponseType.OK:
            filename = gu.decode_filename(dialog.get_filename())
            try:
                self.load_file(filename)
            except Exception, e:
                dialog.destroy()
                m = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
                        Gtk.ButtonsType.CLOSE,
                        _("Loading file '%(filename)s' failed: %(msg)s") %
                            {'filename': filename, 'msg': e})
                m.run()
                m.destroy()

            else:
                dialog.destroy()

        else:
            dialog.destroy()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def add_tasks(self, pcs_files, dirname=''):
        '''????????, ????'''
        def on_list_dir(info, error=None):
            path, pcs_files = info
            if error or not pcs_files:
                dialog = Gtk.MessageDialog(self.app.window,
                        Gtk.DialogFlags.MODAL,
                        Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
                        _('Failed to scan folder to download'))
                dialog.format_secondary_text(
                        _('Please download {0} again').format(path))
                dialog.run()
                dialog.destroy()
                return
            self.add_tasks(pcs_files, dirname)

        self.check_first()
        for pcs_file in pcs_files:
            if pcs_file['isdir']:
                gutil.async_call(pcs.list_dir_all, self.app.cookie,
                                 self.app.tokens, pcs_file['path'],
                                 callback=on_list_dir)
            else:
                self.add_task(pcs_file, dirname)
        self.check_commit(force=True)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def quit(self, widget, event=None, data=None):
        '''Main quit.

        @param widget: who sent the signal.
        @param event: the event that happened
        @param data: optional data to receive.
        '''
        msg = ("Do you really want to quit?")
        dlg = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, msg)
        dlg.set_default_response(Gtk.ResponseType.YES)
        opt = dlg.run()
        dlg.destroy()

        if opt != Gtk.ResponseType.YES:
            return True

        Gtk.main_quit()
        if self.dasm_process:
            self.dasm_process.terminate()
        return True
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def set_dotcode(self, dotcode, filename=None):
        self.openfilename = None
        if isinstance(dotcode, unicode):
            dotcode = dotcode.encode('utf8')
        xdotcode = self.run_filter(dotcode)
        if xdotcode is None:
            return False
        try:
            self.set_xdotcode(xdotcode)
        except ParseError as ex:
            dialog = Gtk.MessageDialog(type=Gtk.MessageType.ERROR,
                                       message_format=str(ex),
                                       buttons=Gtk.ButtonsType.OK)
            dialog.set_title('Dot Viewer')
            dialog.run()
            dialog.destroy()
            return False
        else:
            if filename is None:
                self.last_mtime = None
            else:
                self.last_mtime = os.stat(filename).st_mtime
            self.openfilename = filename
            return True
项目:MPV-VJ2    作者:paulguy    | 项目源码 | 文件源码
def editKeyResponse(self, dialog, response, key):
        if response == Gtk.ResponseType.OK:
            if dialog.get_text() in self.options:
                alertBox = Gtk.MessageDialog(parent=dialog,
                                             flags=Gtk.DialogFlags.MODAL,
                                             type=Gtk.MessageType.ERROR,
                                             buttons=Gtk.ButtonsType.OK,
                                             message_format="Key already exists.")
                alertBox.connect('response', self.closeAlert)
                alertBox.show_all()
            else:
                newKey = dialog.get_text()
                value = self.options[key]
                del self.options[key]
                self.options[newKey] = value

                for row in self.listStore:
                    if row[0] == key:
                        row[0] = newKey
                        break
        if response != Gtk.ResponseType.DELETE_EVENT:
            dialog.destroy()
项目:MPV-VJ2    作者:paulguy    | 项目源码 | 文件源码
def setSelection(self):
        model, rows = self.listView.get_selection().get_selected_rows()

        self.selection = ("F", [])
        for row in rows:
            if model[row.get_indices()[0]][1] == "D":
                alertBox = Gtk.MessageDialog(parent=self,
                                             flags=Gtk.DialogFlags.MODAL,
                                             type=Gtk.MessageType.ERROR,
                                             buttons=Gtk.ButtonsType.OK,
                                             message_format="Only multiple files may be selected.")
                alertBox.connect(FileListDialog.closeAlert)
                alertBox.show_all()
                return
            self.selection[1].append(self.listStore[row.get_indices()[0]][0])
        self.emit('response', Gtk.ResponseType.ACCEPT)
项目:chromecast-player    作者:wa4557    | 项目源码 | 文件源码
def _combo_changed_clients(self, widget):
        ind = widget.get_active()
        if ind == -1:
            return
        else:
            dev = self.chromecasts[ind]
        if not dev:
            return
        self.connect_to_chromecast(dev)
        if self.cast:
            self.cast.wait()
        else:
            self.clients_combo.set_active(-1)
            message = ("Cannot connect to chromecast. You sure you are still connected to the same network?")
            win = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
            dialog = Gtk.MessageDialog(win, None, Gtk.MessageType.ERROR,
                           Gtk.ButtonsType.OK, message)
            dialog.run()
            dialog.destroy()
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, root: Gtk.Window, text: str,
                 ok_button_text: str = Gtk.STOCK_OK,
                 cancel_button_text: str = Gtk.STOCK_CANCEL,
                 header: str = '',
                 message_type: Gtk.MessageType = Gtk.MessageType.WARNING):
        Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type)
        self.set_title(header)
        self.icon = Gtk.Image()
        self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR)
        self.text = Gtk.Label(text)
        heading = Gtk.Box()
        heading.add(self.icon)
        heading.add(self.text)

        self.get_message_area().add(heading)
        self.get_message_area().set_spacing(0)
        self.add_button(cancel_button_text, Gtk.ResponseType.CANCEL)
        self.add_button(ok_button_text, Gtk.ResponseType.OK)
        self.show_all()
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
def __init__(self, root: Gtk.Window, text: str,
                 ok_button_text: str = Gtk.STOCK_OK,
                 header: str = '',
                 message_type: Gtk.MessageType = Gtk.MessageType.ERROR):
        Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type)
        self.set_title(header)
        self.icon = Gtk.Image()
        self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR)
        self.text = Gtk.Label(text)
        heading = Gtk.Box()
        heading.add(self.icon)
        heading.add(self.text)

        self.get_message_area().add(heading)
        self.get_message_area().set_spacing(0)
        self.add_button(ok_button_text, Gtk.ResponseType.OK)
        self.show_all()
项目:Remarkable    作者:jamiemcg    | 项目源码 | 文件源码
def check_for_save(self, widget):
        reply = False
        if self.text_buffer.get_modified():
            message = "Do you want to save the changes you have made?"
            dialog = Gtk.MessageDialog(self.window,
                                       Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                                       Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO,
                                       message)
            dialog.set_title("Save?")

            if dialog.run() == Gtk.ResponseType.NO:
                reply = False
            else:
                reply = True
            dialog.destroy()
        return reply
项目:pycam    作者:SebKuzminsky    | 项目源码 | 文件源码
def emit(self, record):
        message = self.format(record)
        # Replace all "<>" characters (invalid for markup styles) with html entities.
        message = message.replace("<", "&lt;").replace(">", "&gt;")
        from gi.repository import Gtk as gtk
        if record.levelno <= 20:
            message_type = gtk.MessageType.INFO
            message_title = "Information"
        elif record.levelno <= 30:
            message_type = gtk.MessageType.WARNING
            message_title = "Warning"
        else:
            message_type = gtk.MessageType.ERROR
            message_title = "Error"
        window = gtk.MessageDialog(self.parent_window, type=message_type,
                                   buttons=gtk.ButtonsType.OK)
        window.set_markup(str(message))
        window.set_title(message_title)
        # make sure that the window gets destroyed later
        for signal in ("close", "response"):
            window.connect(signal, lambda dialog, *args: dialog.destroy())
        # accept "destroy" action -> remove window
        window.connect("destroy", lambda *args: True)
        # show the window, but don't wait for a response
        window.show()
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def _on_destroy(self, window):
        if not self._need_restart: return

        self._need_restart = False
        msg = _(
            'You need to restart the app for the changes to take effect. Restart now?'
        )
        message_dialog = Gtk.MessageDialog(
            None,
            Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.INFO,
            Gtk.ButtonsType.YES_NO,
            version.APP_NAME
        )
        message_dialog.set_position(Gtk.WindowPosition.CENTER)
        message_dialog.set_icon_from_file(common.ICON_PATH)
        message_dialog.props.secondary_text = msg
        response = message_dialog.run()
        message_dialog.destroy()

        if response == Gtk.ResponseType.YES:
            utils.restart_app()
项目:games_nebula_goglib_scripts    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_set(self, button):

        if (self.custom_width == '') or (self.custom_height == ''):
            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.ERROR,
                Gtk.ButtonsType.OK,
                _("Error")
                )
            message_dialog.format_secondary_text(_("You have to set width and height."))
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            message_dialog.run()
            message_dialog.destroy()

            return

        self.config_save()
项目:games_nebula_goglib_scripts    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_save(self, button):

        if (self.custom_width == '') or (self.custom_height == ''):
            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.ERROR,
                Gtk.ButtonsType.OK,
                _("Error")
                )
            message_dialog.format_secondary_text(_("You have to set width and height."))
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            message_dialog.run()
            message_dialog.destroy()

            return

        self.config_save()
        Gtk.main_quit()
项目:games_nebula_goglib_scripts    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_save(self, button):

        if (self.custom_width == '') or (self.custom_height == ''):
            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.ERROR,
                Gtk.ButtonsType.OK,
                _("Error")
                )
            message_dialog.format_secondary_text(_("You have to set width and height."))
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            message_dialog.run()
            message_dialog.destroy()

            return

        self.config_save()
        Gtk.main_quit()
项目:games_nebula_goglib_scripts    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_save(self, button):

        if (self.custom_width == '') or (self.custom_height == ''):
            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.ERROR,
                Gtk.ButtonsType.OK,
                _("Error")
                )
            message_dialog.format_secondary_text(_("You have to set width and height."))
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            message_dialog.run()
            message_dialog.destroy()

            return

        self.config_save()
        Gtk.main_quit()
项目:games_nebula_goglib_scripts    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_patch(self, button):

        if (self.custom_width == '') or (self.custom_height == ''):
            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.ERROR,
                Gtk.ButtonsType.OK,
                _("Error")
                )
            message_dialog.format_secondary_text(_("You have to set width and height."))
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            message_dialog.run()
            message_dialog.destroy()

            return

        self.config_save()
        self.modify_exe()
        Gtk.main_quit()
项目:battery-monitor    作者:maateen    | 项目源码 | 文件源码
def save_config(self, widget):
        if os.path.exists(self.config_dir):
            pass
        else:
            os.makedirs(self.config_dir)
        self.config['settings'] = {
            'very_low_battery': self.entry0.get_text(),
            'low_battery': self.entry1.get_text(),
            'third_custom_warning': self.entry2.get_text(),
            'second_custom_warning': self.entry3.get_text(),
            'first_custom_warning': self.entry4.get_text(),
            'notification_stability': self.entry5.get_text()
        }
        with open(self.config_file, 'w') as f:
            self.config.write(f)
            dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.INFO,
                                       Gtk.ButtonsType.OK,
                                       "Successfully Saved!")
            dialog.format_secondary_text(
                'You settings have been saved successfully.')
            dialog.run()
            print("Info dialog closed")
            dialog.destroy()
项目:python-sense-emu    作者:RPi-Distro    | 项目源码 | 文件源码
def _play_controls_finish(self, exc):
        # Reverse _play_controls_setup
        self.ui.play_box.props.visible = False
        ( self.props.application.pressure.simulate_noise,
            self.props.application.humidity.simulate_noise,
            self.props.application.imu.simulate_world,
            ) = self._play_restore
        self.ui.environ_box.props.sensitive = True
        self.ui.gyro_grid.props.sensitive = True
        self._play_thread = None
        # If an exception occurred in the background thread, display the
        # error in an appropriate dialog
        if exc:
            dialog = Gtk.MessageDialog(
                transient_for=self,
                message_type=Gtk.MessageType.ERROR,
                title=_('Error'),
                text=_('Error while replaying recording'),
                buttons=Gtk.ButtonsType.CLOSE)
            dialog.format_secondary_text(str(exc))
            dialog.run()
            dialog.destroy()
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def build_confirm_dialog(self, message_type, message_label,
                             on_signal=None, callback=None):
        """
        Create a :class:`Gtk.MessageDialog` asking user for confirmation.

        :param message_type: :class:`Gtk.MessageType`
        :param message_label: text displayed to user as :class`str`
        :param on_signal: Gtk signal as :class:`str`
        :param callback: callback to connect to ``signal``
        """
        confirm_dialog = Gtk.MessageDialog(
            message_type=message_type, message_format=message_label)
        confirm_dialog.set_icon_from_file(self.images.logo_favicon_path)
        confirm_dialog.set_title("Confirmation")
        confirm_dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        confirm_dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
        confirm_dialog.set_modal(True)
        if on_signal and callback:
            confirm_dialog.connect(on_signal, callback)

        confirm_dialog.run()
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def build_error_dialog(self, message_label, on_signal=None, callback=None):
        """
        Create a :class:`Gtk.MessageDialog` to notifiy user that an error
        occurred.

        :param message_label: text displayed to user as :class`str`
        :param on_signal: Gtk signal as :class:`str`
        :param callback: callback to connect to ``signal``
        """
        error_dialog = Gtk.MessageDialog(
            message_type=Gtk.MessageType.ERROR, message_format=message_label)
        error_dialog.set_icon_from_file(self.images.logo_favicon_path)
        error_dialog.set_title("Error")
        error_dialog.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
        error_dialog.set_modal(True)
        if on_signal and callback:
            error_dialog.connect(on_signal, callback)
        else:
            error_dialog.connect("response", self.default_error_callback)

        error_dialog.run()
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _display_confirmation_message(self, new_mode, app):
        """
        Display a popup message to confirm the mode switch.
        """
        text = "Switching to " + new_mode + " mode will end current stream."
        messagebox = Gtk.MessageDialog(
            buttons=Gtk.ButtonsType.OK_CANCEL,
            message_type=Gtk.MessageType.WARNING,
            message_format=text
        )
        messagebox.set_title("Confirmation")

        try:
            response = messagebox.run()
            if response == Gtk.ResponseType.OK:
                application = app()
        finally:
            messagebox.destroy()
            return application
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        Gtk.MessageDialog.__init__(self, flags=Gtk.DialogFlags.MODAL,
                                   type=Gtk.MessageType.INFO)
        self.set_title("")
        icon_name = "softwarecenter"
        if icons.has_icon(icon_name):
            icon = Gtk.Image.new_from_icon_name(icon_name,
                                                Gtk.IconSize.DIALOG)
            self.set_image(icon)
            icon.show()
        self.format_secondary_text(
            _(RecommendationsPanelLobby.RECOMMENDATIONS_OPT_IN_TEXT))
        self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        self.add_button(
            _(RecommendationsPanelLobby.TURN_ON_RECOMMENDATIONS_TEXT),
            Gtk.ResponseType.YES)
        self.set_default_response(Gtk.ResponseType.YES)


# test helpers
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        Gtk.MessageDialog.__init__(self, flags=Gtk.DialogFlags.MODAL,
                                   type=Gtk.MessageType.INFO)
        self.set_title("")
        icon_name = "softwarecenter"
        if icons.has_icon(icon_name):
            icon = Gtk.Image.new_from_icon_name(icon_name,
                                                Gtk.IconSize.DIALOG)
            self.set_image(icon)
            icon.show()
        self.format_secondary_text(
            _(RecommendationsPanelLobby.RECOMMENDATIONS_OPT_IN_TEXT))
        self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        self.add_button(
            _(RecommendationsPanelLobby.TURN_ON_RECOMMENDATIONS_TEXT),
            Gtk.ResponseType.YES)
        self.set_default_response(Gtk.ResponseType.YES)


# test helpers
项目:sticky-notes    作者:rubyAce71697    | 项目源码 | 文件源码
def get_text(self,parent, message, default=''):
        """
        Display a dialog with a text entry.
        Returns the text, or None if canceled.
        """
        dialog = Gtk.MessageDialog(self.window, 0, Gtk.MessageType.INFO,
            Gtk.ButtonsType.OK, "Enter the Title")
        dialog.add_button("CANCEL",Gtk.ButtonsType.CANCEL)

        entry = Gtk.Entry()
        entry.set_text(default)
        entry.show()
        box = dialog.get_content_area()
        box.add(entry)

        entry.connect('activate', lambda _: dialog.response(Gtk.ResponseType.OK))
        dialog.set_default_response(Gtk.ResponseType.OK)

        r = dialog.run()
        text = entry.get_text().decode('utf8')
        dialog.destroy()
        if r == Gtk.ResponseType.OK:
            return text
        else:
            return None
项目:sticky-notes    作者:rubyAce71697    | 项目源码 | 文件源码
def close_sticky(self,widget,event):
        ##print "error whille closing windwo"




        self.save_sticky()
        dialog = Gtk.MessageDialog(self.window, 0, Gtk.MessageType.QUESTION,
            Gtk.ButtonsType.YES_NO, "Do you want to DELETE sticky or not")

        response = dialog.run()
        dialog.destroy()
        if response == Gtk.ResponseType.YES:
            os.remove(self.path)
            self.window.close()
            Revealer_Glade.notes_list.remove(self)

            self.application_menu_object.remove_deleted_note_from_menu( self.title if self.title else str(self.uuid))

        self.window.hide()
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def favoritesSave( self ):
        try:
            self.checkMateMenuFolder()
            appListFile = open(self.favoritesPath, "w")

            for favorite in self.favorites:
                if favorite.type == "location":
                    appListFile.write( "location:" + favorite.desktopFile + "\n" )
                else:
                    appListFile.write( favorite.type + "\n" )

            appListFile.close( )
        except Exception, e:
            msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save favorites. Check if you have write access to ~/.config/mate-menu")+"\n(" + e.__str__() + ")" )
            msgDlg.run();
            msgDlg.destroy();
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_make_backup(self, button):

        self.config_save()

        files_cache = os.listdir(self.winetricks_cache)
        files_backup = os.listdir(self.winetricks_cache_backup)

        files_to_copy = list(set(files_cache) - set(files_backup))
        self.n_files_to_copy = len(files_to_copy)

        if self.n_files_to_copy == 0:

            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.ERROR,
                Gtk.ButtonsType.OK,
                _("Backup is up to date"),
                width_request = 360
                )
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            action_area = message_dialog.get_action_area()
            action_area.set_property('spacing', 10)

            self.main_window.hide()
            message_dialog.run()
            message_dialog.destroy()
            self.main_window.show()

        else:

            self.button_make_backup.set_visible(False)
            self.button_restore_backup.set_visible(False)
            self.progressbar.set_visible(True)

            for file_name in files_to_copy:
                self.copy_files(file_name, 'make_backup')
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_button_restore_backup(self, button):

        self.config_save()

        files_cache = os.listdir(self.winetricks_cache)
        files_backup = os.listdir(self.winetricks_cache_backup)

        files_to_copy = list(set(files_backup) - set(files_cache))
        self.n_files_to_copy = len(files_to_copy)

        if self.n_files_to_copy == 0:

            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.ERROR,
                Gtk.ButtonsType.OK,
                _("All files from backup exists in cache"),
                width_request = 360
                )
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            action_area = message_dialog.get_action_area()
            action_area.set_property('spacing', 10)

            self.main_window.hide()
            message_dialog.run()
            message_dialog.destroy()
            self.main_window.show()

        else:

            self.button_make_backup.set_visible(False)
            self.button_restore_backup.set_visible(False)
            self.progressbar.set_visible(True)

            for file_name in files_to_copy:
                self.copy_files(file_name, 'restore_backup')
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def watch_process(self, io, condition, process_name):

        if condition is GLib.IO_HUP:

            self.progressbar.pulse()

            self.n_files_to_copy -= 1

            if self.n_files_to_copy == 0:

                message_dialog = Gtk.MessageDialog(
                    self.main_window,
                    0,
                    Gtk.MessageType.ERROR,
                    Gtk.ButtonsType.OK,
                    _("Done!"),
                    width_request = 360
                    )
                content_area = message_dialog.get_content_area()
                content_area.set_property('margin-left', 10)
                content_area.set_property('margin-right', 10)
                content_area.set_property('margin-top', 10)
                content_area.set_property('margin-bottom', 10)
                action_area = message_dialog.get_action_area()
                action_area.set_property('spacing', 10)

                self.main_window.hide()
                message_dialog.run()
                message_dialog.destroy()

                Gtk.main_quit()

            return False

        while Gtk.events_pending():
            Gtk.main_iteration_do(False)

        return True
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def create_question(self, option_name):

        message_dialog = Gtk.MessageDialog(
            None,
            0,
            Gtk.MessageType.QUESTION,
            Gtk.ButtonsType.YES_NO,
            _("Install") + " " + option_name + "?"
            )
        message_dialog.set_default_size(360, 120)

        content_area = message_dialog.get_content_area()
        content_area.set_property('margin_top', 10)
        content_area.set_property('margin_bottom', 10)
        content_area.set_property('margin_left', 10)
        content_area.set_property('margin_right', 10)

        action_area = message_dialog.get_action_area()
        action_area.set_spacing(10)

        response = message_dialog.run()
        message_dialog.destroy()

        if response == Gtk.ResponseType.YES:
            return 'Yes'
        elif response == Gtk.ResponseType.NO:
            return 'No'
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
def cb_filechooserbutton_mylib_install_dir(self, button):

        new_mylib_install_dir = button.get_filename()

        if new_mylib_install_dir != self.mylib_install_dir:

            message_dialog = Gtk.MessageDialog(
                self.main_window,
                0,
                Gtk.MessageType.QUESTION,
                Gtk.ButtonsType.YES_NO,
                _("Installation directory changed")
                )
            message_dialog.format_secondary_text(_("Do you really want to change installation directory?\n" + \
                "All your installed games will be moved to the new location.\nProceed?"))
            content_area = message_dialog.get_content_area()
            content_area.set_property('margin-left', 10)
            content_area.set_property('margin-right', 10)
            content_area.set_property('margin-top', 10)
            content_area.set_property('margin-bottom', 10)
            action_area = message_dialog.get_action_area()
            action_area.set_property('spacing', 10)

            message_dialog_response = message_dialog.run()

            if message_dialog_response == Gtk.ResponseType.YES:

                os.system('mv -f ' + self.mylib_install_dir + '/* ' + \
                new_mylib_install_dir + ' && rmdir ' + self.mylib_install_dir)

                os.system('rm ' + new_mylib_install_dir + '/*/.configured > /dev/null 2>&1')

                self.mylib_install_dir = new_mylib_install_dir

            elif message_dialog_response == Gtk.ResponseType.NO:

                button.set_filename(self.mylib_install_dir)

            message_dialog.destroy()
项目:aniwall    作者:worron    | 项目源码 | 文件源码
def run(self):
        """Activate dialog"""
        dialog = Gtk.MessageDialog(
            self.parent, Gtk.DialogFlags.MODAL,
            Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, self.message
        )

        response = dialog.run()
        is_ok = response == Gtk.ResponseType.OK
        dialog.destroy()

        return is_ok
项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
def show_successful_login_dialog(self):
        dialog = Gtk.MessageDialog(self.window, 0,
                                   Gtk.MessageType.INFO, Gtk.ButtonsType.OK,
                                   "Login Successful")
        dialog.format_secondary_text(
            "Saving Login Details in configuration file.")
        dialog.run()
        dialog.destroy()
        self.exit_window()
项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
def show_failed_login_dialog(self):
        dialog = Gtk.MessageDialog(self.window, 0, Gtk.MessageType.ERROR,
                                   Gtk.ButtonsType.CANCEL,
                                   "Incorrect Login Details")
        dialog.format_secondary_text("Please check your login details again.")
        dialog.run()
        dialog.destroy()
项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
def show_connection_error_dialog(self):
        dialog = Gtk.MessageDialog(self.window, 0, Gtk.MessageType.ERROR,
                                   Gtk.ButtonsType.CANCEL, "Internet connectivity problem")
        dialog.format_secondary_text(
            "There is some problem connecting to internet. Please make sure internet is working.")
        dialog.run()
        dialog.destroy()