Python gtk 模块,DIALOG_DESTROY_WITH_PARENT 实例源码

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

项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def _ebFailedLogin(self, reason):
        if isinstance(reason, failure.Failure):
            reason = reason.value
        self.statusMsg(reason)
        if isinstance(reason, (unicode, str)):
            text = reason
        else:
            text = unicode(reason)
        msg = gtk.MessageDialog(self._loginDialog,
                                gtk.DIALOG_DESTROY_WITH_PARENT,
                                gtk.MESSAGE_ERROR,
                                gtk.BUTTONS_CLOSE,
                                text)
        msg.show_all()
        msg.connect("response", lambda *a: msg.destroy())

        # hostname not found
        # host unreachable
        # connection refused
        # authentication failed
        # no such service
        # no such perspective
        # internal server error
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def _ebFailedLogin(self, reason):
        if isinstance(reason, failure.Failure):
            reason = reason.value
        self.statusMsg(reason)
        if isinstance(reason, (unicode, str)):
            text = reason
        else:
            text = unicode(reason)
        msg = gtk.MessageDialog(self._loginDialog,
                                gtk.DIALOG_DESTROY_WITH_PARENT,
                                gtk.MESSAGE_ERROR,
                                gtk.BUTTONS_CLOSE,
                                text)
        msg.show_all()
        msg.connect("response", lambda *a: msg.destroy())

        # hostname not found
        # host unreachable
        # connection refused
        # authentication failed
        # no such service
        # no such perspective
        # internal server error
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def connectionLost(self, reason):
        if len(self.buffer) == 0:
             dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                        gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                        "An error occurred; file could not be retrieved.")
             dialog.run()
             dialog.destroy()
             return

        fd = gtk.FileChooserDialog(title=None, action=gtk.FILE_CHOOSER_ACTION_SAVE,
                                   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
        fd.set_default_response(gtk.RESPONSE_OK)
        fd.set_current_name(self.filename)
        response = fd.run()
        if response == gtk.RESPONSE_OK:
            destfilename = fd.get_filename()
            f = open(destfilename, 'w')
            f.write(self.buffer)
            f.close()
        fd.destroy()
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def delete_format(self, widget, data=None):
    # ???? ???????? gtk.RadioButton
    for format_id in self.format_radio:
      if format_id.get_active():
        # ?????????? ??????, ? ??????? ???????? ???????????? ?????????? ???? ?????
        dialog = gtk.Dialog('???????? ??????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"', self.window, gtk.DIALOG_NO_SEPARATOR | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_NO, gtk.RESPONSE_CANCEL, gtk.STOCK_YES, gtk.RESPONSE_OK))
        dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        dialog.set_resizable(False)
        dialog.set_border_width(10)
        self.confirmation_label = gtk.Label('?? ????????????? ?????? ??????? ?????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"?')
        dialog.vbox.pack_start(self.confirmation_label, True, True, 5)
        dialog.show_all()
        response = dialog.run()
        if response == gtk.RESPONSE_CANCEL:
          dialog.hide()
          dialog.destroy()
        if response == gtk.RESPONSE_OK:
          # ??????? ??????
          name = self.data['formats'][self.format_radio.index(format_id)]['name']
          del self.data['formats'][self.format_radio.index(format_id)]
          config = open(self.path, 'wb')
          json.dump(self.data, config)
          config.close()
          self.format_radio[self.format_radio.index(format_id)].hide()
          if len(self.format_radio) == 1:
            pass
          elif self.format_radio.index(format_id) + 1 <= len(self.format_radio) - 1:
            self.format_radio[self.format_radio.index(format_id) + 1].set_active(True)
          elif self.format_radio.index(format_id) + 1 > len(self.format_radio) - 1:
            self.format_radio[self.format_radio.index(format_id) - 1].set_active(True)
          del self.format_radio[self.format_radio.index(format_id)]
          if len(self.format_radio) < 1:
            self.delete_button.set_sensitive(False)
            self.edit_button.set_sensitive(False)
          self.add_success_label.set_markup('<span foreground="#008600">"' + str(name) + '" ??????? ??????\n</span>')
          dialog.hide()
          dialog.destroy()
        break

  # ??? ??????? ???????????? ?????????? ?????? ???????
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self, visualizer, node_index, statistics_collector):
        InformationWindow.__init__(self)
        self.win = gtk.Dialog(parent=visualizer.window,
                              flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
                              buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.win.connect("response", self._response_cb)
        self.win.set_title("Statistics for node %i" % node_index) 
        self.visualizer = visualizer
        self.statistics_collector = statistics_collector
        self.node_index = node_index
        self.viz_node = visualizer.get_node(node_index)

        self.table_model = gtk.ListStore(*([str]*13))

        treeview = gtk.TreeView(self.table_model)
        treeview.show()
        self.win.vbox.add(treeview)

        def add_column(descr, colid):
            column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
            treeview.append_column(column)

        add_column("Interface", self.COLUMN_INTERFACE)

        add_column("Tx Packets", self.COLUMN_TX_PACKETS)
        add_column("Tx Bytes", self.COLUMN_TX_BYTES)
        add_column("Tx pkt/1s", self.COLUMN_TX_PACKET_RATE)
        add_column("Tx bit/1s", self.COLUMN_TX_BIT_RATE)

        add_column("Rx Packets", self.COLUMN_RX_PACKETS)
        add_column("Rx Bytes", self.COLUMN_RX_BYTES)
        add_column("Rx pkt/1s", self.COLUMN_RX_PACKET_RATE)
        add_column("Rx bit/1s", self.COLUMN_RX_BIT_RATE)

        self.visualizer.add_information_window(self)
        self.win.show()
项目:Web-Stalker    作者:Dylan-halls    | 项目源码 | 文件源码
def open_window(self, url):
      url = address_bar.get_text()
      for letter in url:
          if '.' not in url:
               a = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CANCEL)
               a.set_markup("<big><b>WTF!?!? Thats not even a website?</b></big>")
               a.run()
               return
      if 'http://' not in url:
           w = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK)
           w.set_markup("<big><b>**mumble, mumble** Force to change {} to {}</b></big>".format(url, 'http://'+url+'/'))
           w.run()
           url = 'http://'+url+'/'
      os.system('python Web-Window.py '+url)
项目:Web-Stalker    作者:Dylan-halls    | 项目源码 | 文件源码
def saver(self, text):
      file_name = save_bar.get_text()
      start_iter = textbuffer.get_start_iter()
      end_iter = textbuffer.get_end_iter()
      file_data = textbuffer.get_text(start_iter, end_iter, True)  
      with open('Reports/'+file_name, 'w') as file:
         file.write(file_data)
         file.close()
      done = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
      done.set_markup("<big><b>File {} Has Been Saved</b></big>".format(file_name))
      done.run()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def show_alert_message(parent_window, msg):
    alert = gtk.MessageDialog(parent_window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
                              gtk.BUTTONS_CLOSE, msg)
    alert.run()
    alert.destroy()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def show_error_message(parent_window, msg):
    alert = gtk.MessageDialog(parent_window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
                              gtk.BUTTONS_CLOSE, msg)
    alert.run()
    alert.destroy()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def parse_all(self, event):
        for collector in self.engine.collectors:
            collector.parser.parse()
#        alert = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
#                                       gtk.BUTTONS_CLOSE, "Parsing complete")
#        alert.run()
#        alert.destroy()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def show_confirmation_dialog(self, msg):
        dialog = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
                                      gtk.BUTTONS_YES_NO, msg)
        response = dialog.run()
        dialog.destroy()

        if response == gtk.RESPONSE_YES:
            return True

        return False
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def message(message, parent=None):
    dia = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, message)
    dia.show()
    dia.run()
    dia.destroy()
    return False
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def ask(query, parent=None):
    dia = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, query)
    dia.show()
    rtn=dia.run()
    dia.destroy()
    return rtn == gtk.RESPONSE_YES
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def askQ(query, prompt=None, parent=None):
    if prompt:
        dia = EntryDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, query, default_value=prompt)
    else:
        dia = EntryDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, query)
    dia.show()
    rtn=dia.run()
    dia.destroy()
    return rtn
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def askFolder(query, prompt=None, parent=None):
    if prompt:
        dia = FolderDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, query, default_value=prompt)
    else:
        dia = FolderDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK, query)
    dia.show()
    rtn=dia.run()
    dia.destroy()
    return rtn
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def message(self, message):
        dia = gtk.MessageDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, message)
        dia.show()
        dia.run()
        dia.destroy()
        return False
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def askQ(self, query, prompt=None, title="", ok="Ok"):
        if prompt:
            dia = EntryDialog(title, self.window, gtk.DIALOG_DESTROY_WITH_PARENT, (ok, gtk.RESPONSE_OK, "Cancel", gtk.RESPONSE_CANCEL), query, default_value=prompt)
        else:
            dia = EntryDialog(title, self.window, gtk.DIALOG_DESTROY_WITH_PARENT, (ok, gtk.RESPONSE_OK, "Cancel", gtk.RESPONSE_CANCEL), query)
        dia.show()
        rtn=dia.run()
        dia.destroy()
        return rtn
项目: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)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def show_about(self, widget):
        dialog = gtk.MessageDialog(
            None,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO,
            gtk.BUTTONS_OK,
            """
PiJuice battery 
level status
""")
        dialog.run()
        dialog.destroy()
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def downloadFile(self, treeView, path, column):
        model = treeView.get_model()
        iter = model.get_iter(path)
        filename = model.get(iter, 0)[0]
        h = hashlib.sha1()
        h.update(filename)
        key = h.digest()

        def getTargetNode(result):
            targetNodeID = result[key]
            df = self.node.findContact(targetNodeID)
            return df
        def getFile(protocol):
            if protocol != None:
                protocol.requestFile(filename, self)
        def connectToPeer(contact):
            if contact == None:
                dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                        gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                        "File could not be retrieved.\nThe host that published this file is no longer on-line.")
                dialog.run()
                dialog.destroy()
            else:
                c = ClientCreator(twisted.internet.reactor, FileGetter)
                df = c.connectTCP(contact.address, contact.port)
                return df

        df = self.node.iterativeFindValue(key)
        df.addCallback(getTargetNode)
        df.addCallback(connectToPeer)
        df.addCallback(getFile)
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def _tupleFromStr(self, text):
        tp = None
        try:
            exec 'tp = %s' % text
            if type(tp) != tuple:
                raise Exception
        except Exception:
            dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                       gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                        "Please enter a valid Python tuple,\ne.g. (1, 'abc', 3.14)")
            dialog.set_title('Error')
            dialog.run()
            dialog.destroy()
        finally:
            return tp
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def mess_dlg(mess, title = "NativeCAM"):
    dlg = gtk.MessageDialog(parent = None,
        flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        type = gtk.MESSAGE_WARNING,
        buttons = gtk.BUTTONS_OK, message_format = '%s' % mess)
    dlg.set_title(title)
    dlg.set_keep_above(True)
    dlg.run()
    dlg.destroy()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def mess_with_buttons(mess, buttons, title = ""):
    mwb = gtk.Dialog(parent = None,
                     buttons = buttons,
                     flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
          )
    mwb.set_title(title)
    finbox = mwb.get_content_area()
    l = gtk.Label(mess)
    finbox.pack_start(l)
    mwb.set_keep_above(True)
    mwb.show_all()
    response = mwb.run()
    mwb.hide()
    mwb.destroy()
    return response
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def create_M_file() :
    p = os.path.join(NCAM_DIR, NGC_DIR, 'M123')
    with open(p, 'wb') as f :
        f.write('#!/usr/bin/env python\n# coding: utf-8\n')

        f.write("import gtk\nimport os\nimport pygtk\npygtk.require('2.0')\nfrom gtk import gdk\n\n")

        f.write("fname = '%s'\n" % os.path.join(NCAM_DIR, CATALOGS_DIR, 'no_skip_dlg.conf'))
        f.write('if os.path.isfile(fname) :\n    exit(0)\n\n')

        f.write("msg = '%s'\n" % _('Stop LinuxCNC program,&#10;toggle the shown button,&#10;then restart'))
        f.write("msg1 = '%s'\n" % _('Skip block not active'))
        f.write("icon_fname = '%s'\n\n" % os.path.join(NCAM_DIR, GRAPHICS_DIR, 'skip_block.png'))

        f.write('dlg = gtk.MessageDialog(parent = None, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, type = gtk.MESSAGE_WARNING, buttons = gtk.BUTTONS_NONE, message_format = msg1)\n\n')

        f.write("dlg.set_title('NativeCAM')\ndlg.format_secondary_markup(msg)\n\n")

        f.write('dlg.set_image(gtk.Image())\n')
        f.write('dlg.get_image().set_from_pixbuf(gdk.pixbuf_new_from_file_at_size(icon_fname, 80, 80))\n\n')

        f.write('cb = gtk.CheckButton(label = "%s")\n' % _("Do not show again"))
        f.write('dlg.get_content_area().pack_start(cb, True, True, 0)\n')
        f.write('dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK).grab_focus()\n\n')

        f.write('dlg.set_keep_above(True)\ndlg.show_all()\n\ndlg.run()\n')
        f.write("if cb.get_active() :\n    open(fname, 'w').close()\n")
        f.write('exit(0)\n')

    os.chmod(p, 0o755)
    mess_dlg(_('LinuxCNC needs to be restarted now'))
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def msg_inv(self, msg, msgid):
        msg = msg.replace('&#176;', '°')
        print('\n%(feature_name)s : %(msg)s' % {'feature_name':self.get_name(), 'msg':msg})

        if (("ALL:msgid-0" in EXCL_MESSAGES) or
                ("%s:msgid-0" % (self.get_type()) in EXCL_MESSAGES) or
                (("%s:msgid-%d" % (self.get_type(), msgid)) in EXCL_MESSAGES)) :
            return

        # create dialog with image and checkbox
        dlg = gtk.MessageDialog(parent = None,
            flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            type = gtk.MESSAGE_WARNING,
            buttons = gtk.BUTTONS_NONE,
            message_format = self.get_name())
        dlg.set_title('NativeCAM')
        dlg.format_secondary_text(msg)
        img = gtk.Image()
        img.set_from_pixbuf(self.get_icon(add_dlg_icon_size))
        dlg.set_image(img)
        cb = gtk.CheckButton(label = _("Do not show again"))
        dlg.get_content_area().pack_start(cb, True, True, 0)
        dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK).grab_focus()

        dlg.set_keep_above(True)
        dlg.show_all()
        dlg.run()
        if cb.get_active() :
            GLOBAL_PREF.add_excluded_msg(self.get_type(), msgid)
        dlg.destroy()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def action_renameF(self, *arg):
        self.newnamedlg = gtk.MessageDialog(parent = None,
            flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            type = gtk.MESSAGE_QUESTION,
            buttons = gtk.BUTTONS_OK_CANCEL
        )
        old_name = self.selected_feature.get_attr('name')
        self.newnamedlg.set_markup(_('Enter new name for'))
        self.newnamedlg.format_secondary_markup(old_name)
        self.newnamedlg.set_title('NativeCAM')
        edit_entry = gtk.Entry()
        edit_entry.set_editable(True)
        edit_entry.set_text(old_name)
        edit_entry.connect('key-press-event', self.action_rename_keyhandler)
        self.newnamedlg.vbox.add(edit_entry)
        self.newnamedlg.set_keep_above(True)

        (tree_x, tree_y) = self.treeview.get_bin_window().get_origin()
        self.newnamedlg.move(tree_x, tree_y + self.click_y)

        self.newnamedlg.show_all()
        response = self.newnamedlg.run()
        if (response == gtk.RESPONSE_OK) :
            newname = edit_entry.get_text().lstrip(' ')
            if newname > '' :
                self.selected_feature.attr['name'] = newname
                self.refresh_views()
        self.newnamedlg.destroy()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def error(msg, parent=None):
    dialog = gtk.MessageDialog(parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg)
    dialog.set_skip_taskbar_hint(False)
    dialog.run()
    dialog.destroy()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def urllib_error(msg, parent=None):
    dialog = gtk.MessageDialog(parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg)
    dialog.set_skip_taskbar_hint(False)
    dialog.run()
    dialog.destroy()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def warning(msg, parent=None):
    if mac:
        macutils.createAlert(msg)
    else:
        dialog = gtk.MessageDialog(parent,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, msg)
        dialog.set_skip_taskbar_hint(False)
        dialog.run()
        dialog.destroy()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def info(msg, parent=None):
    if mac:
        macutils.createAlert(msg)
    else:
        dialog = gtk.MessageDialog(parent,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_INFO, gtk.BUTTONS_OK, msg)
        dialog.set_skip_taskbar_hint(False)
        dialog.run()
        dialog.destroy()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def question(msg, window=None):
    if mac:
        response = macutils.question(msg)
        return response
    else:
        dialog = gtk.MessageDialog(window,
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, msg)
        dialog.add_buttons(gtk.STOCK_YES, gtk.RESPONSE_YES,
            gtk.STOCK_NO, gtk.RESPONSE_NO)
        dialog.set_default_response(gtk.RESPONSE_NO)
        dialog.set_skip_taskbar_hint(False)
        response = dialog.run()
        dialog.destroy()
        return response in (gtk.RESPONSE_OK, gtk.RESPONSE_YES)
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def __init__(self,title="Config",parent=None,config = None):
        gtk.Dialog.__init__(self,title,parent, gtk.DIALOG_DESTROY_WITH_PARENT,
                ('Apply',gtk.RESPONSE_APPLY,'Cancel',gtk.RESPONSE_CANCEL))

        self.set_keep_above(True)
        self.set_position(gtk.WIN_POS_CENTER)

        self.last_config= config # settings 
        self.atual_config = config

        # setup all widgets
        self._setup_widgets()
项目:fluxgui    作者:xflux-gui    | 项目源码 | 文件源码
def display_no_zipcode_or_latitude_error_box(self):
        md = gtk.MessageDialog(self.window,
                gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
                gtk.BUTTONS_OK, "The f.lux indicator applet needs to know " +
                "your latitude or zipcode to run. " +
                "Please fill either of them in on the preferences screen "+
                "and click 'Close'.")
        md.set_title("f.lux indicator applet")
        md.run()
        md.destroy()
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self, visualizer, node_index):
        InformationWindow.__init__(self)
        self.win = gtk.Dialog(parent=visualizer.window,
                              flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
                              buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.win.set_default_size(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/2)
        self.win.connect("response", self._response_cb)
        self.win.set_title("OLSR routing table for node %i" % node_index) 
        self.visualizer = visualizer
        self.node_index = node_index

        self.table_model = gtk.ListStore(str, str, str, int)

        treeview = gtk.TreeView(self.table_model)
        treeview.show()
        sw = gtk.ScrolledWindow()
        sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                          vscrollbar_policy=gtk.POLICY_AUTOMATIC)
        sw.show()
        sw.add(treeview)
        self.win.vbox.add(sw)

        # Dest.
        column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(),
                                    text=self.COLUMN_DESTINATION)
        treeview.append_column(column)

        # Next hop
        column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(),
                                    text=self.COLUMN_NEXT_HOP)
        treeview.append_column(column)

        # Interface
        column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(),
                                    text=self.COLUMN_INTERFACE)
        treeview.append_column(column)

        # Num. Hops
        column = gtk.TreeViewColumn('Num. Hops', gtk.CellRendererText(),
                                    text=self.COLUMN_NUM_HOPS)
        treeview.append_column(column)

        self.visualizer.add_information_window(self)
        self.win.show()
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self, visualizer, node_index):
        InformationWindow.__init__(self)
        self.win = gtk.Dialog(parent=visualizer.window,
                              flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
                              buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.win.connect("response", self._response_cb)
        self.win.set_title("IPv4 routing table for node %i" % node_index) 
        self.visualizer = visualizer
        self.node_index = node_index

        self.table_model = gtk.ListStore(str, str, str, str, int)

        treeview = gtk.TreeView(self.table_model)
        treeview.show()
        sw = gtk.ScrolledWindow()
        sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                          vscrollbar_policy=gtk.POLICY_AUTOMATIC)
        sw.show()
        sw.add(treeview)
        self.win.vbox.add(sw)
        self.win.set_default_size(600, 300)

        # Dest.
        column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(),
                                    text=self.COLUMN_DESTINATION)
        treeview.append_column(column)

        # Next hop
        column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(),
                                    text=self.COLUMN_NEXT_HOP)
        treeview.append_column(column)

        # Interface
        column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(),
                                    text=self.COLUMN_INTERFACE)
        treeview.append_column(column)

        # Type
        column = gtk.TreeViewColumn('Type', gtk.CellRendererText(),
                                    text=self.COLUMN_TYPE)
        treeview.append_column(column)

        # Prio
        column = gtk.TreeViewColumn('Prio', gtk.CellRendererText(),
                                    text=self.COLUMN_PRIO)
        treeview.append_column(column)

        self.visualizer.add_information_window(self)
        self.win.show()
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def _take_screenshot(self, dummy_button):
        #print "Cheese!"
        file_name = self._get_export_file_name()
        if file_name is None:
            return

        # figure out the correct bounding box for what is visible on screen
        x1 = self._scrolled_window.get_hadjustment().value
        y1 = self._scrolled_window.get_vadjustment().value
        x2 = x1 + self._scrolled_window.get_hadjustment().page_size
        y2 = y1 + self._scrolled_window.get_vadjustment().page_size
        bounds = goocanvas.Bounds()
        bounds.x1, bounds.y1 = self.canvas.convert_from_pixels(x1, y1)
        bounds.x2, bounds.y2 = self.canvas.convert_from_pixels(x2, y2)
        dest_width = bounds.x2 - bounds.x1
        dest_height = bounds.y2 - bounds.y1
        #print bounds.x1, bounds.y1, " -> ", bounds.x2, bounds.y2

        dummy, extension = os.path.splitext(file_name)
        extension = extension.lower()
        if extension == '.eps':
            surface = cairo.PSSurface(file_name, dest_width, dest_height)
        elif extension == '.pdf':
            surface = cairo.PDFSurface(file_name, dest_width, dest_height)
        elif extension == '.svg':
            surface = cairo.SVGSurface(file_name, dest_width, dest_height)
        else:
            dialog = gtk.MessageDialog(parent  = self.canvas.get_toplevel(),
                               flags   = gtk.DIALOG_DESTROY_WITH_PARENT,
                               type    = gtk.MESSAGE_ERROR,
                               buttons = gtk.BUTTONS_OK,
                               message_format = "Unknown extension '%s' (valid extensions are '.eps', '.svg', and '.pdf')"
                                                          % (extension,))
            dialog.run()
            dialog.destroy()
            return

        # draw the canvas to a printing context
        cr = cairo.Context(surface)
        cr.translate(-bounds.x1, -bounds.y1)
        self.canvas.render(cr, bounds, self.zoom.value)
        cr.show_page()
        surface.finish()
项目: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