Python gtk 模块,RESPONSE_ACCEPT 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用gtk.RESPONSE_ACCEPT

项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def __init__(self, title, parent, ok_button=True, cancel_button=True,
                 width=600, height=260, extra_buttons=None):
        buttons = []

        if extra_buttons:
            buttons.extend(extra_buttons)

        if ok_button:
            buttons.extend([gtk.STOCK_OK, gtk.RESPONSE_ACCEPT])

        if cancel_button:
            buttons.extend([gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT])

        buttons = tuple(buttons)
        gtk.Dialog.__init__(self, title, parent, DEF_DIALOG_FLAGS, buttons)
        self.set_size_request(width, height)
        self.set_has_separator(False)
    # __init__()
# Dialog
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def _choose_mplayer_path(self, btn):
        d = gtk.FileChooserDialog("Select MPlayer binary",
                                  buttons=DEF_DIALOG_BUTTONS)
        d.set_local_only(True)
        d.set_select_multiple(False)
        d.set_current_folder(catota.client.DEF_BIN_PATH)

        p = self.player_path.get_text()
        if p:
            d.set_filename(p)

        d.show()
        r = d.run()
        d.hide()
        if r == gtk.RESPONSE_ACCEPT:
            p = d.get_filename()
            if p:
                self.player_path.set_text(p)
    # _choose_mplayer_path()
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def get_password(self,parent):
        dialog = gtk.Dialog("Configure System Password",parent,gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,gtk.STOCK_OK,gtk.RESPONSE_ACCEPT))
        self.pass1 = gtk.HBox()
                self.label1 = gtk.Label("          Passsword: ")
                self.pass1.pack_start(self.label1,False,True,0)
        self.password1 = gtk.Entry()
        self.password1.set_visibility(False)
        self.pass1.pack_start(self.password1,False,True,0)
        dialog.vbox.add(self.pass1)
        self.pass2 = gtk.HBox()
                self.label2 = gtk.Label("  Verify Password: ")
                self.pass2.pack_start(self.label2,False,True,0)
        self.password2 = gtk.Entry()
        self.password2.set_visibility(False)
        self.pass2.pack_start(self.password2,False,True,0)
        dialog.vbox.add(self.pass2)
        dialog.show_all()
        response = dialog.run()
        if response == gtk.RESPONSE_ACCEPT:
            self.a = self.password1.get_text()
            self.b = self.password2.get_text()
            dialog.destroy()
        else:
            self.a = ''
            self.b = ''
            dialog.destroy()


    # Configure Network Dialog
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def __init__(self):

        self.ip_entry_text = ""
        self.port_entry_text = ""
        self.initial_entry_text = ""
        self.comment_entry_text = ""

        response = self.save_shot()
        if response == gtk.RESPONSE_ACCEPT:
            # wait 1 second before taking the snapshot
            while gtk.events_pending():
                gtk.main_iteration()
            sleep(1)

            timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
            #take the snapshot
            bitmap = autopy.bitmap.capture_screen()
            savepath = os.path.join(os.getcwd(), 'plugins', 'collectors', 'manualscreenshot', 'raw')
            savefilename = self.comment_entry_text.strip().replace("-","") + "-" + timestamp
            savefull = os.path.join(savepath,savefilename+".png")
            bitmap.save(savefull) #TODO: Fix to have raw folder created!

            #write to metafile
            f = open(os.path.join(savepath,"."+savefilename), 'w')
            string = "[{\n" + \
                     " \"ip\" : \"" + self.ip_entry_text + "\"\n"\
                     " \"port\" : \"" + self.port_entry_text + "\"\n"\
                     " \"initial\" : \"" + self.initial_entry_text + "\"\n"\
                     " \"timestamp\" : \"" + timestamp + "\"\n"\
                     " \"savepath\" : \"" + savefull + "\"\n"\
                     " \"comment\" : \"" + self.comment_entry_text + "\"\n"\
                     "}]\n"
            f.write(string)
            f.close()
            #print "write metadata to:",os.path.join(savepath,"."+savefilename)
            #print "Screen shot taken:", savefull
        #else:
            #print "cancelled"
项目:srcsim2017    作者:ZarjRobotics    | 项目源码 | 文件源码
def exitfc_button_cb(self, button):
        label = gtk.Label("Are you sure you want the FC to exit?")
        dialog = gtk.Dialog("Confirm Exit",
                       None,
                       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                       (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                       gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        dialog.vbox.pack_start(label)
        label.show()
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_ACCEPT:
            msg = ZarjExitCommand()
            self.zarj_comm.push_message(msg)
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def run(self, focus_widget=None):
        self.show()
        self._fill_data()
        if not focus_widget:
            self.tab.set_current_page(0)
        else:
            def has_widget(container, wid):
                for w in container.get_children():
                    if w == wid:
                        return True
                    elif isinstance(w, gtk.Container):
                        if has_widget(w, wid):
                            return True
                return False
            # has_widget()

            for i in xrange(self.tab.get_n_pages()):
                w = self.tab.get_nth_page(i)
                if has_widget(w, focus_widget):
                    self.tab.set_current_page(i)
                    break

            focus_widget.grab_focus()

        response = gtk.Dialog.run(self)
        self.hide()
        if response == gtk.RESPONSE_ACCEPT:
            self._save_data()
            return True
        else:
            return False
    # run()
# PlayerPreferences
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def get_url_from_chooser(self):
        self.media_location.set_text(self.preferences["location"])
        self._set_media_type(self.preferences["type"])

        self.gui_url_chooser.show()
        while 1:
            self.media_server.set_label("%s:%s" % (self.preferences["address"],
                                                   self.preferences["port"]))
            r = self.gui_url_chooser.run()
            if r != 1:
                break
            else:
                self.parent_win.show_preferences(self.address)

        self.gui_url_chooser.hide()

        if r == gtk.RESPONSE_ACCEPT:
            l = self.media_location.get_text()
            self.preferences["location"] = l
            t = self.media_type.get_active()
            if t < 0:
                return l
            else:
                m = self.media_model[t][0]
                self.preferences["type"] = m

                parms = {"type": self.preferences["type"],
                         "location": self.preferences["location"]}
                parms = urllib.urlencode(parms)
                return "mythstreamer://%s:%d/?%s" % \
                       (self.preferences["address"], self.preferences["port"],
                        parms)
        else:
            return None
    # get_url_from_chooser()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def get_url_from_chooser(self):
        self.gui_url_chooser_entry.set_text(self.preferences["address"])

        self.gui_url_chooser.show()
        r = self.gui_url_chooser.run()
        self.gui_url_chooser.hide()

        if r == gtk.RESPONSE_ACCEPT:
            b = self.gui_url_chooser_entry
            t = b.get_text(b.get_start_iter(), b.get_end_iter())
            self.preferences["address"] = t
            return t
        else:
            return None
    # get_url_from_chooser()
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def check_network(self,widget,event=None):

        self.network_error = 0

        if self.dhcp.get_active() == True:
            self.dhcp.set_label("DHCP")
            self.ip.set_sensitive(False)
            self.netmask.set_sensitive(False)
            self.gateway.set_sensitive(False)
            self.dns1.set_sensitive(False)
            self.dns2.set_sensitive(False)
        else:
            self.dhcp.set_label("Static IP")
            self.ip.set_sensitive(True)
            self.netmask.set_sensitive(True)
            self.gateway.set_sensitive(True)
            self.dns1.set_sensitive(True)
            self.dns2.set_sensitive(True)

            if self.verify.check_ip(self.ip.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid IP Address!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
                if self.verify.check_ip(self.netmask.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid Netmask!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
            if self.verify.check_ip(self.gateway.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid Gateway!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
            if self.verify.check_ip(self.dns1.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid DNS1 Address!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1
            if self.verify.check_ip(self.dns2.get_text()) == False:
                self.MessageBox(self.window,"<b>Invalid DNS2 Address!</b>",gtk.MESSAGE_ERROR)
                self.network_error = 1

        if self.network_error == 1:
            self.network_dialog.set_response_sensitive(gtk.RESPONSE_ACCEPT,False)
            return False    
        else:
            self.network_dialog.set_response_sensitive(gtk.RESPONSE_ACCEPT,True)
            return True


        # Appply Configurations to Kickstart File
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def save_shot(self):
        # create a new window
        dialog = gtk.Dialog("Manual ScreenShot",
                            None,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))

        dialog.set_size_request(400, 250)
        dialog.set_title("Manual ScreenShot Comment ECEL V2.0")

        table = gtk.Table(5,2,False)
        table.show()
        # create ip row
        ipLabel = gtk.Label("IP")
        ipEntry = gtk.Entry()
        table.attach(ipLabel, 0, 1, 0, 1)
        table.attach(ipEntry, 1, 2, 0, 1)
        ipLabel.show()
        ipEntry.show()

        # create Port row
        portLabel = gtk.Label("Port")
        portEntry = gtk.Entry()
        table.attach(portLabel, 0, 1, 1, 2)
        table.attach(portEntry, 1, 2, 1, 2)
        portLabel.show()
        portEntry.show()

        # create initial row
        initialLabel = gtk.Label("Initials")
        initialEntry = gtk.Entry()
        table.attach(initialLabel, 0, 1, 2, 3)
        table.attach(initialEntry, 1, 2, 2, 3)
        initialLabel.show()
        initialEntry.show()

        #create the comment entry field
        maxChar = 64
        commentEntry = gtk.Entry()
        commentEntry.set_max_length(maxChar)
        commentEntry.insert_text("Enter Comment")
        commentEntry.select_region(0, len(commentEntry.get_text()))
        table.attach(commentEntry, 0, 2, 3, 4)
        commentEntry.show()

        dialog.vbox.pack_start(table)

        response = dialog.run()

        self.ip_entry_text = ipEntry.get_text()
        self.port_entry_text = portEntry.get_text()
        self.initial_entry_text = initialEntry.get_text()
        self.comment_entry_text = commentEntry.get_text()
        dialog.hide_all()
        dialog.destroy()
        return response