[wxPython] Tutorial + newbie question

Hi,

I am new to python and programming in general.

Are there any good wxPython tutorial online ?
So far I have found only those on the wxPython page, which are simple and
clear, but they are not enough.
Moreover, the documentation is C-related (not python), and I cannot
understand much of it.

However, here is my question :

Looking through some examples I found, I am trying to build a very simple
window, read some text from a file and display it in the window; here is my
code :

···

#------------------------

from wxPython.wx import *

class MyFrame(wxFrame):

    def __init__(self, parent, ID, title, text):
        wxFrame.__init__(self, parent, ID, title,
                         wxDefaultPosition, wxSize(400, 300))

        fintesto = wxTextCtrl(self, -1)
        fintesto.WriteText(text)

class MyApp(wxApp):
    def OnInit(self):

        file=open ( 'my_text.txt','r')
        text=file.read()
        file.close()

        frame = MyFrame(NULL, -1,'', text)
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

#----------------------

I would like to :
- Add a vertical scroll bar
- Wrap the text in the screen
- Avoid printing 'tab' characters etc.

Any help ?

Thanks in advance,

Fabrizio C.

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

Fabrizio,

No, I don't think there are any good wxPython tutorials out there, but I get
a lot of help from the wxPython demo source code. Here is your code slightly
modified with an example from the wxTextCtrl demo. I think it does what you
want.

from wxPython.wx import *

class MyFrame(wxFrame):

    def __init__(self, parent, ID, title, text):
        wxFrame.__init__(self, parent, ID, title,
                         wxDefaultPosition, wxSize(400, 300))

        fintesto = wxTextCtrl(self, 30, text, wxPoint(80, 75), wxSize(200,
150), wxTE_MULTILINE)

class MyApp(wxApp):
    def OnInit(self):

        file=open ( 'my_text.txt','r')
        text=file.read()
        file.close()

        frame = MyFrame(NULL, -1,'', text)
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

···

----- Original Message -----
From: "Fabrizio" <facelle@tiscalinet.it>
To: <wxpython-users@lists.sourceforge.net>
Sent: Sunday, January 21, 2001 6:51 AM
Subject: [wxPython] Tutorial + newbie question

Hi,

I am new to python and programming in general.

Are there any good wxPython tutorial online ?
So far I have found only those on the wxPython page, which are simple and
clear, but they are not enough.
Moreover, the documentation is C-related (not python), and I cannot
understand much of it.

However, here is my question :

Looking through some examples I found, I am trying to build a very simple
window, read some text from a file and display it in the window; here is

my

code :

#------------------------

from wxPython.wx import *

class MyFrame(wxFrame):

    def __init__(self, parent, ID, title, text):
        wxFrame.__init__(self, parent, ID, title,
                         wxDefaultPosition, wxSize(400, 300))

        fintesto = wxTextCtrl(self, -1)
        fintesto.WriteText(text)

class MyApp(wxApp):
    def OnInit(self):

        file=open ( 'my_text.txt','r')
        text=file.read()
        file.close()

        frame = MyFrame(NULL, -1,'', text)
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

#----------------------

I would like to :
- Add a vertical scroll bar
- Wrap the text in the screen
- Avoid printing 'tab' characters etc.

Any help ?

Thanks in advance,

Fabrizio C.

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

I agree, it would be nice to have a guide to reading wxWindows documentation
for non-C++ programmers. I'll probably do it if noone gets around to it by
March. It would probably be less than a page.

By far the best tutorial resource for wxPython programming is the wxPython
Demo program. Use it.

Here are a couple hints for reading C++ documentation:
C++:

wxWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos =
wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const
wxString& name = wxPanelNameStr)

Python:

wxWindow(parent, id, pos = wxDefaultPosition, size = wxDefaultSize, style =
0, name = wxPanelNameStr)

In other words, ignore type specifications (or think of them as obscure
clues to the type that the python function expects). Also ignore any
puctuation you don't recognize ("::" for example).

···

----- Original Message -----
From: "Fabrizio" <facelle@tiscalinet.it>
To: <wxpython-users@lists.sourceforge.net>
Sent: Sunday, January 21, 2001 3:51 AM
Subject: [wxPython] Tutorial + newbie question

Hi,

I am new to python and programming in general.

Are there any good wxPython tutorial online ?
So far I have found only those on the wxPython page, which are simple and
clear, but they are not enough.
Moreover, the documentation is C-related (not python), and I cannot
understand much of it.

However, here is my question :

Looking through some examples I found, I am trying to build a very simple
window, read some text from a file and display it in the window; here is

my

code :

#------------------------

from wxPython.wx import *

class MyFrame(wxFrame):

    def __init__(self, parent, ID, title, text):
        wxFrame.__init__(self, parent, ID, title,
                         wxDefaultPosition, wxSize(400, 300))

        fintesto = wxTextCtrl(self, -1)
        fintesto.WriteText(text)

class MyApp(wxApp):
    def OnInit(self):

        file=open ( 'my_text.txt','r')
        text=file.read()
        file.close()

        frame = MyFrame(NULL, -1,'', text)
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

#----------------------

I would like to :
- Add a vertical scroll bar
- Wrap the text in the screen
- Avoid printing 'tab' characters etc.

Any help ?

Thanks in advance,

Fabrizio C.

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users