def on_button_style_clicked(self, widget, data=None): self.ui.comboboxtext_file.remove_all() #let the user choose a self.path with the directory chooser response, self.path = prompts.choose_directory() #make certain the user said ok before working if response == Gtk.ResponseType.OK: #make a list of the supported xml files dicts = dict() counter = 0 #iterate through root directory for files in glob.glob(self.path + "/*.xml"): if files.endswith('.xml'): #create a URI in a format gstreamer likes file_uri = self.path fileSplit = files.split(self.path + "/") dicts[str(counter)] = fileSplit[1] counter = counter + 1 keylist = dicts.keys() keylist.sort() #fill the combotextbox with the xml-files of the initially user-chosen directory try: for key in keylist: #print key, value self.ui.comboboxtext_file.append_text(dicts[key]) except: print "No directory chosen"
def openbutton(self, widget, data=None): response, path = prompts.choose_directory() if response == gtk.RESPONSE_OK: media_files = [] formats = self.supported_audio_formats + self.supported_video_formats for root, dirs, files in os.walk(path): for f in files: for format in formats: if f.lower().endswith(format): file_url = "file://" + os.path.join(root, f) data = {"File" : f, "url" : file_url, "format" : format, } media_files.append(data) for format in self.supported_album_art_formats: if f.lower().endswith(format): self.image_url = os.path.join(root, f) #exception if no supported is found.. if self.image_url is '': self.image_url = "background.png" #print media_files scrolledwindow = self.builder.get_object('scrolledwindow1') #print scrolledwindow for c in scrolledwindow.get_children(): scrolledwindow.remove(c) media_grid = DictionaryGrid(media_files, keys=["File"]) media_grid.connect("selection_changed", self.play_file) media_grid.show() #print media_files scrolledwindow.add(media_grid)
def on_button_style_clicked(self, widget, data=None): # clean up the combobox self.ui.comboboxtext_file.remove_all() # let the user choose a path with the directory chooser response, path = prompts.choose_directory() # make certain the user said ok before working if response == Gtk.ResponseType.OK: self.params.setUserPath(path) self.fillCombobox() elif response == Gtk.ResponseType.CANCEL: self.ui.label_status.set_text("No directory chosen")
def on_button_style_clicked(self, widget, data=None): #clean up the combobox self.ui.comboboxtext_file.remove_all() #let the user choose a path with the directory chooser response, path = prompts.choose_directory() #make certain the user said ok before working if response == Gtk.ResponseType.OK: self.params.setUserPath(path) self.fillCombobox() elif response == Gtk.ResponseType.CANCEL: self.ui.label_status.set_text("No directory chosen")
def __new__(cls): """Special static method that's automatically called by Python when constructing a new instance of this class. Returns a fully instantiated RenderDialog object. """ ####let the user choose a directory that contains one or more mapnik style files global path path = '' #let the user choose a path with the directory chooser response, path = prompts.choose_directory() #make certain the user said ok before working if response == Gtk.ResponseType.OK: #make a list of the supported xml files global dicts dicts = dict() counter = 0 #iterate through root directory for files in glob.glob(path + "/*.xml"): if files.endswith('.xml'): #create a URI in a format gstreamer likes file_uri = path fileSplit = files.split(path + "/") dicts[str(counter)] = fileSplit[1] counter = counter + 1 global keylist keylist = dicts.keys() keylist.sort() #### #initialize some global variables global image image = '' global checkbutton checkbutton = False global checkbutton_open checkbutton_open = False global shapefile shapefile = '' global new_stylesheet new_stylesheet = '' global projection projection = '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6371000 +b=6371000 +units=m +no_defs' builder = get_builder('RenderDialog') new_object = builder.get_object('render_dialog') new_object.finish_initializing(builder) return new_object
def finish_initializing(self, builder): """Called when we're finished initializing. finish_initalizing should be called after parsing the ui definition and creating a OpenDialog object with it in order to finish initializing the start of the new OpenDialog instance. """ # Get a reference to the builder and set up the signals. self.builder = builder self.ui = builder.get_ui(self) self.supported_shape_formats = [".shp"] #let the user choose a path with the directory chooser response, path = prompts.choose_directory() #make certain the user said ok before working if response == Gtk.ResponseType.OK: #make one list of support formats formats = self.supported_shape_formats #make a list of the supported media files media_files = [] #iterate through root directory for files in glob.glob(path + "/*.shp"): for format in formats: if files.endswith(format): #create a URI in a format gstreamer likes file_uri = path fileSplit = files.split(path + "/") #add a dictionary to the list of media files media_files.append({ "File": fileSplit[1], "uri": file_uri, "format": format }) #remove any children in scrolled window #for c in self.ui.scrolledwindow1.get_children(): # self.ui.scrolledwindow1.remove(c) #create the grid with list of dictionaries #only show the File column global media_grid media_grid = DictionaryGrid(media_files, keys=["File"]) #show the grid, and add it to the scrolled window media_grid.show() self.ui.box1.pack_end(media_grid, True, True, 0)
def finish_initializing(self, builder): """Called when we're finished initializing. finish_initalizing should be called after parsing the ui definition and creating a OpenDialog object with it in order to finish initializing the start of the new OpenDialog instance. """ # Get a reference to the builder and set up the signals. self.builder = builder self.ui = builder.get_ui(self) self.supported_shape_formats = [".shp"] #let the user choose a path with the directory chooser response, path = prompts.choose_directory() #make certain the user said ok before working if response == Gtk.ResponseType.OK: #make one list of support formats formats = self.supported_shape_formats #make a list of the supported media files media_files = [] #iterate through root directory for files in glob.glob(path + "/*.shp"): for format in formats: if files.endswith(format): #create a URI in a format gstreamer likes file_uri = path fileSplit = files.split(path + "/") #add a dictionary to the list of media files media_files.append({"File":fileSplit[1],"uri":file_uri, "format":format}) #remove any children in scrolled window #for c in self.ui.scrolledwindow1.get_children(): # self.ui.scrolledwindow1.remove(c) #create the grid with list of dictionaries #only show the File column global media_grid media_grid = DictionaryGrid(media_files, keys=["File"]) #show the grid, and add it to the scrolled window media_grid.show() self.ui.box1.pack_end(media_grid, True, True, 0)
def openbutton_clicked_event(self, widget, data=None): #let the user choose a path with the directory chooser response, path = prompts.choose_directory() #make certain the user said ok before working if response == gtk.RESPONSE_OK: #make one list of support formats formats = self.allowed_formats #make a list of the supported media files media_files = [] #iterate through root directory for root, dirs, files in os.walk(path): #iterate through each file for f in files: #check if the file is a supported formats for format in formats: if f.lower().endswith(format): #create a URI in a format gstreamer likes file_uri = "file://" + os.path.join(root, f) #add a dictionary to the list of media files media_files.append({ "File": f, "uri": file_uri, "format": format }) #remove any children in scrolled window for c in self.ui.scrolledwindow1.get_children(): self.ui.scrolledwindow1.remove(c) #create the grid with list of dictionaries #only show the File column media_grid = DictionaryGrid(media_files, keys=["File"]) #hook up to the selection_changed event media_grid.connect("selection_changed", self.play_file) #show the grid, and add it to the scrolled window media_grid.show() self.ui.scrolledwindow1.add(media_grid)
def openbutton_clicked_event(self, widget, data=None): #let the user choose a path with the directory chooser response, path = prompts.choose_directory() #make certain the user said ok before working if response == gtk.RESPONSE_OK: #make one list of support formats formats = self.allowed_formats #make a list of the supported media files media_files = [] #iterate through root directory for root, dirs, files in os.walk(path): #iterate through each file for f in files: #check if the file is a supported formats for format in formats: if f.lower().endswith(format): #create a URI in a format gstreamer likes file_uri = "file://" + os.path.join(root,f) #add a dictionary to the list of media files media_files.append({"File":f,"uri":file_uri, "format":format}) #remove any children in scrolled window for c in self.ui.scrolledwindow1.get_children(): self.ui.scrolledwindow1.remove(c) #create the grid with list of dictionaries #only show the File column media_grid = DictionaryGrid(media_files, keys=["File"]) #hook up to the selection_changed event media_grid.connect("selection_changed", self.play_file) #show the grid, and add it to the scrolled window media_grid.show() self.ui.scrolledwindow1.add(media_grid)
def finish_initializing(self, builder): """Called when we're finished initializing. finish_initalizing should be called after parsing the ui definition and creating a SetstyleDialog object with it in order to finish initializing the start of the new SetstyleDialog instance. """ # Get a reference to the builder and set up the signals. self.builder = builder self.ui = builder.get_ui(self) global path path = '' #let the user choose a path with the directory chooser response, path = prompts.choose_directory() #make certain the user said ok before working if response == Gtk.ResponseType.OK: #make a list of the supported xml files dicts = dict() counter = 0 #iterate through root directory for files in glob.glob(path + "/*.xml"): if files.endswith('.xml'): #create a URI in a format gstreamer likes file_uri = path fileSplit = files.split(path + "/") dicts[str(counter)] = fileSplit[1] counter = counter + 1 keylist = dicts.keys() keylist.sort() for key in keylist: #print key, value self.ui.comboboxtext1.append_text(dicts[key])