14,952 Topics

Member Avatar for
Member Avatar for user45949219

Hey guys, I've been fiddling around with Tkinter for a bit and can't for the love of me figure out why this code won't work. I'm making a GUI that outputs the price of a product depending on what buttons the user pressed. I have three calculations that revolve around …

Member Avatar for Gribouillis
0
153
Member Avatar for luofeiyu

1.[url]http://www.renren.com/Login.do[/url] it is ok,my code: import cookielib, urllib2, urllib cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) exheaders = [("User-Agent","Mozilla/4.0 (compatible; MSIE 7.1; Windows NT 5.1; SV1)"),] opener.addheaders=exheaders url_login = 'http://www.renren.com/Login.do' body = (('email',' '), ('password', ')) req1 = opener.open(url_login, urllib.urlencode(body)) file=open('/tmp/sample','w') file.write(req1.read()) file.close() 2.[url]https://passport.baidu.com/?login[/url] can't login,my code: import cookielib, urllib2, urllib …

-1
87
Member Avatar for Kleiner

Hi. I am having a problem in creating of one simple program in Python. Here is code. [CODE]import wx class bucky(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, "Testing erea", size=(280,400)) panel = wx.Panel(self) food = wx.Button(panel,label='Food',pos=(10,10),size=(80,40)) pets = wx.Button(panel, label='Pets', pos=(100,10), size=(80,40)) self.Bind(wx.EVT_BUTTON, self.food, food ) def food(self, event): …

Member Avatar for Kleiner
0
280
Member Avatar for theharshest

I am new to Django. When I tried creating a template, I got the following error. Please help. [CODE]>>> from django.template import Template, Context >>> t = Template("The name is {{name}}") Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> t = Template("The name is {{name}}") File "C:\Python27\lib\site-packages\django\template\base.py", …

Member Avatar for Enalicho
0
186
Member Avatar for alibstar

The first problem: I have 12500+ emails stored as text files. The majority of these text files contain quoted text from previous emails which I need to remove for the subsequent analysis of the data. (Example of a standard email text file:) From: … To: … Subject line: … Text …

Member Avatar for Enalicho
0
98
Member Avatar for JeffOwens

Here is my code: [CODE] #------------------------------------------------------------------------------- # Name: Mocha Rotoscoping Via Blender # Purpose: Make rotoscoping more efficient # # Author: Jeff Owens # # Created: 11/07/2011 # Copyright: (c) jeff.owens 2011 # Licence: Grasshorse #------------------------------------------------------------------------------- #!/usr/bin/env python import sys import os import parser sys.path.append('Z:\_protomotion\Prog\HelperScripts') import GetDir sys.path.append('Z:/Blender_Roto') filename = …

Member Avatar for Enalicho
0
134
Member Avatar for JoshuaBurleson

so I recently wrote a function that sorted using the last value in a tuple. Obviously this couldn't be done simply say sorted(tuples, key=tuples[-1]) because that is not a "legal" call. However I did run across, while trying to figure out how to make things like this work, the utilization …

Member Avatar for nabla2
0
578
Member Avatar for emorjon2

Hi all! I try to install PyBluez on my python 2.6 in Windows 7, so a can communicate with my NXT brick, but it seens like there's a file in the library that dosn't work. When I installed PyBluez, it was impossible to import the library into code because then …

0
87
Member Avatar for JoshuaBurleson

if I wanted to remove all of the strings within a given list that met a certain criteria, such as having the str'a' in them, how would I go about doing that? the only way that's intuitive to me a for/in loop, but that can't be done. any ideas? Using …

Member Avatar for Enalicho
0
237
Member Avatar for mools3

Hello everyone , as you can see i'm very beginer in python programming 1 mounth ago , i'm teaching my self from a python and tkinter book i'm trying to write a program that opens the main window after entring the username and password Problem 1: The usernames and passwords …

Member Avatar for Enalicho
0
157
Member Avatar for JoshuaBurleson

I'm doing the google code U python class and came across a problem trying the following problem, which is the commented out region, the solution needs to be a function. I'm on the second part and trying to find a way to count the values which meet the requirement,i[0:2]==i[-2:]. I …

Member Avatar for TrustyTony
0
491
Member Avatar for JoshuaBurleson

I got this snippet out of my text book but it's giving me a type error, I'll just give you the whole code, tell me if you get it too, if you would. [CODE]import urllib.request import math whips=int(0) rate=float(4) while rate <= float(20): improve= rate*float(.15)+rate rate= improve whips=whips+1 print(whips) def …

Member Avatar for JoshuaBurleson
0
317
Member Avatar for pixeldroid

This is related to [url]http://www.daniweb.com/software-development/python/threads/111526[/url] However, in this case, I don't necessarily know the value of the var from which I am getting the name using vars(). Is there a way to get it? [CODE]prefix = 'char' lidControls = [] lidControls2Make = ['uprLid', 'lwrLid','lwrLidTrack', 'uprLidTrack','uprLidRef','lidRig'] for control in lidControls2Make: objTmp …

Member Avatar for pixeldroid
0
204
Member Avatar for Needshelp444

Is it even possible...I am not sure. Here is my code so far when I click on the Prog_1_Database buttons I want a window to pop up with more button widgets in. Currently the button widget unfortunately gets added to the top level Here is the code so far: [CODE] …

Member Avatar for Needshelp444
0
2K
Member Avatar for isendre

I am required to create a function that returns a list of all instances of single characters in 'text' that immediately follow 'last'. For example... def follow_char(text,last): """ >>> follow_char('as we consider the operations', 'co') ['n'] """ I think I am required to solve this using linked lists but am …

Member Avatar for isendre
0
69
Member Avatar for ihatehippies

Currently running python 2.7 on windows 7. I have an app created with wx python and compiled with py2exe. This app has an update utility that polls an update server at startup. If an update is found it downloads the new executable file (approx. 7mb) and makes the switch. It …

0
129
Member Avatar for lawtan87

when the user hits enter it will display Price must be a valid positive number product_price=input("Please enter product price:") while product_price <=0 or product_price=="": print"Price must be a valid positive number" product_price=input("Enter product price:") but it get the following error when the user hits enter SyntaxError: unexpected EOF while parsing

Member Avatar for Enalicho
0
117
Member Avatar for Purkinje

[url=http://www.daniweb.com/software-development/python/threads/375271/1621485#post1621485]Sample code credited to Enalicho[/url] In this example, we count the number of appearances of the number 1 through a range of pages using while loops. First off, notice how easy it is to tell what the variables in this method are doing. I did not write this method, but …

0
187
Member Avatar for pYnewb

Hello, I would like to stress that this is for personal practice and nothing school or assignment related. The question: Create a function countPages(x) that takes the number of pages of a book as an argument and counts the number of times the digit '1' appears in the page number. …

Member Avatar for Purkinje
0
562
Member Avatar for kur3k
0
58
Member Avatar for JeffOwens

So I have some code that basically takes a file given with 4 points taken from a rotoscoped scene and spits out an output of information in the form of a list Original File Format Frame 1(Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s)) Frame 2(Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s)) Frame 3(Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s)) Frame 4(Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s)) Frame 5(Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s)) Frame 6(Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s),Point(x,y,z,w,s)) Output ============ Frame …

Member Avatar for TrustyTony
0
119
Member Avatar for TrustyTony

What does this print statement produce and why? Learned it today, I still must be a newbie. [CODE]print('%0*d' % (3, 7))[/CODE]

Member Avatar for Purkinje
1
192
Member Avatar for patto78

I want to install the dateutil module to work with Python 3.1. I didn't get very far through this installation however before I was advised that I also needed to install setuptools. I've tried to do this using the commands given below, but am not having any success. [CODE][/CODE]$ tar …

Member Avatar for TrustyTony
0
187
Member Avatar for Alex9385

Hi, I would like to select rows from a 2D numpy array according to a condition. I would like to get a 2D results array directly without the need of the costly np.reshape statement. Does anybody know how to assemble array b more efficiently? Thanks, Alexander [CODE]>>> a = np.array([[0, …

Member Avatar for TrustyTony
0
171
Member Avatar for kaellee

#!/usr/bin/env python from socket import * import time import sys import select import threading import Queue _name_='_main_' loop=2 def client1_chat(connection1,connection2,i): while 1: data1=connection1.recv(1024) if data1=='end': end1=data1 connection1.close() connection2.send('%s' % data1) break else: connection2.send('%s' % data1) def client2_chat(connection2,connection1,i): while 1: data2=connection2.recv(1024) if data2=='end': end2=data2 connection2.close() connection1.send('%s' % data2) break else: connection1.send('%s' …

0
69
Member Avatar for halien

Hi all, I am trying to write a list of complex numbers to a csv file. The list looks like: [QUOTE] cpl1 = [(-6.4703169037894082e-12-2.7429131015110908e-12j), (-9.0688415110840026e-11+1.7513018812920222e-11j), (-1.8522787470498514e-10+1.3074128585310874e-11j), (-5.8563154325952382e-10-6.4430377699764563e-10j), (2.1451734832922398e-10-9.987741744765799e-10j), (2.9095870157647141e-10-6.3227384439201728e-10j), (1.9448214150230569e-09+5.1612969453884716e-10j)] [/QUOTE] The complex numbers are to be written to file to look like: [QUOTE] real, imaginary, real, imaginary, real, imaginary, …

Member Avatar for bvdet
0
272
Member Avatar for shasta90

[url]http://www.daniweb.com/software-development/python/threads/187060/1572491#post1572491[/url] based on a previous thread I would like to know how to replicate the appearance of a house five times on the gasp interface via the script below: #!/usr/bin/env python from gasp import * # import everything from the gasp library begin_graphics(title="Houses At Night", background=color.BLACK) # open the graphics …

Member Avatar for ~s.o.s~
0
1K
Member Avatar for Simplicity.

Hi all, This code solves the Euler Equation of Gas Dynamics which is a system of partial differential equations. The problem is that it takes very long to run than it would normally required. Things become worse after including the functions "S_p(a_p,a,b)" and "S_m(a_p,a,b)" which are called within other functions …

Member Avatar for Simplicity.
0
143
Member Avatar for Gribouillis

A functor, or function object is sometimes a convenient way to encapsulate helper functions and data needed to achieve a small task, and also to share data between calls to the same function. This snippet defines a base class [b]functor[/b] which permits an easy functor creation for python 2.

Member Avatar for TrustyTony
2
700
Member Avatar for blivori

Hi, I created a Python script using pyPDF that automatically merges all the PDFs in a folder and puts them into an output folder and rename them automatically as per the folder's name. What I want to do now is for the script to search for sub-directories, process all the …

Member Avatar for blivori
0
222

The End.