GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Jul 24, 2014 3:22 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Simple gi.repository.Gio.File Question
PostPosted: Mon Feb 27, 2012 9:26 pm 
Offline

Joined: Mon Feb 27, 2012 9:17 pm
Posts: 3
Hello,

It seems very simple, but I can't open a File object:
Code:
>>> from gi.repository import Gio
>>> f = Gio.File('foo.txt')
Traceback (most recent call last):
  File "/usr/lib/gedit/plugins/pythonconsole/console.py", line 387, in __run
    exec(command, self.namespace)
  File "<string>", line 1, in <module>
TypeError: GInterface.__init__() takes exactly 0 arguments (1 given)
>>> f = Gio.File()
Traceback (most recent call last):
  File "/usr/lib/gedit/plugins/pythonconsole/console.py", line 387, in __run
    exec(command, self.namespace)
  File "<string>", line 1, in <module>

NotImplementedError: File can not be constructed
>>>


??? Sorry, but I looke around a lot for documentation/examples, and couldn't find any that work for the pygobject version. I'd appreciate some help.


Thanks & Bye,

Ami


Top
 Profile  
 
 Post subject: Re: Simple gi.repository.Gio.File Question
PostPosted: Thu Mar 01, 2012 1:02 pm 
Offline
Familiar Face

Joined: Sat Feb 04, 2012 12:41 pm
Posts: 10
Hi,
I think it is:
Code:
f = Gio.file_new_for_path("foo.txt")

I have not tried it. :)


Top
 Profile  
 
 Post subject: Re: Simple gi.repository.Gio.File Question
PostPosted: Thu Mar 01, 2012 9:59 pm 
Offline

Joined: Mon Feb 27, 2012 9:17 pm
Posts: 3
Thanks! Following your reply, I checked, and it seems there are indeed "Classwise factory methods" for creating these objects.
Code:
File.parse_name
seems to do the job. Again, thanks. Much appreciated.


Top
 Profile  
 
 Post subject: Re: Simple gi.repository.Gio.File Question
PostPosted: Fri Mar 02, 2012 11:35 am 
Offline
Familiar Face

Joined: Sat Feb 04, 2012 12:41 pm
Posts: 10
Glad i could be of help :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group