本文整理匯總了Python中FileManager.FileManager.browse方法的典型用法代碼示例。如果您正苦於以下問題:Python FileManager.browse方法的具體用法?Python FileManager.browse怎麽用?Python FileManager.browse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileManager.FileManager
的用法示例。
在下文中一共展示了FileManager.browse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_window_destroy
# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import browse [as 別名]
class PicThing:
window = None
builder = None
iconview = None
filemgr = None
meta = None
libs = None
image = None
def on_window_destroy(self, widget, data=None):
gtk.main_quit()
def __init__(self):
self.builder = gtk.Builder()
self.builder.add_from_file("picthing.glade")
self.window = self.builder.get_object("window")
self.builder.connect_signals(self)
config = ConfigParser.ConfigParser()
config.read(['picthing.ini', os.path.expanduser('~/.picthing.ini')])
self.libs = config.items('libraries')
place = self.builder.get_object("place_librarypicker")
libpick = gtk.combo_box_new_text()
libpick.connect('changed',self.action_switchlibrary)
place.add(libpick)
libpick.show()
if(len(self.libs)):
for lib in self.libs:
libpick.append_text(lib[0])
libpick.set_active(0)
else:
#FIXME use some dialog here
sys.exit()
# add image canvas
self.image = ResizableImage()
self.image.show()
self.builder.get_object("picframe").add(self.image)
def action_switchlibrary(self, widget):
""" Load a new library """
library = self.libs[widget.get_active()]
print "loading library '"+library[0]+"' in '"+library[1]+"'"
self.meta = None
self.builder.get_object('notebook').set_current_page(0)
if(self.filemgr != None):
self.filemgr.index.close();
self.filemgr = FileManager(library[1])
self.iconview = self.builder.get_object("iconview")
self.iconview.set_model(self.filemgr.store)
self.iconview.set_text_column(self.filemgr.COL_TITLE)
self.iconview.set_pixbuf_column(self.filemgr.COL_PIXBUF)
self.iconview.set_tooltip_column(self.filemgr.COL_PATH)
self.new_query('')
self.filemgr.index.tagcloud()
def action_search(self,widget):
querybox = self.builder.get_object("querybox")
self.set_status("Searching...")
query = querybox.get_text()
query = query.strip()
m = re.search('^folder:("([^"]*)")?$',query)
try:
if(m):
query = m.group(2);
self.filemgr.browse(query)
elif(query == ''):
self.filemgr.browse(query)
else:
self.filemgr.search(query)
self.set_status("okay")
except ParseException:
self.set_status("Couldn't parse query")
except KeyError:
self.set_status("Wrong field name")
except NoDirException:
self.set_status("No such directory")
self.builder.get_object('notebook').set_current_page(0)
def action_iconclick(self,widget,item):
model = widget.get_model()
path = model[item][self.filemgr.COL_PATH]
ftype = model[item][self.filemgr.COL_TYPE]
if(ftype == 'dir'):
if(path):
self.new_query('folder:"'+path+'"')
else:
#.........這裏部分代碼省略.........