Python gi.repository.Gtk 模块,STOCK_OK 实例源码

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

项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
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()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
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
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def add_file_task(self, dir_name=None):
        '''??????, ?????????????'''
        file_dialog = Gtk.FileChooserDialog(_('Choose Files..'),
                self.app.window, Gtk.FileChooserAction.OPEN,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        file_dialog.set_modal(True)
        file_dialog.set_select_multiple(True)
        file_dialog.set_default_response(Gtk.ResponseType.OK)
        response = file_dialog.run()
        if response != Gtk.ResponseType.OK:
            file_dialog.destroy()
            return
        source_paths = file_dialog.get_filenames()
        file_dialog.destroy()
        if source_paths:
            self.upload_files(source_paths, dir_name)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def add_folder_task(self, dir_name=None):
        '''??????, ??????????????'''
        folder_dialog = Gtk.FileChooserDialog(_('Choose Folders..'),
                self.app.window, Gtk.FileChooserAction.SELECT_FOLDER,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        folder_dialog.set_modal(True)
        folder_dialog.set_select_multiple(True)
        folder_dialog.set_default_response(Gtk.ResponseType.OK)
        folder_dialog.set_current_folder(Config.HOME_DIR)
        response = folder_dialog.run()
        if response != Gtk.ResponseType.OK:
            folder_dialog.destroy()
            return
        source_paths = folder_dialog.get_filenames()
        folder_dialog.destroy()
        if source_paths:
            self.upload_files(source_paths, dir_name)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def on_download_to_activated(self, menu_item):
        '''????/??????????.'''
        tree_paths = self.iconview.get_selected_items()
        if not tree_paths:
            return

        dialog = Gtk.FileChooserDialog(_('Save to...'), self.app.window,
                Gtk.FileChooserAction.SELECT_FOLDER,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        response = dialog.run()
        if response != Gtk.ResponseType.OK:
            dialog.destroy()
            return
        dirname = dialog.get_filename()
        dialog.destroy()

        pcs_files = [self.get_pcs_file(p) for p in tree_paths]
        self.app.blink_page(self.app.download_page)
        self.app.download_page.add_tasks(pcs_files, dirname)
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
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)
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
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)
项目:SolStudio    作者:alianse777    | 项目源码 | 文件源码
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
项目: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 save_html(self, data):
        html = data
        chooser = Gtk.FileChooserDialog("Export HTML", None, Gtk.FileChooserAction.SAVE,
                                        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
        html_filter = Gtk.FileFilter()
        html_filter.set_name("HTML Files")
        html_filter.add_pattern("*.html")
        html_filter.add_pattern("*.htm")
        chooser.set_do_overwrite_confirmation(True)
        chooser.add_filter(html_filter)
        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            file_name = chooser.get_filename()
            if not file_name.endswith(".html"):
                file_name += ".html"
            file = open(file_name, 'w')
            soup = BeautifulSoup(html, "lxml")

            file.write(soup.prettify())
            file.close()
        elif response == Gtk.ResponseType.CANCEL:
            pass
        chooser.destroy()
        self.window.set_sensitive(True)
项目: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()
项目:susi_linux    作者:fossasia    | 项目源码 | 文件源码
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()
项目:mama    作者:maateen    | 项目源码 | 文件源码
def __init__(self, app):
        Gtk.Window.__init__(self, title="Mama Manager", application=app)
        self.set_default_size(800, 400)
        self.set_resizable(True)
        self.set_border_width(0)
        self.get_focus()
        self.set_position(Gtk.WindowPosition.CENTER)
        path = os.path.dirname(os.path.abspath(__file__)).strip('librairy')
        self.icon_path = path + 'resources/icons/'
        self.set_default_icon_from_file(path + '/resources/icons.png')

        # get two button to switch between view
        setup_icon = Gtk.Image()
        setup_icon.set_from_file(self.icon_path + 'setup.png')
        button_config = Gtk.ToolButton(icon_widget=setup_icon)
        button_config.set_label("Setup")
        button_config.set_is_important(True)
        button_config.set_tooltip_text('Open setup window')
        button_config.show()
        button_config.connect("clicked", self.change_page, 1)

        button_back = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
        button_back.connect("clicked", self.change_page, 0)
        button_cancel = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.change_page, 0)

        # get the main view
        content = AddWindow(button_config)
        label_main = Gtk.Label("main")
        config = SetupWindow(button_back, button_cancel)
        label_config = Gtk.Label("config")

        # create a Gtk.Notebook to store both page
        self.notebook = Gtk.Notebook.new()
        self.notebook.set_show_tabs(False)
        self.notebook.append_page(content.get_grid(), label_main)
        self.notebook.append_page(config.getGrid(), label_config)

        # show
        self.add(self.notebook)
        self.show_all()
项目:mama    作者:maateen    | 项目源码 | 文件源码
def __init__(self, store, iter=None):
        self.grid = Gtk.Grid()
        self.grid.set_border_width(5)
        self.grid.set_row_spacing(5)
        self.grid.set_vexpand(True)
        self.grid.set_hexpand(True)
        self.grid.set_column_spacing(2)
        self.grid.set_column_homogeneous(False)
        self.grid.set_row_homogeneous(False)

        label1 = Gtk.Label('key sentence')
        label1.set_justify(Gtk.Justification.LEFT)
        label1.set_halign(Gtk.Align.START)
        label1.set_hexpand(True)
        label2 = Gtk.Label('your command')
        label2.set_justify(Gtk.Justification.LEFT)
        label2.set_halign(Gtk.Align.START)
        ll = Gtk.Label()
        ll.set_vexpand(True)
        self.entry1 = Gtk.Entry()
        if iter is not None:
            self.entry1.set_text(store[iter][0])

        self.combo = self.__get_combobox(store, iter)
        button = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
        button.connect("clicked", self.button_clicked, store, iter)
        button_cancel = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.do_destroy)

        self.grid.attach(label1, 0, 0, 11, 1)
        self.grid.attach(self.entry1, 11, 0, 4, 1)
        self.grid.attach(label2, 0, 1, 11, 1)
        self.grid.attach(self.combo, 11, 1, 4, 1)
        self.grid.attach(ll, 0, 2, 15, 1)
        self.grid.attach(button_cancel, 13, 3, 1, 1)
        self.grid.attach(button, 14, 3, 1, 1)
        self.grid.show_all()
项目:mama    作者:maateen    | 项目源码 | 文件源码
def __init__(self, store, iter=None):
        self.grid = Gtk.Grid()
        self.grid.set_border_width(5)
        self.grid.set_row_spacing(5)
        self.grid.set_vexpand(True)
        self.grid.set_hexpand(True)
        self.grid.set_column_spacing(2)
        self.grid.set_column_homogeneous(False)
        label1 = Gtk.Label('key sentence')
        label1.set_hexpand(True)
        label1.set_justify(Gtk.Justification.LEFT)
        label1.set_halign(Gtk.Align.START)
        label2 = Gtk.Label('your command')
        label2.set_justify(Gtk.Justification.LEFT)
        label2.set_halign(Gtk.Align.START)
        ll = Gtk.Label()
        ll.set_vexpand(True)
        self.entry1 = Gtk.Entry()
        self.entry2 = Gtk.Entry()

        if iter is not None:
            self.entry1.set_text(store[iter][0])
            self.entry2.set_text(store[iter][1])

        button = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
        button.connect("clicked", self.button_clicked, store, iter)
        button_cancel = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.do_destroy)

        self.grid.attach(label1, 0, 0, 11, 1)
        self.grid.attach(self.entry1, 11, 0, 4, 1)
        self.grid.attach(label2, 0, 1, 11, 1)
        self.grid.attach(self.entry2, 11, 1, 4, 1)
        self.grid.attach(ll, 0, 2, 15, 1)
        self.grid.attach(button_cancel, 13, 3, 1, 1)
        self.grid.attach(button, 14, 3, 1, 1)
        self.grid.show_all()
项目:stickies    作者:aboudzakaria    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
def on_button_clicked(self,widget):
        dialog =Gtk.FileChooserDialog("Select folder",None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        filter = Gtk.FileFilter()
        filter.set_name("Folder")
        filter.add_pattern("*")  # whats the pattern for a folder
        dialog.add_filter(filter)
        if dialog.run() == Gtk.ResponseType.ACCEPT:
            dialog.hide()
            print(dialog.get_filename())
            self.button.set_label(dialog.get_filename())
        dialog.destroy()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
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()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
def on_button_clicked(self,widget):
        dialog =Gtk.FileChooserDialog("Select folder",None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        filter = Gtk.FileFilter()
        filter.set_name("Folder")
        filter.add_pattern("*")  # whats the pattern for a folder
        dialog.add_filter(filter)
        if dialog.run() == Gtk.ResponseType.ACCEPT:
            dialog.hide()
            print(dialog.get_filename())
            self.button.set_label(dialog.get_filename())
        dialog.destroy()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
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
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
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()
项目:pyspc    作者:carlosqsilva    | 项目源码 | 文件源码
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()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def on_open(self, widget):
        """
        Open a FileChooserDialog and select a file.
        Load into this editor window if it is empty and unused,
        if not load into a new one.

        This method will catch exceptions raised while loading the file
        and display a dialog. Then it will destroy any newly created
        dialog.
        """
        dialog = Gtk.FileChooserDialog(None, self,
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        dialog.set_current_folder(self.savedir)
        ret = dialog.run()
        if ret == Gtk.ResponseType.OK:
            try:
                new_file = decode_filename(dialog.get_filename())
                assert new_file not in self.instance_dict
                win = self.__class__(new_file)
                win.show_all()
                win.set_title(new_file)

                if (not self.m_filename) and (not self.m_changed):
                    del self.instance_dict[self.get_idict_key()]
                    self.destroy()
            except Exception, e:
                # Since we catch all sorts of exceptions here, we don't have
                # to do handle string to int conversion in
                # PractiseSheet.parse_file. Just let int() raise ValueException
                # if the string in not an integer.

                if 'msg1' in dir(e):
                    solfege.win.display_error_message2(getattr(e, 'msg1', ''),
                        getattr(e, 'msg2', ''))

                else:
                    display_exception_message(e)
        dialog.destroy()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def get_save_as_dialog(self):
        dialog = Gtk.FileChooserDialog(_("Save As..."), self,
            Gtk.FileChooserAction.SAVE,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        dialog.set_default_response(Gtk.ResponseType.OK)
        return dialog
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def select_empty_directory(self, title):
        msg = _("Select an empty directory, since we want to fill it with files.")
        dialog = Gtk.FileChooserDialog(title,
            self, Gtk.FileChooserAction.SELECT_FOLDER,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        label = Gtk.Label(label=msg)
        label.show()
        dialog.vbox.pack_start(label, False, False, padding=0)
        while 1:
            res = dialog.run()
            if res in (Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT):
                dialog.destroy()
                return

            elif res == Gtk.ResponseType.OK:

                if os.listdir(decode_filename(dialog.get_filename())):
                    msg_dlg = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL,
                        Gtk.MessageType.INFO, Gtk.ButtonsType.OK, msg)
                    msg_dlg.run()
                    msg_dlg.destroy()

                else:
                    break
        ret = decode_filename(dialog.get_filename())
        dialog.destroy()
        return ret
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, app):
        super().__init__(_('Password:'), app.window, Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.set_default_response(Gtk.ResponseType.OK)
        self.set_default_size(320, 100)
        self.set_border_width(10)
        box = self.get_content_area()

        self.entry = Gtk.Entry()
        self.entry.props.placeholder_text = _('Password ...')
        box.pack_start(self.entry, False, False, 0)

        box.show_all()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, path):
        super().__init__(_('New Folder'), app.window, Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
        self.set_default_response(Gtk.ResponseType.OK)
        self.connect('show', self.on_show)
        self.set_default_size(550, 200)

        self.app = app
        self.path = path

        self.set_border_width(10)
        box = self.get_content_area()

        folder_name = _('New Folder')
        abspath = os.path.join(path, folder_name)
        self.entry = Gtk.Entry()
        self.entry.set_text(abspath)
        self.entry.connect('changed', self.on_entry_changed)
        self.entry.connect('activate', self.on_entry_activated)
        box.pack_start(self.entry, True, True, 10)

        self.infobar = Gtk.InfoBar()
        self.infobar.timestamp = 0
        self.infobar.set_message_type(Gtk.MessageType.ERROR)
        box.pack_start(self.infobar, False, False, 0)
        self.info_label= Gtk.Label()
        self.infobar.get_content_area().pack_start(self.info_label, False,
                                                   False, 0)

        box.show_all()
        self.infobar.hide()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, info):
        super().__init__(_('Verification..'), app.window,
                         Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                          Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.set_default_response(Gtk.ResponseType.OK)
        self.set_default_size(320, 200)
        self.set_border_width(10)
        self.app = app

        box = self.get_content_area()
        box.set_spacing(10)

        gutil.async_call(net.urlopen, info['img'],
                         {'Cookie': app.cookie.header_output()},
                         callback=self.update_img)
        self.img = Gtk.Image()
        box.pack_start(self.img, False, False, 0)

        self.entry = Gtk.Entry()
        self.entry.connect('activate',
                lambda *args: self.response(Gtk.ResponseType.OK))
        box.pack_start(self.entry, False, False, 0)

        box.show_all()
项目:backlight-indicator    作者:atareao    | 项目源码 | 文件源码
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()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def __init__(self, main, title='Search results'):
        super(SearchDialog,self).__init__(title, main.window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_OK,Gtk.ResponseType.ACCEPT))

        # the cancel button
        self.butt_cancel = self.action_area.get_children()[0]
        self.butt_cancel.connect("clicked", lambda x: self.destroy())

        # Positions
        self.resize(400, 400)
        self.set_position(Gtk.WindowPosition.CENTER)
        ui.gtk3.common.set_bokken_icon(self)

        # Log TextView
        #################################################################
        self.output_text = Gtk.TextView(buffer=None)
        self.output_text.set_wrap_mode(Gtk.WrapMode.NONE)
        self.output_text.set_editable(False)
        self.output_buffer = self.output_text.get_buffer()

        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
        self.scrolled_window.is_visible = True

        # Add Textview to Scrolled Window
        self.scrolled_window.add_with_viewport(self.output_text)

        #self.vbox.pack_start(self.output_text, True, True, 0)
        self.vbox.pack_start(self.scrolled_window, True, True, 0)
        self.show_all()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def __init__(self, title='Add comment'):
        super(CommentsDialog,self).__init__(title, None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))

        # the cancel button
        self.butt_cancel = self.action_area.get_children()[1]
        self.butt_cancel.connect("clicked", lambda x: self.destroy())

        # Positions
        self.resize(400, 200)
        self.set_position(Gtk.WindowPosition.CENTER)
        ui.gtk3.common.set_bokken_icon(self)

        # Log TextView
        #################################################################
        self.input_text = Gtk.TextView(buffer=None)
        self.input_text.set_wrap_mode(Gtk.WrapMode.NONE)
        self.input_text.set_left_margin(10)
        self.input_buffer = self.input_text.get_buffer()

        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolled_window.is_visible = True

        # Add Textview to Scrolled Window
        self.scrolled_window.add_with_viewport(self.input_text)

        #self.vbox.pack_start(self.input_text, True, True, 0)
        self.vbox.pack_start(self.scrolled_window, True, True, 0)
        self.show_all()
项目:SolStudio    作者:alianse777    | 项目源码 | 文件源码
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()
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
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()
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
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
项目:national-geographic-wallpaper    作者:atareao    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Dialog.__init__(
            self,
            _('National Geographic Wallpaper'),
            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(350, 80)
        self.set_icon_from_file(comun.ICON)
        self.connect('destroy', self.close_application)

        self.config = Config()
        self.croni = Croni()
        self.autostart = Autostart()

        grid = Gtk.Grid()
        grid.set_row_spacing(5)
        grid.set_column_spacing(5)
        grid.set_border_width(5)
        self.get_content_area().add(grid)

        label10 = Gtk.Label(_('Change wallpaper automatically?') + ':')
        label10.set_alignment(0, 0.5)
        grid.add(label10)

        self.switch = Gtk.Switch()
        self.switch.set_active(self.croni.is_enabled())
        hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 5)
        hbox.pack_start(self.switch, False, False, 0)
        grid.attach(hbox, 1, 0, 1, 1)

        label20 = Gtk.Label(_('Select backgrounds source') + ':')
        label20.set_alignment(0, 0.5)
        grid.attach(label20, 0, 1, 1, 1)

        source_store = Gtk.ListStore(str, str)
        source_store.append([_('National Geographic'), 'national-geographic'])
        source_store.append([_('Bing'), 'bing'])
        source_store.append([_('GoPro'), 'gopro'])
        source_store.append([_('Powder'), 'powder'])
        source_store.append([_('Fstoppers'), 'fstoppers'])
        source_store.append([_('Desktoppr'), 'desktoppr'])
        source_store.append([_('Nasa'), 'nasa'])
        self.combobox_source = Gtk.ComboBox.new()
        self.combobox_source.set_model(source_store)
        cell1 = Gtk.CellRendererText()
        self.combobox_source.pack_start(cell1, True)
        self.combobox_source.add_attribute(cell1, 'text', 0)
        grid.attach(self.combobox_source, 1, 1, 1, 1)

        button = Gtk.Button(_('Change now'))
        button.connect('clicked', self.button_pressed)
        hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 5)
        hbox.pack_start(button, True, False, 0)
        grid.attach(hbox, 0, 2, 2, 1)

        self.load_preferences()

        self.show_all()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def add_engine(self, widget, data=None):
        dialog = Gtk.FileChooserDialog(
            _("Add UCI Engine.."),
            gv.gui.get_window(),
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OPEN, Gtk.ResponseType.OK)
        )
        dialog.set_default_response(Gtk.ResponseType.OK)
        dialog.set_current_folder(os.path.expanduser("~"))

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            fname = dialog.get_filename()
            # print "attempting to add new engine"
            path = dialog.get_filename()
            # use a new uci object so not to mess with main game engine
            u = uci.Uci("0")
            u.set_engine("addengine", path)
            errmsg, name = u.test_engine(path)
            if errmsg != "":
                err_dialog = Gtk.Dialog(_("Error Adding Engine"), None, 0,
                                        (Gtk.STOCK_OK, Gtk.ResponseType.OK))
                err_dialog.set_default_size(380, -1)
                lbl = Gtk.Label(label=errmsg)
                lbl.show()
                al = Gtk.Alignment.new(xalign=0.0, yalign=0.5,
                                       xscale=0.0, yscale=0.0)
                al.set_padding(20, 20, 20, 20)
                al.add(lbl)
                al.show()
                err_dialog.vbox.pack_start(al, True, False, 0)
                response = err_dialog.run()
                err_dialog.destroy()
            else:
                self.liststore.append([name, path])
                self.add_engine_to_list([name, path, {}])

        dialog.destroy()

    # Called from this module by clicking 'configure' button
    # or from gui.py by selecting configure engine from menu
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def __init__(self, parent, sbrick_configuration):
        Gtk.Dialog.__init__(self, "Configure SBrick", parent, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.sbrickConfiguration = sbrick_configuration
        self.set_default_size(150, 100)

        self.channelTypeStore = Gtk.ListStore(str, str)
        self.channelTypeStore.append(["motor", "Motor"])
        self.channelTypeStore.append(["servo", "Servo"])
        self.content = self.get_content_area()

        hbox = Gtk.FlowBox()
        hbox.set_max_children_per_line(2)
        hbox.set_min_children_per_line(2)
        hbox.set_selection_mode(Gtk.SelectionMode.NONE)

        hbox.add(Gtk.Label("Name:"))
        self.edit_brick_name = Gtk.Entry()
        self.edit_brick_name.set_max_length(20)
        hbox.add(self.edit_brick_name)

        hbox.add(Gtk.Label("Address:"))
        self.edit_brick_address = Gtk.Entry()
        self.edit_brick_address.set_max_length(17)
        hbox.add(self.edit_brick_address)

        self.content.pack_start(hbox, False, True, 0)

        self.channel1_id_edit, self.channel1_name_edit, self.channel1_combo_type = self.create_channel_box(1)
        self.channel2_id_edit, self.channel2_name_edit, self.channel2_combo_type = self.create_channel_box(2)
        self.channel3_id_edit, self.channel3_name_edit, self.channel3_combo_type = self.create_channel_box(3)
        self.channel4_id_edit, self.channel4_name_edit, self.channel4_combo_type = self.create_channel_box(4)

        if "name" in self.sbrickConfiguration:
            self.edit_brick_name.set_text(self.sbrickConfiguration["name"])
        if "addr" in self.sbrickConfiguration:
            self.edit_brick_address.set_text(self.sbrickConfiguration["addr"])

        self.set_from_config(0, self.channel1_id_edit, self.channel1_name_edit, self.channel1_combo_type)
        self.set_from_config(1, self.channel2_id_edit, self.channel2_name_edit, self.channel2_combo_type)
        self.set_from_config(2, self.channel3_id_edit, self.channel3_name_edit, self.channel3_combo_type)
        self.set_from_config(3, self.channel4_id_edit, self.channel4_name_edit, self.channel4_combo_type)

        self.show_all()
        self.connect('response', self.on_response)

    # noinspection PyUnusedLocal
项目:btcwidget    作者:rafalh    | 项目源码 | 文件源码
def __init__(self, parent):
        Gtk.Dialog.__init__(self, "Alarms", parent, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self._store = Gtk.ListStore(str, str, str, object)
        for i, alarm in enumerate(config['alarms']):
            row = self._build_row(alarm)
            self._store.append(row)

        self._tree = Gtk.TreeView(self._store)
        self._selection = self._tree.get_selection()
        self._selection.connect("changed", self._on_tree_selection_changed)
        self._tree.set_size_request(300, 150)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Exchange", renderer, text=self._EXCHANGE_COL)
        self._tree.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Market", renderer, text=self._MARKET_COL)
        self._tree.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Alarm Trigger", renderer, text=self._TRIGGER_COL)
        self._tree.append_column(column)

        vbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL)

        new_button = Gtk.Button.new_with_label("New Alarm")
        new_button.connect("clicked", self._on_new_button_clicked)
        vbox.pack_start(new_button, False, False, 0)

        self._remove_button = Gtk.Button.new_with_label("Remove Alarm")
        self._remove_button.connect("clicked", self._on_remove_button_clicked)
        vbox.pack_start(self._remove_button, False, False, 0)

        self._market_combo, self._market_store = self._create_market_combo()
        self._market_combo.connect("changed", self._on_market_changed)
        vbox.pack_start(self._market_combo, False, False, 0)

        self._above_radio = Gtk.RadioButton.new_with_label_from_widget(None, "Above")
        self._above_radio.connect("clicked", self._on_type_radio_clicked)
        self._below_radio = Gtk.RadioButton.new_with_label_from_widget(self._above_radio, "Below")
        self._below_radio.connect("clicked", self._on_type_radio_clicked)
        type_hbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.HORIZONTAL)
        type_hbox.pack_start(self._above_radio, True, True, 0)
        type_hbox.pack_start(self._below_radio, True, True, 0)
        vbox.pack_start(type_hbox, False, False, 0)

        self._price_entry = Gtk.Entry()
        self._price_entry.connect("changed", self._on_price_changed)
        _add_label_and_widget(vbox, "Price:", self._price_entry)

        hbox = Gtk.Box(spacing=6)
        hbox.pack_start(self._tree, True, True, 0)
        hbox.pack_start(vbox, False, False, 0)

        self.get_content_area().add(hbox)
        self._set_inputs_sensitive(False)
        self.show_all()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, title, source_url, save_path):
        '''???BT???????.

        source_url - ???BT????, ?????????.
                      ???????, ???magent:???????.
        '''
        super().__init__(title, app.window, Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.app = app
        self.source_url = source_url
        self.save_path = save_path

        self.set_default_response(Gtk.ResponseType.OK)
        self.set_default_size(520, 480)
        self.set_border_width(10)
        box = self.get_content_area()

        select_all_button = Gtk.ToggleButton.new_with_label(_('Select All'))
        select_all_button.props.halign = Gtk.Align.START
        select_all_button.props.margin_bottom = 5
        select_all_button.connect('toggled', self.on_select_all_toggled)
        box.pack_start(select_all_button, False, False, 0)

        scrolled_win = Gtk.ScrolledWindow()
        box.pack_start(scrolled_win, True, True, 0)

        # check, name, size, humansize
        self.liststore = Gtk.ListStore(bool, str, GObject.TYPE_INT64, str)
        self.treeview = Gtk.TreeView(model=self.liststore)
        self.treeview.set_tooltip_column(NAME_COL)
        scrolled_win.add(self.treeview)
        check_cell = Gtk.CellRendererToggle()
        check_cell.connect('toggled', self.on_check_cell_toggled)
        check_col = Gtk.TreeViewColumn('', check_cell, active=CHECK_COL)
        self.treeview.append_column(check_col)
        name_cell = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END,
                                         ellipsize_set=True)
        name_col = Gtk.TreeViewColumn(_('Name'), name_cell, text=NAME_COL)
        name_col.set_expand(True)
        self.treeview.append_column(name_col)
        size_cell = Gtk.CellRendererText()
        size_col = Gtk.TreeViewColumn(_('Size'), size_cell, text=HUMANSIZE_COL)
        self.treeview.append_column(size_col)

        box.show_all()
        self.request_data()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, username, cookie, tokens, codeString, vcodetype):
        super().__init__(_('Verification..'), parent, Gtk.DialogFlags.MODAL)

        self.set_default_size(280, 130)
        self.set_border_width(10)
        self.username = username
        self.cookie = cookie
        self.tokens = tokens
        self.codeString = codeString
        self.vcodetype = vcodetype

        box = self.get_content_area()
        box.set_spacing(5)

        self.vcode_img = Gtk.Image()
        box.pack_start(self.vcode_img, True, True, 0)

        button_box = Gtk.Box(spacing=5)
        box.pack_start(button_box, True, True, 0)

        self.vcode_entry = Gtk.Entry()
        self.vcode_entry.connect('activate', self.check_entry)
        button_box.pack_start(self.vcode_entry, True, True, 0)

        if Config.GTK_GE_312:
            vcode_refresh = Widgets.IconButton('view-refresh-symbolic')
        else:
            vcode_refresh = Gtk.Button.new_from_stock(Gtk.STOCK_REFRESH)
        vcode_refresh.props.valign = Gtk.Align.CENTER
        vcode_refresh.connect('clicked', self.on_vcode_refresh_clicked)
        button_box.pack_start(vcode_refresh, False, False, 0)

        # show loading process
        self.loading_spin = Gtk.Spinner()
        self.loading_spin.props.valign = Gtk.Align.CENTER
        button_box.pack_start(self.loading_spin, False, False, 0)

        vcode_confirm = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
        vcode_confirm.connect('clicked', self.on_vcode_confirm_clicked)
        vcode_confirm.props.valign = Gtk.Align.END
        box.pack_start(vcode_confirm, False, False, 10)

        box.show_all()
        self.loading_spin.hide()

        gutil.async_call(auth.get_signin_vcode, cookie, codeString,
                         callback=self.update_img)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, title=_('Save to..')):
        self.parent = parent
        self.app = app
        super().__init__(title, app.window, Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
        self.set_default_size(440, 480)
        self.set_border_width(10)
        self.set_default_response(Gtk.ResponseType.OK)

        box = self.get_content_area()

        control_box = Gtk.Box()
        box.pack_start(control_box, False, False, 0)

        mkdir_button = Gtk.Button.new_with_label(_('Create Folder'))
        control_box.pack_end(mkdir_button, False, False, 0)
        mkdir_button.connect('clicked', self.on_mkdir_clicked)

        reload_button = Gtk.Button.new_with_label(_('Reload'))
        control_box.pack_end(reload_button, False, False, 5)
        reload_button.connect('clicked', self.on_reload_clicked)

        scrolled_win = Gtk.ScrolledWindow()
        box.pack_start(scrolled_win, True, True, 5)

        # disname, path, empty, loaded
        self.treestore = Gtk.TreeStore(str, str, bool, bool)
        self.treeview = Gtk.TreeView(model=self.treestore)
        self.selection = self.treeview.get_selection()
        scrolled_win.add(self.treeview)
        icon_cell = Gtk.CellRendererPixbuf(icon_name='folder')
        name_cell = Gtk.CellRendererText()
        name_col = Gtk.TreeViewColumn(_('Folder'))
        name_col.pack_start(icon_cell, False)
        name_col.pack_start(name_cell, True)
        if Config.GTK_LE_36:
            name_col.add_attribute(name_cell, 'text', NAME_COL)
        else:
            name_col.set_attributes(name_cell, text=NAME_COL)
        self.treeview.append_column(name_col)
        self.treeview.connect('row-expanded', self.on_row_expanded)

        box.show_all()

        self.reset()
项目:any_ping_indicator    作者:leggedrobotics    | 项目源码 | 文件源码
def __init__(self, parent, preference):
        gtk.Dialog.__init__(self, "Edit ping...", parent, 0,
                            (gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL,
                             gtk.STOCK_OK, gtk.ResponseType.OK))

        self.set_position(gtk.WindowPosition.CENTER)

        # set ui to dialog
        builder = gtk.Builder()
        file_path = os.path.dirname(os.path.abspath(__file__))
        builder.add_from_file(resource.ui_path("ping_edit_dialog"))
        self.box1 = builder.get_object('box1')
        self.box = self.get_content_area()
        self.box.add(self.box1)

        # get ui elements
        self.entry_name = builder.get_object("entry_name")
        self.entry_address = builder.get_object("entry_address")
        self.spinbutton_update_rate = \
            builder.get_object("spinbutton_update_rate")
        self.spinbutton_number_of_pings = \
            builder.get_object("spinbutton_number_of_pings")
        self.radiobutton_yes = builder.get_object("radiobutton_yes")
        self.radiobutton_no = builder.get_object("radiobutton_no")
        self.radiobutton_show_text_yes = \
            builder.get_object("radiobutton_show_text_yes")
        self.radiobutton_show_text_no = \
            builder.get_object("radiobutton_show_text_no")
        self.radiobutton_activate_yes = \
            builder.get_object("radiobutton_activate_yes")
        self.radiobutton_activate_no = \
            builder.get_object("radiobutton_activate_no")

        # set data
        self.entry_name.set_text(preference[0])
        self.entry_address.set_text(preference[1])
        self.spinbutton_update_rate.set_value(preference[2])
        self.spinbutton_number_of_pings.set_value(preference[3])
        if preference[4]:
            self.radiobutton_yes.set_active(True)
        else:
            self.radiobutton_no.set_active(True)
        if preference[5]:
            self.radiobutton_show_text_yes.set_active(True)
        else:
            self.radiobutton_show_text_no.set_active(True)
        if preference[6]:
            self.radiobutton_activate_yes.set_active(True)
        else:
            self.radiobutton_activate_no.set_active(True)

        # show dialog
        self.show_all()
项目:Remarkable    作者:jamiemcg    | 项目源码 | 文件源码
def save_pdf(self, html):
        chooser = Gtk.FileChooserDialog("Export PDF", None, Gtk.FileChooserAction.SAVE,
                                        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
        pdf_filter = Gtk.FileFilter()
        pdf_filter.add_pattern("*.pdf")
        pdf_filter.set_name("PDF Files")
        chooser.add_filter(pdf_filter)
        chooser.set_do_overwrite_confirmation(True)
        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            file_name = chooser.get_filename()
            if not file_name.endswith(".pdf"):
                file_name += ".pdf"
            try:
                pdfkit.from_string(html, file_name, options= {'quiet': '', 'page-size': 'Letter',
                    'margin-top': '0.75in',
                    'margin-right': '0.75in',
                    'margin-bottom': '0.75in',
                    'margin-left': '0.75in',
                    'encoding': "UTF-8",
                    'javascript-delay' : '550',
                    'no-outline': None})
            except:
                try:
                    #Failed so try with no options
                    pdfkit.from_string(html, file_name)
                except:
                    #Pdf Export failed, show warning message
                    if not self.pdf_error_warning:
                        self.pdf_error_warning = True
                        print("\nRemarkable Error:\tPDF Export Failed!!")

                    pdf_fail_dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR,
                            Gtk.ButtonsType.CANCEL, "PDF EXPORT FAILED")
                    pdf_fail_dialog.format_secondary_text(
                            "File export to PDF was unsuccessful.")
                    pdf_fail_dialog.run()
                    pdf_fail_dialog.destroy()
        elif response == Gtk.ResponseType.CANCEL:
            pass

        chooser.destroy()
        self.window.set_sensitive(True)
项目:Vulnerabilities-spider    作者:muhammad-bouabid    | 项目源码 | 文件源码
def __init__(self, parent):
      Gtk.Dialog.__init__(self, "History Scanne Tables", parent,
          Gtk.DialogFlags.MODAL, buttons=(
          Gtk.STOCK_OK, Gtk.ResponseType.OK,
          Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

      self.set_default_size(500, 400)

      box = self.get_content_area()

      self.HoriBox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
      box.add(self.HoriBox)

      self.scrolledwindow = Gtk.ScrolledWindow()
      self.scrolledwindow.set_hexpand(True)
      self.scrolledwindow.set_vexpand(True)

      self.HoriBox.pack_start(self.scrolledwindow, True, True, 0)

      self.people_lst = []

      #convert data to listStore Now (lists that TreeView can Display)
      peoples_list_store = Gtk.ListStore(str, str, str, str)
      for item in self.people_lst:
        peoples_list_store.append(list(item))
      #Make treeView for those item will display
      people_tree_view = Gtk.TreeView(peoples_list_store)

      for i, col_title in enumerate(["Website", "Point", "Faille","Payload"]):
        #Render means how to draw the data
        renderer = Gtk.CellRendererText()
        #create columns
        column = Gtk.TreeViewColumn(col_title, renderer, text=i)
        column.set_sort_column_id(i) # Make the Columns Sortable just bech ywali bsort (option)
        people_tree_view.append_column(column) # Add column to treeView

      #Handel data
      selected_row = people_tree_view.get_selection()
      selected_row.connect("changed", self.the_item_selected)

      # Add TreeView to main layout now
      self.scrolledwindow.add(people_tree_view)
      self.show_all()

  #user selectred row method