Forum: Python 1 Day Ago |
| Replies: 2 Views: 96 Call for update() as shown below:
from tkinter import *
class fb( Frame ):
def fastbuttons( self ):
b = Button(self)
b.grid()
self.update()
print(... |
Forum: Python 8 Days Ago |
| Replies: 8 Views: 235 Well, in Python just about anything is an object not just the typical OOP stuff. I assume that your instructor forgot about that and actualy means creating a class Student where each instance is a... |
Forum: Python 16 Days Ago |
| Replies: 7 Views: 423 You may also take a look at:
http://www.daniweb.com/forums/thread240778.html |
Forum: Python Nov 7th, 2009 |
| Replies: 8 Views: 309 Okay, this might even be mildly better:
import string
a = list(string.ascii_lowercase + "!@#$%^&*()-+={}|\/?><,.'") + range(1, 10)
print a
For Python3 change to list(range(1, 10)). Oh, the... |
Forum: Python Nov 7th, 2009 |
| Replies: 8 Views: 309 Also the OP didn't want a zero in the digits part. :) |
Forum: Python Nov 7th, 2009 |
| Replies: 3 Views: 453 It's always good to use a few test prints:
import operator
OPERATORS = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.div,
} |
Forum: Python Oct 31st, 2009 |
| Replies: 5 Views: 512 Well, you could do something like this:
# File_lister2.py
# create a list of all the files and sizes in a given direcory
# and optionally any of its subdirectories (Python2 & Python3)
# snee
... |
Forum: Python Oct 31st, 2009 |
| Replies: 8 Views: 329 You could do:
for c in "Hello World":
print c ,
In Python2 the comma puts in a space and keeps it on the same line. |
Forum: Python Oct 30th, 2009 |
| Replies: 6 Views: 269 You are somewhat confused about functions. |
Forum: Python Sep 21st, 2009 |
| Replies: 9 Views: 412 I made an attempt on user friendly data entry with just such a simple temperature converter program, see:
http://www.daniweb.com/forums/post992595.html#post992595 |
Forum: Python Sep 21st, 2009 |
| Replies: 4 Views: 727 And don't forget to use self to turn those functions into methods for the instance, like
def moveup(self): |
Forum: Python Sep 21st, 2009 |
| Replies: 6 Views: 315 Something like that might do. I avoided the use of float() until the end to keep time-stamp and port info from turning into floats:
raw_data = """\
501 0 0.932 0.933 0.931 0.931 0.929 0.933... |
Forum: Python Sep 20th, 2009 |
| Replies: 7 Views: 409 With wxPython code you can give py2exe an XML based manifest to force it to adopt the Windows XP theme. |
Forum: Python Sep 18th, 2009 |
| Replies: 7 Views: 379 Like gerard4143 says, you have to make the print statement part of the function, since Tf is local to the function. The other option would be to return Tf to make it available outside the function:... |
Forum: Python Sep 17th, 2009 |
| Replies: 16 Views: 594 Gribouillis is right, global constants have their place, but like he mentioned, make them stick out. One time when all upper case is appropriate. |
Forum: Python Sep 17th, 2009 |
| Replies: 9 Views: 445 Some simple changes will do:
comments = []
inComment = False
for i, line in enumerate(open(filename)):
if "//***" in line:
inComment = not inComment
elif inComment: # changed... |
Forum: Python Sep 15th, 2009 |
| Replies: 14 Views: 521 If you are new to Python, I wouldn't 'putz' around with old Python2. There are simply too many things that Python3 has to offer. Otherwise, after a few years you will be stuck with old Python2 code... |
Forum: Python Sep 15th, 2009 |
| Replies: 14 Views: 521 Should you decide to have fun with Python, be aware that the language has been modernized starting with version 3. I would recommend to start with the present version Python 3.1.1
Some examples... |
Forum: Python Sep 15th, 2009 |
| Replies: 14 Views: 521 The binary windows installer of Pyhon26 or Python31 both have tkinter. In fact in Python31 Tkinter has been spruced up with the module ttk.
Vegaseat left this example somewhere on this forum:... |
Forum: Python Sep 13th, 2009 |
| Replies: 3 Views: 854 You have to read up on the slicing operator in the Python Manual.
Generally you can slice a sequence with [start: end: step]
By default start=0, end=len(seq), step=1
step=-1 goes from the end to... |
Forum: Python Sep 13th, 2009 |
| Replies: 5 Views: 467 Oops, DaniWeb is behaving goofy and made two copies of my code! |
Forum: Python Sep 13th, 2009 |
| Replies: 5 Views: 467 I would stay away from module cturtle and use Python's own thoroughly tested module turtle. Here is a small code sample that shows you how to handle the turtle direction properly:
import math... |
Forum: Python Sep 13th, 2009 |
| Replies: 11 Views: 680 If you are used to Python2 code, then Python3 is full of surprises. However they all make the language better! So, keep an open mind, use the 2to3.py utility and try to make the old code work. |
Forum: Python Sep 10th, 2009 |
| Replies: 8 Views: 457 This approach should work:
#
def replace_one_two(name):
"""Switch letters in 2nd and 3rd position"""
left = name[1]
right = name[2]
name.remove(left)
name.remove(right)... |
Forum: Python Aug 31st, 2009 |
| Replies: 4 Views: 295 Grid does not have anchor, but it has sticky:
rb[i].grid(row=i, column=0, sticky='w') |
Forum: Python Aug 31st, 2009 |
| Replies: 4 Views: 295 Courier is the most common font to space all character equal. |
Forum: Python Aug 31st, 2009 |
| Replies: 5 Views: 696 Right now you simply have to use one of the many image view utilities to convert your jpg files to gif files. |
Forum: Python Aug 21st, 2009 |
| Replies: 2 Views: 313 Take a quick look at:
http://www.daniweb.com/forums/showpost.php?p=954810&postcount=53 |
Forum: Python Aug 18th, 2009 |
| Replies: 6 Views: 337 How about a blank icon as a spacer? Or maybe just a label with a few spaces? |
Forum: Python Aug 18th, 2009 |
| Replies: 6 Views: 337 Something like ...
toolbar.AddSimpleTool(wx.ID_SAVE, self.getBMP(wx.ART_FILE_SAVE),
"Save", " Save the text file")
... shows you the text "Save" as a popup hint |
Forum: Python Aug 18th, 2009 |
| Replies: 7 Views: 295 I don't understand how you go from :
(4, 22, 51): 3
to:
4 22 7 51 |
Forum: Python Aug 17th, 2009 |
| Replies: 7 Views: 295 I don't understand what you are asking for. Could you explain, maybe give a short example? |
Forum: Python Aug 17th, 2009 |
| Replies: 14 Views: 558 PMW has not been updated since 2007. Do you really want to go with this stale old thing? |
Forum: Python Aug 13th, 2009 |
| Replies: 3 Views: 296 Is the directory there and do you have access to it? |
Forum: Python Aug 13th, 2009 |
| Replies: 5 Views: 455 # optionally scroll to the bottom of the listbox
lines = listbox.size()
listbox.yview_scroll(lines, 'units') |
Forum: Python Aug 8th, 2009 |
| Replies: 7 Views: 569 Most likely maintenance time, those are scheduled most often on weekends. |
Forum: Python Aug 8th, 2009 |
| Replies: 6 Views: 344 Just a note:
avoid using 'file' for an identifier, since it is a built-in Python function. |
Forum: Python Jul 25th, 2009 |
| Replies: 3 Views: 267 If Sound Recorder has a command-line option, then you can send the arguments along to start it etc. |
Forum: Python Jul 21st, 2009 |
| Replies: 3 Views: 213 Your carlist is a list of instances of the class carType. To compare the car's name you have to use the instance.name as shown here:
class carType:
def __init__(self, name, brand, price):
... |
Forum: Python Jul 21st, 2009 |
| Replies: 4 Views: 185 You post makes no sense to me! |