Ejemplo n.º 1
0
    def xgc_frame(self, parent, node):
        label = node.getAttribute('label')
        title = __(label)  # not support
        if title:
            widget = Labelframe(parent, text=label)
        else:
            widget = Frame(parent)

#        label_align = node.getAttribute('label_align')
#        if label_align:
#            widget.set_label_align(float(label_align), 0.5)

#        type = xgc_get_shadow_type(self._xgc_attr(node, 'type', 'etched_in'))
#        widget.set_shadow_type(type)
        self._xgc_container_public(widget, node)
        #self._xgc_box_public(widget, node)
        return widget
Ejemplo n.º 2
0
    def __init__(self, master, cam):
        self.cam = cam
        self.master = master
        self.frame = None
        self.canvas = None
        self.histCanvas = None
        self.video = None
        self.position = None

        ##window frame
        self.frame = tk.LabelFrame(self.master, text='Captured video')
        self.frame.pack()

        ##toolbar
        self.toolbar = tk.Frame(self.master)
        self.toolbar.configure(background='grey', borderwidth=2)
        self.toolbar.pack(side=tk.BOTTOM, padx=5, pady=5)  # ),expand=tk.YES,fill=tk.BOTH)

        ##adding buttons to toolbar
        self.button = tk.Button(self.toolbar, text="QUIT", fg="red", command=master.destroy)
        self.button.configure(background='tan')
        self.button.pack(side=tk.LEFT, padx=5, pady=5)
        ## ttk Combobox
        self.efLabel = Labelframe(self.toolbar, text="Choose an effect:")
        self.efLabel.pack(anchor=tk.W, padx=5, pady=2)
        self.efCombo = Combobox(self.efLabel, values=['none', 'erode', 'smooth', 'dilate', 'laplace', 'threshold_otsu'],
                                state='readonly')
        self.efCombo.current(0)
        self.efCombo.bind('<FocusIn>', self._update_values)
        self.efCombo.pack(anchor=tk.NW, padx=5, pady=5)

        ##fps

        ## for using of command binding see: 'Thinkink in Tkinter' tt077.py
        self.camon = tk.Button(self.toolbar, text="CAM on", fg="darkgreen", command=lambda: self.video.setOnoff(True))
        self.camon.configure(background='tan')
        self.camon.pack(side=tk.LEFT, padx=5, pady=5)

        self.camoff = tk.Button(self.toolbar, text="CAM off", fg="blue", command=lambda: self.video.setOnoff(False))
        self.camoff.configure(background='tan')
        self.camoff.pack(side=tk.LEFT, padx=5, pady=5)

        self.detector = tk.Button(self.toolbar, text="detect face", fg="blue",
                                  command=lambda: self.video.setDetection())
        self.detector.configure(background='tan')
        self.detector.pack(side=tk.LEFT, padx=5, pady=5)

        self.effect = tk.Button(self.toolbar, text="effect", fg="yellow",
                                command=lambda: self.video.setEffect(self.efCombo.get()))
        self.effect.configure(background='tan')
        self.effect.pack(side=tk.LEFT, padx=5, pady=5)

        self.hi_there = tk.Button(self.toolbar, text="Hello")  # , command=self.say_hi)
        self.hi_there.bind("<Control-Button-1>", self.say_hi)  # event binding
        self.hi_there.configure(background='tan')
        self.hi_there.pack(side=tk.LEFT, padx=5, pady=5)
        ##canvas to draw on
        self.canvas = tk.Canvas(self.frame, width=620, height=460)
        self.canvas.configure(background="black", relief='ridge', highlightthickness=5, borderwidth=5)
        self.canvas.pack(side=tk.RIGHT, padx=5, pady=5)  # (expand=tk.YES,fill=tk.BOTH)
        ##canvas to draw histogram
        self.histLabel = Labelframe(self.frame, text="Histogram")
        self.histLabel.pack(anchor=tk.W, padx=5, pady=2)
        self.histCanvas = tk.Canvas(self.histLabel, width=300, height=240)
        self.histCanvas.configure(background="black", relief='ridge', highlightthickness=5, borderwidth=5)
        self.histCanvas.pack(side=tk.TOP, padx=5, pady=5)
        ##sliders
        var = tk.DoubleVar()
        self.contrast = tk.Scale(self.frame, orient=tk.HORIZONTAL,
                                 label='Contrast', variable=var, resolution=0.5, from_=0.0, to=100.0,
                                 command=self._update_contrast)
        self.contrast.pack(side=tk.LEFT, anchor=tk.NW, padx=5, pady=5)
        self.brightness = tk.Scale(self.frame, orient=tk.HORIZONTAL,
                                   label='Brightness', from_=0, to=100, command=self._update_brightness)
        # self.brightness.bind('<FocusIn>', self._update_brightness)
        self.brightness.pack(side=tk.LEFT, anchor=tk.NW, padx=5, pady=5)
        ##position label
        self.position = tk.StringVar()
        self.xyLabel = tk.Label(self.toolbar, textvariable=self.position, fg='red', width=30, justify='left').pack(
            padx=1, pady=5)

        ##set the camera
        self.video = Camera(self.cam, self.master, self.canvas, self.histCanvas, self.frame, self.position)
        self.video.setOnoff(False)
Ejemplo n.º 3
0
Archivo: booru.py Proyecto: Reyuu/abd
    def initUI(self):
        self.parent.title("Booru")
        self.pack(fill=Y, expand=0, side=LEFT)
        myicon = ImageTk.PhotoImage(file="sbooru.ico")
        self.current_booru_var = StringVar()
        self.mb = Menubutton(self,
                             textvariable=self.current_booru_var,
                             relief=RAISED,
                             image=myicon,
                             compound=LEFT)
        self.mb.image = myicon
        self.mb.pack(side=TOP)
        self.mb.menu = Menu(self.mb, tearoff=0)
        self.mb["menu"] = self.mb.menu
        self.current_booru_var.set("Safebooru")

        def change_booru(booru):
            self.current_booru = booru
            if self.current_booru == 0:
                self.current_booru_var.set("Danbooru")
            if self.current_booru == 1:
                self.current_booru_var.set("Safebooru")

        self.mb.menu.add_command(label="Danbooru",
                                 command=lambda: change_booru(0))
        self.mb.menu.add_command(label="Safebooru",
                                 command=lambda: change_booru(1))

        self.mb.pack()

        image = Image.open(
            get_image_from_internet_binary(
                u"%s%s" % (main_url, self.posts[0][u"preview_file_url"])))
        photo = ImageTk.PhotoImage(image)
        self.label = Label(self, image=photo)
        self.label.image = photo
        self.label.pack(fill=Y, expand=0, side=TOP)

        self.lb = Listbox(self)
        for i in self.posts:
            self.lb.insert(END, i["id"])
        self.lb.bind("<<ListboxSelect>>", self.onSelect)
        self.lb.pack(pady=15, fill=Y, expand=0, side=LEFT)

        self.description = Labelframe(self,
                                      text="Description",
                                      height=350,
                                      width=350)
        self.description.pack(pady=15, expand=0)
        #artist
        self.artist_v = StringVar()
        self.artist = Label(self.description,
                            textvariable=self.artist_v,
                            justify=LEFT,
                            wraplength=350,
                            anchor=W)
        self.artist.pack()
        #md5
        self.md5_v = StringVar()
        self.md5 = Label(self.description,
                         textvariable=self.md5_v,
                         justify=LEFT,
                         wraplength=350,
                         anchor=W)
        self.md5.pack()
        #source
        self.source_v = StringVar()
        self.source = Label(self.description,
                            textvariable=self.source_v,
                            justify=LEFT,
                            wraplength=350,
                            anchor=W)
        self.source.pack()
        #wxh
        self.wxh_v = StringVar()
        self.wxh = Label(self.description,
                         textvariable=self.wxh_v,
                         justify=LEFT,
                         wraplength=350,
                         anchor=W)
        self.wxh.pack()
        #tags (for now all)
        self.tags_v = StringVar()
        self.tags = Label(self.description,
                          textvariable=self.tags_v,
                          justify=LEFT,
                          wraplength=350,
                          anchor=W)
        self.tags.pack()
        #uploader
        self.uploader_v = StringVar()
        self.uploader = Label(self.description,
                              textvariable=self.uploader_v,
                              justify=LEFT,
                              wraplength=350,
                              anchor=W)
        self.uploader.pack()
        idx = (0, 0)
        try:
            self.artist_v.set(u"Artist:\t%s" %
                              self.posts[idx[0]][u"tag_string_artist"])
        except KeyError:
            self.artist_v.set(u"Artist:\t")
        try:
            self.md5_v.set(u"MD5:\t%s" % self.posts[idx[0]][u"md5"])
        except KeyError:
            self.md5_v.set(u"MD5:\t")
        try:
            self.source_v.set(u"Source:\t%s" % self.posts[idx[0]][u"source"])
        except KeyError:
            self.source_v.set(u"Source:\t")
        try:
            self.wxh_v.set(u"Size:\t%sx%s" %
                           (self.posts[idx[0]][u"image_width"],
                            self.posts[idx[0]][u"image_height"]))
        except KeyError:
            self.wxh_v.set(u"Size:\t")
        try:
            self.tags_v.set(u"Tags:\t%s" % self.posts[idx[0]][u"tag_string"])
        except KeyError:
            self.tags_v.set(u"Tags:\t")
        try:
            self.uploader_v.set(u"Uploader:\t%s" %
                                self.posts[idx[0]][u"uploader_name"])
        except KeyError:
            self.uploader_v.set(u"Uploader:\t")

        self.button_frame = Frame(self.description)
        self.button_frame.pack(fill=Y, expand=0, side=LEFT)

        def download_image_current():
            def download():
                urllib.urlretrieve(
                    "%s%s" % (main_url, self.current_image[u"file_url"]),
                    "%s_%s.%s" %
                    (self.current_image[u"id"], self.current_image[u"md5"],
                     self.current_image[u"file_ext"]))

            t1 = Thread(target=download, args=())
            t1.start()

        self.download_button = Button(self.button_frame,
                                      text="Download",
                                      command=download_image_current)
        self.download_button.pack(side=LEFT)

        def bigger_preview():
            image = Image.open(
                get_image_from_internet_binary(
                    u"%s%s" % (main_url, self.current_image[u"file_url"])))
            photo = ImageTk.PhotoImage(image)
            self.bigpreview = Toplevel(self)
            labelu = Label(self.bigpreview, image=photo)
            labelu.image = photo
            labelu.pack(fill=Y, expand=0, side=LEFT)

        self.preview_button = Button(self.button_frame,
                                     text="Preview",
                                     command=bigger_preview)
        self.preview_button.pack(side=RIGHT)

        def onRefresh():
            def method():
                query_args["page"] = self.current_page.get()
                self.posts = get_posts("posts.json", query_args)
                self.lb.delete(0, END)
                for i in self.posts:
                    self.lb.insert(END, i["id"])

            t1 = Thread(target=method, args=())
            t1.start()

        self.refresh = Button(self.button_frame,
                              text="Refresh posts",
                              command=onRefresh)
        self.refresh.pack(side=LEFT)

        page_control = Frame(self)
        page_control.pack(pady=15, side=BOTTOM)
        self.current_page = IntVar()
        self.current_page.set(1)

        def forward_f():
            self.current_page.set(self.current_page.get() + 1)
            onRefresh()

        forward = Button(page_control, text=">>", command=forward_f)
        forward.pack(side=RIGHT)

        def backward_f():
            self.current_page.set((self.current_page.get() - 1) if (
                self.current_page.get() - 1 > 0) else self.current_page.get())
            onRefresh()

        backward = Button(page_control, text="<<", command=backward_f)
        backward.pack(side=LEFT)
        curpaglabl = Label(page_control,
                           textvariable=self.current_page,
                           background="orange")
        curpaglabl.pack(pady=15, side=BOTTOM)
Ejemplo n.º 4
0
    def __init__(self, parent, txt=dict()):
        """Instanciating the output workbook."""
        self.parent = parent
        Frame.__init__(self)

        # subframe
        self.FrDb = Labelframe(self,
                               name='database',
                               text=txt.get('gui_fr2', "SGBD"))

        # DB variables
        self.opt_pgvw = IntVar(self.FrDb)  # able/disable PostGIS views
        self.host = StringVar(self.FrDb, 'localhost')
        self.port = IntVar(self.FrDb, 5432)
        self.dbnb = StringVar(self.FrDb)
        self.user = StringVar(self.FrDb, 'postgres')
        self.pswd = StringVar(self.FrDb)

        # Form widgets
        self.ent_H = Entry(self.FrDb, textvariable=self.host)
        self.ent_P = Entry(self.FrDb, textvariable=self.port, width=5)
        self.ent_D = Entry(self.FrDb, textvariable=self.dbnb)
        self.ent_U = Entry(self.FrDb, textvariable=self.user)
        self.ent_M = Entry(self.FrDb, textvariable=self.pswd, show='*')

        caz_pgvw = Checkbutton(self.FrDb,
                               text=txt.get('gui_views', "Views enabled"),
                               variable=self.opt_pgvw)

        # Label widgets
        self.lb_H = Label(self.FrDb, text=txt.get('gui_host', "Host"))
        self.lb_P = Label(self.FrDb, text=txt.get('gui_port', "Port"))
        self.lb_D = Label(self.FrDb, text=txt.get('gui_db', "Database"))
        self.lb_U = Label(self.FrDb, text=txt.get('gui_user', "User"))
        self.lb_M = Label(self.FrDb, text=txt.get('gui_mdp', "Password"))
        # widgets placement
        self.ent_H.grid(row=1,
                        column=1,
                        columnspan=2,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.ent_P.grid(row=1,
                        column=3,
                        columnspan=1,
                        sticky="NSE",
                        padx=2,
                        pady=2)
        self.ent_D.grid(row=2,
                        column=1,
                        columnspan=1,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.ent_U.grid(row=2,
                        column=3,
                        columnspan=1,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.ent_M.grid(row=3,
                        column=1,
                        columnspan=3,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.lb_H.grid(row=1, column=0, sticky="NSEW", padx=2, pady=2)
        self.lb_P.grid(row=1, column=3, sticky="NSW", padx=2, pady=2)
        self.lb_D.grid(row=2, column=0, sticky="NSW", padx=2, pady=2)
        self.lb_U.grid(row=2, column=2, sticky="NSW", padx=2, pady=2)
        self.lb_M.grid(row=3, column=0, sticky="NSWE", padx=2, pady=2)
        caz_pgvw.grid(row=4, column=0, sticky="NSWE", padx=2, pady=2)

        # frame position
        self.FrDb.grid(row=3, column=1, sticky="NSWE", padx=2, pady=2)
Ejemplo n.º 5
0
    def __init__(self):
        u"""
        Main window constructor
        Creates 1 frame and 2 labelled subframes
        """

        # basics settings
        Tk.__init__(self)               # constructor of parent graphic class
        self.title(u'DicoGIS {0}'.format(DGversion))

        self.li_raster_formats = ['ecw', 'geotiff']

        # notebook
        self.nb = Notebook(self)
        self.FrProg = Labelframe(self,
                                 name='progression',
                                 text='gui_prog')
        self.FrOutp = Labelframe(self,
                                 name='output',
                                 text='gui_fr4')
        # tabs
        self.tab_files = Frame(self.nb)    # tab_id = 0
        self.tab_sgbd = Frame(self.nb)          # tab_id = 1
        self.tab_webservices = Frame(self.nb)   # tab_id = 2
        self.tab_isogeo = Frame(self.nb)        # tab_id = 3
        self.tab_about = Frame(self.nb)        # tab_id = 4


        ## TAB 1: FILES
        self.nb.add(self.tab_files,
                    text='gui_files', padding=3)
        # frame: path folder
        self.FrPath = Labelframe(self.tab_files,
                                 name='files',
                                 text='gui_fr1')
        self.labtarg = Label(self.FrPath, text='gui_path')
        self.target = Entry(master=self.FrPath, width=35)
        self.browsetarg = Button(self.FrPath,       # browse button
                                 text='gui_choix',
                                 command=lambda: self.setpathtarg(),
                                 takefocus=True)
        self.browsetarg.focus_force()               # force the focus on

        # widgets placement
        self.labtarg.grid(row=1, column=1, columnspan=1,
                          sticky="NSWE", padx=2, pady=2)
        self.target.grid(row=1, column=2, columnspan=1,
                         sticky="NSWE", padx=2, pady=2)
        self.browsetarg.grid(row=1, column=3,
                             sticky="NSWE", padx=2, pady=2)

        # frame: filters
        self.FrFilters = Labelframe(self.tab_files,
                                    name='filters',
                                    text='filters')
        # formats options
        self.opt_shp = IntVar(self.FrFilters)   # able/disable shapefiles
        self.opt_tab = IntVar(self.FrFilters)   # able/disable MapInfo tables
        self.opt_kml = IntVar(self.FrFilters)   # able/disable KML
        self.opt_gml = IntVar(self.FrFilters)   # able/disable GML
        self.opt_geoj = IntVar(self.FrFilters)  # able/disable GeoJSON
        self.opt_gxt = IntVar(self.FrFilters)  # able/disable GXT
        self.opt_egdb = IntVar(self.FrFilters)  # able/disable Esri FileGDB
        self.opt_spadb = IntVar(self.FrFilters)  # able/disable Spatalite DB
        self.opt_rast = IntVar(self.FrFilters)  # able/disable rasters
        self.opt_cdao = IntVar(self.FrFilters)  # able/disable CAO/DAO files
        self.opt_pdf = IntVar(self.FrFilters)   # able/disable Geospatial PDF
        self.opt_lyr = IntVar(self.FrFilters)   # able/disable Geospatial Lyr
        self.opt_mxd = IntVar(self.FrFilters)   # able/disable Geospatial MXD
        self.opt_qgs = IntVar(self.FrFilters)   # able/disable Geospatial QGS

        # format choosen: check buttons
        caz_shp = Checkbutton(self.FrFilters,
                              text=u'.shp',
                              variable=self.opt_shp)
        caz_tab = Checkbutton(self.FrFilters,
                              text=u'.tab',
                              variable=self.opt_tab)
        caz_kml = Checkbutton(self.FrFilters,
                              text=u'.kml',
                              variable=self.opt_kml)
        caz_gml = Checkbutton(self.FrFilters,
                              text=u'.gml',
                              variable=self.opt_gml)
        caz_geoj = Checkbutton(self.FrFilters,
                               text=u'.geojson',
                               variable=self.opt_geoj)
        caz_gxt = Checkbutton(self.FrFilters,
                              text=u'.gxt',
                              variable=self.opt_gxt)
        caz_egdb = Checkbutton(self.FrFilters,
                               text=u'Esri FileGDB',
                               variable=self.opt_egdb)
        caz_spadb = Checkbutton(self.FrFilters,
                                text=u'Spatialite',
                                variable=self.opt_spadb)
        caz_rast = Checkbutton(self.FrFilters,
                               text=u'rasters ({0})'.format(', '.join(self.li_raster_formats)),
                               variable=self.opt_rast)
        caz_cdao = Checkbutton(self.FrFilters,
                               text=u'CAO/DAO',
                               variable=self.opt_cdao)
        caz_pdf = Checkbutton(self.FrFilters,
                              text=u'Geospatial PDF',
                              variable=self.opt_pdf)
        caz_lyr = Checkbutton(self.FrFilters,
                              text=u'.lyr',
                              variable=self.opt_lyr)
        caz_mxd = Checkbutton(self.FrFilters,
                              text=u'.mxd',
                              variable=self.opt_mxd)
        caz_qgs = Checkbutton(self.FrFilters,
                              text=u'.qgs',
                              variable=self.opt_qgs)
        # widgets placement
        caz_shp.grid(row=1,
                     column=0,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_tab.grid(row=1,
                     column=1,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_kml.grid(row=1,
                     column=2,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_gml.grid(row=1,
                     column=3,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_geoj.grid(row=1,
                      column=4,
                      sticky="NSWE",
                      padx=2, pady=2)
        caz_gxt.grid(row=1,
                     column=7,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_pdf.grid(row=1,
                     column=5,
                     columnspan=2,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_rast.grid(row=2,
                      column=0,
                      columnspan=2,
                      sticky="NSWE",
                      padx=2, pady=2)
        caz_egdb.grid(row=2,
                      column=2,
                      columnspan=2,
                      sticky="NSWE",
                      padx=2, pady=2)
        caz_cdao.grid(row=2,
                      column=4,
                      columnspan=1,
                      sticky="NSWE",
                      padx=2, pady=2)
        caz_spadb.grid(row=2,
                       column=5,
                       columnspan=2,
                       sticky="NSWE",
                       padx=2, pady=2)
        caz_lyr.grid(row=3,
                     column=0,
                     columnspan=2,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_mxd.grid(row=3,
                     column=1,
                     columnspan=2,
                     sticky="NSWE",
                     padx=2, pady=2)
        caz_qgs.grid(row=3,
                     column=2,
                     columnspan=2,
                     sticky="NSWE",
                     padx=2, pady=2)


        # frames placement
        self.FrPath.grid(row=3, column=1, padx=2, pady=2,
                 sticky="NSWE")
        self.FrFilters.grid(row=4, column=1, padx=2, pady=2,
                    sticky="NSWE")

        # tab 2: database
        self.nb.add(self.tab_sgbd,
                    text='gui_database', padding=3)





        # tab 3: webservices
        self.nb.add(self.tab_webservices,
                    text='gui_webservices', padding=3)



        ## TAB 4: ISOGEO
        self.nb.add(self.tab_isogeo,
                    text='gui_Isogeo', padding=3)


        ## TAB 5: ABOUT
        self.nb.add(self.tab_about,
                    text='gui_about', padding=3)


        ## MAIN FRAME
        # Welcome message
        self.welcome = Label(self,
                             text='hola test',
                             foreground="red2")

        # Progression bar
        self.status = StringVar(self.FrProg, '')
        # widgets
        self.prog_layers = Progressbar(self.FrProg,
                                       orient="horizontal")
        Label(master=self.FrProg,
              textvariable=self.status,
              foreground='DodgerBlue').pack()
        # widgets placement
        self.prog_layers.pack(expand=1, fill='both')

        # Output configuration
        # widgets
        self.nameoutput = Label(self.FrOutp,
                                text='gui_fic')
        self.output = Entry(self.FrOutp, width=35)
        # widgets placement
        self.nameoutput.grid(row=0, column=1,
                             sticky="NSWE", padx=2, pady=2)
        self.output.grid(row=0, column=2, columnspan=2,
                         sticky="NSWE", padx=2, pady=2)

        # Image
        self.icone = PhotoImage(file=r'../data/img/DicoGIS_logo.gif')
        Label(self,
              borderwidth=2,
              image=self.icone).grid(row=1,
                                     rowspan=4,
                                     column=0,
                                     padx=2,
                                     pady=2,
                                     sticky=W)
        # credits
        s = Style(self)
        s.configure('Kim.TButton', foreground='DodgerBlue', borderwidth=0)
        Button(self,
               text='by @GeoJulien\nGPL3 - 2015',
               style='Kim.TButton',
               command=lambda: open_new('https://github.com/Guts/DicoGIS')).grid(row=4,
                                                                                 padx=2,
                                                                                 pady=2,
                                                                                 sticky="WE")
        # language switcher
        self.ddl_lang = Combobox(self,
                                 values=['fr', 'en'],
                                 width=5)

        # grid placement
        self.val = Button(self,
                          text='gui_go',
                          state=ACTIVE,
                          command=lambda: self.process())
        self.can = Button(self, text='gui_quit',
                          command=lambda: self.destroy())
        self.welcome.grid(row=1, column=1, columnspan=1, sticky="NS",
                          padx=2, pady=2)
        self.ddl_lang.grid(row=1, column=1, sticky="NSE", padx=2, pady=2)
        self.nb.grid(row=2, column=1)
        self.FrProg.grid(row=3, column=1, sticky="NSWE", padx=2, pady=2)
        self.FrOutp.grid(row=4, column=1, sticky="NSWE", padx=2, pady=2)
        self.val.grid(row=5, column=1, columnspan=2,
                      sticky="NSWE", padx=2, pady=2)
        self.can.grid(row=5, column=0, sticky="NSWE", padx=2, pady=2)
Ejemplo n.º 6
0
    def __init__(self, parent, txt=dict(), path_browser=None, path_var=""):
        """Instanciating the output workbook."""
        self.p = parent
        self.txt = txt
        Frame.__init__(self)

        # -- VARIABLES -------------------------------------------------------
        self.target_path = StringVar()
        # formats / type: vectors
        self.li_vectors_formats = (".shp", ".tab", ".kml", ".gml", ".geojson"
                                   )  # vectors handled
        self.li_shp = []  # list for shapefiles path
        self.li_tab = []  # list for MapInfo tables path
        self.li_kml = []  # list for KML path
        self.li_gml = []  # list for GML path
        self.li_geoj = []  # list for GeoJSON paths
        self.li_gxt = []  # list for GXT paths
        self.li_vectors = []  # list for all vectors
        # formats / type: rasters
        self.li_raster = []  # list for rasters paths
        self.li_raster_formats = (".ecw", ".tif", ".jp2")  # raster handled
        # formats / type: file databases
        self.li_fdb = []  # list for all files databases
        self.li_egdb = []  # list for Esri File Geodatabases
        self.li_spadb = []  # list for Spatialite Geodatabases
        # formats / type: CAO/DAO
        self.li_cdao = []  # list for all CAO/DAO files
        self.li_dxf = []  # list for AutoCAD DXF paths
        self.li_dwg = []  # list for AutoCAD DWG paths
        self.li_dgn = []  # list for MicroStation DGN paths
        # formats / type: maps documents
        self.li_mapdocs = []  # list for all map & documents
        self.li_pdf = []  # list for GeoPDF path
        self.li_lyr = []  # list for LYR path
        self.li_mxd = []  # list for MXD path
        self.li_qgs = []  # list for QGS path

        # -- Source path -----------------------------------------------------
        self.FrPath = Labelframe(self,
                                 name='files',
                                 text=txt.get('gui_fr1', "Path"))

        # target folder
        self.lb_target = Label(self.FrPath, text=txt.get('gui_path'))
        self.ent_target = Entry(master=self.FrPath,
                                width=35,
                                textvariable=self.target_path)
        self.btn_browse = Button(self.FrPath,
                                 text=u"\U0001F3AF " +
                                 txt.get('gui_choix', "Browse"),
                                 command=lambda: self.get_target_path(r"."),
                                 takefocus=True)
        self.btn_browse.focus_force()

        # widgets placement
        self.lb_target.grid(row=1,
                            column=1,
                            columnspan=1,
                            sticky="NSWE",
                            padx=2,
                            pady=2)
        self.ent_target.grid(row=1,
                             column=2,
                             columnspan=1,
                             sticky="NSWE",
                             padx=2,
                             pady=2)
        self.btn_browse.grid(row=1, column=3, sticky="NSE", padx=2, pady=2)

        # -- Format filters --------------------------------------------------
        self.FrFilters = Labelframe(self,
                                    name='filters',
                                    text=txt.get('gui_fr3', "Filters"))
        # formats options
        self.opt_shp = IntVar(self.FrFilters)  # able/disable shapefiles
        self.opt_tab = IntVar(self.FrFilters)  # able/disable MapInfo tables
        self.opt_kml = IntVar(self.FrFilters)  # able/disable KML
        self.opt_gml = IntVar(self.FrFilters)  # able/disable GML
        self.opt_geoj = IntVar(self.FrFilters)  # able/disable GeoJSON
        self.opt_gxt = IntVar(self.FrFilters)  # able/disable GXT
        self.opt_egdb = IntVar(self.FrFilters)  # able/disable Esri FileGDB
        self.opt_spadb = IntVar(self.FrFilters)  # able/disable Spatalite DB
        self.opt_rast = IntVar(self.FrFilters)  # able/disable rasters
        self.opt_cdao = IntVar(self.FrFilters)  # able/disable CAO/DAO files
        self.opt_pdf = IntVar(self.FrFilters)  # able/disable Geospatial PDF
        self.opt_lyr = IntVar(self.FrFilters)  # able/disable Geospatial Lyr
        self.opt_mxd = IntVar(self.FrFilters)  # able/disable Geospatial MXD
        self.opt_qgs = IntVar(self.FrFilters)  # able/disable Geospatial QGS

        # format choosen: check buttons
        caz_shp = Checkbutton(self.FrFilters,
                              text=u'.shp',
                              variable=self.opt_shp)
        caz_tab = Checkbutton(self.FrFilters,
                              text=u'.tab',
                              variable=self.opt_tab)
        caz_kml = Checkbutton(self.FrFilters,
                              text=u'.kml',
                              variable=self.opt_kml)
        caz_gml = Checkbutton(self.FrFilters,
                              text=u'.gml',
                              variable=self.opt_gml)
        caz_geoj = Checkbutton(self.FrFilters,
                               text=u'.geojson',
                               variable=self.opt_geoj)
        caz_gxt = Checkbutton(self.FrFilters,
                              text=u'.gxt',
                              variable=self.opt_gxt)
        caz_egdb = Checkbutton(self.FrFilters,
                               text=u'Esri FileGDB',
                               variable=self.opt_egdb)
        caz_spadb = Checkbutton(self.FrFilters,
                                text=u'Spatialite',
                                variable=self.opt_spadb)
        caz_rast = Checkbutton(self.FrFilters,
                               text=u'rasters ({0})'.format(', '.join(
                                   self.li_raster_formats)),
                               variable=self.opt_rast)
        caz_cdao = Checkbutton(self.FrFilters,
                               text=u'CAO/DAO',
                               variable=self.opt_cdao)
        caz_pdf = Checkbutton(self.FrFilters,
                              text=u'Geospatial PDF',
                              variable=self.opt_pdf)
        self.caz_lyr = Checkbutton(self.FrFilters,
                                   text=u'.lyr',
                                   variable=self.opt_lyr)
        self.caz_mxd = Checkbutton(self.FrFilters,
                                   text=u'.mxd',
                                   variable=self.opt_mxd)
        caz_qgs = Checkbutton(self.FrFilters,
                              text=u'.qgs',
                              variable=self.opt_qgs)
        # widgets placement
        caz_shp.grid(row=1, column=0, sticky="NSWE", padx=2, pady=2)
        caz_tab.grid(row=1, column=1, sticky="NSWE", padx=2, pady=2)
        caz_kml.grid(row=1, column=2, sticky="NSWE", padx=2, pady=2)
        caz_gml.grid(row=1, column=3, sticky="NSWE", padx=2, pady=2)
        caz_geoj.grid(row=1, column=4, sticky="NSWE", padx=2, pady=2)
        caz_gxt.grid(row=1, column=7, sticky="NSWE", padx=2, pady=2)
        caz_pdf.grid(row=1,
                     column=5,
                     columnspan=2,
                     sticky="NSWE",
                     padx=2,
                     pady=2)
        caz_rast.grid(row=2,
                      column=0,
                      columnspan=2,
                      sticky="NSWE",
                      padx=2,
                      pady=2)
        caz_egdb.grid(row=2,
                      column=2,
                      columnspan=2,
                      sticky="NSWE",
                      padx=2,
                      pady=2)
        caz_cdao.grid(row=2,
                      column=4,
                      columnspan=1,
                      sticky="NSWE",
                      padx=2,
                      pady=2)
        caz_spadb.grid(row=2,
                       column=5,
                       columnspan=2,
                       sticky="NSWE",
                       padx=2,
                       pady=2)
        self.caz_lyr.grid(row=3,
                          column=0,
                          columnspan=2,
                          sticky="NSWE",
                          padx=2,
                          pady=2)
        self.caz_mxd.grid(row=3,
                          column=1,
                          columnspan=2,
                          sticky="NSWE",
                          padx=2,
                          pady=2)
        caz_qgs.grid(row=3,
                     column=2,
                     columnspan=2,
                     sticky="NSWE",
                     padx=2,
                     pady=2)

        # frames placement
        self.FrPath.grid(row=3, column=1, padx=2, pady=2, sticky="NSWE")
        self.FrFilters.grid(row=4, column=1, padx=2, pady=2, sticky="NSWE")