本文整理汇总了Python中gi.repository.Gtk.STOCK_OPEN属性的典型用法代码示例。如果您正苦于以下问题:Python Gtk.STOCK_OPEN属性的具体用法?Python Gtk.STOCK_OPEN怎么用?Python Gtk.STOCK_OPEN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.STOCK_OPEN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_quick_open
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def run_quick_open(self):
"""
Display a dialog asking a user which file should be opened. The
value of target_path in the returned dictionary is an absolute path.
:return: A dictionary with target_uri and target_path keys representing the path chosen.
:rtype: dict
"""
self.set_action(Gtk.FileChooserAction.OPEN)
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
self.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT)
self.show_all()
response = self.run()
if response == Gtk.ResponseType.CANCEL:
return None
target_path = self.get_filename()
if not os.access(target_path, os.R_OK):
gui_utilities.show_dialog_error('Permissions Error', self.parent, 'Can not read the selected file.')
return None
target_uri = self.get_uri()
return {'target_uri': target_uri, 'target_path': target_path}
示例2: run_quick_select_directory
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def run_quick_select_directory(self):
"""
Display a dialog which asks the user to select a directory to use. The
value of target_path in the returned dictionary is an absolute path.
:return: A dictionary with target_uri and target_path keys representing the path chosen.
:rtype: dict
"""
self.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
self.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT)
self.show_all()
response = self.run()
if response == Gtk.ResponseType.CANCEL:
return None
target_uri = self.get_uri()
target_path = self.get_filename()
return {'target_uri': target_uri, 'target_path': target_path}
示例3: __select_file
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def __select_file(self, obj):
"""
Call back function to handle the open button press
"""
my_action = Gtk.FileChooserAction.SAVE
dialog = Gtk.FileChooserDialog('lxml',
action=my_action,
buttons=(Gtk.STOCK_CANCEL,
Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN,
Gtk.ResponseType.OK))
name = os.path.basename(self.entry.get_text())
dialog.set_current_name(name)
dialog.set_current_folder(self.__base_path)
dialog.present()
status = dialog.run()
if status == Gtk.ResponseType.OK:
self.set_filename(dialog.get_filename())
dialog.destroy()
示例4: on_import_click
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def on_import_click(self, widget):
fcd = Gtk.FileChooserDialog(
'Select a colorscheme', self.parent,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
filter = Gtk.FileFilter()
filter.set_name("JSON colorscheme")
filter.add_mime_type("application/json")
fcd.add_filter(filter)
response = fcd.run()
if response == Gtk.ResponseType.OK:
self.color_list = color.get_color_list(fcd.get_filename(), True)
self.render_buttons()
self.render_sample()
fcd.destroy()
示例5: __show_file_chooser
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def __show_file_chooser(self, button):
""" Tworzenie dialogu wyboru pliku obrazu
"""
dialog = Gtk.FileChooserDialog("Please choose a file", self, Gtk.FileChooserAction.OPEN, (
Gtk.STOCK_CANCEL
, Gtk.ResponseType.CANCEL
, Gtk.STOCK_OPEN
, Gtk.ResponseType.OK
))
filters = {
"application/x-cd-image": "CD/DVD image"
}
for key, val in filters.items():
filter_text = Gtk.FileFilter()
filter_text.set_name(val)
filter_text.add_mime_type(key)
dialog.add_filter(filter_text)
response = dialog.run()
if response == Gtk.ResponseType.OK:
self.path.set_text(dialog.get_filename())
elif response == Gtk.ResponseType.CANCEL:
print("Cancel clicked")
dialog.destroy()
示例6: bruter_open_user_file
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def bruter_open_user_file(self ,widget):
dialog = Gtk.FileChooserDialog("Please choose a file", None,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
file_filters.add_filter_txt(dialog)
response = dialog.run()
if response == Gtk.ResponseType.OK:
file_selected = dialog.get_filename()
self.bruter_user_wl_path.set_text(file_selected)
elif response == Gtk.ResponseType.CANCEL:
dialog.destroy()
dialog.destroy()
示例7: bruter_open_pass_file
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def bruter_open_pass_file(self ,widget):
dialog = Gtk.FileChooserDialog("Please choose a file", None,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
file_filters.add_filter_txt(dialog)
response = dialog.run()
if response == Gtk.ResponseType.OK:
file_selected = dialog.get_filename()
self.bruter_pass_wl_path.set_text(file_selected)
elif response == Gtk.ResponseType.CANCEL:
dialog.destroy()
dialog.destroy()
示例8: import_file
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def import_file(self, widget):
""" import nmap xml """
dialog = Gtk.FileChooserDialog("Please choose a file", None,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
file_filters.add_filter_nmap(dialog)
response = dialog.run()
if response == Gtk.ResponseType.OK:
file_selected = dialog.get_filename()
self.engine.import_file(file_selected)
self._sync()
elif response == Gtk.ResponseType.CANCEL:
dialog.destroy()
dialog.destroy()
示例9: select_image
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def select_image(self, button):
"""
Show a file chooser dialog and let the user to select an image.
"""
dialog = Gtk.FileChooserDialog(_('Please select an image'), self.window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
png_filter = Gtk.FileFilter()
png_filter.set_name("PNG files")
png_filter.add_mime_type("image/png")
png_filter.add_pattern("*.png")
dialog.add_filter(png_filter)
response = dialog.run()
if response == Gtk.ResponseType.OK:
self.break_config['image'] = dialog.get_filename()
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(self.break_config['image'], 16, 16, True)
self.img_break.set_from_pixbuf(pixbuf)
elif response == Gtk.ResponseType.CANCEL:
self.break_config.pop('image', None)
self.img_break.set_from_stock('gtk-missing-image', Gtk.IconSize.BUTTON)
dialog.destroy()
示例10: on_file
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def on_file(self, button):
dialog = Gtk.FileChooserDialog("Please choose a file", self,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
filter_csv = Gtk.FileFilter()
filter_csv.set_name("CSV Files")
filter_csv.add_pattern("*.csv")
dialog.add_filter(filter_csv)
response = dialog.run()
if response == Gtk.ResponseType.OK:
path = dialog.get_filename()
self.data = pd.read_csv(path)
self.verticalbox.remove(self.scrollable_treelist)
self.add_treeview()
dialog.destroy()
示例11: on_file_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def on_file_clicked(self, widget):
# dialog = Gtk.FileChooserDialog("Please choose a file", self,
# Gtk.FileChooserAction.OPEN,
# (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
# Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
# response = dialog.run()
# if response == Gtk.ResponseType.OK:
# path = dialog.get_filename()
# # self.open_file.set_label("File Selected: %s" % os.path.basename(path))
# self.data = pd.read_csv(path)
# elif response == Gtk.ResponseType.CANCEL:
# print("Cancel clicked")
# dialog.destroy()
dialog = FileDialog(self)
# dialog.show_all()
response = dialog.run()
if response == Gtk.ResponseType.OK:
self.data = dialog.data
dialog.destroy()
示例12: on_new_subtitle_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def on_new_subtitle_clicked(self):
dialog = Gtk.FileChooserDialog("Please choose a subtitle file...", self.win,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
if self.fn:
dialog.set_current_folder(os.path.dirname(self.fn))
filter_py = Gtk.FileFilter()
filter_py.set_name("Subtitles")
filter_py.add_pattern("*.srt")
filter_py.add_pattern("*.vtt")
dialog.add_filter(filter_py)
response = dialog.run()
if response == Gtk.ResponseType.OK:
print("Open clicked")
print("File selected: " + dialog.get_filename())
self.select_subtitles_file(dialog.get_filename())
elif response == Gtk.ResponseType.CANCEL:
print("Cancel clicked")
self.subtitle_combo.set_active(0)
dialog.destroy()
示例13: on_download_subtitle_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def on_download_subtitle_clicked(self):
dialog = Gtk.FileChooserDialog("Please choose a subtitle file...", self.win,
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
if self.fn:
dialog.set_current_folder(os.path.dirname(self.fn))
filter_py = Gtk.FileFilter()
filter_py.set_name("Subtitles")
filter_py.add_pattern("*.srt")
filter_py.add_pattern("*.vtt")
dialog.add_filter(filter_py)
response = dialog.run()
if response == Gtk.ResponseType.OK:
print("Open clicked")
print("File selected: " + dialog.get_filename())
self.select_subtitles_file(dialog.get_filename())
elif response == Gtk.ResponseType.CANCEL:
print("Cancel clicked")
self.subtitle_combo.set_active(0)
dialog.destroy()
示例14: show_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def show_dialog(self, importing=False):
"""
Displays FileChooserDialog with ePub file filters and returns Gtk.ResponseType and filename string
:return (response, filename):
"""
dialog = Gtk.FileChooserDialog(_("Please choose a file"), self, Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
# Always start in user dir
dialog.set_current_folder(path.expanduser("~"))
# Add filters so only .epub files show
# TODO: Filter list for all conversion supported ebooks
self.__add_filters(dialog, importing)
response = dialog.run()
filename = dialog.get_filename()
dialog.destroy()
return response, filename
示例15: on_open
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import STOCK_OPEN [as 别名]
def on_open(self, action):
chooser = Gtk.FileChooserDialog(title="Open dot File",
action=Gtk.FileChooserAction.OPEN,
buttons=(Gtk.STOCK_CANCEL,
Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN,
Gtk.ResponseType.OK))
chooser.set_default_response(Gtk.ResponseType.OK)
chooser.set_current_folder(self.last_open_dir)
filter = Gtk.FileFilter()
filter.set_name("Graphviz dot files")
filter.add_pattern("*.dot")
chooser.add_filter(filter)
filter = Gtk.FileFilter()
filter.set_name("All files")
filter.add_pattern("*")
chooser.add_filter(filter)
if chooser.run() == Gtk.ResponseType.OK:
filename = chooser.get_filename()
self.last_open_dir = chooser.get_current_folder()
chooser.destroy()
self.open_file(filename)
else:
chooser.destroy()