Python wx 模块,TextEntryDialog() 实例源码

我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用wx.TextEntryDialog()

项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def OnSetMeta(self, ev=None):
      """
      set user meta on selected groups + items
      """
      tree = self.treeCtrlItems
      itemsL, groupsL = self._getSelections()
      namesL  = itemsL + groupsL
      if namesL:     
         namesS = ',\n '.join(namesL)
         msg = 'User meta data string for:\n %s' % namesS
         dlg = wx.TextEntryDialog(self, msg, 'Enter meta data')
         dlg.CentreOnParent()
         if dlg.ShowModal() == wx.ID_OK:
            meta=dlg.GetValue()
            for name in namesL:
               self.nsc_set_meta(name,meta)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddNewComment(self, bbox):
        dialog = wx.TextEntryDialog(self.ParentWindow,
                                    _("Edit comment"),
                                    _("Please enter comment text"),
                                    "", wx.OK | wx.CANCEL | wx.TE_MULTILINE)
        dialog.SetClientSize(wx.Size(400, 200))
        if dialog.ShowModal() == wx.ID_OK:
            value = dialog.GetValue()
            id = self.GetNewId()
            comment = Comment(self, value, id)
            comment.SetPosition(bbox.x, bbox.y)
            min_width, min_height = comment.GetMinSize()
            comment.SetSize(*self.GetScaledSize(max(min_width, bbox.width), max(min_height, bbox.height)))
            self.AddComment(comment)
            self.Controler.AddEditedElementComment(self.TagName, id)
            self.RefreshCommentModel(comment)
            self.RefreshBuffer()
            self.RefreshScrollBars()
            self.RefreshVisibleElements()
            comment.Refresh()
        dialog.Destroy()
项目:hostswitcher    作者:fiefdx    | 项目源码 | 文件源码
def OnAdd(self, evt):
        dialog = wx.TextEntryDialog(self,
                                    "Enter name:",
                                    "Add", style = wx.OK | wx.CANCEL)
        dialog.Centre(wx.BOTH)
        if dialog.ShowModal() == wx.ID_OK:
            name = dialog.GetValue()
            if name not in ("CURRENT", ) and name not in self.all_hosts:
                fpath = os.path.join(DataPath, name)
                shutil.copy(os.path.join(DataPath, "default"), fpath)
                call_editor(fpath)
                self.all_hosts.append(name)
                self.combo_box_1.AppendItems([name])
            else:
                msg_dialog = wx.MessageDialog(self,
                                              "Failed to create \"%s\".\nFile already exists." % name,
                                              'Failed to create "%s"' % name, wx.OK | wx.ICON_ERROR)
                msg_dialog.Centre(wx.BOTH)
                msg_dialog.ShowModal()
                msg_dialog.Destroy()
        dialog.Destroy()
项目:5622_PacMan_NN    作者:Brennan-M    | 项目源码 | 文件源码
def getplayername(self):
            """Ask the player his name, to go on the high-score list."""
            if NO_WX: return USER_NAME
            try:
              import wx
            except:
              print "Pacman Error: No module wx. Can not ask the user his name!"
              print "     :(       Download wx from http://www.wxpython.org/"
              print "     :(       To avoid seeing this error again, set NO_WX in file pacman.pyw."
              return USER_NAME
            app=wx.App(None)
            dlog=wx.TextEntryDialog(None,"You made the high-score list! Name:")
            dlog.ShowModal()
            name=dlog.GetValue()
            dlog.Destroy()
            app.Destroy()
            return name
项目:multiplierz    作者:BlaisProteomics    | 项目源码 | 文件源码
def text_input(prompt='', value='', title=''):
    """Provides a text input dialog and returns the user input

    The value field can be used to enter the default initial value.

    Example:
    >> textInput('Enter your name:', title='Name')

    """

    try:
        dlg = wx.TextEntryDialog(None, message=prompt, caption=title, defaultValue=value)
    except wx._core.PyNoAppError:
        app = mzApp()
        app.launch()
        dlg = wx.TextEntryDialog(None, message=prompt, caption=title, defaultValue=value)

    dlg.ShowModal()
    output = dlg.GetValue()
    dlg.Destroy()

    return output
项目:i3ColourChanger    作者:PMunch    | 项目源码 | 文件源码
def OnCreateVariable(self,event):
        openColourDialog = wx.ColourDialog(self)
        if openColourDialog.ShowModal() == wx.ID_CANCEL:
            return
        openNameChooser = wx.TextEntryDialog(self,"What would you like your new colour variable to be called?")
        if openNameChooser.ShowModal() == wx.ID_CANCEL:
            return  
        proposed = openNameChooser.GetValue()
        name = ""
        seenChar = False
        for character in proposed:
            if not seenChar:
                if character in string.ascii_letters:
                    name+=character
                    seenChar=True
            elif character in string.ascii_letters+string.digits:
                name+=character
        if name=="":
            i = 0
            for name in self.config.setColours:
                if name[:14]=="colourVariable":
                    i+=1
            name = "colourVariable"+str(i)
        name = "$"+name
        self.config.setColourChanged(openColourDialog.GetColourData(),name)
        self.LoadConfig(self.config)
项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def nsc_findNS(self, ident=None):
      """
      Locating the Name Server by using given nsHost and nsPort
      """
      locator = NameServerLocator(identification=ident)
      try:
         if self.nsHost:
            self._log('connecting to Name Server (%s:%s)' % (self.nsHost,
                                                             self.nsPort))
            self.NS = locator.getNS(self.nsHost, self.nsPort, trace=1, bcaddr=self.bcAddr)
         else:
            self._log('broadcasting to find Name Server')
            self.NS = locator.getNS(None, None, trace = 1, bcaddr=self.bcAddr) 
            self.nsHost = self.NS.URI.address
            self.nsPort = self.NS.URI.port
         self.NS._setIdentification(ident)
         self._log('Name Server found, URI = %s' % self.NS.URI)
         self._setNSData()
      except ConnectionDeniedError, e:
         if str(e).find( Pyro.constants.deniedReasons[Pyro.constants.DENIED_SECURITY] ) != -1:
            msg = 'Authentication required:'
            dlg = wx.TextEntryDialog(self, msg, 'Authentication',
                                    style=wx.OK|wx.CANCEL|wx.TE_PASSWORD)
            dlg.CentreOnParent()
            if dlg.ShowModal() == wx.ID_OK:
               ident = dlg.GetValue()
               self.nsc_findNS(ident)
            else:
               self.NS = None
               self._log('Connection to Name Server denied!','error')
         else:
            self.NS = None
            self._logError('Unable to connect to Name Server')
      except:
         self.NS = None
         self._logError('Name Server not found!')
项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def OnCreateGroup(self, event):
      """
      Creating group in selected parent
      """
      tree = self.treeCtrlItems
      items = tree.GetSelections()
      if items:
         if tree.GetPyData(items[0]) == 0:
            # use the selected group
            parentGroupI = items[0]
            parentGroupName = tree.GetItemText(parentGroupI)
         else:
            # take the parent
            parentGroupI = tree.GetItemParent(items[0])
            parentGroupName = tree.GetItemText(parentGroupI)
      else:
         parentGroupI    = tree.GetRootItem()
         parentGroupName = ':'
      msg = 'Create group in "%s", with name:' % parentGroupName
      dlg = wx.TextEntryDialog(self, msg, 'Enter group name')
      dlg.CentreOnParent()
      if dlg.ShowModal() == wx.ID_OK:
         if parentGroupName != ':':
            groupName = '%s.%s' % (parentGroupName, dlg.GetValue())
         else:
            groupName = ':%s' % (dlg.GetValue())
         if self.nsc_create_group(groupName):
            groupI = tree.AppendItem(parentGroupI, groupName)
            tree.SetPyData(groupI, 0)
            tree.SetItemImage(groupI, self.__idGroup)
            tree.SetItemImage(groupI, self.__idGroupOpen,
                              wx.TreeItemIcon_Expanded)
            tree.Expand(parentGroupI)
项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def OnRegisterItem(self, event):
      """
      Registering item in selected parent.
      """
      tree = self.treeCtrlItems
      items = tree.GetSelections()
      if items:
         if tree.GetPyData(items[0]) == 0:
            # use the selected group
            parentGroupI = items[0]
            parentGroupName = tree.GetItemText(parentGroupI)
         else:
            parentGroupI = tree.GetItemParent(items[0])
            parentGroupName = tree.GetItemText(parentGroupI)
      else:
         parentGroupI    = tree.GetRootItem()
         parentGroupName = ':'

      msg = 'Register new item in "%s", with:\n <name> <URI>' % parentGroupName
      dlg =  wx.TextEntryDialog(self, msg, 'Register item')
      dlg.CentreOnParent()
      if dlg.ShowModal() == wx.ID_OK:
         try:
            itemName, uri = dlg.GetValue().split()
         except:
            self._log('Invalid arguments, use <name> <URI>', 'error')
         else:
            if parentGroupName != ':':
               itemName = '%s.%s' % (parentGroupName, itemName)
            else:
               itemName = ':%s' % (itemName)
            if self.nsc_register_item(itemName, uri):
               label = '%s (%s)' % (dlg.GetValue().split()[0], uri)
               itemI = tree.AppendItem(parentGroupI, label)
               tree.SetPyData(itemI, 1)
               tree.SetItemImage(itemI, self.__idItem)
               tree.SetItemImage(itemI, self.__idItem,
                                 wx.TreeItemIcon_Selected)
               tree.Expand(parentGroupI)
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def __init__(self, parent, messageString, titleString="pySIM", defaultValue='', style=wx.OK|wx.CANCEL|wx.CENTRE, pos=wx.DefaultPosition):
        wx.TextEntryDialog.__init__(self, parent, messageString, titleString, defaultValue, style, pos)
        self.SetBackgroundColour(backgroundColour)


################################################################################
#                           pySIM dialog helper classes                        #
################################################################################
项目:tindieorderprintout    作者:limpkin    | 项目源码 | 文件源码
def edit_text(self):
        "Allow text edition (i.e. for doubleclick)"
        dlg = wx.TextEntryDialog(
            self.frame, 'Text for %s' % self.name,
            'Edit Text', '')
        if self.text:
            dlg.SetValue(self.text)
        if dlg.ShowModal() == wx.ID_OK:
            self.text = dlg.GetValue().encode("latin1")
        dlg.Destroy()
项目:tindieorderprintout    作者:limpkin    | 项目源码 | 文件源码
def do_find(self, evt):
        # busco nombre o texto
        dlg = wx.TextEntryDialog(
            self, 'Enter text to search for',
            'Find Text', '')
        if dlg.ShowModal() == wx.ID_OK:
            txt = dlg.GetValue().encode("latin1").lower()
            for element in self.elements:
                if txt in element:
                    element.selected = True
                    print "Found:", element.name
            self.canvas.Refresh(False)
        dlg.Destroy()
项目:mobileinsight-core    作者:mobile-insight    | 项目源码 | 文件源码
def OnSearch(self, e):
        search_dlg = wx.TextEntryDialog(
            self, "Search for", "", "", style=wx.OK | wx.CANCEL)
        if (search_dlg.ShowModal() == wx.ID_OK):
            keyword = search_dlg.GetValue()
            self.data_view = [
                x for x in self.data_view if keyword in x["Payload"]]
            self.SetupGrid()
        search_dlg.Destroy()
项目:Supplicant    作者:mayuko2012    | 项目源码 | 文件源码
def OnSet(self,event):
        windows=wx.TextEntryDialog(None, "host",u'????', '210.45.194.10')
        windows.Show()
        if windows.ShowModal() == wx.ID_OK:
            response = windows.GetValue()
        else:
            response = windows.GetValue()
        windows.Destroy()
项目:pinder    作者:dhharris    | 项目源码 | 文件源码
def onChangeLoc(self, event):
        '''
        Change location
        '''
        loc_set = False
        while not loc_set:
            dlg = wx.TextEntryDialog(self.frame, 'Please enter a location', 'Current location: ' + self.location)
            if dlg.ShowModal() == wx.ID_OK:
                # do something here
                loc = str(dlg.GetValue())
            else:
                # handle dialog being cancelled or ended by some other button
                loc = None

            dlg.Destroy()

            geolocator = Nominatim()
            # Look up location given
            try:
                l = geolocator.geocode(loc, exactly_one=True)
                self.latlon = (l.latitude, l.longitude)
                self.location = loc
                loc_set = True

            except Exception as e:
                print('Error setting location\n' + str(e))
        self.session.update_location(self.latlon[0], self.latlon[1])
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, message, caption="Please enter text", defaultValue="",
                 style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
        wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)

        self.PouNames = []

        self.Bind(wx.EVT_BUTTON, self.OnOK,
                  self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton())
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, iec_type, defaultValue=""):
        wx.TextEntryDialog.__init__(
            self, parent,
            message=_("Forcing Variable Value"),
            caption=_("Please enter value for a \"%s\" variable:") % iec_type,
            defaultValue=defaultValue,
            style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition)

        self.IEC_Type = iec_type

        self.Bind(wx.EVT_BUTTON, self.OnOK,
                  self.GetSizer().GetItem(2).GetSizer().GetItem(1).
                  GetSizer().GetAffirmativeButton())
        self.ValueTextCtrl = self.GetSizer().GetItem(1).GetWindow()
        if self.IEC_Type == "BOOL":
            self.ToggleButton = wx.ToggleButton(self, label=_("Toggle value"))
            value = GetTypeValue[self.IEC_Type](defaultValue)
            if value is not None:
                self.ToggleButton.SetValue(value)

            border = self.GetSizer().GetItem(1).GetBorder()
            self.GetSizer().Insert(before=2, item=self.ToggleButton,
                                   border=border,
                                   flag=wx.LEFT | wx.RIGHT | wx.EXPAND)
            self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleBoolValue, self.ToggleButton)

        self.Fit()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GetValue(self):
        return GetTypeValue[self.IEC_Type](wx.TextEntryDialog.GetValue(self))
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, message, caption="Please enter text", defaultValue="",
                 style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
        wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)

        self.PouNames = []
        self.Variables = []
        self.StepNames = []

        self.Bind(wx.EVT_BUTTON, self.OnOK,
                  self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton())
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def __init__(self, parent, message, caption=_("Please enter text"), defaultValue="",
                         style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
                wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)

                self.Tests = []
                if wx.VERSION >= (2, 8, 0):
                    self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetAffirmativeId())
                elif wx.VERSION >= (2, 6, 0):
                    self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
                else:
                    self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
项目:hachoir3    作者:vstinner    | 项目源码 | 文件源码
def ask_split(self, caption, min, max):
        # Note: we would prefer a NumberEntryDialog but this isn't currently wrapped
        # by wxPython Phoenix.
        res = None
        dlg = wx.TextEntryDialog(self.parent, 'Enter split offset:', '',
                                 caption, min, min, max)
        if dlg.ShowModal() == wx.ID_OK:
            try:
                res = int(dlg.GetValue())
            except ValueError:
                res = None
        dlg.Destroy()
        return res