wxFile existence?

Hi all,

I wanted to do some thing with files, so I searched wxWindows documentation
and found wxFile class. So far everything is good. When I tried to build an
instance of this class in wxPython I got an error message: "global name
'wxFile' is not defined". I thought that maybe I need to import some module
in order to make it work,
so I searched wxPython directory and still found nothing related. Is this
class exists in wxPython or it exists only in wxWindows?

Thanks in advance,
Ilia Kats

I wrote:

Hi all,

I wanted to do some thing with files, so I searched wxWindows

documentation

and found wxFile class. So far everything is good. When I tried to build

an

instance of this class in wxPython I got an error message: "global name
'wxFile' is not defined". I thought that maybe I need to import some

module

in order to make it work,
so I searched wxPython directory and still found nothing related. Is this
class exists in wxPython or it exists only in wxWindows?

What about an answer Rubin?

Thanks in advance,
Ilia Kats

A number of wxWindows classes are not wrapped in wxPython,
because they (more or less) duplicate existing Python
functionality.

In this case, Python has a capable file object...
* Opened by
       fileref = open( filename [, mode] )
    where mode is 'r' (read), 'w' (write), or 'a' (append),
    with optional '+' to indicate update operation. E.g.,
       fileref = open( filename, 'r+' )
    opens an existing file for updating.
* Closed by
       fileref.close()
* Use fileref.read, fileref.readln, or fileref.readlines to read.
* Use fileref.write or fileref.writelines to write.
* Use fileref.tell and fileref.seek to deal with file position.
See your favorite Python reference for details.

After a brief look at the wxFile description, it would be
a simple matter to duplicate wxFile in pure Python (as a
wrapper for the file object), with the possible exception
of the attach/detach methods.

HTH.

- Sam

···

At 2003-05-26 08:32 AM +0200, you wrote:

I wrote:
>
> Hi all,
>
> I wanted to do some thing with files, so I searched wxWindows
documentation
> and found wxFile class. So far everything is good. When I tried to build
an
> instance of this class in wxPython I got an error message: "global name
> 'wxFile' is not defined". I thought that maybe I need to import some
module
> in order to make it work,
> so I searched wxPython directory and still found nothing related. Is this
> class exists in wxPython or it exists only in wxWindows?

>
> I wanted to do some thing with files, so I searched wxWindows
documentation
> and found wxFile class. So far everything is good. When I tried to build
an
> instance of this class in wxPython I got an error message: "global name
> 'wxFile' is not defined". I thought that maybe I need to import some
module
> in order to make it work,
> so I searched wxPython directory and still found nothing related. Is

this

> class exists in wxPython or it exists only in wxWindows?

File operations are done with Python itself. You can download the latest
documentation from Our Documentation | Python.org

Basically, there is an "open" keyword with C++ style parameters and the file
object has C++ style methods.

I hope this is what you were asking about.
-Rick King

Hi all,

(Sorry if this question has already been asked here, I am quite new to
wxPython and to this mailing-list too)

So I am trying to use a wxListCtrl... and I am wondering:
what is the label in InsertStringItem(index, label) used for ?

   Thanks for your answers.

Stephane Ninin
stephane@parasoft.com.pl

  Hi all,

(Sorry if this question has already been asked here, I am quite new to
wxPython and to this mailing-list too)

So I am trying to use a wxListCtrl... and I am wondering:
what is the label in InsertStringItem(index, label) used for ?

The text that will be displayed in the first column (col index 0)

If you have more than one column, you will set other columns text with

SetStringItem(index, col, label, imageId)

-philippe

> So I am trying to use a wxListCtrl... and I am wondering:
> what is the label in InsertStringItem(index, label) used for ?

The text that will be displayed in the first column (col index 0)

If you have more than one column, you will set other columns text with

SetStringItem(index, col, label, imageId)

This is my test file:

from wxPython.wx import *
class MainFrame(wxFrame):
    def __init__(self,parent,ID,title):
        wxFrame.__init__(self,parent,ID,title)
        self.__listbox = wxListCtrl(self, -1, style=wxLC_REPORT)
        self.__listbox.InsertColumn(0, 'Subject')
        self.__listbox.InsertColumn(1, 'Name')

        for i in range(10):
            self.__listbox.InsertStringItem(i, 'what is this label for ? ');
            self.__listbox.SetStringItem(i, 0, str(i))
            self.__listbox.SetStringItem(i, 1, "hop")
        self.__listbox.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)
        self.__listbox.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER)

class MyApp(wxApp):
    def OnInit(self):
        frame = MainFrame(NULL,-1,'Test')
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

What I get is two columns, one labeled 'Subject', the other 'Name',
but this 'what is this label for ? ' doesnot appear anywhere on the list
control.

Well, it works fine for me this way, I can do what I want, I am just
curious.
How should I write this bit of code if I wanted to use this label in
InsertStringItem
somewhere ?

   Stephane

Hi,

That's because you overwrite it with the first SetStringItem(i,0,
str(i)) command.
(this command does the same as the InsertStringItem )

Remove that and you will get the label string.

/Rob

Stephane Ninin wrote:

···

> > So I am trying to use a wxListCtrl... and I am wondering:
> > what is the label in InsertStringItem(index, label) used for ?
>
> The text that will be displayed in the first column (col index 0)
>
> If you have more than one column, you will set other columns text with
>
> SetStringItem(index, col, label, imageId)

This is my test file:

from wxPython.wx import *
class MainFrame(wxFrame):
    def __init__(self,parent,ID,title):
        wxFrame.__init__(self,parent,ID,title)
        self.__listbox = wxListCtrl(self, -1, style=wxLC_REPORT)
        self.__listbox.InsertColumn(0, 'Subject')
        self.__listbox.InsertColumn(1, 'Name')

        for i in range(10):
            self.__listbox.InsertStringItem(i, 'what is this label for ? ');
            self.__listbox.SetStringItem(i, 0, str(i))
            self.__listbox.SetStringItem(i, 1, "hop")
        self.__listbox.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER)
        self.__listbox.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER)

class MyApp(wxApp):
    def OnInit(self):
        frame = MainFrame(NULL,-1,'Test')
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

What I get is two columns, one labeled 'Subject', the other 'Name',
but this 'what is this label for ? ' doesnot appear anywhere on the list
control.

Well, it works fine for me this way, I can do what I want, I am just
curious.
How should I write this bit of code if I wanted to use this label in
InsertStringItem
somewhere ?

   Stephane

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

--
/----------------------------------------------------------\

Rob Schmersel |
System Architect |
                                                         >
Enea data |
Nytorpsvägen 5B | Tel: +46(0)8-50714314 |
Box 232 | Mob: +46(0)709-714314 |
SE-183 23 Täby, Sweden | Fax: +46(0)8-50714040 |

\----------------------------------------------------------/

That's because you overwrite it with the first SetStringItem(i,0,
str(i)) command.
(this command does the same as the InsertStringItem )

Remove that and you will get the label string.

I am stup....

  Thanks.

  Stephane

> > So I am trying to use a wxListCtrl... and I am wondering:
> > what is the label in InsertStringItem(index, label) used for ?
>
> The text that will be displayed in the first column (col index 0)
>
> If you have more than one column, you will set other columns text with
>
> SetStringItem(index, col, label, imageId)

This is my test file:

from wxPython.wx import *
class MainFrame(wxFrame):
    def __init__(self,parent,ID,title):
        wxFrame.__init__(self,parent,ID,title)
        self.__listbox = wxListCtrl(self, -1, style=wxLC_REPORT)
        self.__listbox.InsertColumn(0, 'Subject')
        self.__listbox.InsertColumn(1, 'Name')

        for i in range(10):
            self.__listbox.InsertStringItem(i, 'what is this label for ? ');
            self.__listbox.SetStringItem(i, 0, str(i))

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Comment this line if you want to see what the 'label' string produce

-philippe

Ilia Kats wrote:

Hi all,

I wanted to do some thing with files, so I searched wxWindows documentation
and found wxFile class. So far everything is good. When I tried to build an
instance of this class in wxPython I got an error message: "global name
'wxFile' is not defined". I thought that maybe I need to import some module
in order to make it work,
so I searched wxPython directory and still found nothing related. Is this
class exists in wxPython or it exists only in wxWindows?

No, it isn't wrapped.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!