473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using python to extend a python app

I'm writing a python app that works as a replacement for the menu that
comes with most minimalist wms when you right click the root window.
It's prettier and written completely in python.

I'd like to provide hooks or some system so that people can write their
own extensions to the app, for example adding fluxbox options, and then
fluxbox users can choose to use that extension. But I'm not sure how to
implement it.

Right now the best idea I have is to have all desired extensions in a
folder, import each .py file in that folder as a module using
__import__, and then call some predetermined method, say "start", and
pass it the menu as it exists so far so they can add to it, start(menu).
This seems kind of hackish.

I looked at how gdesklets handles this, but its solution looks way more
complex than I'd prefer to have to dive into for this tiny app.

What's the most pythonic way to do this? How do apps that extend
themselves with python usually do this?
Jul 18 '05 #1
1 1331
dataangel <k0*****@kzoo.edu> writes:
I'm writing a python app that works as a replacement for the menu that
comes with most minimalist wms when you right click the root window.
It's prettier and written completely in python.

I'd like to provide hooks or some system so that people can write
their own extensions to the app, for example adding fluxbox options,
and then fluxbox users can choose to use that extension. But I'm not
sure how to implement it.

Right now the best idea I have is to have all desired extensions in a
folder, import each .py file in that folder as a module using
__import__, and then call some predetermined method, say "start", and
pass it the menu as it exists so far so they can add to it,
start(menu). This seems kind of hackish.


That looks pretty reasonable, and easy. There have been some recent
threads (in the past month or so) on plugins, so you might want to
search the archives. Most of it's revolved around not using exec :-)

I just had a look at pyblosxom (one program that I know that uses
plugins), and it uses exactly this approach, with some extra frills:
looking in subdirectories, for instance.

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Andy Bulka | last post by:
Whilst almost responding to the 'dream project' thread I decided that this post warranted its own thread. What about a solid UML tool with round trip functionality for the Python Community? ...
5
by: Robert Brewer | last post by:
WARNING: The following is NOT all Pythonic. However, it is Python. This is just fun--nothing I'm going to put into production. I don't have any questions or problems--just thought I'd share. ...
75
by: David MacQuigg | last post by:
Seems like we need a simple way to extend Python syntax that doesn't break existing syntax or clash with any other syntax in Python, is easy to type, easy to read, and is clearly distinct from the...
7
by: Bo Peng | last post by:
Dear Python group: I am planning on an application that involves several complicated C++ classes. Basically, there will be one or two big data objects and some "action" objects that can act on...
8
by: John Salerno | last post by:
Ok, for those who have gotten as far as level 2 (don't laugh!), I have a question. I did the translation as such: import string alphabet = string.lowercase code = string.lowercase + 'ab'...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
18
by: Jens | last post by:
I'm starting a project in data mining, and I'm considering Python and Java as possible platforms. I'm conserned by performance. Most benchmarks report that Java is about 10-15 times faster than...
2
by: vijay | last post by:
Hi I have a python code performing some computation for me.I have a html page which passes certain argumnets to a php page.This php page needs to pass on the value to the Python class and get the...
4
by: spectrumdt | last post by:
Hello. I am trying to extend Python with some C code. I made a trivial "Hello World" program in C that I am trying to wrap in "boilerplate" for inclusion in a Python program. But I can't compile...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.