4,305 Posted Topics
Re: For a listbox with a srollbar see: http://www.daniweb.com/software-development/python/threads/191210/python-gui-programming/11#post1860815 | |
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 … | |
Re: 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") … | |
Re: 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 … | |
Re: In other words ... f = open("c:/users/verzo/desktop/hello.txt") text = f.read() print(text) | |
Re: Using a months dictionary makes this a nicely thought out solution. Well done! | |
Re: What is your problem with the code you have? | |
Re: Running your program with Python27 gives 11 matches. Which is correct, since you are looking for a name in a list of names. | |
Re: The tuple that shows up in a numpy array is not a true Python tuple. In other words you can change its values. | |
Re: 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 ''' | |
Re: 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 … | |
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. | |
Re: Check out: http://www.lfd.uci.edu/~gohlke/pythonlibs/ | |
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. | |
Re: 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 … | |
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. ![]() | |
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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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. | |
Re: 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 … | |
Re: 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! | |
Re: 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. | |
Re: 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). | |
Re: [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. | |
Re: 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. … | |
Re: 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. | |
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 … | |
Re: Just in the news ... Mitt Romney's proofreaders allowed a typo spelling “America” as “Amercia” into Romney’s new iPhone app. | |
Re: I agree, http://www.dmoz.org/ is a very useful resource. | |
Re: 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] | |
Re: Looks like I have to wait till 2050 to buy one of those neat gadgets! | |
Re: 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 … | |
![]() | Re: 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 … ![]() |
Re: Congratulations to the two new Python moderators. Your contributions have been outstanding! | |
Re: You can speed things up by taking line 10 out of the for loop. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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)` | |
Re: 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. | |
Re: 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. | |
Re: 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) | |
Re: 404 - File or directory not found. ... this is what I get with your second reference. |
The End.