本文整理匯總了Python中gtk.ListStore.get_iter方法的典型用法代碼示例。如果您正苦於以下問題:Python ListStore.get_iter方法的具體用法?Python ListStore.get_iter怎麽用?Python ListStore.get_iter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.get_iter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: InputWidget
# 需要導入模塊: from gtk import ListStore [as 別名]
# 或者: from gtk.ListStore import get_iter [as 別名]
#.........這裏部分代碼省略.........
def add_picture_cb(self, widget):
"""Show image selection dialog."""
self.main_widget().soundplayer.stop()
self.liststore.clear()
self.imagedir = self.conf['imagedir']
if not os.path.exists(self.imagedir):
self.imagedir = "./images" # on Desktop
if not os.path.exists(self.imagedir):
self.main_widget().information_box(\
_("'Images' directory does not exist!"))
return
if os.listdir(self.imagedir):
self.widgets["MediaDialog"].show()
for fname in os.listdir(self.imagedir):
if os.path.isfile(os.path.join(self.imagedir, fname)):
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(\
os.path.join(self.imagedir, fname), 100, 100)
self.liststore.append(["", "img", fname, \
self.imagedir, pixbuf])
else:
self.main_widget().information_box(\
_("There are no files in 'Images' directory!"))
def select_item_cb(self, widget):
"""
Set html-text with media path and type when user
select media filefrom media selection dialog.
"""
self.widgets["MediaDialog"].hide()
item_index = self.w_tree.get_widget("iconview_widget"). \
get_selected_items()[0]
item_type = self.liststore.get_value( \
self.liststore.get_iter(item_index), 1)
item_fname = self.liststore.get_value( \
self.liststore.get_iter(item_index), 2)
item_dirname = self.liststore.get_value( \
self.liststore.get_iter(item_index), 3)
question_text = """<%s src="%s">""" % \
(item_type, os.path.abspath(os.path.join(item_dirname, item_fname)))
self.areas["question"].get_buffer().set_text(question_text)
self.show_snd_container()
def add_sound_cb(self, widget):
"""Show sound selection dialog."""
self.main_widget().soundplayer.stop()
self.liststore.clear()
self.sounddir = self.conf['sounddir']
if not os.path.exists(self.sounddir):
self.sounddir = "./sounds" # on Desktop
if not os.path.exists(self.sounddir):
self.main_widget().information_box(\
_("'Sounds' directory does not exist!"))
return
if os.listdir(self.sounddir):
self.widgets["MediaDialog"].show()
for fname in os.listdir(self.sounddir):
if os.path.isfile(os.path.join(self.sounddir, fname)):
sound_logo_file = os.path.join( \
self.conf["theme_path"], "soundlogo.png")
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(\
sound_logo_file, 100, 100)
self.liststore.append([fname, "sound", fname, \
self.sounddir, pixbuf])
else: