当前位置: 首页>>代码示例>>Python>>正文


Python Gtk.FileChooserDialog方法代码示例

本文整理汇总了Python中gi.repository.Gtk.FileChooserDialog方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.FileChooserDialog方法的具体用法?Python Gtk.FileChooserDialog怎么用?Python Gtk.FileChooserDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gtk的用法示例。


在下文中一共展示了Gtk.FileChooserDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_choose_other_location_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [as 别名]
def on_choose_other_location_clicked(self, widget):
        win = FileChooserDialog()
        win.on_folder_clicked()
        app.obj("act_othloc").set_text(win.selectedfolder)
        app.obj("dir_content_info").set_text(cli.card_content(win.selectedfolder))
        if cli.abs_size == 0:
            app.obj("import_other").set_sensitive(False)
            cli.show_message(_("No files here to import..."))
        elif cli.freespace(win.selectedfolder, cli.stdir):
            app.obj("import_other").set_sensitive(True)
            cli.cardpath = win.selectedfolder
        else:
            app.obj("import_other").set_sensitive(False)
            app.obj("nospace_info").set_text(
                _("Not enough disc space.\nFree at least {}.").format(cli.needspace))

    # treeview table 
开发者ID:encarsia,项目名称:gpt,代码行数:19,代码来源:modules.py

示例2: on_folder_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [as 别名]
def on_folder_clicked(self):
        Gtk.Window.__init__(self, title=_("Change working directory"))
        dialog = Gtk.FileChooserDialog(_("Choose directory"),
                                       self,
                                       Gtk.FileChooserAction.SELECT_FOLDER,
                                       (Gtk.STOCK_CANCEL,
                                        Gtk.ResponseType.CANCEL,
                                        _("Apply"),
                                        Gtk.ResponseType.OK,
                                        )
                                       )
        dialog.set_default_size(800, 400)
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            self.selectedfolder = dialog.get_filename()
        elif response == Gtk.ResponseType.CANCEL:
            self.selectedfolder = cli.stdir

        dialog.destroy() 
开发者ID:encarsia,项目名称:gpt,代码行数:21,代码来源:modules.py

示例3: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [as 别名]
def __init__(self, canvas, window):
        """
        figManager is the FigureManagerGTK3 instance that contains the
        toolbar, with attributes figure, window and drawingArea

        """
        GObject.GObject.__init__(self)

        self.canvas = canvas
        # Note: Gtk.Toolbar already has a 'window' attribute
        self.win    = window

        self.set_style(Gtk.ToolbarStyle.ICONS)

        self._create_toolitems()
        self.update = self._update
        self.fileselect = FileChooserDialog(
            title='Save the figure',
            parent=self.win,
            filetypes=self.canvas.get_supported_filetypes(),
            default_filetype=self.canvas.get_default_filetype())
        self.show_all()
        self.update() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:backend_gtk3.py

示例4: __select_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:gramps-project,项目名称:addons-source,代码行数:24,代码来源:lxmlGramplet.py

示例5: on_import_click

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:deviantfero,项目名称:wpgtk,代码行数:20,代码来源:color_grid.py

示例6: __show_file_chooser

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:Mati365,项目名称:pyWinUSB,代码行数:27,代码来源:window.py

示例7: bruter_open_user_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:r3vn,项目名称:badKarma,代码行数:18,代码来源:bruter.py

示例8: bruter_open_pass_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:r3vn,项目名称:badKarma,代码行数:18,代码来源:bruter.py

示例9: save_file_as

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [as 别名]
def save_file_as(self, widget):
		""" save the project's sqlite database """

		dialog = Gtk.FileChooserDialog("Please choose a filename", None,
			Gtk.FileChooserAction.SAVE,
			(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
			 Gtk.STOCK_SAVE, Gtk.ResponseType.OK))


		dialog.set_filename("project")
		file_filters.add_filter_database(dialog)

		response = dialog.run()
		if response == Gtk.ResponseType.OK:
			file_selected = dialog.get_filename()
			try:
				shutil.copy(self.engine.database.db_loc, file_selected)
			except: pass
			
		elif response == Gtk.ResponseType.CANCEL:
			dialog.destroy()

		dialog.destroy() 
开发者ID:r3vn,项目名称:badKarma,代码行数:25,代码来源:main.py

示例10: file_chooser_save_action

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [as 别名]
def file_chooser_save_action(self, on_success):
        """
        Opens the file chooser and runs on_success upon completion of valid file choice.

        :param on_success: A function to run upon selection of a filename. Takes 2
            parameters: The instance of the application (App) and the chosen filename. This
            gets run immediately in the same thread.
        :return: None
        """
        dialog = Gtk.FileChooserDialog("Save file", self.window,
                                       Gtk.FileChooserAction.SAVE,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                        Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
        dialog.set_current_name("Untitled")
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            filename = dialog.get_filename()
            dialog.destroy()
            on_success(self, filename)
        elif response == Gtk.ResponseType.CANCEL:
            self.info("Save cancelled.")  # print("Cancel clicked")
            dialog.destroy() 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:24,代码来源:FlatCAMApp.py

示例11: select_image

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:slgobinath,项目名称:SafeEyes,代码行数:24,代码来源:settings_dialog.py

示例12: exportToCSV

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [as 别名]
def exportToCSV(self, sender):
        report = self.createReport(False)
        if report == None:
            return

        content = ""
        for key in report["heading"]:
            content += key.replace(",", "") + ","
        content += "\n"

        for data in report["data"]:
            for item in data:
                content += item.replace(",", "") + ","
            content += "\n"

        dialog = Gtk.FileChooserDialog(None, self.window, Gtk.FileChooserAction.SAVE, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                                                                                       Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT))
        res = dialog.run()
        if res == Gtk.ResponseType.ACCEPT:
            filename = os.path.splitext(dialog.get_filename())[0]
            file = open(filename + ".csv", "w")
            file.write(content)
            file.close()
        dialog.destroy() 
开发者ID:Jooyeshgar,项目名称:amir,代码行数:26,代码来源:docreport.py

示例13: exportToCSV

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [as 别名]
def exportToCSV(self, sender):
        report = self.createReport()
        if report == None:
            return

        content = ""
        for key in report["heading"]:
            content += key.replace(",", "") + ","
        content += "\n"

        for data in report["data"]:
            for item in data:
                content += item.replace(",", "") + ","
            content += "\n"

        dialog = Gtk.FileChooserDialog(None, self.window, Gtk.FileChooserAction.SAVE, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                                                                                       Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT))
        dialog.run()
        filename = os.path.splitext(dialog.get_filename())[0]
        file = open(filename + ".csv", "w")
        file.write(content)
        file.close()
        dialog.destroy() 
开发者ID:Jooyeshgar,项目名称:amir,代码行数:25,代码来源:tbalancereport.py

示例14: on_file

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:carlosqsilva,项目名称:pyspc,代码行数:21,代码来源:pyspc_gui.py

示例15: on_file_clicked

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import FileChooserDialog [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() 
开发者ID:carlosqsilva,项目名称:pyspc,代码行数:23,代码来源:pyspc_gui.py


注:本文中的gi.repository.Gtk.FileChooserDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。