Good day to all. This is actually my first time ever posting a question so I'm gonna go straight to the point. Me and my team mates are actually working on an application using python as our programming language and we are stuck in finding ways on how to create a file manager using the said language.
We have been searching and scouring the web but we can't seem to find the appropriate answer for the questions.
We are trying to achieve something like this using python in either eclipse or using glade.
.-root
. - dir_one
. -file_one
. -file_two
. -file_three
. -dir_two
. -image_one
. -image_two
Sorry, I can't seem to post images as of the moment. Any help would be greatly appreciated.
Thank you in advance.
Since you specify glade, I assume you're using GTK+.
As I see it, there are really two problems for you to solve:
How to list/move/delete/copy files and directories. This problem is practically solved for you using python's os module ( http://docs.python.org/2/library/os.html ), and GLib's GIO. (No docs AFAIK, I find it's quite trivial to work out what to do based on the C functions)
How to make your interface. From the layout that you suggest, I think the Gtk.TreeView model/widget is what you're after: https://python-gtk-3-tutorial.readthedocs.org/en/latest/treeview.html
Also, there's a relatively simple pre-made example here: http://zetcode.com/gui/pygtk/advancedwidgets/
If you just want to print something like what you showed in your post, then what you are searching for is os.walk.
Here is a good example on how to use it.
And as Michael mentioned, the os module is probably filling most of your needs regarding file manager operations.
Related
Is there a difference between face_recognition.api.face_locations and face_recognition.face_locations. The offical documentation explains the use of the former while many example codes use the latter.
if you are willing to use your face recognition program from a api provider like Microsoft, im not really sure(even tho i used the library quite a lot). In another way if you are planning to do the coding and processing on your computer, .api funtion is kind of useless(you wont need it).
Now if you need more inf check out this example that should help you understant the diffrence between the 2 : https://github.com/ageitgey/face_recognition/tree/master/face_recognition
Hope This helped you :)
Feel free to ask any question
This has got to be a silly question... but googling didn't actually help. Extra kudos for pycharm enabled answers. :)
I need a simple little UDP echo server (spare me the twisted advertisements please, this is a throw away thing, I just need to use it to peek at what a little embedded gadget is broadcasting). So I find section 21.21 of the Python 3 reference manual. It's a simple example that does exactly what I want.
But the same document also mentions a DatagramRequestHandler class. But there's no further explanation on how that differs from its parent class, or what it provides. I had really hoped that when I imported said class, that pycharm would somehow display a helpful popup for it, but I'm unable to discover such a thing.
Do I assume correctly, that I should just go find the source in my (macosx) install and look directly at that? is there a pattern for how people do that? My actual question here, is actually less about DatagramRequestHandler, and more about the general pattern, because this obviously will happen else where in the base docs.
(context: my traditional experience is with Smalltalk image based environments, where you can always just jump from class to class to class, and navigate quickly from application code all the way to the bowels, as a sort of exploratory way of learning and discovery)
There is an option to navigate to the declaration of the name under your cursor, Navigate->Declaration (shortcut CTRL+b in my keymap).
If you have such a question there are three things to do:
google it (eg. python DatagramRequestHandler)
use the help function in a interactive python session. eg.
import socketserver; help(socketserver.DatagramRequestHandler)
look into the code
Most of the time the first option is enough (this time I found only something in german). The result from the second option is in this "example" not so interesting or useful. So you have to use try third option.
I'm aware I'm supposed to show some starting code to give you a clue as to what I'm trying to do, but I'm really at a basic level and I can't find any resources to show me what I'm after. Basically, I'm trying to write a plug-in for Sublime Text editor, which selects all div ID's then outputs them into a file. What's the best approach? It seems like it should be easy, but I'm not too sure.
Thanks in advance for your help,
Ewan
This looks like a good place to start: http://www.sublimetext.com/docs/plugin-basics
Look at http://www.sublimetext.com/docs/2/api_reference.html, though be advised that Sublime Text 3 is currently in beta. It introduces changes to the plugin api, and a requirement to support Python 3. See http://www.sublimetext.com/docs/3/porting_guide.html
Assuming you have some familiarity with python, I would start with this tutorial on for writing plugins (Link). The author of that tutorial wrote, among other things, package control. Granted, it is for ST2, but for what you are trying to do, I don't for see any major issues with writing a plugin that is compatible with both ST2 and ST3.
How you go about writing your particular plugin is up to you. One approach may be leveraging the view.find_all() method. This takes a regular expression and returns a set of regions. From these regions, you can grab the text, and subsequently the IDs for the divs. There may be a better way, but that might work as an initial attempt. Writing to a file can be done through the usual python means.
I am trying to learn Python and referencing the documentation for the standard Python library from the Python website, and I was wondering if this was really the only library and documentation I will need or is there more? I do not plan to program advanced 3d graphics or anything advanced at the moment.
Edit:
Thanks very much for the responses, they were very useful. My problem is where to start on a script I have been thinking of. I want to write a script that converts images into a web format but I am not completely sure where to begin. Thanks for any more help you can provide.
For the basics, yes, the standard Python library is probably all you'll need. But as you continue programming in Python, eventually you will need some other library for some task -- for instance, I recently needed to generate a tone at a specific, but differing, frequency for an application, and pyAudiere did the job just right.
A lot of the other libraries out there generate their documentation differently from the core Python style -- it's just visually different, the content is the same. Some only have docstrings, and you'll be best off reading them in a console, perhaps.
Regardless of how the other documentation is generated, get used to looking through the Python APIs to find the functions/classes/methods you need. When the time comes for you to use non-core libraries, you'll know what you want to do, but you'll have to find how to do it.
For the future, it wouldn't hurt to be familiar with C, either. There's a number of Python libraries that are actually just wrappers around C libraries, and the documentation for the Python libraries is just the same as the documentation for the C libraries. PyOpenGL comes to mind, but it's been a while since I've personally used it.
As others have said, it depends on what you're into. The package index at http://pypi.python.org/pypi/ has categories and summaries that are helpful in seeing what other libraries are available for different purposes. (Select "Browse packages" on the left to see the categories.)
One very common library, that should also fit your current needs, is the Python Image Library (PIL).
Note: the latest version is still in beta, and available only at Effbot site.
If you're just beginning, all you'll need to know is the stuff you can get from the Python website. Failing that a quick Google is the fastest way to get (most) Python answers these days.
As you develop your skills and become more advanced, you'll start looking for more exciting things to do, at which point you'll naturally start coming across other libraries (for example, pygame) that you can use for your more advanced projects.
It's very hard to answer this without knowing what you're planning on using Python for. I recommend Dive Into Python as a useful resource for learning Python.
In terms of popular third party frameworks, for web applications there's the Django framework and associated documentation, network stuff there's Twisted ... the list goes on. It really depends on what you're hoping to do!
Assuming that the standard library doesn't provide what we need and we don't have the time, or the knowledge, to implement the code we reuse 3rd party libraries.
This is a common attitude regardless of the programming language.
If there's a chance that someone else ever wanted to do what you want to do, there's a chance that someone created a library for it. A few minutes Googling something like "python image library" will find you what you need, or let you know that someone hasn't created a library for your purposes.
I want to learn it but I have no idea where to start. Everything out there suggests reading the libpurple source but I don't think I understand enough c to really get a grasp of it.
There isn't much about it yet... the intro, the howto, and the sources (here browsing them online but of course you can git clone them) are about it. In particular, the tiny example client you can get from here does have some miniscule example of use of purple's facilities (definitely not enough, but maybe it can get you started with the help of some 'dir', 'help' and the like...?)
Not sure how much help this will be but based on information from here, it seems like you just install python-purple and import and call the functions as normal Python functions.
Can't help you with a concrete example as I decided to use something else. However, one of the first things I wanted to do after I cloned the repo was remove the ecore dependency. Here's a patch submitted to the mailing list to do just that: https://garage.maemo.org/pipermail/python-purple-devel/2009-March/000000.html
Incidentally, if you're looking for AIM take a look at twisted.words. For Yahoo, trying getting the source for curphoo or zinc (both are console YMSG clients). For GTalk/Jabber, I've had good experiences with xmpppy.