here is a thing, i'm beginner at wxPython ant Pyhton too. I have written small program here is a example:

import wx
import urllib2
import re

class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, -1, title, size=(600,400))
        self.areaa = wx.TextCtrl(self.panel, pos=(0,10), size=(400, 20))
        self.area = wx.TextCtrl(self.panel, style = wx.MULTIPLE, pos=(0,50), size=(400,250))
        self.pirmas=wx.Button(self.panel, label="Parodyk", pos=(420, 10), size=(100,20))
        self.Bind(wx.EVT_BUTTON, self.aaa, self.pirmas)

    def aaa (self, event):
        response = urllib2.urlopen(self.areaa)
        html = response.read()
        failas = open("failas.txt", 'w')

        failas = open("failas.txt", 'r')
        regex = re.compile ('http://someurl.*?<')
        for line in failas:
            g = regex.findall(line)
            for word in g:
                print (word)[:-1]

app = wx.PySimpleApp()
frm = MyFrame(None, "Simple Program")

programs starts fine, but then i input something in areaa box i get this error message

Traceback (most recent call last):
  File "C:\Python27\11.py", line 19, in aaa
    response = urllib2.urlopen(self.areaa)
  File "C:\Python27\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 384, in open
    protocol = req.get_type()
AttributeError: 'TextCtrl' object has no attribute 'get_type'

What should i change about program to work. I need to input url address and then program grabs it's html and so on..
one more question, how to show the results in area box (that list of links)?

P.S on what highest python version wxpython works?

Thank You.

5 Years
Discussion Span
Last Post by snippsat

shouldn't it be

response = urllib2.urlopen(self.areaa.GetValue())

urlopen does not know anything about wx.TextCtrl widgets.

Check your naming of things and using of empty lines.

You should also let wx handle the suitable size of widgets and not use absolute positioning and sizing (sizers).

Edited by pyTony: n/a


Thanks, working good! Yea i know i need to learn those sizers. :) I just experimenting so its a bit messy, sorry :)

P.S maybe someone know anything about other questions?


P.S on what highest python version wxpython works?

2.7 wxpython Roadmap

Just a note dont use findall() in a loop.
findall() iterate through all text it`s given.

g = regex.findall(regex, failas.read())

If you shall iterate through to text,use finditer()

for line in failas:
    for match in regex.finditer(line):
        print (match.group())[:-1]

And print in GUI is most for troubelshoothing.
You wirte to a label text,texbox ...

Edited by snippsat: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.