1 | """ |
---|
2 | File Converter Plugin |
---|
3 | """ |
---|
4 | |
---|
5 | import logging |
---|
6 | from sas.sasgui.guiframe.plugin_base import PluginBase |
---|
7 | from sas.sasgui.perspectives.file_converter.converter_panel import ConverterWindow |
---|
8 | |
---|
9 | logger = logging.getLogger(__name__) |
---|
10 | |
---|
11 | class Plugin(PluginBase): |
---|
12 | """ |
---|
13 | This class defines the interface for a Plugin class |
---|
14 | for File Converter perspective |
---|
15 | """ |
---|
16 | |
---|
17 | def __init__(self): |
---|
18 | PluginBase.__init__(self, name="File Converter") |
---|
19 | logger.info("File Converter plug-in started") |
---|
20 | self._sub_menu = "Tool" |
---|
21 | self.converter_frame = None |
---|
22 | |
---|
23 | def get_tools(self): |
---|
24 | """ |
---|
25 | Returns a set of menu entries |
---|
26 | """ |
---|
27 | help_txt = "Convert ASCII or BSL/OTOKO data to CanSAS or NXcanSAS formats" |
---|
28 | return [("File Converter", help_txt, self.on_file_converter)] |
---|
29 | |
---|
30 | def on_file_converter(self, event): |
---|
31 | if self.converter_frame is None: |
---|
32 | frame = ConverterWindow(parent=self.parent, base=self.parent, |
---|
33 | manager=self) |
---|
34 | self.put_icon(frame) |
---|
35 | self.converter_frame = frame |
---|
36 | else: |
---|
37 | self.converter_frame.Show(False) |
---|
38 | self.converter_frame.Show(True) |
---|
39 | |
---|
40 | def put_icon(self, frame): |
---|
41 | """ |
---|
42 | Put icon in the frame title bar |
---|
43 | """ |
---|
44 | if hasattr(frame, "IsIconized"): |
---|
45 | if not frame.IsIconized(): |
---|
46 | try: |
---|
47 | icon = self.parent.GetIcon() |
---|
48 | frame.SetIcon(icon) |
---|
49 | except: |
---|
50 | pass |
---|