Exemplo n.º 1
0
    def import_menu(self):
        folder = PluginFolder("plugins.import")

        menu = GUI.Menu(self.gui_window)
        for module_name in folder.enumerate():
            # what happends on_click
            def on_click():
                try:
                    import_plugin = folder.load(module_name)

                    # start plugin, give it access to the record codec
                    def create_output_file():
                        file_name = tkinter.simpledialog.askstring(
                            "Save As", "choose file name:")
                        if file_name == "":
                            raise Exception("user cancelled")
                        #return record_codec.StreamEncoder(open("../records/{}.pgrecord".format(file_name), "wb"));

                    import_plugin.start(create_output_file)
                except Exception as e:
                    # user cancelled or serious error
                    GUI.messagebox.showwarning("Error", str(e))

            menu.add_command(label=module_name, command=on_click)

        # popup menu
        menu.post(
            self.button_export.winfo_rootx(),
            self.button_export.winfo_rooty() +
            self.button_export.winfo_height())
Exemplo n.º 2
0
	def export_image_menu(self):
		if self.codec is None:
			return

		folder = PluginFolder("plugins.export_image")

		# create menu
		menu = GUI.Menu(self.gui_window)
		for module_name in folder.enumerate():
			# what happends on_click
			def on_click():
				try:
					export_plugin = folder.load(module_name)
					imp.reload(export_plugin)

					# suggest a filename and initial directory. let's hope the plugin uses these values
					default_filename = os.path.basename(self.codec.byte_stream.name)
					if default_filename.endswith(".pgrecord"):
						default_filename = default_filename[:-9]
					default_folder = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../exports")

					pdf_canvas = export_plugin.ExporterCanvas(self.gui_window, default_filename, default_folder)
					self.plot.render(pdf_canvas, Point(0, 0), Point(self.canvas_widget.width, self.canvas_widget.height))
				except Exception as e:
					# user cancelled or serious error
					GUI.messagebox.showwarning("Error", str(traceback.format_exc()))
			menu.add_command(label=module_name, command=on_click)

		# popup menu
		menu.post(self.button_export_image.winfo_rootx(), self.button_export_image.winfo_rooty() + self.button_export_image.winfo_height())
Exemplo n.º 3
0
	def export_menu(self):
		if self.codec is None:
			return

		folder = PluginFolder("plugins.export")

		menu = GUI.Menu(self.gui_window)
		for module_name in folder.enumerate():
			# what happends on_click
			def on_click():
				try:
					export_plugin = folder.load(module_name)

					# suggest a filename and initial directory. let's hope the plugin uses these values
					default_filename = os.path.basename(self.codec.byte_stream.name)
					if default_filename.endswith(".pgrecord"):
						default_filename = default_filename[:-9]
					default_folder = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../exports")

					self.codec.goto_sample_index(0)
					export_plugin.export(self.codec, lambda: dialogs.ProgressDialog(self.gui_window, "asdf"))
				except Exception as e:
					# user cancelled or serious error
					GUI.messagebox.showwarning("Error", str(e))
			menu.add_command(label=module_name, command=on_click)

		# popup menu
		menu.post(self.button_export.winfo_rootx(), self.button_export.winfo_rooty() + self.button_export.winfo_height())
Exemplo n.º 4
0
    def export_image_menu(self):
        if self.codec is None:
            return

        folder = PluginFolder("plugins.export_image")

        # create menu
        menu = GUI.Menu(self.gui_window)
        for module_name in folder.enumerate():
            # what happends on_click
            def on_click():
                try:
                    export_plugin = folder.load(module_name)
                    imp.reload(export_plugin)

                    # suggest a filename and initial directory. let's hope the plugin uses these values
                    default_filename = os.path.basename(
                        self.codec.byte_stream.name)
                    if default_filename.endswith(".pgrecord"):
                        default_filename = default_filename[:-9]
                    default_folder = os.path.abspath(
                        os.path.dirname(os.path.realpath(__file__)) +
                        "/../exports")

                    pdf_canvas = export_plugin.ExporterCanvas(
                        self.gui_window, default_filename, default_folder)
                    self.plot.render(
                        pdf_canvas, Point(0, 0),
                        Point(self.canvas_widget.width,
                              self.canvas_widget.height))
                except Exception as e:
                    # user cancelled or serious error
                    GUI.messagebox.showwarning("Error",
                                               str(traceback.format_exc()))

            menu.add_command(label=module_name, command=on_click)

        # popup menu
        menu.post(
            self.button_export_image.winfo_rootx(),
            self.button_export_image.winfo_rooty() +
            self.button_export_image.winfo_height())
Exemplo n.º 5
0
    def export_menu(self):
        if self.codec is None:
            return

        folder = PluginFolder("plugins.export")

        menu = GUI.Menu(self.gui_window)
        for module_name in folder.enumerate():
            # what happends on_click
            def on_click():
                try:
                    export_plugin = folder.load(module_name)

                    # suggest a filename and initial directory. let's hope the plugin uses these values
                    default_filename = os.path.basename(
                        self.codec.byte_stream.name)
                    if default_filename.endswith(".pgrecord"):
                        default_filename = default_filename[:-9]
                    default_folder = os.path.abspath(
                        os.path.dirname(os.path.realpath(__file__)) +
                        "/../exports")

                    self.codec.goto_sample_index(0)
                    export_plugin.export(
                        self.codec, lambda: dialogs.ProgressDialog(
                            self.gui_window, "asdf"))
                except Exception as e:
                    # user cancelled or serious error
                    GUI.messagebox.showwarning("Error", str(e))

            menu.add_command(label=module_name, command=on_click)

        # popup menu
        menu.post(
            self.button_export.winfo_rootx(),
            self.button_export.winfo_rooty() +
            self.button_export.winfo_height())
Exemplo n.º 6
0
	def import_menu(self):
		folder = PluginFolder("plugins.import")

		menu = GUI.Menu(self.gui_window)
		for module_name in folder.enumerate():
			# what happends on_click
			def on_click():
				try:
					import_plugin = folder.load(module_name)

					# start plugin, give it access to the record codec
					def create_output_file():
						file_name = tkinter.simpledialog.askstring("Save As", "choose file name:")
						if file_name == "":
							raise Exception("user cancelled")
						#return record_codec.StreamEncoder(open("../records/{}.pgrecord".format(file_name), "wb"));
					import_plugin.start(create_output_file)
				except Exception as e:
					# user cancelled or serious error
					GUI.messagebox.showwarning("Error", str(e))
			menu.add_command(label=module_name, command=on_click)

		# popup menu
		menu.post(self.button_export.winfo_rootx(), self.button_export.winfo_rooty() + self.button_export.winfo_height())