4,305 Posted Topics

Member Avatar for vegaseat

Here we experiment with a gauge or progress bar made from a label displaying a variable number of spaces in color. In this example, we use from 0 to 100 spaces. This label based gauge allows you to choose many different colors, and you can even change the color as …

Member Avatar for naytanl
1
592
Member Avatar for MooGeek

I changed my New Year's Resolution to not making any New Year's Resolution in the future. :)

Member Avatar for ifiok.idiang
1
312
Member Avatar for ramesh125

You could store it as a list of (x, y) or (x, y, z) tuples. I think [B]richieking[/B] already gave you the hint.

Member Avatar for TrustyTony
0
175
Member Avatar for bumsfeld

I fell in love with Python the moment I started using it to solve scientific problems. That was about 7 years ago. Before that I used C and then Pascal/Delphi.

Member Avatar for vegaseat
1
127
Member Avatar for cwarn23

Might be better to find a virus that gets rid of all mosquitoes. Who needs those blood sucking beasts anyway? :)

Member Avatar for vegaseat
0
222
Member Avatar for scru

Here is one example I have: [QUOTE]Quit will quit the tcl interpreter of Tkinter! If IDLE is used, then quit will freeze it, since IDLE uses Tkinter too! Replace quit with destroy, destroy is used to destroy a particular window in a multiwindow program.[/QUOTE]

Member Avatar for richieking
0
235
Member Avatar for sneekula

The Spanish Flu after WW1 was mostly a bird flu and killed about 50 million people worldwide. Of course nobody in those days even knew what a virus was. In this modern age influenza kills about 36,000 people in the USA every year. Of course mostly the elderly and very …

Member Avatar for bumsfeld
2
935
Member Avatar for vegaseat

Does anybody have a tested function in C or C++ that sends text to the printer in a Windows Console Application? I would be very appreciative! It would be nice, if I could specify the font. Yes, I can google!

Member Avatar for abdullah0
0
221
Member Avatar for rssk

With older versions of Python you might have to use ... [code]""" file_1.txt--> 99 root S 5176 95 41.2 8.3 snmpd file_2.txt--> 99 root S 5176 95 1.0 8.3 snmpd """ from __future__ import with_statement with open('file_1.txt') as file_1: with open('file_2.txt') as file_2: f1 = [float(item.split()[5]) for item in file_1] …

Member Avatar for snippsat
0
193
Member Avatar for Ene Uran

[COLOR="Red"]after pylab.show() I don't get the >>> in IDLE! The program stalls on that last pylab.show() statement.[/COLOR] For heaven sake don't run the code from the Python shell! Run it from the editor! The python shell is used for testing very short Python code concepts, mostly one-liners!

Member Avatar for Flintstone_
2
2K
Member Avatar for Boubakr

If you want to do that with a while loop, you need an updated counter and an exit condition.

Member Avatar for -ordi-
0
92
Member Avatar for mossa
Member Avatar for Smed

Something like this could do it ... [code]listA = [1, 5, 3, 4] # index to be excluded index = 1 mx = 0 for ix, n in enumerate(listA): if n > mx and ix != index: mx = n print(mx) [/code]

Member Avatar for TrustyTony
0
126
Member Avatar for rssk

Something like this may give you a hint ... [code]def extract_number(data_str): """ extract the numeric value from a string (the string should contain only one numeric value) return the number or None """ s = "" for c in data_str: if c in '1234567890.-': s += c if s: # …

Member Avatar for rssk
0
120
Member Avatar for Boubakr
Re: PyQt

You could take a look at: [url]http://www.riverbankcomputing.com/software/pyqt/download[/url] Also check if the Eric IDE is available in your repository. It is written in Python and PyQT and should install PyQT for you. [url]http://eric-ide.python-projects.org/[/url]

Member Avatar for Boubakr
0
77
Member Avatar for saransh60

Python does "duck typing", look at this example ... [code]def adder(d): d = d + d print d x = 1 adder(x) # 2 x = 1.5 adder(x) # 3.0 x = 'bon' adder(x) # bonbon [/code]

Member Avatar for vegaseat
0
142
Member Avatar for romes87

You could change your last lines to something like this ... [code]print '-'*10 print "lines different in text 2 from text 1:" difference21 = "" for line in result: if line[0] == '+': print line difference21 += line print '-'*10 print "lines different in text 4 from text 3:" difference43 …

Member Avatar for richieking
0
910
Member Avatar for Blackberryy

[QUOTE=Blackberryy;1409211]Cheers for your help guys. Not sure what Tkinter is as i am using the graphics module anybody have any help using the graphics module.[/QUOTE] John Zelle, Ph.D. teaches Python at Wartburg College He is the author of graphics.py used by a number of schools instead of Tkinter Get the …

Member Avatar for richieking
0
2K
Member Avatar for Harris00

turtle.circle(radius, extent=None, steps=None) extent is an angle, 360 by default, less than 360 for an arc

Member Avatar for loveerl
0
726
Member Avatar for mirena
Member Avatar for vegaseat
0
177
Member Avatar for vegaseat

This little code snippet shows you how you save a wxPython canvas drawing to a standard image file.

1
2K
Member Avatar for Cup of Squirrel

Pelles C is free and comes with support for Pocket PC and Smartphones. It has a great IDE and helpfile! Download it from: [url]http://smorgasbordet.com/pellesc/index.htm[/url]

Member Avatar for mslade
1
2K
Member Avatar for tech291083
Member Avatar for ukAntt

Take a look at: [url]http://sourceforge.net/projects/pymilter/[/url] very sophisticated approach: [url]http://www.ailab.si/orange/[/url]

Member Avatar for vegaseat
0
126
Member Avatar for qingmui

I am showing this only as a basic example of a recursive function ... [code]# a typical example of a recursive function # there is a limit to recursions in Python # sys.getrecursionlimit() --> usually 1000 # can be changed with # sys.setrecursionlimit(new_limit) def palindrome_recursive(s): # slicing gets the first …

Member Avatar for vegaseat
0
780
Member Avatar for thomas.jerald

Python has a module ConfigParser that makes writing and reading configuration files easier. Look in your Python documentation, there are actual examples there.

Member Avatar for vegaseat
0
101
Member Avatar for novice20

My fatherly advice, do not name a variable [COLOR="Red"]str[/COLOR] since [COLOR="Red"]str[/COLOR] is also a built-in Python function name. This would get you into trouble if you ever want to use the str function later in your code.

Member Avatar for novice20
0
109
Member Avatar for FreezeBlink

The Tkinter GUI toolkit that installs with just about every Python version, has some power under the hood even for console applications. See: [url]http://www.daniweb.com/forums/post1288813.html#post1288813[/url]

Member Avatar for richieking
0
14K
Member Avatar for durhamandy

Just a few common Python functions will do ... [code]# find the index of the largest item in a list # index starts at zero a = [77, 123, 18] a_max = max(a) ix_max = a.index(a_max) print(a) # [77, 123, 18] print(a_max) # 123 print(ix_max) # 1 [/code]

Member Avatar for vegaseat
0
246
Member Avatar for linux

Here is an example using PIL ... [code]# use the Python Image Library (PIL) to load and flip an image # convert the two PIL images to Tkinter images and display # tested with Python26 by vegaseat import Tkinter as tk from PIL import Image, ImageTk root = tk.Tk() cv …

Member Avatar for richieking
0
4K
Member Avatar for Dark_Omen

Download the BCX system from: [url]http://www.rjpcomputing.com/programming/bcx/devsuite.html[/url] It's free, creates C or C++ code you can look at and learn from. Super help file and lots of GUI samples. Look at BCX as a preprocessor. I use it all the time, a great learning tool.

Member Avatar for kvprajapati
-1
4K
Member Avatar for Thisisnotanid

C (or its OOP cousin C++) is a compiled language and will be faster than an interpreted language like Python.

Member Avatar for Thisisnotanid
0
574
Member Avatar for LogicallyInsane

One way ... [code]text = 'This is a line of text' # notice the added spaces new_text = text.replace(' is ', ' is not ') print(text) # This is a line of text print(new_text) # This is not a line of text [/code]

Member Avatar for vegaseat
0
119
Member Avatar for MooGeek

With minor breaks I have done up to 18 hours of coding in a day's time. After that, things get even more goofy than normal.

Member Avatar for ajst
0
170
Member Avatar for novice20

[QUOTE=novice20;1426811]can anyone suggest a simple method to define an enum in python. as some examples floating on net, i used class Animal: DOG=1 CAT=2 print Animal.DOG but it doesn't seem to be working...[/QUOTE] This works ... [code]class Animal: DOG = 1 CAT = 2 print Animal.DOG # 1 [/code]

Member Avatar for novice20
0
126
Member Avatar for AndreRet

2010 resolution --> drop your weight by 10 pounds 2011 resolution --> drop your weight by 5 pounds

Member Avatar for vegaseat
0
167
Member Avatar for mcenley

It might be simpler to draw a Koch fractal using the module turtle that comes with your Python installation ... [code]import turtle as tu def Koch(length): """draw a Koch fractal curve recursively""" if length <= 2 : tu.fd(length) return Koch(length/3) tu.lt(60) Koch(length/3) tu.rt(120) Koch(length/3) tu.lt(60) Koch(length/3) tu.speed(0) length = 300.0 …

Member Avatar for vegaseat
0
3K
Member Avatar for Dave Sinkula

What is missing here is an example of a text entry followed by a numeric entry. I tried to combine the code presented and should the text exceed its length of 19 and have numbers at the end, ouch!

Member Avatar for WaltP
10
8K
Member Avatar for deepakgupta2186

The keys in a Python dictionary are in hash order for fast look-up. You can not maintain alphanumeric order unless you use an OrderedDict object, new in Python27 and higher.

Member Avatar for TrustyTony
0
177
Member Avatar for FAITH2011

Create your random numbers inside the loop, something like this ... [code]# generate random number a certain number of times import random # now print different number 10 times for count in range(1,11): # create random numbers d1= random.randint(1,10) d2= random.randint(1,10) print (d1,d2) [/code]

Member Avatar for FAITH2011
0
152
Member Avatar for pi_lord12

[QUOTE=pi_lord12;1420529]Hey, I'm new to Python and wondering about the following bit of code. It tells me that the module random has no attribute randint. I've looked at the documentation and such and I think I'm doing it correctly, but obviously something's wrong. Any ideas? Thanks! [code] import random int1=random.randint(1, 6) …

Member Avatar for pi_lord12
0
2K
Member Avatar for LanierWexford

I am running Python 25, 26, 27 and 31 in my Windows7 machine. The trick is to use an IDE like Editra that allows you to specify which Python version to use.

Member Avatar for richieking
0
172
Member Avatar for brianmitchell

If you want to do a selection sort without any for/while, you have to do a recursive function. List comprehension does contain a for loop. [QUOTE]Hopefully helpful hint: A selection sort of a list of numbers is pretty simple. You start with two lists, let's call the original unsorted list …

Member Avatar for seanbp
0
210
Member Avatar for ~s.o.s~

Just to interject the lighter side of the nuptials into this sometimes sober discussion ... [QUOTE] By all Means... MARRY! I recently read that love is entirely a matter of chemistry. That must be why my wife treats me like toxic waste. - David Bissonette When a man steals your …

Member Avatar for Borzoi
0
726
Member Avatar for acrocephalus

An oldy but goody (includes Tkinter): [url]http://bembry.org/technology/python/index.php[/url] Tkinter reference: [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdf[/url] Another tutorial source (uses graphics.py, a simplified wrapper for Tkinter): [url]http://webpages.cs.luc.edu/~anh/python/hands-on/index26.html[/url] This online book does not touch graphics, but is rather thorough with Python: [url]http://learnpythonthehardway.org/static/LearnPythonTheHardWay.pdf[/url] Swaroop C.H. has rewritten his excellent beginning Python tutorial for Python3 (Python2 version is still …

Member Avatar for Dylan Solarsh
0
239
Member Avatar for Naynah
Member Avatar for patrickgormally

I would use ... [code] # the next 2 items have to be numbers not strings increase_rate = float(name_DOB_salary[4]) initial_money = float(name_DOB_salary[3]) final_money = initial_money + initial_money*increase_rate [/code]... and then multiply increase_rate by 100 to get percent

Member Avatar for patrickgormally
0
3K
Member Avatar for happygeek
Member Avatar for The Dude
Member Avatar for ritcherjd

What a lively thread!!! I have been accused of using lame old Turbo C code in the past by our friend Narue, and heeded her salutary advice. I have to admit that I enjoy her comments a lot, and of course the always impeccable English. Please take it easy on …

Member Avatar for angelique28
0
1K

The End.