Forum: Python 8 Days Ago |
| Replies: 2 Views: 170 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 14 Days Ago |
| Replies: 8 Views: 275 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 23 Days Ago |
| Replies: 7 Views: 477 You may also take a look at:
http://www.daniweb.com/forums/thread240778.html |
Forum: Python Nov 7th, 2009 |
| Replies: 8 Views: 341 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: 341 Also the OP didn't want a zero in the digits part. :) |
Forum: Python Nov 7th, 2009 |
| Replies: 3 Views: 484 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: 530 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: 337 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: 278 You are somewhat confused about functions. |
Forum: Python Sep 21st, 2009 |
| Replies: 9 Views: 418 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: 761 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: 323 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: 420 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: 387 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: 601 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: 451 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: 530 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: 530 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: 530 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: 890 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: 473 Oops, DaniWeb is behaving goofy and made two copies of my code! |
Forum: Python Sep 13th, 2009 |
| Replies: 5 Views: 473 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: 716 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: 461 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: 301 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: 301 Courier is the most common font to space all character equal. |
Forum: Python Aug 31st, 2009 |
| Replies: 5 Views: 715 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: 318 Take a quick look at:
http://www.daniweb.com/forums/showpost.php?p=954810&postcount=53 |
Forum: Python Aug 18th, 2009 |
| Replies: 6 Views: 341 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: 341 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: 299 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: 299 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: 565 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: 297 Is the directory there and do you have access to it? |
Forum: Python Aug 13th, 2009 |
| Replies: 5 Views: 456 # optionally scroll to the bottom of the listbox
lines = listbox.size()
listbox.yview_scroll(lines, 'units') |
Forum: Python Aug 8th, 2009 |
| Replies: 7 Views: 580 Most likely maintenance time, those are scheduled most often on weekends. |
Forum: Python Aug 8th, 2009 |
| Replies: 6 Views: 346 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: 269 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: 215 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: 187 You post makes no sense to me! |