Exemple #1
0
 def _open(self):
     filename = tkFile.askopenfilename()
     if os.path.exists(filename):
         self.set(filename)
         return filename
     else:
         return ''
Exemple #2
0
    def command(self):
        file = filedialog.askopenfilename()

        if file is None:
            return

        self.var.set(file)
Exemple #3
0
 def _upload_button_clicked(self, *args):
     name = tkfiledialog.askopenfilename(
         filetypes=(("Image Stores", "metadata.yaml"),
                    ("Videos",
                     "*.mp4 *.MP4 *.mpg *.mpeg *.MPG *.MPEG *.avi *.AVI")))
     if name and os.path.isfile(name):
         self.start_upload(name)
Exemple #4
0
    def _loadFromFile(self):
        """
      Load state from a pickle file.
    """
        import pickle
        import six.moves.tkinter_tkfiledialog as tkFileDialog
        pfe = self._pickleFileExtension()
        fn = tkFileDialog.askopenfilename(defaultextension=pfe, title="Load from pickle file", \
                                          filetypes=[("pickle files", "*"+pfe)])
        state = pickle.load(self._fileOpenMethod()(fn))

        class Event:
            def __init__(self, xd, yd, inax):
                self.button = 2
                self.inaxes = inax
                self.xdata = xd
                self.ydata = yd

        for p in state["points"]:
            e = Event(p[0], p[1], self.a)
            self._mouseButtonClicked(e)

        self.splineSelectBox.select_clear(0, len(self.splineOptions))
        selected = self.splineOptions.index(state["splineKind"])
        self.splineSelectBox.select_set(selected)
        self._splineSelected(None)
Exemple #5
0
 def _loadFromFile(self):
   """
     Load state from a pickle file.
   """
   import pickle
   import six.moves.tkinter_tkfiledialog as tkFileDialog
   pfe = self._pickleFileExtension()
   fn = tkFileDialog.askopenfilename(defaultextension=pfe, title="Load from pickle file", \
                                     filetypes=[("pickle files", "*"+pfe)])
   state = pickle.load(self._fileOpenMethod()(fn))
   
   class Event:
     def __init__(self, xd, yd, inax):
       self.button = 2
       self.inaxes = inax
       self.xdata = xd
       self.ydata = yd
   
   for p in state["points"]:
     e = Event(p[0], p[1], self.a)
     self._mouseButtonClicked(e)
   
   self.splineSelectBox.select_clear(0, len(self.splineOptions))
   selected = self.splineOptions.index(state["splineKind"])
   self.splineSelectBox.select_set(selected)
   self._splineSelected(None)
Exemple #6
0
 def ask_cba_file(self):
     self.dir_cba_opt = options = {}
     options['initialdir'] = Constant.FOLDER_PATH.IP_ASK_CBA
     options['defaultextension'] = '.xml'
     options['parent'] = self
     options['title'] = 'Choose Spec File'
     self.cba=askopenfilename(**self.dir_cba_opt)
     self.choose_cba_file_lbl['text']=self.cba
    def _loadimage(self):

        if self.fn is not None:
            # clear old plot
            for i in range(4):
                self._clr_plt(i)
                self.plt[i].axis("off")

        self.fn = self.sample_image.get()
        # update what is occurring text box
        self.text.insert(tk.END, "\nloading image {:s}".format(self.fn))
        self.text.see(tk.END)
        self.canvas.draw()

        if self.fn == "from file":
            self.fn = filedialog.askopenfilename()
            # read image file
            if ".txt" in self.fn:
                self.IM = np.loadtxt(self.fn)
            else:
                self.IM = plt.imread(self.fn)
        elif self.fn == "from transform":
            self.IM = self.AIM.transform
            self.AIM = None
            for i in range(1, 4):
                self._clr_plt(i)
                self.plt[i].axis("off")
            self.direction.current(0)
        else:
            self.fn = self.fn.split(' ')[-1]
            self.IM = abel.tools.analytical.SampleImage(n=1001,
                                                        name=self.fn).func
            if len(self.direction["values"]) > 1:
                self.direction.current(
                    1)  # raw images require 'forward' transform
            self.text.insert(
                tk.END, "\nsample image: (1) Abel transform 'forward',\n")
            self.text.insert(tk.END,
                             "              (2) load 'from transform',\n")
            self.text.insert(tk.END,
                             "              (3) Abel transform 'inverse',\n")
            self.text.insert(tk.END, "              (4) Speed")
            self.text.see(tk.END)

        # if even size image, make odd
        if self.IM.shape[0] % 2 == 0:
            self.IM = shift(self.IM, (-0.5, -0.5))[:-1, :-1]

        self.old_method = None
        self.AIM = None
        self.action = "file"
        self.rmin.delete(0, tk.END)
        self.rmin.insert(0, self.rmx[0])
        self.rmax.delete(0, tk.END)
        self.rmax.insert(0, self.rmx[1])

        # show the image
        self._display()
Exemple #8
0
 def file_open(self):
     """
     Implement the menu File->Open action.
     """
     filename = tkinter_tkfiledialog.askopenfilename()
     if filename:
         self.filename = filename
         # self.cubelist = iris.load(filename)
         self.master.title('irisview {}'.format(filename))
Exemple #9
0
    def __ask__(self):
        kw = {
            "title" : self.title.get(),
            "filetypes": [
                (filter_name.get(), filter) for (filter_name, filter) in \
                    self.filetypes
            ]
        }

        return askopenfilename(**kw)
Exemple #10
0
 def __getitem__(self, filename):
     if filename is self.root_node.constants.ASK_DIALOG:
         filename = askopenfilename(filetypes=[('TAR Files', ('*.tar', '*.tar.gz', '*.tgz')), ('All Files', '*.*')])
     if not filename:
         return
         
     manipulator = TarFileManipulator(filename=filename)
     object.__setattr__(manipulator, 'parent_node', self)
     manipulator.lock_attribute('parent_node')
     return manipulator
Exemple #11
0
 def support_ask_ordered_files(self, arg, **kwargs):
     if arg is self.root_node.constants.ASK_ORDERED_FILES:
         file_list = []
         while True:
             filename = askopenfilename(**kwargs)
             if filename:
                 file_list.append(filename)
                 kwargs['initialdir'] = os.path.split(filename)[0]
             if not askyesno('Continue?', 'Continue selecting files?'):
                 break
         arg = file_list
         showinfo('File List', 'The following files are selected:\n' + '\n'.join(arg))
         self._print_actual_value(self.root_node.constants.ASK_ORDERED_FILES, arg)
     return arg        
Exemple #12
0
    def file_open(self, package=False, _=None):
        """launch a file browser"""
        if not package:
            filename = askopenfilename(parent=self.root,
                                       filetypes=[('pythonfiles', '*.py'),
                                                  ('allfiles', '*')],
                                       title='Select Module')
        else:
            filename = askdirectory(title="Select A Folder", mustexist=1)

        if filename == ():
            return

        self.txt_module.delete(0, END)
        self.txt_module.insert(0, filename)
Exemple #13
0
    def file_open(self, package=False, _=None):
        """launch a file browser"""
        if not package:
            filename = askopenfilename(parent=self.root,
                                       filetypes=[('pythonfiles', '*.py'),
                                                  ('allfiles', '*')],
                                       title='Select Module')
        else:
            filename = askdirectory(title="Select A Folder", mustexist=1)

        if filename == ():
            return

        self.txt_module.delete(0, END)
        self.txt_module.insert(0, filename)
Exemple #14
0
    def _loadcuts(self, event=None):
        filetypes = [
            ('Cuts file','*.csv'),
            ('Allfiles','*'),
            ]
        if platform.system() != 'Windows':
            filetypes.append(filetypes.pop(0)) # Reorder so the all gradefiles is selected first

        root = Tk()
        root.withdraw()
        csvfile = askopenfilename(filetypes=filetypes, title='Choose a file to load cuts from')
        root.destroy()

        if csvfile:
            cuts = pd.DataFrame.from_csv(csvfile).values.flatten()
            for i in range(len(cuts)):
                self._change(i,cuts[i])
def _getfilename():
    global IM, text
    fn = filedialog.askopenfilename()

    # update what is occurring text box
    text.delete(1.0, tk.END)
    text.insert(tk.END, "reading image file {:s}\n".format(fn))
    canvas.draw()

    # read image file
    if ".txt" in fn:
        IM = np.loadtxt(fn)
    else:
        IM = imread(fn)

    if IM.shape[0] % 2 == 0:
        text.insert(tk.END, "make image odd size")
        IM = shift(IM, (-0.5, -0.5))[:-1, :-1]

    # show the image
    _display()
 def selectFile(self, **options):
     """
     Show a folder selection window for the user to import/export
     private pre-built libraries
     """
     return tkFileDialog.askopenfilename(parent=self.root, **options)
Exemple #17
0
 def support_ask_open_filename(self, arg, **kwargs):
     if arg is self.root_node.constants.ASK_OPEN_FILENAME:
         filename = askopenfilename(**kwargs)
         arg = filename
         self._print_actual_value(self.root_node.constants.ASK_OPEN_FILENAME, arg)
     return arg
Exemple #18
0
 def on_fill_from_csv_click(self, event):
     fname = filedialog.askopenfilename(filetypes=(("txt(csv)", "*.txt"), ("csv", "*.csv"), ("All files", "*.*")))
     self.controller.fill_from_csv(fname)
Exemple #19
0
 def load_dialog(self):
     self.wad_path = tkFileDialog.askopenfilename(filetypes=[('wad files', "wad")])
     self.load_wad(self.wad_path)
Exemple #20
0
 def on_database_click(self, event):
     database_name = filedialog.askopenfilename(filetypes=(("money files", "*.db"), ("All files", "*.*")))
     if database_name:
         self.initialize_db(database_name=database_name)