pygtk-文件选择

filesel = gtk.FileSelection(title=None)
filesel.set_filename(filename)
filename = filesel.get_filename()

 

filesel属性:

filesel.dir_list
filesel.file_list
filesel.selection_entry
filesel.selection_text

filesel.main_vbox
filesel.ok_button
filesel.cancel_button
filesel.help_button
filesel.history_pulldown
filesel.history_menu
filesel.fileop_dialog
filesel.fileop_entry
filesel.fileop_file
filesel.fileop_c_dir
filesel.fileop_del_file
filesel.fileop_ren_file
filesel.button_area
filesel.action_area

 


 

#!/usr/bin/env python

# example filesel.py

import pygtk
pygtk.require('2.0')
import gtk

class FileSelectionExample:
 # Get the selected filename and print it to the console
	 def file_ok_sel(self, w):
		 print "%s" % self.filew.get_filename()

	 def destroy(self, widget):
		 gtk.main_quit()

	 def __init__(self):
	 # Create a new file selection widget
		 self.filew = gtk.FileSelection("File selection")

		 self.filew.connect("destroy", self.destroy)
		 # Connect the ok_button to file_ok_sel method
		 self.filew.ok_button.connect("clicked", self.file_ok_sel)

		 # Connect the cancel_button to destroy the widget
		 self.filew.cancel_button.connect("clicked",
		 lambda w: self.filew.destroy())

		 # Lets set the filename, as if this were a save dialog,
		 # and we are giving a default filename
		 self.filew.set_filename("penguin.png")

		 self.filew.show()

def main():
	 gtk.main()
	 return 0

if __name__ == "__main__":
	 FileSelectionExample()
	 main()

 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值