python类MessageDialog()的实例源码

settings.py 文件源码 项目:games_nebula_goglib_scripts 作者: yancharkin 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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-gui.py 文件源码 项目:battery-monitor 作者: maateen 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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()
gui.py 文件源码 项目:python-sense-emu 作者: RPi-Distro 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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()
main_window.py 文件源码 项目:hubangl 作者: soonum 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
main_window.py 文件源码 项目:hubangl 作者: soonum 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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()
main_window.py 文件源码 项目:hubangl 作者: soonum 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
recommendations.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
recommendations.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
stickies.py 文件源码 项目:sticky-notes 作者: rubyAce71697 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
stickies.py 文件源码 项目:sticky-notes 作者: rubyAce71697 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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()
applications.py 文件源码 项目:mate-menu 作者: ubuntu-mate 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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();
winetricks_cache_backup.py 文件源码 项目:games_nebula 作者: yancharkin 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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')
winetricks_cache_backup.py 文件源码 项目:games_nebula 作者: yancharkin 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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')
winetricks_cache_backup.py 文件源码 项目:games_nebula 作者: yancharkin 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
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
dialogs.py 文件源码 项目:games_nebula 作者: yancharkin 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:games_nebula 作者: yancharkin 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
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()
dialog.py 文件源码 项目:aniwall 作者: worron 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
login_window.py 文件源码 项目:susi_linux 作者: fossasia 项目源码 文件源码 阅读 90 收藏 0 点赞 0 评论 0
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()
login_window.py 文件源码 项目:susi_linux 作者: fossasia 项目源码 文件源码 阅读 49 收藏 0 点赞 0 评论 0
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()
login_window.py 文件源码 项目:susi_linux 作者: fossasia 项目源码 文件源码 阅读 76 收藏 0 点赞 0 评论 0
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()


问题


面经


文章

微信
公众号

扫码关注公众号