python类Dialog()的实例源码

gui_text_editor.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        Gtk.Dialog.__init__(self, "Search", parent,
            Gtk.DialogFlags.MODAL, buttons=(
            Gtk.STOCK_FIND, Gtk.ResponseType.OK,
            Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

        box = self.get_content_area()

        label = Gtk.Label("Insert text you want to search for:")
        box.add(label)

        self.entry = Gtk.Entry()
        box.add(self.entry)

        self.show_all()
appwin.py 文件源码 项目:PyFlowChart 作者: steelcowboy 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def create_import_from_server_dialog(self, chart_list):
        import_chart = None 

        import_dialog = Gtk.Dialog("Import from server", self, 0)
        box = import_dialog.get_content_area()

        content_box = Gtk.Box()
        box.add(content_box)

        chart_selector = Gtk.ComboBoxText()
        for chart in sorted(chart_list):
            chart_selector.append_text(chart)

        content_box.pack_start(Gtk.Label("Choose a chart:"), True, True, 0)
        content_box.pack_start(chart_selector, True, True, 0)
        import_dialog.add_button('Import', Gtk.ResponseType.OK)

        content_box.show_all()

        response = import_dialog.run()

        if response == Gtk.ResponseType.OK:
            import_chart = chart_selector.get_active_text()

        import_dialog.destroy()

        if import_chart:
            return import_chart
impressWriter.py 文件源码 项目:impress-writer 作者: CSEC-NITH 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        Gtk.Dialog.__init__(self, "Search", parent,
            Gtk.DialogFlags.MODAL, buttons=(
            Gtk.STOCK_FIND, Gtk.ResponseType.OK,
            Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

        box = self.get_content_area()

        label = Gtk.Label("Insert text you want to search for:")
        box.add(label)

        self.entry = Gtk.Entry()
        box.add(self.entry)

        self.show_all()
preferences.py 文件源码 项目:draobpilc 作者: awamper 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _on_button_clicked(self, button):
        dialog = Gtk.Dialog()
        dialog.set_transient_for(self)

        gpaste_settings = GPaste.SettingsUiWidget()

        for child in gpaste_settings.get_children():
            if isinstance(child, Gtk.StackSwitcher):
                toplevel = dialog.get_toplevel()
                if not toplevel: continue

                gpaste_settings.remove(child)

                header_bar = Gtk.HeaderBar()
                header_bar.set_show_close_button(True)
                header_bar.set_title(None)
                header_bar.set_subtitle(None)
                header_bar.set_custom_title(child)

                toplevel.set_titlebar(header_bar)

            if isinstance(child, Gtk.Stack):
                child.set_transition_type(
                    Gtk.StackTransitionType.SLIDE_LEFT_RIGHT
                )
                child.set_transition_duration(self._transition_duration)

        content_area = dialog.get_content_area()
        content_area.add(gpaste_settings)

        dialog.show_all()
        dialog.run()
        dialog.destroy()
logindialog.py 文件源码 项目:google-tasks-indicator 作者: atareao 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self,url):
        self.code = None
        Gtk.Dialog.__init__(self)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_title(comun.APP)
        self.set_icon_from_file(comun.ICON)
        #
        vbox = Gtk.VBox(spacing = 5)
        self.get_content_area().add(vbox)
        hbox1 = Gtk.HBox()
        vbox.pack_start(hbox1,True,True,0)
        #
        self.scrolledwindow1 = Gtk.ScrolledWindow()
        self.scrolledwindow1.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN)
        hbox1.pack_start(self.scrolledwindow1,True,True,0)
        #
        self.viewer = WebKit.WebView()
        self.scrolledwindow1.add(self.viewer)
        self.scrolledwindow1.set_size_request(600,420)
        self.viewer.connect('navigation-policy-decision-requested', self.on_navigation_requested)
        self.viewer.open(url)
        #       
        self.show_all()

    ####################################################################
    #########################BROWSER####################################
    ####################################################################
tasklist_dialog.py 文件源码 项目:google-tasks-indicator 作者: atareao 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()
main.py 文件源码 项目:pytimetrack 作者: fhackerz 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, transient_for):
        kwargs = {}
        if self.use_header_bar:
            kwargs['use_header_bar'] = True
        Gtk.Dialog.__init__(self, transient_for=transient_for,
                            title=_("Preferences"), **kwargs)
        self.set_default_size(500, -1)

        if not self.use_header_bar:
            self.add_button(_("Close"), Gtk.ResponseType.CLOSE)
            self.set_default_response(Gtk.ResponseType.CLOSE)
        else:
            # can't do it now, it doesn't have window decorations yet!
            GLib.idle_add(self.make_enter_close_the_dialog)

        builder = Gtk.Builder.new_from_file(PREFERENCES_UI_FILE)
        vbox = builder.get_object('dialog-vbox')
        self.get_content_area().add(vbox)

        virtual_midnight_entry = builder.get_object('virtual_midnight_entry')
        self.virtual_midnight_entry = virtual_midnight_entry

        hours_entry = builder.get_object('hours_entry')
        office_hours_entry = builder.get_object('office_hours_entry')
        name_entry = builder.get_object('name_entry')
        sender_entry = builder.get_object('sender_entry')
        recipient_entry = builder.get_object('recipient_entry')

        self.gsettings = Gio.Settings.new("org.gtimelog")
        self.gsettings.bind('hours', hours_entry, 'value', Gio.SettingsBindFlags.DEFAULT)
        self.gsettings.bind('office-hours', office_hours_entry, 'value', Gio.SettingsBindFlags.DEFAULT)
        self.gsettings.bind('name', name_entry, 'text', Gio.SettingsBindFlags.DEFAULT)
        self.gsettings.bind('sender', sender_entry, 'text', Gio.SettingsBindFlags.DEFAULT)
        self.gsettings.bind('list-email', recipient_entry, 'text', Gio.SettingsBindFlags.DEFAULT)
        self.gsettings.connect('changed::virtual-midnight', self.virtual_midnight_changed)
        self.virtual_midnight_changed()
        self.virtual_midnight_entry.connect('focus-out-event', self.virtual_midnight_set)
application.py 文件源码 项目:Icon-Requests 作者: bil-elmoussaoui 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __about_response(self, dialog, response_id):
        """
            Destroy about dialog when closed
            @param dialog as Gtk.Dialog
            @param response id as int
        """
        dialog.destroy()
main.py 文件源码 项目:MTTT 作者: roxana-lafuente 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
alert.py 文件源码 项目:Postgres-GUI 作者: atlast 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, message, window):
        d = Gtk.Dialog(
            title="Alert",
            parent=window,
            flags=1,
            buttons=("Ok", Gtk.ResponseType.CANCEL)
        )
        label = Gtk.Label(message)
        label.set_padding(40, 30)
        d.vbox.add(label)
        d.show_all()
        d.run()
        d.destroy()
dialog_tos.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        Gtk.Dialog.__init__(self)
        self.set_default_size(420, 400)
        self.set_transient_for(parent)
        self.set_title(_("Terms of Use"))
        # buttons
        self.add_button(_("Decline"), Gtk.ResponseType.NO)
        self.add_button(_("Accept"), Gtk.ResponseType.YES)
        # label
        self.label = Gtk.Label(_(u"One moment, please\u2026"))
        self.label.show()
        # add the label
        box = self.get_action_area()
        box.pack_start(self.label, False, False, 0)
        box.set_child_secondary(self.label, True)
        # hrm, hrm, there really should be a better way
        for itm in box.get_children():
            if itm.get_label() == _("Accept"):
                self.button_accept = itm
                break
        self.button_accept.set_sensitive(False)
        # webkit
        wb = ScrolledWebkitWindow()
        wb.show_all()
        self.webkit = wb.webkit
        self.webkit.connect(
            "notify::load-status", self._on_load_status_changed)
        # content
        content = self.get_content_area()
        self.spinner = SpinnerNotebook(wb)
        self.spinner.show_all()
        content.pack_start(self.spinner, True, True, 0)
dialog_tos.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def run(self):
        self.spinner.show_spinner()
        self.webkit.load_uri(SOFTWARE_CENTER_TOS_LINK_NO_HEADER)
        return Gtk.Dialog.run(self)
imagedialog.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, title, pixbuf, parent=None):
        Gtk.Dialog.__init__(self)
        # find parent window for the dialog
        if not parent:
            parent = self.get_parent()
            while parent:
                parent = parent.get_parent()

        # screenshot
        img = Gtk.Image.new_from_pixbuf(pixbuf)

        # scolled window for screenshot
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
                               Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(img)
        content_area = self.get_content_area()
        content_area.pack_start(scroll, True, True, 0)

        # dialog
        self.set_title(title)
        self.set_transient_for(parent)
        self.set_destroy_with_parent(True)
        self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
        self.set_default_size(SimpleShowImageDialog.DEFAULT_WIDTH,
                              SimpleShowImageDialog.DEFAULT_HEIGHT)
imagedialog.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run(self):
        # show all and run the real thing
        self.show_all()
        Gtk.Dialog.run(self)
weblivedialog.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def run(self):
        if self.show_dialog == False:
            return Gtk.ResponseType.OK

        self.show_all()

        # and run the real thing
        return Gtk.Dialog.run(self)
dialog_tos.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run(self):
        self.spinner.show_spinner()
        self.webkit.load_uri(SOFTWARE_CENTER_TOS_LINK_NO_HEADER)
        return Gtk.Dialog.run(self)
imagedialog.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, title, pixbuf, parent=None):
        Gtk.Dialog.__init__(self)
        # find parent window for the dialog
        if not parent:
            parent = self.get_parent()
            while parent:
                parent = parent.get_parent()

        # screenshot
        img = Gtk.Image.new_from_pixbuf(pixbuf)

        # scolled window for screenshot
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
                               Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(img)
        content_area = self.get_content_area()
        content_area.pack_start(scroll, True, True, 0)

        # dialog
        self.set_title(title)
        self.set_transient_for(parent)
        self.set_destroy_with_parent(True)
        self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
        self.set_default_size(SimpleShowImageDialog.DEFAULT_WIDTH,
                              SimpleShowImageDialog.DEFAULT_HEIGHT)
imagedialog.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def run(self):
        # show all and run the real thing
        self.show_all()
        Gtk.Dialog.run(self)
weblivedialog.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run(self):
        if self.show_dialog == False:
            return Gtk.ResponseType.OK

        self.show_all()

        # and run the real thing
        return Gtk.Dialog.run(self)


问题


面经


文章

微信
公众号

扫码关注公众号