4,305 Posted Topics

Member Avatar for natehome

For a listbox with a srollbar see: http://www.daniweb.com/software-development/python/threads/191210/python-gui-programming/11#post1860815

Member Avatar for vegaseat
0
420
Member Avatar for vegaseat

The Tkinter library folder \lib-tk contains a module called turtle. You can import this module and experiment with turtle graphics. Tell the turtle to move and draw circles, lines, rectangles and more, and watch it, as it performs on a Tkinter canvas. In typical turtle fashion it moves at its …

Member Avatar for woooee
0
2K
Member Avatar for dan.nitschke

Looks at the problem from another direction ... name = "Mark Zumkoff!" # testing only # lists all characters that are not alpha or space print([c for c in name if not (c.isalpha() or c.isspace())]) if len([c for c in name if not (c.isalpha() or c.isspace())]): print("not an allowed name") …

Member Avatar for vegaseat
0
5K
Member Avatar for Tortura

The Python GUI toolkit Tkinter is based on TCL and contains a TCL interpreter ... # it is simple to run tcl scripts via Tkinter # tested with Python273 import Tkinter root = Tkinter.Tk() tcl_script = """ # this is a tcl script label .label -text "Hello World! in tcl …

Member Avatar for Tortura
0
4K
Member Avatar for Frensi

In other words ... f = open("c:/users/verzo/desktop/hello.txt") text = f.read() print(text)

Member Avatar for vegaseat
0
127
Member Avatar for rexmorgan
Member Avatar for rexmorgan
0
1K
Member Avatar for keyoh
Member Avatar for M.S.

Running your program with Python27 gives 11 matches. Which is correct, since you are looking for a name in a list of names.

Member Avatar for vegaseat
2
273
Member Avatar for python1956

The tuple that shows up in a numpy array is not a true Python tuple. In other words you can change its values.

Member Avatar for vegaseat
0
544
Member Avatar for depy

Another possible way, maybe more clear for beginners ... def items(list1): s = "" for item in list1: # build up a string s += str(item) + '\n' return s a = [1,2,3,4,5] print items(a) '''output --> 1 2 3 4 5 '''

Member Avatar for vegaseat
0
610
Member Avatar for chris99

Text based role playing games (RPG) used to be plentiful in the early days of personal computing. Usually written in Basic, C or Pascal, but I have not seen just a text based RPG in a modern language like Python. I would most likely define a function for each room …

Member Avatar for Jacklittle01
0
1K
Member Avatar for vegaseat

Just a few more explorations using a Python class to mimic a C Structure or Pascal Record. Loading the record from a csv type data file, displaying the data and sorting and searching the data in various ways.

Member Avatar for hughesadam_87
3
365
Member Avatar for ryantroop
Member Avatar for GrimJack
Member Avatar for vegaseat

Just a simple text editor using the Tkinter expansion TIX. You are encouraged to improve this program with added functions. TIX is included with the latest Python distributions.

Member Avatar for Lardmeister
2
2K
Member Avatar for Image1

Try something like this ... # plot some collected data import sys import matplotlib.pyplot as plt import numpy as np import pylab as pl raw_data = '''\ Run1 Run2 Run3 RUN4 Run5 1 23 123 1234 12.33 2 12 124 1225 13.123 3 15 125 1345 32.32 4 18 135 …

Member Avatar for vegaseat
0
169
Member Avatar for Portgas D. Ace
Member Avatar for vinnitro
2
254
Member Avatar for sillyboy
Member Avatar for vegaseat

You have to mildly trick Windows, but it is possible to put a bitmap image on your console. Uses a flock of WinApi calls. Works well with the free PellesC compiler and Dev-C++. This is a Windows Console Application. Drop me a comment, if you have luck with another compiler.

Member Avatar for I_m_rude
2
10K
Member Avatar for vegaseat

The computer is a binary beast. We want to go from the one-fingered digital box to the ten-fingered human being and convert binary to denary(base 10) numbers. This is how it works, for instance, binary 10010 is calculated as 1*16+0*8+0*4+1*2+0*1 = decimal 18. Just because it's easy, let's throw in …

Member Avatar for soorajshaji
0
2K
Member Avatar for orionscode

Too many highschool math teachers fail to inspire their students, presenting math in a dull and boring manner. If you have one of those teachers, not all is lost! Go to self-action! Ask some of your peers, that do well in math, about what makes math interesting to them. Go …

Member Avatar for ThatGuyEli
0
1K
Member Avatar for veledrom

Check also this discussion: http://www.daniweb.com/software-development/python/threads/426800/ide-for-python#post1825928 Also check this example of PyQT/PySide and its Designer program: http://www.daniweb.com/software-development/python/threads/191210/python-gui-programming/9#post1777652

Member Avatar for HiHe
0
2K
Member Avatar for avgprogramerjoe

Just a note, the use of globals is a bad habit. With a little extra effort you can assign them to function arguments and return statements.

Member Avatar for astronautlevel
0
3K
Member Avatar for WolfShield
Member Avatar for itzarun
0
1K
Member Avatar for pythonstudent11

Strings are immutable, but you can create a list of characters in the string and then process the list. Finally join the list characters to a string again. Here is an example how to do this ... [code]# capitalize the sentences in a text string text = """hello there! my …

Member Avatar for alexgwhiz69
0
5K
Member Avatar for Lardmeister

If you are rich enough to buy one of those new electric cars, you most likely won't mind paying 8 to 10 bucks for gas/petrol. Just took a look at: http://www.chevrolet.com/volt-electric-car/ and: http://www.nissanusa.com/leaf-electric-car/index http://www.nissanusa.com/leaf-electric-car/index#/leaf-electric-car/index They are sweet little cars though! In the USA there is a nice tax credit too!

Member Avatar for Stuugie
1
178
Member Avatar for johndb

I assume you used the Windows installer VPython-Win-Py2.6-5.12.exe not quite sure if that needs numpy too. I don't use Python26. The example works very well with Python25.

Member Avatar for alex.avak
0
302
Member Avatar for sneekula

A good teacher can keep students interested regardless what programming language they have to use. If I would have to teach children, I would most likely use Python because that has a turtle module (LOGO like).

Member Avatar for Sanchixx
0
482
Member Avatar for mahela007

[QUOTE=mahela007;1041863]No.. that's not it.. The new numbers keep printing on new lines.[/QUOTE]If your output window is a true console window, it will work! Many IDEs have their own GUI based output windows. It wont work there.

Member Avatar for Lucaci Andrew
0
11K
Member Avatar for mozart_azul

The **place layout manager** is probably the most difficult one to work with. Using relative values makes the widgets stretch proberly when the master is stretched. Arguments **relwidth** and **relheight** are relative to the master the widgts are in. Giving them a value of zero makes them not show up. …

Member Avatar for mozart_azul
0
925
Member Avatar for heinlein_

A question to Tony: How did you get the correct address of that post? I haven't been able to figure that out since Dani changed her format.

Member Avatar for vegaseat
0
251
Member Avatar for vegaseat

This code snippet allows you to list the files in a folder sorted by "last modified date". The tuple returned by the os.stat() function contains amongst other things the last modified date, which is then converted by the time.localtime() function to a tuple that is ideal for sorting. You can …

Member Avatar for leong87
2
8K
Member Avatar for HiHe

Just in the news ... Mitt Romney's proofreaders allowed a typo spelling “America” as “Amercia” into Romney’s new iPhone app.

Member Avatar for vegaseat
0
229
Member Avatar for webecedarian
Member Avatar for panpwintlay

A prime number is ... any natural number greater than 1 that has the two divisors 1 and itself (defined in: [URL]http://en.wikipedia.org/wiki/Prime_number[/URL]) Your algorithm is pretty bad, take a look at this C# code snippet at DaniWeb to help you out: [URL]http://www.daniweb.com/code/snippet676.html[/URL]

Member Avatar for Momerath
-1
1K
Member Avatar for jkon
Member Avatar for treyb

This should give you some hints ... # use Python module datetime # to check if a dated filename +14 days is older than todays date import datetime as dt # dated filename for test file_str = "28-Feb-12" # abbreviated month list month_abv = ['Jan','Feb','Mar','Apr', 'May','Jun','Jul','Aug', 'Sep','Oct','Nov','Dec'] # convert to …

Member Avatar for treyb
0
234
Member Avatar for CriticalError

It's a little clumsy since the output is in cmd.exe window. Here is how you do it: load the python file you want to run click the run tab run in the edit area type for instance **C:\Python27\python.exe -u $(FULL_CURRENT_PATH)** and run the command If your code is a tkinter …

Member Avatar for polochen
0
537
Member Avatar for TrustyTony

Congratulations to the two new Python moderators. Your contributions have been outstanding!

Member Avatar for vegaseat
1
282
Member Avatar for Darek6
Member Avatar for Gribouillis
0
234
Member Avatar for sunfutbol

My advice, in Python2 it is better not to use the input() function. If you don't want to type raw_input all the time start your code with something like this ... >>> input = raw_input >>> >>> name = input("Enter your name: ") Enter your name: Clark Kent >>> name …

Member Avatar for sunfutbol
0
202
Member Avatar for tiffanynguyen08

You may want to strip off the newline character ... '''file "Questions101.txt" could look like this ... Which animal has three hearts? What is Captain Kirks middle name? Which country has the most Dentists? What type of organism causes malaria? What was the first brand name for Bubble Gum? Which …

Member Avatar for vegaseat
0
5K
Member Avatar for Wolfenstein

You need to actually write the new high score out to file ... def replacement(topscore,thisplayer): if thisplayer > topscore: print "You are now the top scorer" text_file = open("topscore.txt","w") text_file.write(str(thisplayer)) text_file.close() else: print "You have not topped the score this time" # testing ... topscore = 100 thisplayer = 155 …

Member Avatar for vegaseat
0
159
Member Avatar for Ancient Dragon
Member Avatar for NetJunkie

I followed the development of computer languages just about every ten years. As a scientist in the seventies I used FORTRAN. In the eighties I switched to C. The nineties had the Delphi RAD (pascal) and ten years later I happily fooled around with Python.

Member Avatar for Reverend Jim
0
966
Member Avatar for sidestrand

What does the array look like that you get if you use ... `arr = np.loadtxt('myfile.csv', delimiter=',', usecols=(0,12,18), skiprows=1, dtype=('S5, i4, S8'), unpack=False)`

Member Avatar for sidestrand
0
2K
Member Avatar for memomk

This code is a simulation (hint) that drives your progress bar for testing purposes.. You have to replace it with code you want to move the progress bar with.

Member Avatar for memomk
0
8K
Member Avatar for anonymous0502

Tony is correct, take a look at: http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qthread.html#details and http://qt-project.org/doc/qt-4.8/threads-starting.html PySide (PyQT) example: http://www.matteomattei.com/en/pyside-signals-and-slots-with-qthread-example/ If you can, stay away from using module multiprossing with PyQT/PySide. I have locked my Windows7 machine pretty badly in the past doing just that.

Member Avatar for vegaseat
0
544
Member Avatar for 4evrmrepylrning

Maybe this will help ... data = """\ 1 apple--1 pear--1 peach--2 onion--2 carrot--3 <bee mince--3 <por chops--4 <oth salad:--potato--4 <oth bread:--garlic """ for item in data.split('--'): print item print item.split(" ", 2)

Member Avatar for 4evrmrepylrning
0
218
Member Avatar for klevasseur

404 - File or directory not found. ... this is what I get with your second reference.

Member Avatar for vegaseat
0
136

The End.