Re: Python versus Perl ?
If you give it a good go, you will be amazed at how the text processing is so much better than Perl's. The same with the object orientation (what oop in Perl?? none... at least none worth mentioning :-) It's been said before by many Python users... Python allows newbies to program and wizards to be even more wizardly... or something to that effect. -- http://mail.python.org/mailman/listinfo/python-list
Success using Python .NET with py2exe?
Has anyone had any success using py2exe with anything you've written using the Python .NET implementation? (This is the one from the Zope website -- not ActiveState). I seem to be having trouble with py2exe and anything I've written using the CLR modules. Has anyone encountered this? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: goto, cls, wait commands
No goto needed. If this makes no sense (which it may not if all you've
been exposed to is BASIC) it wouldn't be a bad idea to Google why you
should never use a goto statement.
To do a clear screen you'll need to use the method that your command
shell uses. The shortcut to this is for Windows, 'cls' and Linux (and
other Unix derivatives) is 'clear'. To put this into your programs
you'll need to import the OS module. Then use the method, system() to
run the command:
import os
os.system('cls')
or
os.system('clear')
To do a 'wait' you can use the Time module.
import time
seconds = 10 #This is an integer value
time.sleep(seconds)
Only on Unix systems can you use the system command 'sleep'. However,
in the name of portability it's better to use the Python modules
whenever possible (they'll work on any system that supports Python).
Hope it helps.
Harlin
--
http://mail.python.org/mailman/listinfo/python-list
Re: [N00B] What's %?
In the mode of anticipating another question... I get these all the time at work of all places! You'd think IT workers would know the answer to these... What good is the modulus operator? What would I ever need it for? * A quick way of testing whether an integer is even and odd * For that matter, a quick way of testing whether a the variable is a factor of any other arbitrary number. * In some programs (a weight control program I worked on comes to mind) it's necessary to get a remainder so that you can get the results of a leftover evenly divisible number. Regards, Harlin administrata wrote: > Hi! it's been about a week learning python! > I've read 'python programming for the absolute begginer' > I don't understand about % like... > > 107 % 4 = 3 > 7 % 3 = 1 > > I'm confused with division :/ > Please help me... > > thx 4 reading. -- http://mail.python.org/mailman/listinfo/python-list
Re: MYSQL - how to install ?
For MySQL on windows go here: http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.10-win32.zip/from/pick#mirrors For Python 2.3.5 binary installer for win32: http://www.python.org/ftp/python/2.3.5/Python-2.3.5.exe -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?
Any reason you're asking about wxPython for "DOS"? Just curious. -- http://mail.python.org/mailman/listinfo/python-list
Re: some qustions on python
Can you be a bit more specific about what you're wanting? A design process will be very similar across languages no matter which language it is. If you'd like a "small evaluation" of Python you're best served by reading the official summary: http://www.python.org/doc/Summary.html Else you'll always be directed to Eric Raymond's How To Ask Smart Questions FAQ ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiler
Easy, easy... Use py2exe: http://starship.python.net/crew/theller/py2exe/ -- http://mail.python.org/mailman/listinfo/python-list
Re: MYSQL - how to install ?
Sorry about the mis-read. Keep in mind that if you're doing this on win32 (and it looks like you are), you can use ODBC a bit easier. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: need of help
Need more info on this. Are you:
1. Trying to create a GUI window of your own making? If so, what
toolkit are you using?
2. Trying to open a web browser? If so, you can do the following:
import os
os.system('path/to/executable options')
or
os.startfile('pagename.html')
--
http://mail.python.org/mailman/listinfo/python-list
Re: Pausing a program - poll/sleep/threads?
import time play_something() time.sleep(LengthOfSongInSeconds) do_something() Have you tried that? I'd be interesting in seeing this app you have. ! -- http://mail.python.org/mailman/listinfo/python-list
How to write a ping client
Is there a way to write a ping client? I would like to be able to write
a small ping client so that I dont have to do os.system('ping args')
and thereby keep the resource overhead low. Does anyone know how this
can be done or can point me in the right direction?
thanks,
Harlin
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to write a ping client
whoa... this is not in the standard library, is it? I never knew this was out there. Thanks! Please use your powers for good (the one about halting production on teenage sex comedies :) -- http://mail.python.org/mailman/listinfo/python-list
Creating Button arrays with different commands using Tkinter
I have an array of Appnames. Let's say they are 'Monkeys', 'Cats', 'Birds'. I would like create a button array with these: ---Start Code--- # Constructing and displaying buttons for a in Appnames: Button(root, text=a, command=lambda:self.OpenFile(a)).pack() # Somewhere else I have this function defined within the class... def OpenFile(self, AppName): fh = open(AppName+".txt", 'r').read() do something with fh ---End Code--- When I do this, whatever the last value a was is what the each button's command option is. Does anyone know what I can do to differentiate each button so that it has its own separate argument for self.OpenFile? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Function to retrieve running script
Is there a function that allows one to get the name of the same script running returned as a string? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Function to retrieve running script
Thanks Mike, that will work just as well... just disappointed in myself that i lack the creativity to think of something that simple ;-) thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Need eyes to look at code... time not having an attribute called asctime()
from utilities import *
from extractor import *
import time
import os
print 'Running AgentPing at '+time.asctime()
confFile = '../conf/AgentPing/AgentPing.conf'
ex = extractor(confFile)
names = ex.array('name')
comments = ex.array('comment')
ips = ex.array('ip')
counts = ex.array('count')
thresholds = ex.array('threshold')
alarms = ex.array('alarm')
levels = ex.array('level')
records = ex.array('record')
plogger = Logger('../logs/AgentPing.log')
for name,comment,count,ip,threshold,alarm,level,record in
zip(names,comments,counts,ips,thresholds,alarms,levels,records):
msg = 'AGENT INFORMATION: Pinging '+ip+' at '+time.asctime()
print msg
plogger.loggit(msg)
line = 'ping -n '+count+' '+ip
try:
data = os.popen(line).readlines()
time = data[-1].split()[-1][:-2]
except:
msg = 'AGENT FAILURE: Unable to run ping on '+ip+' for unknown
reason.'
print msg
msg += 'Error created at '+time.asctime()
time = float(threshold)*2
plogger.loggit(msg)
createAlarm(name, comment, ip, threshold, level, msg)
Whenever I run this I get:
Traceback (most recent call last):
File "agentPing.py", line 23, in ?
msg = 'AGENT INFORMATION: Pinging '+ip+' at '+time.asctime()
AttributeError: 'str' object has no attribute 'asctime'
Press any key to exit
I'm sure this is something simple but for this I am having trouble
figuring it out.
Thanks,
Harlin Seritt
--
http://mail.python.org/mailman/listinfo/python-list
Using Tix and Tkinter
I am trying to create a simple window using the following code: --code--- import Tix from Tkconstants import * from Tkinter import * root = Tix.Tk() Label(root, text="Hello!").pack() Tix.tixControl().pack() root.mainloop() ---code--- When I run this, I get the following error: Traceback (most recent call last): File "TixTest.py", line 8, in ? Tix.tixControl().pack() AttributeError: 'module' object has no attribute 'tixControl' Any reason why I am not able to pull up this widget to work with it? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: extreme newbie
? -- http://mail.python.org/mailman/listinfo/python-list
Re: Want to learn a language - is Python right?
Aziz McTang wrote: > Hi Paul, > > Thanks for your input. > > As usual, hearing some answers helps formulate the question... > > What I'm looking for is more to learn one good, comprehensive > programming language well than several approximately on an ad hoc > basis. What I also failed to mention is the desire to develop my > presently limited computer skills a lot further. > > So although your answer to 1 suggests I'd be using a steam-roller to > kill a fly, if I do need to go further (or ask other people to help and > still understand what's going on: one site I may want to develop later > involves a number of languages including Japanese as well as audio) I > won't have to re-learn another program. Is this right? > > As to 2, I have yet to find a canned program that does what I want, and > so far every programmer I've asked to write it has said "hey that's > easy" then escaped, never to be heard of again. > > And 3: good! Actually, having learned half a dozen languages, I can > vouch for it being an excellent way to acquire and consolidate > vocabulary. Talking to (or, rather, understanding) the natives is > another kettle of fish! > > Thanks again! > > Any new slants from yourself or others are welcome. > > Aziz You can use CherryPy for creating a Python-esque web application. Never buy into the fluff that says Python is not as good as PHP for web apps! PHP is still too Perl-Like (meaning old and useless)! Python is the choice of a new generation baby!!! :) JK... For your vocab program, Python is actually perfect. This could even go for apps that require some Unicode and other Internationalization snafus (like right-to-left characters and Cyrillic typesets). If you're looking for one programming language then you should consider the idea that no one language can do it all (although Python comes close in my biased opinion). Python is not for memory management, writing device drivers and the like. As far as needing something for web apps, CherryPy is great -- just learn Python first. PHP is good but it has fallen out of favor with me though there are a ton of people out there who think it is the greatest thing since sliced bread. Take a look at the Python tutorial: http://docs.python.org/tut/tut.html. Good luck, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Formatting data to output in web browser from web form
Hi,
I am using CherryPy to make a very small Blog web app.
Of course I use a textarea input on a page to get some information.
Most of the time when text is entered into it, there will be carriage
returns.
When I take the text and then try to re-write it out to output (in html
on a web page), I notice the Python strings don't translate these
special characters (carriage returns) to a "" so that these
paragraphs show up properly in html for output. I tried doing something
like StringData.replace('\n', ''). Of course this doesnt work
because it appears that '\n' is not being used.
Is there anything I can do to make sure paragraphs show up properly?
Thanks,
Harlin Seritt
--
http://mail.python.org/mailman/listinfo/python-list
Re: Formatting data to output in web browser from web form
This is perfect. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
How to run python script in background after i logout
I have a remote linux server where I can only access it via ssh. I have a script that I need to have run all the time. I run like so: python script.py & It runs fine. When I log off ssh I notice that the script died when I logged off. How do I make sure it stays running? thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Help with Regular Expressions
I have been looking at the Python re module and have been trying to make sense of a simple function that I'd like to do. However, no amount of reading or googling has helped me with this. Forgive my stone-headedness. I have done this with .NET and Java in the past but damn if I can't get it done with Python for some reason. As such I am sure it is something even simpler. I am trying to find some matches and have them put into a list when processing is done. I'll use a simple example like email addresses. My input is the following: wordList = ['myname1', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]'] My regular expression would be something like '[EMAIL PROTECTED]' (I realize it could and should be more detailed but that's not the point for now). I would like to find out how to output the matches for this expression of my 'wordList' into a neat list variable. How do I get this done? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with Regular Expressions
Ahh that's it Frederik. That's what I was looking for. The regular expression problems I will take care of, but first wanted to walk before running. ;) Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with Regular Expressions
Forgive another question here, but what is the 'r' for when used with expression: r'\w+...' ? -- http://mail.python.org/mailman/listinfo/python-list
Machine Name
How does one get the machine name with Python that the actual script is running on? Obviously, one could parse the hosts file but I was wondering if there was a quick way to get it done? thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: use threading without classes
Is there any reason why you wouldn't want to do this using the the
threading class? To each his own I suppose. You can try the following
though you'll at least need to use functions:
import time
import thread
def myfunction(string,sleeptime,*args):
while 1:
print string
time.sleep(sleeptime) #sleep for a specified amount of time.
if __name__=="__main__":
thread.start_new_thread(myfunction,("Thread No:1",2))
while 1:pass
--
http://mail.python.org/mailman/listinfo/python-list
Re: Considering moving from PowerBuilder to Python
For: So, is there any data on the popularity of IDEs (most users), or is there a chart comparing the most popular versions. Hi Norm, You can do a Google search for these sorts of things like opinions and comparisons. Believe me, there are more blogs and articles on these things than you can shake a stick at :-). Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Win32: Possible to use Python to create Snap-Ins for MMC?
Is it possible to use Python to create snapins for the MMC? Thanks, Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Re: problems with smtplib
What are you getting in your smtpd logs? Are you using postfix? sendmail? or are you running this against a Windows stmp service? Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Re: python script under windows
Hi Jan, Unfortunately you will have to register it as a service. I am almost certain there is no other way to do it. However, setting up an executable as a true Windows Service is extremely tedious. You can try this utility that I use. You can get it here: http://www.seritt.org/pub/srvinst13b.exe. I'm probably not supposed to distribute it, but the site and owners that used to host it have gone belly up best that I can tell. As with anything, use it at your own risk. I found it as freeware a few months back. If you want a decent cheap solution, FireDaemon is pretty good. I think it's like 30USD but it does a great job and adds a few extra features. HTH, Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Python Search Engine app
Hi, Is anyone aware of an available open-source/free search engine app (something similar to HTDig) written in Python that is out there? Googling has turned up nothing. Thought maybe I'd mine some of you guys' minds on this. thanks, Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Rendering HTML
I am looking for a module that will render html to console but formatted much like one might see with Lynx. Is there such a module already out there for this? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Rendering HTML
Hi DH, Thanks for this blurb from ASPN. I am really looking, however, to do this on a Windows machine as opposed to a Unix one at this point. This will come in handy down the road I am sure. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: pinging from within python
You can do the following:
import os
data = os.popen('ping machineName').read()
if 'request timed out' in data or 'unknown host' in data:
Ping Failed Code
else:
Ping Returned Something Good Code
This is the quickest and really most effective way to get it done IMO.
Harlin Seritt
Internet Villa: www.seritt.org
--
http://mail.python.org/mailman/listinfo/python-list
Putting a lock on file.
I have a file that a few different running scripts will need to access. Most likely this won't be a problem but if it is, what do I need to do to make sure scripts don't crash because the input file is in use? Would it be best to run a loop like the following: flag = 0 while not flag: try: open(file, 'r').read() flag = 1 except: pass This may seem nice on paper but I hate to run a while for an indeterminate amount of time. Is there anything else that can be done that would be better? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating Button arrays with different commands using Tkinter
Thanks Frederik. I knew it was not binding the way I intended to, but just had no idea why or how to make it do so... thanks for the quick lambda lesson :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: user interface for python
Tkinter! Ease* Well-documented? Easy to Learn? Functionality * Can I get it to do what I need it to do? Looks *** Does it look good? Well, beauty is after all in the eye of the beholder. Anything I can get to work on either platform with minimum effort and quick writing looks good to me :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to write a ping client
? -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about logfiles in Python
I'm not familiar with Exchange log files but this can be done rather easily assuming the log file is a flat text file (which usually these are not-- like NT event logs). search_str = "words and phrases" data = open(LogFile, 'r').read() if search_str in data: flag = 1 If they are binary files, you may have to use a special module (or write one yourself if it doesn't exist). A good place to look is in Mark Hammond's Win32 modules. You'll find some stuff here: http://starship.python.net/crew/mhammond/ Hope this sends you in the right direction. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Online Programming Contest
Actually MIT is an abbreviation and not an acronym in the true sense of the word :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Best IDe
IDLE, PytonWin and SPE are all free and offer all of the important features you'll see even in commercial IDE's. -- http://mail.python.org/mailman/listinfo/python-list
Default value for Listbox (Tkinter)
Whenever I set up something similar: vals = ['1', '2','3'] for v in vals: listbox.inset(END, v) I notice that when this listbox is displayed, there is never a default value. How can I make sure that one of the indices is selected by default? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython tutorials
Here is the old one... http://www.wxpython.org/tutorial.php It truly is a short tutorial though. This one's even better: http://wiki.wxpython.org/index.cgi/FrontPage I am not a wxPython enthusiast. I like Tkinter much better. If you have an interest, take a look at: http://www.pythonware.com/library/tkinter/introduction/ by Frederik Lundh. It is very easy to understand. Tkinter is easier to learn. It is better documented IMO. Tkinter is just as functional as any other GUI toolkit for Python. Creating your own widget sets is usually a breeze. Tkinter is not ugly if done properly. Tkinter apps are ported easily. On and on :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Default value for Listbox (Tkinter)
Thanks Jorgen! I was reading the Tkinter tutorial (I was looking at this particular page: http://www.pythonware.com/library/tkinter/introduction/x5513-methods.htm) and saw this for select_set(): select_set(index), select_set(first, last) Add one or more items to the selection. I think this was why I overlooked it. The description for it says the listbox adds one or more items to a selection. I would think the description should say the listbox sets the index or element. Thanks again, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Trees
Would this be for a GUI toolkit or maybe using a standard class scheme? -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another logo design...
I like the type logo (on the right of the image). The black snake-like image can be cropped though. :-) Harlin -- http://mail.python.org/mailman/listinfo/python-list
Polling selections from a listbox (Tkinter)
I am trying to poll selections from a listbox but can't seem to get it
to work correctly.
class pollstuff:
def __init__(self, master):
self.listbox = Listbox(master)
self.listbox.pack()
names = ['Bob', 'Neal', 'Mike']
for n in names:
self.listbox.insert(END, n)
self.listbox.select_set(0)
LabelStr = StringVar()
self.label = Label(master, textvariable=LabelStr)
self.label.pack()
LabelStr.set(names[map(int, self.listbox.curselection())])
root = Tk()
app = pollstuff(root)
root.mainloop()
Obviously when this starts up this is going to show selection #0 inside
the label box. How do I make sure that whatever is arbitrarily selected
ends up in the label box as this gui runs? I tried doing a bind:
self.listbox.bind("", self.changelabel)
This did not work as intended as the changelabel's text option only
showed what the selection index was BEFORE the event took place. Does
anyone know of any special thing I need to do in order to poll the
listbox items?
Thanks,
Harlin
--
http://mail.python.org/mailman/listinfo/python-list
Re: function expression with 2 arguments
Not exactly sure what you're looking for but you can do the following: def dosomething(numlist): return numlist[0] + numlist[1] numlist = [ 5, 10] val = dosomething(numlist) If so, that would be somewhat pointless. It's always best to keep it simple. It looks like the function you wrote above is very adequate for the results you want returned. -- http://mail.python.org/mailman/listinfo/python-list
Re: function expression with 2 arguments
? -- http://mail.python.org/mailman/listinfo/python-list
How to define a window's position (Tkinter)
I am trying to use the geometry() method with the toplevel window
called root. I know that one can do the following:
root.geometry('400x400+200+200')
This will put the window in 200, 200 position with a size of 400x400.
Now, I don't really want to set the size. I simply want to set the
position of the window. I've tried this:
root.geometry('200+200')
However, this doesn't seem to work. What can I do to set the position
of the window without actually setting the size?
Thanks,
Harlin
--
http://mail.python.org/mailman/listinfo/python-list
Re: Googlewhacker
They actually won't ban your IP for this. They only limit your number of searches per day. I discovered this once when I used http://www.google.com as a test metric for my network monitoring program. I do like your script though. Regards, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Explicit or general importing of namespaces?
Is there really a major performance difference between doing the following: import Tkinter as TK TK.Label(yada yada) OR from Tkinter import * Label(yada yada) I'm unable to tell a real difference other than in the code writing :-). Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Faster way to do this...
I've got the following code: nums = range(0) for a in range(100): nums.append(a) Is there a better way to have num initialized to a list of 100 consecutive int values? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Faster way to do this...
Excellent point Warren. I have been working with Python for about 3 years in all, but only really seriously for about a year. I am still utterly amazed that near everything that takes me about 5 to 20 lines of code can be done in 1, 2 or 3 lines of Python code (when done correctly). It is very frustrating that I am still using Python as though I would if I were writing Java or C++ code. One day I'll get the hang of this. Roy, I like what you showed: nums = [a for a in range(100)] . My mistake for not expressing my question as well as I should have. Not only am I looking for a way to fill in 100 spots (more or less) in an array er... list, but I'd like to be able to do it in intervals of 2, 4, 8 etc. as well as other things. Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Closing dialog window in Tkinter
You can add this: button = Button(top, text="Close Me", command=top.destroy) button.pack() That will kill the Toplevel window. Cheers, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Closing dialog window in Tkinter
Do you need this toplevel window to not be iconified--where it shows up as a separate window? You can also do this: def new_window(self, master): t = Toplevel() t.transient(master) etc... Svennglen, I put this in here because most likely you're next question may be, how in the world do I make a modal window? I believe it was my next question after I finally figured out how to kill a child window without wiping out the entire app ;-). Check out Frederik Lundh's tutorial: http://www.pythonware.com/library/tkinter/introduction/ You can now buy a PDF form of John Grayson's Python and Tkinter Programming from Manning Publications. I won't provide the link so that no one will think I'm spamming (:-). Grayson's book is essential reading if you are to write any serious apps with Tkinter. Good luck, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: scrollbar dependencies
Pardon a question I should already know the answer to, but what are the *args in the: def xscrollboth(*args): c1.xview(*args) c2.xview(*args) Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Setting default option values for Tkinter widgets
There are certain options for Tkinter widgets that have default values that I don't much care for (borderwidth, font come to mind) and continuously change when I'm building interfaces. With a bit of tweaking I have been able to give the widgets a look that rivals the best of them. However, I get tired of doing this when I'm writing code and would like a way that I could universally change them on my system. I have tried to find where in the class files (Tkinter.py) that I can change these and haven't been able to find them. Are there certain lines in certain files/modules/classes that I can change the values for these things like font, border, etc.? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python glade tute
Not to make light of your tutorial but it can use some editing (the English grammar and spelling is below par). I understand that most likely English is not your first language. Given that, I think you did a great job. If you like, email me back and I'll be glad to help out with that, but I can only do it if I can get my hands on the source of your docs (not sure if you're using some type of doc tool -- it does appear that way). I must say, I thought your tutorial was very good. I despise RAD tools but you almost had me convinced to give PyGTK and Glade a shot ;-) Regards, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter entry eat chars?
You can use the textvariable option for the Entry widget. Set a bind event for this widget that when any key pressed the StringVar() will be polled via StringVar().get(). You do some checking for certain chars you don't want entered and then delete them as they occur. Harlin "phil" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In a Tkinter entry field (or Pmw entry) > how could I eat charactres? > > Say a certain char is keyed in. Say & > I notice in the event handler for . > I don't want any more charactres to display or > be in the field until I handle a see, in the > event handler, another character. Say ? > > Can the event handler somehow destroy the char? > > Thanks > -- http://mail.python.org/mailman/listinfo/python-list
Re: Explicit or general importing of namespaces?
I think the bottom line on this is using your own sense of risk/reward with each given module imported. Some modules (Tkinter comes to mind) it makes sense to pollute while others it doesn't. Harlin "Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Peter Mayne wrote: > > Peter Hansen wrote: > >> and it's still a bad idea in almost all cases anyway > > > > Since I've been playing with PyQt lately... > > > > Is qt not one of the "almost all" cases? From the limited number of > > examples I've seen, it seems to be common to do > > > > from qt import * > > This sort of thing seems common amongst large frameworks such > as PyQt or wxPython. This is unfortunate, IMHO, though it isn't > really a serious concern for most users. > > I'm grateful that the most recent versions of wxPython have > abandoned that approach in favour of a nice clean "import wx", > and as far as I can tell the code does not suffer as a result, > and gains substantially in clarity. Maybe the "qt" module > defines far fewer names than the "wx" module does, but I for > one am glad not to have to worry that I won't accidentally > conflict with the hundreds that are there (in wx), nor to > worry that my code lacks in readability. > > > Since most of the imported names start with "Q", are called QLabel, > > QSlider, etc, and are generally recognisable in context, this would seem > > to be a reasonable case of namespace pollution. > > > > I'm certainly not arguing with the general premise, just wondering if qt > > is one of the sensible exceptions. > > If not sensible, at least fairly widely accepted, not a serious > impediment to effective use, and definitely not without precedent. > > -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: [announcement] - python graph library
"Maxim Khesin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello Folks, > I recently started working on a graph-algorithms library in Python. What > makes this one different from the other couple of libs that are > available is a heavy influence from the C++ Boost Graph Library. There > are IMO a lot of good ideas there, so I am attempting to translate the > spirit of it into Python without loosing the Pythonness :). There is no > official code release so far, but I have been blogging ideas and code > snippets here: http://pythonzweb.blogspot.com/. Your comments are most > welcome (you can leave them right on the blog).I also wanted to tap your > opinion on naming this thing. There is (duh) already PyGL and PGL names > associated with python (but not graph libs) floating around, but as they > are not so well-known as far as I can tell I do not mind taking them on > and stealing the name. What do you guys think? pygribs :-) -- Harlin's Internet Villa: http://seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Adding an option on the fly (Tkinter)
I am making use of a Checkbutton widget. However, I would like to add
an option or method "on the fly." For example I would like to bind a
filename ("filename.txt") to a particular Checkbutton widget so that I
call it later as:
widget["filename"]
Is this possible to do?
Thanks,
Harlin
--
http://mail.python.org/mailman/listinfo/python-list
Re: Can a method in one class change an object in another class?
Here's what I came up with: #objtest.py class first: def __init__(self): a = 'a' self.a = a print self.a def update(self): print 'initially, a is', self.a self.a = second(self.a) print 'afterwards, a is', self.a.call(self.a) class second: def __init__(self, a): pass def call(self, a): a = 'aa' return a if __name__ == '__main__': app = first() app.update() Not sure if this is what you are wanting though. -- http://mail.python.org/mailman/listinfo/python-list
Using for... for multiple lists
I am using the following code: for i, f in filelist, self.checkbox: if f.get(): print i I am getting an error: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python23\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args) File "install.py", line 123, in select_stage for i, f in filelist, self.checkbox: ValueError: unpack list of wrong size Both filelist and self.checkbox are the same size (4 items btw). Is there any way to get this done? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding an option on the fly (Tkinter)
Would I do this like:
buttondict = {button1, "name.txt"}
??
Thanks,
Harlin
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using for... for multiple lists
Actually the sequences are of the same length. Forgot to mention that. thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: seeking tree-browser widget for use with Tkinter
Actually it should be here: http://py.vaults.ca/apyllo.py/808292924.247038364.90387689.96972321 Cheers, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: global variables
You most likely need to construct your script using OOP. Can give you give an example of code you're using when you get this error? This helps a lot. Regards, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: How to script DOS app that doesn't use stdout
"Phantom of the Keyboard" ... now that's a name! -- http://mail.python.org/mailman/listinfo/python-list
Setting sizes of widgets (PyGTK)
I have the following code and I would like to know how to set the
length and width of widgets like Buttons. When the window opens the
button fills up the space even though I have told it not to. Anyone
know how I can accomplish this?
:
import pygtk, gtk
class Greeter:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.box = gtk.VBox()
self.window.add(self.box)
self.label = gtk.Label("Please enter your name in the box
below:")
self.namebox = gtk.Entry(12)
self.button = gtk.Button("Greet Me!")
self.output = gtk.Label("Your output will appear here.")
self.box.pack_start(self.label, False, False, 2)
self.box.pack_start(self.namebox, False, False, 2)
self.box.pack_start(self.button, False, False, 2)
self.box.pack_start(self.output, False, False, 2)
self.label.show()
self.namebox.show()
self.button.show()
self.output.show()
self.box.show()
self.window.show()
def main(self):
gtk.main()
a = Greeter()
a.main()
--
http://mail.python.org/mailman/listinfo/python-list
Re: Python Tkinter Newbie question
You have: ="@/test.xbm" take the '/' out or (if it is in a different dir which i think it is), do ="/@test.xbm" also... make sure your *.xbm is really a bitmap file (that would just be another thing to check... not to say its not the proper format)... Regards, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Licensing Python code under the Python license
If this is for making money, make it either a proprietary license or BSD. If you're giving it away and expect nothing for it except maybe fame, do GPL. :-) Regards, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Licensing Python code under the Python license
When you ask an opinion, you can expect a long thread list... even if it's something inane like "What kind of license should I use?"... hacker/geeks/freaks/wannabes are only too happy to issue an opinion -- warranted or otherwise... Regards, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Tkinter Newbie question
Try not to triple post if you can help it (I'll assume you accidentally hit the SENT button three times ) Regards, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: is there a problem on this simple code
hah, this code is anything but simple... -- http://mail.python.org/mailman/listinfo/python-list
Searching for a ComboBox for Tkinter?
I've created a ghetto-ized ComboBox that should work nicely for Tkinter
(unfortunately no dropdown capabilities yet).
I've found why it's such a pain in the @ss to create one. You have to
re-create common methods and make sure they're mapped to the right
component (inside this widget are frame, entry, listbox, and scrollbar
widgets). I tried to look for ways I could inherit some methods from
other widgets but couldn't think of how to do it in an efficient way.
If anyone has suggestions to improve it, please respond... Remember...
I'm a traditional c/c++ turned python programmer who forgets that there
usually is a better, faster more graceful way to do things with Python
than with C/C++/Java.
Cheers,
Harlin
##
# Seritt Extensions:
# Date: 02262005
# Class ComboBox
# Add this section to your Tkinter.py file in 'PYTHONPATH/Lib/lib-tk/'
# Options: width, border, background, foreground, fg, bg, font
# , relief, cursor, exportselection, selectbackgroun,
selectforeground, height
#
# Methods: activate(int index) => int, curselection() => int,
delete(item=["ALL" or int], start=int, end=["END" or
# int],
# focus_set()/focus(), get()=>selected string in box, pack(padx=int,
pady=int, fill(X, Y, BOTH), expand=bool, # side=LEFT,
# RIGHT, TOP, BOTTOM, CENTER
#
class ComboBox:
ITEMS = range(0)
def activate(self, index):
self.listbox.activate(index)
def curselection(self):
return map(int, self.listbox.curselection())[0]
def delete(self, item=None, start=None, end=None):
if item=='ALL':
self.listbox.delete(0, END)
elif start == None and end == None:
self.listbox.delete(item)
else:
self.listbox.delete(start, end)
def get_focus(self):
self.entry.get_focus()
def focus(self):
self.entry.get_focus()
def get(self):
return self.entry.get()
def pack(self, padx=None, pady=None, fill=None, expand=None,
side=None):
self.frame.pack(padx=padx
, pady=pady
, fill=fill
, expand=expand
, side=side)
def size(self):
return self.listbox.size()
def insert(self, START, ITEM):
self.ITEMS.append(ITEM)
self.listbox.insert(START, ITEM)
self.listbox.select_set(0)
self.entry.delete(0, END)
self.entry.insert(0,
self.listbox.get(self.listbox.curselection()))
def change_entry(self, event):
def i(event):
try:
self.entry.delete(0, END)
self.entry.insert(0,
self.listbox.get(self.listbox.curselection()))
except:
pass
self.listbox.bind("", i)
def __init__(self, parent, width=None, border=1, background=None,
foreground=None, fg=None, bg=None, font=None
, relief=None, cursor=None, exportselection=None,
selectbackgroun=None, selectforeground=None, height=None):
self.frame = Frame(parent)
self.entry = Entry(self.frame
, width=None
, border=border
, background=background
, foreground=foreground
, fg=fg
, bg=bg
, font=font
, relief=relief
, cursor=cursor
, exportselection=exportselection
, selectbackgroun=selectbackgroun
, selectforeground=selectforeground
, height=height)
self.entry.pack(fill=X)
self.scroll = Scrollbar(self.frame)
self.scroll.pack(side=RIGHT, fill=Y)
self.listbox = Listbox(self.frame
, yscrollcommand=self.scroll.set
, width=None
, border=border
, background=background
, foreground=foreground
, fg=fg
, bg=bg
, font=font
, relief=relief
, cursor=cursor
, exportselection=exportselection
, selectbackgroun=selectbackgroun
, selectforeground=selectforeground
, height=height)
self.listbox.pack(fill=X)
self.scroll.config(comma
Re: Bind Escape to Exit
Binny,
The only way I could think to get this done was like so:
from Tkinter import *
class Application: # take away the inherited class
def end(self, event):
self.master.destroy()
def createWidgets(self):
self.lab = Label(text="Hello World")
self.lab.pack()
def __init__(self, master):
self.master = master#
Create a class version of master:
self.master
self.frame = Frame(self.master) # Change master to self.master
self.frame.pack()
self.createWidgets()
self.master.bind('', self.end) # Change to
, link bind to self.end
root = Tk() # Use a tk instance
a = Application(root)
root.mainloop() # Call tk.mainloop()
I am almost certain that I had the same dilemma as you. Good luck. If
you find a better way please post it.
Thanks,
Harlin Seritt
--
http://mail.python.org/mailman/listinfo/python-list
Re: Searching for a ComboBox for Tkinter?
Or if you prefer you can download it here: http://www.seritt.org/pub/tkinter/Tkinter-03132005.py Replace your Tkinter.py with this one. Make sure you back up your old one in case you decide mine sucks. Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Creating desktop icons for Innosetup file
I have a test app that I am creating an Innosetup script for. Everything works great except for the fact that my icons (start menu and desktop) are not starting the executable in the appropriate directory. This is causing problems because it can't find "icon.ico" and other stuff. When I go and manually change the startpath on the icon's property box, everything works fine. How do I ensure that the icon starts in the apppath? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating desktop icons for Innosetup file
Thanks Will! That did the trick. -- http://mail.python.org/mailman/listinfo/python-list
Re: Searching for a ComboBox for Tkinter?
Thanks nirinA... I've played with that one before. I'm not a big fan of Pmw or Tix so much I guess although when it gets down to it, those 'extra' toolkits are probably more functional. Cheers, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Searching for a ComboBox for Tkinter?
ahh Frame! I didn't even think of extending Frame. I kept wondering how I could instead extend entry and listbox... thanks for the pointer. Yeah I know there are others out there, I just wanted to create one from tkinter widgets and keep the constructor as close to other tkinter widgets as possible. I notice that when you use Pmw you have different option names and methods that are a bit inconsistent (not too hard to remember though--it's not a criticism of Pmw or Tix). I am very narrow-minded. :-) As far as the other lists/wiki, I will be looking at them. Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib's functionality with urllib2
Is there any reason why you can't import both? import urllib as u import urllib2 as uu -- http://mail.python.org/mailman/listinfo/python-list
Re: how to delete the close button (the X on the right most corner of the window) on a window
What GUI toolkit are you using? I think this is the point Jeremy is making. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
A Font Dialog (Tkinter)
Is there a way to call up the Font dialog box (at least in the Windows API) from Tkinter or another module? thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Listbox fill=BOTH expand=YES (Tkinter)
I am trying the following: Listbox(parent).pack(fill=BOTH, expand=YES) I notice that the listbox will fill on the X axis but will not on the Y axis unlike other widgets. Is there any way to force this? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Listbox fill=BOTH expand=YES (Tkinter)
That was it Martin. I forgot to expand the parent. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Listbox fill=BOTH expand=YES (Tkinter)
either YES, True, or 1 should work. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter wrappers for TkTreeCtrl and Tile
I was looking at the Tcl/Tk sourceforge page and found that there were a couple of new widgets being produced for Tcl 8.5. Does anyone know if there are any Tkinter wrappers somewhere? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter wrappers for TkTreeCtrl and Tile
Martin, Take a look here: http://mail.python.org/pipermail/tkinter-discuss/2004-March/10.html It is a well-known post from what I understand. You may have already seen it before. Actually, (as I'm looking at a 8.4 demo set from ActiveTcl distribution), it seems the Tree widget has been added to the 8.4 set. I don't think the Tiles has been added just yet though. Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Jython Phone Interview Advice
George, Know what they will be wanting you to do with Jython. This has bitten me in @ss a couple of times. I guess it was lack of attention to detail. :-) Good Luck! Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter wrappers for TkTreeCtrl and Tile
Martin, If I may ask, who actually works on the Tkinter module? Is there a certain group that does this? I'm just curious as I've never been able to find this information. I know there are, of course, someone who develops Tk but just not sure who does this on the Python side. Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter wrappers for TkTreeCtrl and Tile
(snip) >>That said I have got a Tile Button example working (and I can change >>it's style) so perhaps not that much work Do you happen to have a sampling of this that I can get my hands on?? >>I've cc'd the tkinter mailing list to see if there is any more interest >>over there... Thanks for doing so! Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python like VB?
"Would Python meet our requirements? " Yes and no. Because Python is a very high-level language and dynamically typed it is easy to learn. Python doesn't make use of pointers but you are able to write object-oriented code (as opposed to just being object-friendly like Visual Basic is). You will find that on its own you won't be able to do any Office macro scripting although there are several packages that will give you added functionality like access to Com+ objects (see win32 modules by Mark Hammond). Now, this may require more work than using VBA but it *is* doable. The com portion of the win32 modules can enable one to create even a macro-language unto itself! Python is very powerful. There are many 3rd party modules and frameworks (Zope, CherryPy). Also, there are many GUI toolkits available for it (wxWindows, GTK, QT, Tk and on and on) and you can also use it as a wrapper to write and compile to Java bytecode (see Jython). The problem for you, however, is it may or may *not* meet every requirement. For that you'll have to find out for yourself. I suggest downloading Python and giving the Python tutorial a whirl and then taking a look at other Python-related stuff: [For programmers:] http://docs.python.org/tut/tut.html [For non-programmers:] http://honors.montana.edu/~jjc/easytut/easytut/ [Win32 stuff:] http://starship.python.net/crew/mhammond/ [Tk 'Tkinter':] http://www.pythonware.com/library/tkinter/introduction/ [wxPython:]http://www.wxpython.org/ [PyGTK:] http://www.pygtk.org/ Purusing these links will give you a very good idea of whether Python is right for you. Naturally we'd all like to say 'YES Python is good for you!' but you have to investigate for yourself. Good luck! Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
(Tkinter) Adding delay to PopUpMsg
I am working on making something called a PopMsg widget which is
actually identical to a Balloon widget from Pmw. Here is the code:
---code---
from Tkinter import *
import time
class PopMsg:
def showmsg(self, event):
for a in range(1000): pass
self.t.deiconify()
self.t.geometry(str(self.msg.winfo_reqwidth())+'x'+str(self.msg.winfo_reqheight())+'+'+str(event.x_root)+'+'+str(event.y_root))
self.widget.bind('', self.hide)
time.sleep(0.001)
def hide(self, event):
self.t.withdraw()
def __init__(self, parent, widget, text=None):
self.parent=parent
self.widget=widget
self.text=text
self.t = Toplevel()
self.t.withdraw()
self.t.overrideredirect(1)
self.msg = Message(self.t
, text=self.text
, bg='white'
, border=1
, relief=SOLID
, aspect=250)
self.msg.pack(ipadx=10, ipady=5)
self.parent.unbind('')
self.parent.focus()
self.widget.bind('', self.showmsg)
def printhello():
print 'Hello'
root = Tk()
button = Button(root, text='Hello !', command=printhello)
button.pack(padx=10, pady=10)
p = PopMsg(root, button, text='Some messaging text can go here.')
root.mainloop()
---End Code---
My problem you'll notice is that I tried to put something of a 'delay'
that will allow the popup to show a few seconds after the cursor has
entered the targeted widget's space (in this case the button). That
works ok but I've found that while waiting I can't activate (or
'click') on the button until the PopMsg has shown up. Is there anything
I can do to solve this problem?
thanks,
Harlin Seritt
--
http://mail.python.org/mailman/listinfo/python-list
Re: Video Catalogue
Tom B.:
If you're not having trouble saving with dict then use that. You only need
pickle if using lists or dicts are not doing the job when the data in them
are integers or long.
"Tom B." <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Rodney Dangerfield" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Greetz!
> >
> > Recently I started creating a CGI application for my gf that
> > she would use for indexing and keeping track of her video
> > collection.
> >
> > I am relatively new to python so I started with the basics.
> > I figured out how to extract the form field values in a
> > script and how to save to a file.
> >
> > My question is which data type should I use to store the information
> > about the videos? I was thinking of using a dictionary variable,
> > I saw something about the pickle module too, could I use it to
> > save the state of my dictionary to a file and than later read it
> > and feed values from it to the form fields via CGI?
> >
> > All help is greatly appreciated.
>
> I think a dictionary might work well, I might use a dictionary within a
> dictionary.
>
> vidiodict =
>
{'Title':{'description':'','date':'','cast':'','length':'130.99','comments':
''}}
>
> that way you could look at vidiodict['Title']['length'] it returns
'130.99'.
>
> Tom
>
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: change windows system path from cygwin python?
[EMAIL PROTECTED] wrote: > [Windows XP Pro, cygwin python 2.4, *nix hacker, windows newbie] > > I want to write some kind of install script for my python app that > will add c:\cygwin\usr\bin to the system path. I don't want > to walk around to 50 PC's and twiddle through the GUI to: > > My Computer --> Control Panel --> System --> Advanced --> Environment > > > How can a python, or even a .bat script modify the system PATH? > It doesn't appear to be in the registry. If you're just wanting to add a path to the system environments you can do: "set path=c:\path\to\whatever" # As a line in a Batch file -- Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
