python

How do I get a windows border like this in Tkinter?

Is there any way to get a border like this in Tkinter? Notice how it lacks the buttons on the top right. Also I don't want this program to show in the task bar. This is in windows 7, btw. ...

How to install Bazaar to a shared server via SSH?

If I have SSH access to a shared server (running centOS) and I want to install Bazaar. I do not have root access, but Python is already installed on the server, so that shouldn't be a problem. I really don't know where to begin after logging into the server. I'm assuming the first step is to copy the Bazaar application files onto the se...

Any good recursive tutorials? Python?

Wondering if anyone could point me towards a good recursion tutorial. I am a bit rusty on it as I learned about it in my Data Structures class first semester. Would like to brush up on my recursion...any help? ...

Create an instance that represents the average of multiple instances

I have a Review Model like the one defined below (I removed a bunch of the fields in REVIEW_FIELDS). I want to find the average of a subset of the attributes and populate a ModelForm with the computed information. REVIEW_FIELDS = ['noise'] class Review(models.Model): notes = models.TextField(null=True, blank=True) CHOICES = ((1, ...

Else clause on Python while statement

Hi everyone, I've noticed the following code is legal in Python. My question is why? Is there a specific reason? n = 5 while n != 0: print n n -= 1 else: print "what the..." Thanks. ...

How do you refresh a window in Tkinter

If I created Tkinter window with some text that filled the whole window and now wanted to replace the window with a new text, is there a way to refresh the window? For Example: a= 100 win= Tk() win.geometry("500x300") while a > 0: if a%2 == 0: lbl = Label (win, bg = "purple") lbl.pack() ...

Django subclasses having unique IDs

Assuming I have an abstract class ("AbstractClass") and two subclasses ("Subclass1" and "Subclass2"), two separate database tables will be created to hold instances of Subclass1 and Subclass2. These database tables currently number normally, from 1 upwards. Is there a way to ensure the IDs of all implementing subclasses are unique betwe...

Why aren't my sqlite3 foreign keys working?

I run the following code from a python interpreter, and expect the insert statement to fail and throw some kind of exception. But it's not happening: Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 >>> conn = s...

Opposite of Python for ... else

The following python code will result in n (14) being printed, as the for loop is completed. for n in range(15): if n == 100: break else: print(n) However, what I want is the opposite of this. Is there any way to do a for ... else (or while ... else) loop, but only execute the else code if the loop did break? ...

Is there a way to fix vim not-noticing python if statements that have comments?

Consider the following block of code- if (1==1):#Go forever print "Wooo." Vim doesn't see the :, due to the comment, so it insists that the print should be at the same indent level as the "if" using http://www.vim.org/scripts/script.php?script_id=974 Any thoughts would be appreciated. ...

Rich text to be stored using django

If csv file has rich text in it. Using csv.reader() can the same format stored in the Mysql database using django and retrieved back to html pages? Thanks.. ...

Case insensitive dictionary search with Python

I can use map to implement the case insensitive list search with Python. a = ['xyz', 'wMa', 'Pma']; b = map(string.lower, a) if 'Xyz'.lower() in b: print 'yes' How can I do the same thing with dictionary? I tried the following code, but ap has the list of ['a','b','c'], not the case insensitive dictionary. a = {'a':1, 'B':2, '...

Improve performance of self join in sqlite

I have a table with 21 columns (all integers) id, c1 , c2 ... c20 and what to fetch ids for rows that have the same values in the columns ... so row 1 will match row 10 if row 1 c1 = row 10 c1 and row 1 c2 = row 10 c2 ... and so on. This is what the query looks like: select r1.id, r2.id from tbl r1, tbl r2 where 1=1 and r1.c1=r...

Convert a Python snippet to PHP?

Can anyone translate my small Python snippet to PHP? I'm not a familiar with both languages. :( matches = re.compile("\"cap\":\"(.*?)\"") totalrewards = re.findall(matches, contents) print totalrewards Thank you for those who'd help! :( ...

Why do I get an error in python saying that a method cannot be found even though I previously defined the method?

index = 0 def changeColor(): global index if index%2==0: label.configure(bg = "purple") else: label.configure(bg = "blue") index+=1 label.after(1000, changeColor) def Start (self): # command when start button is clicked in GUI self.root = Tk() self.root.geometry("500x300") mainContainer...

How to pass an argument to event handler? python, tkinter programming

Hi friends., widget.bind('<Button-1>',callback) # binding def callback(self,event) #do something i need to pass an argument to callback() .the argument is a dictionary object. thanks in advance sag ...

Scripting OpenOffice Forms with VB or python

Hi I'm trying to script my OpenOffice document (Writer in my case) to do some simple things with widgets. Namely I'd like to copy text from widget to widget. For this I want to get one component and than get text from it. I've been trying to do sth like this: document = ThisComponent.CurrentController.Frame oDocument = ThisCo...

Python: How to call unbound method with other type parameter?

Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class A(object): ... def f(self): ... print self.k ... >>> class B(object):pass ... >>> a=A() >>> b=B() >>> a.k="a.k" >>> b.k="b.k" >>> a.f() a.k >>> A.f(a) a.k >>> A.f(b) Trace...

Python threading + socket IO lockup problem in Cygwin

I am having a weird concurrency issue with Python on Cygwin. I am running two threads: A thread which sends UDP packets at regular intervals A main thread which waits for KeyBoardInterrupt and when it receives one, it tells the UDP thread to stop sending via a boolean flag This works just fine under Linux (python 2.6) and Windows (Py...

What's the equivalent of C#'s GetBytes() in Python?

Hi, I have byte[] request = UTF8Encoding.UTF8.GetBytes(requestParams); in a C# AES encryption only class that I'm converting to Python. Can anyone tell me the Python 2.5 equivalent(I'm using this on google app engine? Example inputs: request_params: &r=p&playerid=6263017 (or a combination of query strings) dev_key: GK1FzK12iPYKE9...