python

In GTK, is there an easy way to scale all widgets by an arbitrary amount?

I want my widget to look exactly like it does now, except to be smaller. It includes buttons, labels, text, images, etc. Is there any way to just say "scale this to be half the size", and have GTK do all the image processing, widget resizing, etc., necessary? If not, what's the easiest way to accomplish this? ...

Scale an image in GTK

In GTK, how can I scale an image? Right now I load images with PIL and scale them beforehand, but is there a way to do it with GTK? ...

How can I change the font size in GTK?

Is there an easy way to change the font size of text elements in GTK? Right now the best I can do is do set_markup on a label, with something silly like: lbl.set_markup("<span font_desc='Tahoma 5.4'>%s</span>" % text) This 1) requires me to set the font , 2) seems like a lot of overhead (having to parse the markup), and 3) would make ...

Python threading question - returning control to parent

Hi all, Basically, I have a python program which listens for DeviceAdded DBus events (e.g. when someone plugs in a USB drive), and when an event occurs, I want to create a thread which collects metadata on that newly connected device. However, I want to do this asynchronously - that is, allow one thread to keep collecting metadata on th...

Passing kwargs from template to view?

As you may be able to tell from my questions, I'm new to both python and django. I would like to allow dynamic filter specifications of query sets from my templates using **kwargs. I'm thinking like a select box of a bunch of kwargs. For example: <select id="filter"> <option value="physician__isnull=True">Unassigned patients</opti...

Get information from related object in generic list view

So, I've been noodling about with Django's generic views, specifically the object_list view. I have this in my urls.py: from django.conf.urls.defaults import * from django.views.generic import list_detail from diplomacy.engine.models import Game game_info = { "queryset": Game.objects.filter(state__in=('A', 'P')), "template_obj...

which BBS or forum are good for python learner?

Possible Duplicates: Best online resource to learn Python? Python Forums I am a python beginner. Can you give me some suggests ? ...

Unusual Speed Difference between Python and C++

I recently wrote a short algorithm to calculate happy numbers in python. The program allows you to pick an upper bound and it will determine all the happy numbers below it. For a speed comparison I decided to make the most direct translation of the algorithm I knew of from python to c++. Surprisingly, the c++ version runs significantly...

mechanize (python) click on a javascript type link

Hi, is it possible to have mechanize follow an anchor link that is of type javascript? I am trying to login into a website in python using mechanize and beautifulsoup. this is the anchor link <a id="StaticModuleID15_ctl00_SkinLogin1_Login1_Login1_LoginButton" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&...

About Python's Mixed Numeric Data Types converting results up to the most complicated operand...

A little background: I'm in the process of learning Python through O'Reilly's, "Learning Python" book, I've had some experience in Java. Anyway, upon reading Chapter 5 (I'm still in the middle of it, actually) I have come across a question with the way Python treats results of Mixed Numeric expressions. In the book, they use an example...

Python standard library to POST multipart/form-data encoded data

hello, I would like to POST multipart/form-data encoded data. I have found an external module that does it: http://atlee.ca/software/poster/index.html however I would rather avoid this dependency. Is there a way to do this using the standard libraries? thanks ...

how to print python location(where python is install) in the output

Lets say Python is installed in the location "C:\TOOLS\COMMON\python\python252" . I want to print this location in the output of my program. Please let me know which is the function for doing this. Thank you very much. ...

Python Get Docstring Without Going into Interactive Mode

I want to grab the docstring in my commandline application, but every time I call the builtin help() function, Python goes into interactive mode. How do I get the docstring of an object and not have Python grab focus? ...

Print out the line with the longest length, the line with the highest sum of ASCII values, or the line with the greatest number of words

I need some help to print out the line with the longest length, the line with the highest sum of ASCII values, or the line with the greatest number of words from a text file. This is my first time programming and I'm really struggling with python and don't know how to calculate want is required for my lab this week. I 've try to work it ...

django unit testing and global fixtures

I'm working on a web project in Django, and I'm using the python unittest framework. For every app I have some fixtures. This means, that every app has some identical tables in fixtures. I would like to share fixtures between apps and testcases, because otherwise if I change a model, I will have to change all json fixtures where this con...

Why does import of ctypes raise ImportError?

Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import ctypes Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python26\lib\ctypes\__init__.py", line 17, in <module> from struct import ca...

Most concise way to check whether a list is empty or [None]?

Most concise way to check whether a list is empty or [None]? I understand that I can test: if MyList: pass and: if not MyList: pass but what if the list has an item (or multiple items), but those item/s are None: MyList = [None, None, None] if ???: pass ...

Python - how to refer to relative paths of resources when working with code repository

We are working with a code repository which is deployed both to windows and linux, sometimes on different directories. How should one of the modules inside the project refer to one of the non-python resources in the project (CSV file, etc.)? If we do something like thefile=open('test.csv') or thefile=open('../somedirectory/test.csv')...

How to remove two chars from the beginning of a line

I'm a complete Python noob. How can I remove two characters from the beginning of each line in a file? I was trying something like this: #!/Python26/ import re f = open('M:/file.txt') lines=f.readlines() i=0; for line in lines: line = line.strip() #do something here ...

Resize a figure automatically in matplotlib

Is there a way to automatically resize a figure to properly fit contained plots in a matplotlib/pylab image? I'm creating heatmap (sub)plots that differ in aspect ratio according to the data used. I realise I could calculate the aspect ratio and manually set it, but surely there's an easier way? ...